Skip to content

APL Null

Vector 14:3, page 12

language design

Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 12

APL character null '' (or 0/'anystring') and numeric null ⍬ (or 0/any numeric vector) surprised me. I have checked this with APL*PLUS III, APL*Win, Sharp APL and Dyalog/APL: all these interpreters behave identically. Therefore, tempted as I am, I cannot call this a bug. However, I would like to be able to express what is happening in words.

''∊'ABCD'          ⍝ Returns null
'ABCD'∊''          ⍝ Returns 0 0 0 0
''⍷'ABCD'          ⍝ Returns 1 1 1 1
'ABCD'⍷''          ⍝ Returns null

The results are consistent when 1 2 3 4, say, is substituted for 'ABCD'.

'A'∧.=0/'ABCD' ⍝ Returns a surprise 1

as does

(0/'ABCD')∧.='A'

What is APL doing? The surprise result which prompted me to look into this was

2∧.=0/1 1

or more generally, 2∧.=condition/value which caused my function to branch to a routine I had not expected. I would have expected the result to be null or zero.

Can you express what APL is doing in words?