⍝ lazy and/or:

    {0}and{0} '' 
0
    {0}and{1} '' 
0
    {1}and{0} '' 
0
    {1}and{1} '' 
1

    {0}or{0} '' 
0
    {0}or{1} '' 
1
    {1}or{0} '' 
1
    {1}or{1} '' 
1

    {1}and{0}and{÷⍵}0   ⍝ and stops at leftmost false.
0
    {0}or{1}or{÷⍵} 0    ⍝ or stops at lefmost true.
1

    { {0≠≡⍵} or  {⍬≢0/⍵} or  (<∘0) ⍵: 'NOPE' ⋄ 'YEP'}¨ 3 ¯1 '7' ('ding' 'bat')
┌───┬────┬────┬────┐
│YEP│NOPE│NOPE│NOPE│
└───┴────┴────┴────┘

    { {0=≡⍵} and {⍬≡0/⍵} and (0∘<) ⍵: 'YEP' ⋄ 'NOPE'}¨ 3 ¯1 '7' ('ding' 'bat')
┌───┬────┬────┬────┐
│YEP│NOPE│NOPE│NOPE│
└───┴────┴────┴────┘

Back to: code

Back to: Workspaces