Conditional Arrays in ::SHE+ILA::

Woman in Purple Velvet Gown Reflected in Grand Mirror
49
1
  • Squishy Plushie's avatar Artist
    Squishy Pl...
  • Prompt
    Read prompt
  • DDG Model
    DaVinci2
  • Access
    Public
  • Created
    1w ago
  • Try

More about Conditional Arrays in ::SHE+ILA::

The expression ( count $> 1 : "s" ) represents a "conditional array", an array which has 1 element if count is greater than 1, or has no elements if count is less or equal to 1. As in
{ ttyout ( "There ", ("is", "are") [1+ ( count $> 1 ) ], count, " cat", count $> 1 :"s" ) };
This prints "There are 3 cats" when count is 3, but "There is 1 cat" when count is 1. When used inside a procedure, it implements the IF ... THEN construct more elegantly than the alternative { (falsebranch, truebranch) [1+condition] }, which is also shown in the example above, to select "is" or "are". More information on the homebrew retro OS ::SHE+ILA:: is at the hashtag #sheila based on a mashup of C++, APL, and LISP :)

Comments


Loading Dream Comments...

Discover more dreams from this artist