It may be interesting to note that each delivers its results boxed
even if the input is not boxed.

  3 + &.> i.11
+-+-+-+-+-+-+-+--+--+--+--+
|3|4|5|6|7|8|9|10|11|12|13|
+-+-+-+-+-+-+-+--+--+--+--+

2010/2/25 Björn Helgason <[email protected]>:
> each is a very important operation in J
> You can of course use its contants
>
>  3 + &.> a
> +---+-----+-----------+
> |4 5|6 7 8|10 11 12 14|
> +---+-----+-----------+
>
> It is a matter of taste which is better to use the primitives directly
> or in a name like each.
>
> 2010/2/25 Björn Helgason <[email protected]>:
>>  a=.1 2;3 4 5;7 8 9  11
>>   3 + each a
>> +---+-----+-----------+
>> |4 5|6 7 8|10 11 12 14|
>> +---+-----+-----------+
>>
>>
>> 2010/2/25 Björn Helgason <[email protected]>:
>>> each is an operation that unboxes then operates on the contents and boxes 
>>> again
>>>
>>>   each
>>> &.>
>>>   a=.12;345;789 11
>>>   3 + a
>>> |domain error
>>> |   3    +a
>>>   3 + each a
>>> +--+---+------+
>>> |15|348|792 14|
>>> +--+---+------+
>>>
>>>
>>> 2010/2/25 Alexander Mikhailov <[email protected]>:
>>>>
>>>> I'm a novice in J, and when trying to write programs, I'm very often use 
>>>> boxes to store arrays of different length together, like this -
>>>>
>>>> +---+-------+-----+
>>>> |1 2|3 4 5 6|7 8 9|
>>>> +---+-------+-----+
>>>>
>>>> Those arrays are usually results of previous steps of computations, and 
>>>> semantically the rows are similar, but I can't store them in a table, like 
>>>> this -
>>>>
>>>> 1 2
>>>> 3 4 5 6
>>>> 7 8 9
>>>>
>>>> because J requires all items to have the same shape. So, I end up doing 
>>>> boxing and unboxing.
>>>>
>>>> As far as I know, the reason to have boxes in J was to allow to have 
>>>> elements of different "kinds" - like ranks, or lengths, or types - in the 
>>>> same array. Is it reasonable to have boxing/unboxing operations to be done 
>>>> implicitly in the case like above - or am I missing other important uses 
>>>> of boxes?
>>>>
>>>> Alexander
>>>>
>>>>
>>>>
>>>>
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>
>>>
>>>
>>> --
>>> Björn Helgason, Verkfræðingur
>>> Fornustekkum II
>>> 781 Hornafirði
>>> Po Box 127,801 Selfoss ,
>>> t-póst: [email protected]
>>> gsm: +3546985532
>>> sími: +3544781286
>>> http://groups.google.com/group/J-Programming
>>>
>>>
>>> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>>>
>>> góður kennari getur stigið á tær án þess að glansinn fari af skónum
>>>          /|_      .-----------------------------------.
>>>         ,'  .\  /  | Með léttri lund verður        |
>>>     ,--'    _,'   | Dagurinn í dag                     |
>>>    /       /       | Enn betri en gærdagurinn  |
>>>   (   -.  |        `-----------------------------------'
>>>   |     ) |         (\_ _/)
>>>  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
>>>   `. )----'        (")_(") ☃☠
>>>
>>
>>
>>
>> --
>> Björn Helgason, Verkfræðingur
>> Fornustekkum II
>> 781 Hornafirði
>> Po Box 127,801 Selfoss ,
>> t-póst: [email protected]
>> gsm: +3546985532
>> sími: +3544781286
>> http://groups.google.com/group/J-Programming
>>
>>
>> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>>
>> góður kennari getur stigið á tær án þess að glansinn fari af skónum
>>          /|_      .-----------------------------------.
>>         ,'  .\  /  | Með léttri lund verður        |
>>     ,--'    _,'   | Dagurinn í dag                     |
>>    /       /       | Enn betri en gærdagurinn  |
>>   (   -.  |        `-----------------------------------'
>>   |     ) |         (\_ _/)
>>  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
>>   `. )----'        (")_(") ☃☠
>>
>
>
>
> --
> Björn Helgason, Verkfræðingur
> Fornustekkum II
> 781 Hornafirði
> Po Box 127,801 Selfoss ,
> t-póst: [email protected]
> gsm: +3546985532
> sími: +3544781286
> http://groups.google.com/group/J-Programming
>
>
> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>
> góður kennari getur stigið á tær án þess að glansinn fari af skónum
>          /|_      .-----------------------------------.
>         ,'  .\  /  | Með léttri lund verður        |
>     ,--'    _,'   | Dagurinn í dag                     |
>    /       /       | Enn betri en gærdagurinn  |
>   (   -.  |        `-----------------------------------'
>   |     ) |         (\_ _/)
>  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
>   `. )----'        (")_(") ☃☠
>



-- 
Björn Helgason, Verkfræðingur
Fornustekkum II
781 Hornafirði
Po Box 127,801 Selfoss ,
t-póst: [email protected]
gsm: +3546985532
sími: +3544781286
http://groups.google.com/group/J-Programming


Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans

góður kennari getur stigið á tær án þess að glansinn fari af skónum
          /|_      .-----------------------------------.
         ,'  .\  /  | Með léttri lund verður        |
     ,--'    _,'   | Dagurinn í dag                     |
    /       /       | Enn betri en gærdagurinn  |
   (   -.  |        `-----------------------------------'
   |     ) |         (\_ _/)
  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
   `. )----'        (")_(") ☃☠
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to