[Top][All Lists]

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

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

From: Juergen Sauermann
Subject: Re: [Bug-apl] ≡/⍎¨ '5' "5" ⍝returns 1
Date: Mon, 21 Sep 2015 15:08:23 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0


yes, thanks.

I believe 4 ⎕CR tells the difference:

      4 ⎕CR 5
      4 ⎕CR ,5

In GNU APL the difference between e.g. '5' and "5" is on purpose because  the fact
that '5' is a scalar and '55' is a vector can sometimes be quite annoying, and was one
of the reasons for introducing "" in addition to ''. Another reason was support for ASCII
control characters like \n  in APL literals.

/// Jürgen

On 09/20/2015 11:15 PM, Kacper Gutowski wrote:
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'"

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


reply via email to

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