the reason I asked about left to right, is that this is the @. way:

   0:`-:@.(0>])`+: @.(0<])"0 i:5
_2.5 _2 _1.5 _1 _0.5 0 2 4 6 8 10

   if =. @.
   else =. `
   0: else -:if (0>])else +: if (0<])"0 i:5
_2.5 _2 _1.5 _1 _0.5 0 2 4 6 8 10

   '0'"_ else ('<'"_) if (0>])else ('>'"_) if (0<])"0 i:5
<<<<<0>>>>>



----- Original Message -----
From: Pascal Jasmin <godspiral2...@yahoo.ca>
To: "programm...@jsoftware.com" <programm...@jsoftware.com>
Cc: 
Sent: Tuesday, February 4, 2014 7:39:32 AM
Subject: Re: [Jprogramming] 'if' and 'else' operators

There is:

   '0><' {~ * i:5
<<<<<0>>>>>

and the verb: ([ {~ *@]) could be called selectnounfrom01_1

When selecting among expressions you should look at @. for if. do. u else. v , 
and ^:boolean for if. do.u else y

I can think of syntactic sugar for if else as you put it to verbs/expressions, 
but does it have to be parsed left to right to be readable?



----- Original Message -----
From: Michal Wallace <michal.wall...@gmail.com>
To: programm...@jsoftware.com
Cc: 
Sent: Tuesday, February 4, 2014 3:48:15 AM
Subject: [Jprogramming] 'if' and 'else' operators

       ('O' if (=0:) else ('<' if (<0:) else '>'))"0 i:5
    <<<<<O>>>>>

There are nicer ways to make this output,
but how would you code 'if' and 'else' above?

Or... 'if'/'then'/'else' below, if you prefer?

    a =: assert
    a   4 1 0 2 4  -:   if (<0:) then (*: else +:)  i:2
    a   4 1 0 2 4  -:  (if (<0:) then (*: else +:)) i:2
    a  (if ] then (| else -.)) 1 1 0 0 1 0 1 0
    a   if ] then (| else -.)  1 1 0 0 1 0 1 0

My versions are here:

    https://github.com/tangentstorm/tangentlabs/blob/master/j/syntax.ijs

Thoughts? :)

-Michal
----------------------------------------------------------------------
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