[Jprogramming] newbie help: how to avoid division by zero

Linda Alvord lindaalvord at verizon.net
Tue May 21 13:21:29 UTC 2013


'(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: programming-bounces at forums.jsoftware.com
[mailto:programming-bounces at forums.jsoftware.com] On Behalf Of Linda Alvord
Sent: Tuesday, May 21, 2013 7:13 AM
To: programming at jsoftware.com
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: programming-bounces at forums.jsoftware.com
[mailto:programming-bounces at forums.jsoftware.com] 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" <lindaalvord at verizon.net>
>To: <programming at jsoftware.com>
>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



More information about the Programming mailing list