You have a useful expression.  It is not a verb.
    
   a=:2 3 5
   b=:0 1 2 3
   4!:0 <'('''';,.a),.(b);a +/ b'  
_2

A result of  3  would indicate a verb.

   f=: 13 '('''';,.a),.(b);a +/ b' 
|syntax error
|   f=:    13'('''';,.a),.(b);a +/ b'

This doesn't work.  Note however the use of a double  ''  for each  ' inside 
the outer pair.

Now use  x  and  y  only as replacements for the left and right arguments. 
                                       
   f=: 13 :'('''';,.x),.(y);x +/ y' 
   a f b
┌─┬───────┐
│ │0 1 2 3│
├─┼───────┤
│2│2 3 4 5│
│3│3 4 5 6│
│5│5 6 7 8│
└─┴───────┘

   4!:0 <'f'  
3

You have defined or made a verb.  It is also often called a function.

You did the hard part when you created a simple expression that works! Creating 
the verb is what makes it useful to use with other data.

Linda

        
-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Björn Helgason
Sent: Sunday, November 20, 2011 8:09 AM
To: Programming forum
Subject: Re: [Jprogramming] table challenge in simple J

or

('';,.a),.(b);a +/ b

2011/11/20 Björn Helgason <[email protected]>

>
> Ok it is simple j we are after
> We start by defining a and b
>
>      a=: 2 3 5
>      b=: 0 1 2 3
>
> Then we create the elements we want
>
>    '';b;a;a +/ b
> ┌┬───────┬─────┬───────┐
> ││0 1 2 3│2 3 5│2 3 4 5│
> ││       │     │3 4 5 6│
> ││       │     │5 6 7 8│
> └┴───────┴─────┴───────┘
>
> Now we rearrange a so it goes down in a column
>
>    '';b;(,.a);a +/ b
> ┌┬───────┬─┬───────┐
> ││0 1 2 3│2│2 3 4 5│
> ││       │3│3 4 5 6│
> ││       │5│5 6 7 8│
> └┴───────┴─┴───────┘
>
> Next we arrange it in a 2 by 2
>
>    ('';b),.(,.a);a +/ b
> ┌───────┬───────┐
> │       │2      │
> │       │3      │
> │       │5      │
> ├───────┼───────┤
> │0 1 2 3│2 3 4 5│
> │       │3 4 5 6│
> │       │5 6 7 8│
> └───────┴───────┘
>
> ooppss wrong wa around we fix it with transpose
>
>
>    |:('';b),.(,.a);a +/ b
> ┌─┬───────┐
> │ │0 1 2 3│
> ├─┼───────┤
> │2│2 3 4 5│
> │3│3 4 5 6│
> │5│5 6 7 8│
> └─┴───────┘
>
>


-- 
Björn Helgason, Verkfræðingur
Fornustekkum II
781 Hornafirði,
t-póst: [email protected]
gsm: +3546985532
twitter: @flugfiskur
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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to