odd=:2 & |
halve=:-:
veco =: 3 : '(c*1+3*y) + (halve y) * (1-c =. odd y)'
data =: 1 + i. 10000
veco3=:'((odd y)*1+3*y) + (halve y) * (1-odd y)'(13 : )
(veco3 data) -: (veco data)
1
veco3
(odd * 1 + 3 * ]) + halve * 1 - odd
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Tuesday, May 21, 2013 9:21 AM
To: [email protected]
Subject: Re: [Jprogramming] newbie help: how to avoid division by zero
'(c*1+3*y) + (halve y) * (1-c =: odd y)'(13 : )
3 : '(c*1+3*y) + (halve y) * (1-c =: odd y)'
'(c*1+3*y) + (halve y) * (1-c =. odd y)'(13 : ) halve (* + [ * 1 - ]) odd
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Tuesday, May 21, 2013 7:13 AM
To: [email protected]
Subject: Re: [Jprogramming] newbie help: how to avoid division by zero
I didn't realize that this definition for veco2 did not work.
data =: 1 + i. 10000
veco =: 3 : '(c*1+3*y) + (halve y) * (1-c =. odd y)'
'(c*1+3*y) + (halve y) * (1-c =. odd y)'(13 : ) halve (* + [ * 1 - ]) odd
veco2=:halve (* + [ * 1 - ]) odd
(veco2 data) -: (veco data)
0
So, although your substitution works, it doesn't help.
veco3=:halve (* -.) odd
(veco3 data) -: (veco data)
I'll be more careful about testing the results of: ' '(13 : )
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David Ward
Lambert
Sent: Monday, May 20, 2013 12:24 PM
To: programming
Subject: Re: [Jprogramming] newbie help: how to avoid division by zero
I'd replace ([ * 1 - ]) with (* -.) .
As previously observed, 13 :'quoted expression' won't write hooks.
(([ * 1 - ]) -: (* -.)) -:i:8 NB. monad
1
(([ * 1 - ])/ -: (* -.)/)~ -:i:8 NB. dyad
1
>Date: Sun, 19 May 2013 11:43:52 -0400
>From: "Linda Alvord" <[email protected]>
>To: <[email protected]>
>Subject: Re: [Jprogramming] newbie help: how to avoid division by zero
>Message-ID: <000101ce54a7$aa2d4c10$fe87e430$@net>
>Content-Type: text/plain; charset=US-ASCII
>
> It is worth noting further simplification by J:
>
> veco=: 13 :'(c*1+3*y) + (halve y) * (1-c =. odd y)'
> veco
>halve (* + [ * 1 - ]) odd
>
>Linda
----------------------------------------------------------------------
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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm