(c*y<0)+(d*y>:0)
may also be written 

  c+(d-c)*y>:0



>________________________________
> Fra: Linda Alvord <[email protected]>
>Til: [email protected] 
>Sendt: 7:50 søndag den 19. maj 2013
>Emne: Re: [Jprogramming] newbie help: how to avoid division by zero
> 
>
>I think you missed my point.
>
>In the vocabulary in "Control Structures" you provide hints to formulate this:
>
>    if. y<0 do. c elseif. y>:0 do. d end.
>
>A beginner who finds this is likely to assume that this is the best way to 
>provide a conditional solution in J.
>
>Sadly, they are likely to work to master the use of this structure. A better 
>way is not there for them to see.  I'm suggesting that a better way (or the 
>best known option at the current time) be provided right there. 
>
>   c*y<0)+(d*y>:0)
>
>Often these better ways appear on wiki pages. They are only brought to light 
>by some link on the forum which would otherwise never be found.
>
>If gems like this one were to appear in the vocabulary section it would 
>encourage faster development of good writing skills.
>
>So much of the give and take of the forum reduces concepts to a simpler way of 
>solving problems. It would be great if those "better ways" could find their 
>way into the vocabulary.
>
>Linda 
>
>-----Original Message-----
>From: [email protected] 
>[mailto:[email protected]] On Behalf Of Roger Hui
>Sent: Saturday, May 18, 2013 7:03 PM
>To: Programming forum
>Subject: Re: [Jprogramming] newbie help: how to avoid division by zero
>
>​We don't do anyone any favors by providin
>  if. y<0 do. c elseif. y>:0 do. d end.
>instead of
>  c*y<0)+(d*y>:0)
>
>
>For one thing, the former has to work scalar-by-scalar, and for now and for 
>the forseeable future it'll be orders of magnitude slower that the latter 
>expression.
>
>> There are many places where newer and better ways of doing things 
>> could
>be added to save lots of new users many pitfalls.
>
>Yes, we have newer and better ways of doing things; it's called array 
>thinking, and booleans returning 0 and 1 instead of false and true, and ...
>
>
>
>On Sat, May 18, 2013 at 1:41 PM, Linda Alvord <[email protected]>wrote:
>
>>    try=: 3 : 0
>>    c=:12
>>    d=:14
>>    if. c*y<0 do. c elseif. d*y>:0 do. d end.
>>    )
>>    try _3
>> 12
>>    try 0
>> 14
>>    try 3
>> 14
>>
>>    c=:12
>>    d=:14
>>    y=:_3
>>    (c*y<0)+(d*y>:0)
>> 12
>>    x=:0
>>    (c*y<0)+(d*y>:0)
>> 12
>>    x=:3
>>    (c*y<0)+(d*y>:0)
>> 12
>>
>> Roger, Most people seem to go first to the vocabulary to find a 
>> starting place to solve their problems.
>>
>> Wouldn't it be useful to go to "Control Structures" to find a major 
>> improvement such as the one you just wrote:
>>
>>    if. c*y<0 do. c elseif. d*y>:0 do. d end.
>> or:
>>   (c*y<0)+(d*y>:0)
>>
>> There are many places where newer and better ways of doing things 
>> could be added to save lots of new users many pitfalls.
>>
>> 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

Reply via email to