[Top][All Lists]

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

Re: [Bug-apl] scalar/array

From: Juergen Sauermann
Subject: Re: [Bug-apl] scalar/array
Date: Sat, 4 Mar 2017 12:13:48 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.2.0


the scalar extension mechanism is a very fundamental principle which existed since
the beginning of APL. If you randomly pick an 1-element value from any APL program,
then I would bet that the value is a scalar with a probability of ≥ 90%, and a matrix or
higher rank value with a probability of ≤ 1%. There have been studies about this in
the 1980s.

Therefore taking a 1-element item as a scalar is simply the most pragmatic choice.

/// Jürgen

On 03/03/2017 10:57 PM, address@hidden wrote:
On Fri, 3 Mar 2017 20:45:45 +0100
Juergen Sauermann <address@hidden> wrote:


what is the reason? do you know their reasoning

cause   1  is 1 element   and 1 2 3 is 3 elements   so   ⍴ 1 2 3   is 3    and  ⍴ 1  should have been 1   

I never understood their reasoning or how it negatively affected anything else - it must have been in the implementation that they had couldn't apply vector/array code to just one element so they did it this way
i think like the char type vs array type   but     you can have an array of 1 element (in c and fpc anyway)

I believe the reason why 'a' is scalar and 'abc' is not is the same as why 1 is a scalar and 1 2 3 is not.

It is very consistent, but often very inconvenient. And in practice it is often a pitfall for the unaware programmer.
I fooled myself a couple of times and then decided to introduce "a" which avoids the problems with 'a'.

Before "a" you had to (,'a') or ,'a' if circumstances allowed (introducing other traps, of course).

/// Jürgen

On 03/03/2017 06:57 PM, address@hidden wrote:
thank you - fantastic ...it sure 'fixes' the inconsistency     i had no idea about "a"

I saw the use of " only in the FILE_IO   "r"  in the apl.html    but thought that was related to just fopen/bash/c syntax


Do you know the 'details' about why iverson did this to begin with?

How did you deal with scalar 'a' before the "a" in gnuap? 

didn't you have 'wasted code'  to deal with the following   to deal with scalar 'a'





the video in case you hadn't seen it

# APL 1991 Conference.mpg   1 hour, 50 minutes


On Sat, 4 Mar 2017 01:37:18 +0800
Elias Mårtenson <address@hidden> wrote:

In GNU APL, try this instead :


The reason this seems inconsistent is because single quote is used to
define a string, i.e. an array of characters. Except the case where there
is only a single  character, in which case it represents a scalar

GNU APL allows you to use double quote instead which doesn't have this

That should make things a bit more clear, I hope.


On 4 Mar 2017 01:29, <address@hidden> wrote:

i just watched a great video on apl   and this was discussed    i still
don't know what the harm/problem would be if instead of returning 'nothing'

      ⍴'a'                 why doesn't it return 1   - there is something
there    please don't mention scalar i know all about it - but to me this
has always been an inconsistency in apl that made no sense to me

      ⍴'aa'               the ,   isn't required in   ⍴,'aa'    to be
consistent ??

      ^  ^

under what condition would   'a'[1]    returning 'a'  be a problem?

reply via email to

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