Array arguments to verbs containing loops : A confused Newbies 
Author Message
 Array arguments to verbs containing loops : A confused Newbies


Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Description: Main Body
X-Mailer: Mutt 0.71

 on Tue, May 06, 1997 at 11:59:03PM -0300

> a=. _0.5j_0.65
> mbz a       NB. a single argument
> 11             NB. Works Fine !

>    ]a=. _2+0.5* i.7
> _2 _1.5 _1 _0.5 0 0.5 1

>    ]b=. j.(_1.5+ 0.5* i.7)
> 0j_1.5 0j_1 0j_0.5 0 0j0.5 0j1 0j1.5

>  ]c=. |:a+/|.b                NB. an array of input arguments
>  _2j1.5    _1.5j1.5  _1j1.5    _0.5j1.5   0j1.5   0.5j1.5    1j1.5
>  _2j1       _1.5j1     _1j1      _0.5j1      0j1     0.5j1       1j1
>  _2j0.5    _1.5j0.5   _1j0.5   _0.5j0.5   0j0.5   0.5j0.5   1j0.5
>  _2         _1.5         _1        _0.5        0        0.5         1
> _2j_0.5   _1.5j_0.5  _1j_0.5 _0.5j_0.5 0j_0.5 0.5j_0.5  1j_0.5
> _2j_1     _1.5j_1     _1j_1   _0.5j_1     0j_1    0.5j_1     1j_1
> _2j_1.5  _1.5j_1.5  _1j_1.5 _0.5j_1.5  0j_1.5  0.5j_1.5 1j_1.5

>    mbz c
> 0              NB. only returns the result of the first argument

> Any help understanding the cause of this effect or in finding the
> proper documentation or resource is greatly appreciated

The parts of J's documentation you're interested in reading is the
documentation on RANK.  You should understand the rank of a noun,
the rank of a verb, and the rank conjunction.

For the moment, I'm going to assume that you want to apply mbz
independently on each element of c.  Then,

   mbz"0 c

should do what you want.

There are several ways of encapsulating this into the function
definition, such as

mbzfixed=: mbz"0

Or, better yet, begin your definition of mbz with the line

mbz =. 3 : 0 " 0


Sun, 24 Oct 1999 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Array arguments to verbs containing loops : A confused Newbies Question

2. MS 5.0 - C programmer confused: Redeclared array argument

3. What confuses the newbies: An unscientific study

4. 1d array containing means of a 2d array

5. DEALLOCATE of a derived type array containing pointer array components

6. array components containing arrays

7. Arrays: Build array in multiple for loops or replace array elements

8. array section as actual argument where dummy argument is INTENT(OUT)

9. Detecting uninitialized subroutine argument used as array bound of another argument

10. NB. gray.js: a J verb that generates a grayscale postscript image from a 2d array

11. New J feature to apply different verbs to array elements

12. Regina REXX - How to Parse Arguments Containing Spaces


Powered by phpBB® Forum Software