Page 1 of 1

?: Operator in APL+Win

PostPosted: September 17th, 2016, 5:13 am
by Ajay Askoolum
In C#, this has the following syntax:

(condition) ? (return if true) : (return if false)

The nearest syntax in APL+Win is:

Code: Select all
      ⍬⍴(condition↓falseValue),truevalue


Works fine, as is; except that in C#, the argument following ? (or :) can be another ?: operator statement (which can also include another ?: operator, etc.)

Can APL+Win implement the ?: operator within the interpreter?

Re: ?: Operator in APL+Win

PostPosted: September 17th, 2016, 7:02 pm
by Davin Church
Ajay, what about "Inline Control Sequences" (ICS)? Won't that do just what you want?

From the documentation...
Code: Select all
The following list shows all recognized forms of ICS expression (for brevity the :OR form of each expression is not shown; wherever :AND appears it can be replaced by :OR):

( Cond  :THEN   Case1 :ELSE Case0 )
( Cond  :THEN   Case1 )
( Cond  :ELSE   Case0 )
( Cond1 :AND    Cond2 )
( Cond1 :AND    Cond2 ... :AND  CondN )
( Cond1 :AND    Cond2 ... :THEN Case1 :ELSE Case0 )
( Cond1 :AND    Cond2 ... :THEN Case1 )
( Cond1 :AND    Cond2 ... :ELSE Case0 )
( Index :CHOOSE Case1 : Case2 : ... : CaseN :ELSE Else )
( Index :CHOOSE Case1 : Case2 : ... : CaseN )

Re: ?: Operator in APL+Win

PostPosted: November 19th, 2016, 4:45 pm
by Ajay Askoolum
I omitted to follow this; thanks Davin, ICS will do nicely.