Tag Info

Hot answers tagged

45

The answer seems to be yes. At least, I will try to describe an attempt which would pass the "under 100 lines of code" test. How well it satisfies the other criteria is a subjective matter, but I have already used it for larger-scale project with so far very positive results. I will present two implementations. One is an absolute toy, but extremely simple. ...


14

I know this thread is old and that Leonid provided a great solution, but I'd like to present a bit different approach. My approach is inspired by JavaScript. There are no classes, just "pure objects". To directly answer requirements from question Support instantiation, inheritance and polymorphism. Objects are fully dynamic, everything can be changed in ...


4

I believe the crux of your problem is, as you say, how to match n_NewHead. Let's look at the FullForm: FullForm[n_NewHead] Pattern[n, Blank[NewHead]] As you can see this is composed of Blank and Pattern, both of which are special heads with regard to pattern matching. You therefore need to wrap them in Verbatim to make a literal match: MatchQ[ ...


1

I don't understand why you need this functionality. If you really need Part to write to your object, then again, I suggest you use one of the ways of simulating OOP in MMA (see my linked question in comments). You ask if instead there is a simpler, more obvious approach. I think that all you really need is the following: ContiguousOrderedIntegerMap /: ...



Only top voted, non community-wiki answers of a minimum length are eligible