bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] ≡/⍎¨ '5' "5" ⍝returns 1


From: Kacper Gutowski
Subject: Re: [Bug-apl] ≡/⍎¨ '5' "5" ⍝returns 1
Date: Sun, 20 Sep 2015 23:15:16 +0200

On Sun, Sep 20, 2015 at 9:57 PM,  <address@hidden> wrote:
> Should the execute primitive include the structure data? I thought that the
> phrase in the subject line would return zero. I thought the first element
> would return a scalar 5, and the second would return a single element five.
> Both evaluate to a scalar five.

In some places single-element vectors and scalars are treated equally.
That's why ⍎'5' is even allowed in the first place.  ⍎ throws domain
error if its argument has rank higher than one, but otherwise it doesn't
care and executes ravel list of its argument as a single line regardless
if it's a vector or scalar.

It's always a line of APL program, not data with any kind of structure.
And by the rules of APL language, a program consisting of single digit 5
has scalar result.  It is still so if you were to put, for example, a
space before or after it (necessarily making the code itself a vector;
but without changing the result it evaluates to).

Distinction between kind of quotes used would matter if they were the
part of the line executed by ⍎:

      ≡/⍎¨'"5"' "'5'"
0

Here "5" and '5' are executed giving a (character) vector and a scalar,
respectively, in the result.

-k



reply via email to

[Prev in Thread] Current Thread [Next in Thread]