- Is it an array rather than a space?
Is it depth two?
Is it rank one?
Are all its items strings?
(2∊⎕NC'⍵')∧(2=≡⍵)∧(1=≢⍴⍵)∧∧/(''≡0∘/)¨⍵won't cut it.
2∊⎕NC'⍵':2=≡⍵:1=≢⍴⍵:∧/(''≡0∘/)¨⍵ ⋄ 0
2∊⎕NC'⍵':{2=≡⍵:{1=≢⍴⍵:∧/(''≡0∘/)¨⍵ ⋄ 0}⍵ ⋄ 0}⍵ ⋄ 0
2∊⎕NC'⍵':{Above presents three versions of the same bit of code. The first doesn't work. The second and third are just silly requiring two extra levels of embedded dfn just to allow nested guards. The third is arguably more readable than the second.
2=≡⍵:{
1=≢⍴⍵:∧/(''≡0∘/)¨⍵
0}⍵
0}⍵
0
I'd like two things. First is to allow the "result expression" of a guard itself to be a guard. "AndIf" would be the obvious implication. It's modelable by use of the dop:
and←{⍺⍺⊣⍵:⍵⍵⊣⍵ ⋄ 0}requiring all operands to be braced or parenthesised:
{2∊⎕NC'⍵'}and(2=≡)and(1=≢∘⍴)and(∧/(''≡0∘/)¨)⍵If and were a primitive conjunction all well and good; as it is it only hides the issue.
APL# proved there are no counter examples of the nested guard's rectitude.
The other thing I'd like is a better and more concise way to test for lists of strings.
p.s. OK we don't need the first test. If it's a space its depth and rank are both zero. I just wanted an example that had four tests!