Thanks for the suggestions, I am using this one from Raul for now:
3 :'X__y'"0 n


On Tue, Apr 21, 2009 at 8:01 PM, Oleg Kobchenko <[email protected]> wrote:
>
>> From: Eric Iverson <[email protected]>
>>
>> An array of object values that 'often' to be dealt with as an array is
>> perhaps best implemented as a normal J array that is a global class object.
>> This can be referenced directly as an array and then in each of the objects
>> the object value is the index into the class array and you use simple
>> accessor funtions.
>
> This could probably be illustrated with the Diagram
> script, where there is an array of object item and
> accessors to properties like Posistion, Name, Members, etc.
>
>    http://www.jsoftware.com/jwiki/Scripts/Diagram
>
> ITEMS=:     ,: 10  10;'Sample 1';<;:'one two'
> ITEMS=: ITEMS,160  10;'Sample 2';<;:'three four five'
> ITEMS=: ITEMS, 80 160;'Sample 3';<;:'six seven'
> ITEMS=: ITEMS,250 160;'Sample 4';<;:'eight nine'
>
> item_pos=:   3 : '(y,."1 0]0){::ITEMS'
> item_setpos=:4 : 'ITEMS=:(<x)(<y,0)}ITEMS'
> item_name=:  3 : '(y,1){::ITEMS'
> item_membs=: 3 : '(y,2){::ITEMS'
> item_memb=:  3 : '((({.y),2);{:y){::ITEMS'
>
>
> NB. get connector positions
>
> CONS=: 0 1,1 2,:1 3
>
> ... =. item_pos CONS
>
>
> NB. find item by hit test
>
>  for_i. i.#ITEMS do.
>    P=. item_pos i
>    if. *./(P<M),M<P+IBSZ do.
>       ...
>    end.
>  end.
>
>
>
>
>> On Mon, Apr 20, 2009 at 12:49 PM, Matthew Brand wrote:
>>
>> > If I have a simple class such as:
>> > coclass 'example'
>> >
>> > create =: 3 : ' X =: y'
>> > destroy =: codestroy
>> >
>> > And I make a list of new objects:
>> > n =.'example' (conew~)"(1 0) i.4
>> >
>> >   n
>> > +-+-+-+-+
>> > |4|5|6|7|
>> > +-+-+-+-+
>> >
>> > Then I can get at the X's inside each object like this:
>> >   X_4_
>> > 0
>> >   X_5_
>> > 1
>> >
>> > And like this:
>> > v =. <":5
>> > X__v
>> > 1
>> >
>> > But how can I reconstruct the values of the X's from the list n?
>> >
>> > i.e., is there anything that looks like this?
>> >    (X__ )"0 n
>> > 0 1 2 3
>> >
>> > Presumably the code to call a method on each object would look the same?
>> >
>> > I.e if there was a method: getX =: 3 : 'X'
>> >
>> > then calling it would look like?
>> > (getx__ )"0 n
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> >
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
http://www.ixquick.com/

Ixquick Protects Your Privacy!
The only search engine that does not record your IP address.

http://www.vivapalestina.org/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to