And with some comments
answer3=: verb define NB. My first verb
b=. # y NB. take the argument y and put in b
c=. -: b NB. half the contents of b
d=. <. c NB. even to next lower decimal
e=. %: d NB. take the squareroot and give
NB. it as a result of the verb
)
answer4=: verb define NB. My first verb
b=. # y NB. take the argument y and put in b
smoutput 'the argument is: ',":y
c=. -: b NB. half the contents of b
smoutput 'half of the argument is: ',": c
d=. <. c NB. even to next lower decimal
smoutput 'lower decimal is: ',": d
e=. %: d NB. take the squareroot and give
NB. it as a result of the verb
smoutput 'the result of the squareroot is: ',": e
''
)
answer3 i.5
1.41421
answer4 i.5
the argument is: 0 1 2 3 4
half of the argument is: 2.5
lower decimal is: 2
the result of the squareroot is: 1.41421
2009/4/26 Björn Helgason <[email protected]>
> %:<.-:# i.5
> 1.41421
> (%:<.-:#) i.5
> 0 0 0 0 0
>
> For a beginner I would recommend to use explicit
>
> answer1=: 3 : 0
> b=. # y
> c=. -: b
> d=. <. c
> e=. %: d
> )
>
> Even use =: instead of =. (global vs local) to investigate immediate
> results
>
>
> answer2=: 3 : 0
> b=: # y
> c=: -: b
> d=: <. c
> e=: %: d
> )
>
>
> answer1 i.5
> 1.41421
> answer2 i.5
> 1.41421
> b
> 5
> c
> 2.5
> d
> 2
> e
> 1.41421
>
>
>
>
> 2009/4/26 Don Watson <[email protected]>
>
>> Hi Bjorn,
>>
>>
>> I took that example from J documentation. I obviously needed a longer
>> train:
>>
>> Why can I write:
>>
>> %:<.-:# y
>>
>> but have to change it when I want to store a verb that does the same thing
>> to:
>>
>> answer =: %:@:<.@:-:@:#
>>
>> answer y
>>
>> I am not complaining that you can't give me an answer, but that the
>> situation doesn't make sense.
>>
>> Don
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
>
> --
> Björn Helgason, Verkfræðingur
> Fugl&Fiskur ehf,
> Þerneyjarsundi 23, Hraunborgum
> Po Box 127,801 Selfoss ,
> t-póst: [email protected]
> gsm: +3546985532
> Landslags og skrúðgarðagerð, gröfuþjónusta
> 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
Fugl&Fiskur ehf,
Þerneyjarsundi 23, Hraunborgum
Po Box 127,801 Selfoss ,
t-póst: [email protected]
gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
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