Replicate: NARS2000 vs GNU APL

77 views
Skip to first unread message

Brian McGuinness

unread,
Aug 30, 2021, 4:24:55 PMAug 30
to
NARS2000 requires the left and right arguments to have the same length:

1 ¯2 3 2 / 10 20 30
LENGTH ERROR
1 ¯2 3 2 / 10 20 30

¯2 3 2 / 10 20 30
0 0 20 20 20 30 30


GNU APL requires the number of nonnegative values in the left argument to match the number of items in the right argument:

1 ¯2 3 2 / 10 20 30
10 0 0 20 20 20 30 30
¯2 3 2 / 10 20 30
LENGTH ERROR
¯2 3 2/10 20 30
^ ^


The GNU APL approach seems to agree with the description of replicate in the IBM APL2 manual.

J. Clarke

unread,
Aug 30, 2021, 5:44:25 PMAug 30
to
On Mon, 30 Aug 2021 13:24:54 -0700 (PDT), Brian McGuinness
<b.mcgui...@gmail.com> wrote:

>NARS2000 requires the left and right arguments to have the same length:
>
> 1 ¯2 3 2 / 10 20 30
>LENGTH ERROR
> 1 ¯2 3 2 / 10 20 30
> ?
> ¯2 3 2 / 10 20 30
>0 0 20 20 20 30 30
>
>
>GNU APL requires the number of nonnegative values in the left argument to match the number of items in the right argument:
>
> 1 ¯2 3 2 / 10 20 30
>10 0 0 20 20 20 30 30
> ¯2 3 2 / 10 20 30
>LENGTH ERROR
> ¯2 3 2/10 20 30
> ^ ^
>
>
>The GNU APL approach seems to agree with the description of replicate in the IBM APL2 manual.

The following trace is from Dyalog:
1 ¯2 3 2 / 10 20 30
LENGTH ERROR
1 ¯2 3 2/10 20 30
^

I believe emulating Dyalog is a better choice than emulating APL2,
which seems to be starting down the path to abandonware.

Adám Brudzewsky

unread,
Aug 31, 2021, 9:36:45 AMAug 31
to
After Dyalog adopted the definition of Replicate used by NARS, APL2 developed another definition, which differs in its handling of negative numbers in the left argument. In APL2, a negative number does not "consume" an element of the right argument, so that instead of (≢⍺)=≢⍵, we have (+/0≤⍺)=≢⍵. Developers of XAPL noticed that both extensions can be supported simultaneously: if the left argument has any negative numbers, the interpreter can tell which one the programmer meant by checking whether the right argument's length is equal to the left (NARS-style) or shorter (APL2-style). In fact, APLX already does this:
```
APLX for Windows
Copyright (C) 2001-2010 MicroAPL Ltd
WS Size = 20.0MB, Version = 5.1.0
CLEAR WS
1 ¯2 3 2 / 10 20 30
10 0 0 20 20 20 30 30
¯2 3 2 / 10 20 30
0 0 20 20 20 30 30
```

joseph turco

unread,
Oct 6, 2021, 2:14:28 PMOct 6
to
sorry to hijack this thread, but are you learning GNU APL from the IBM manual? I cant find anything like 'Mastering dyalog APL' for using GNU APL.

Brian McGuinness

unread,
Oct 24, 2021, 9:54:33 PMOct 24
to
I am experimenting with the interpreters and comparing the results with a copy of the IBM APL2 manual.

--- Brian McGuinness
Reply all
Reply to author
Forward
0 new messages