bug-apl
[Top][All Lists]
Advanced

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

Re: /⍨


From: Dr . Jürgen Sauermann
Subject: Re: /⍨
Date: Tue, 31 May 2022 22:02:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

Hi Hudson,

I checked with IBM APL2.

Unfortunately my IBM APL2 has no ⍨ (aka. duplicate) operator.
But we can emulate it easily:

      DUP ←{ ⍵ ⍶ ⍵ }
      + DUP 1 2 3
2 4 6
      × DUP 1 2 3
1 4 9

In GNU APL, DUP gives the same result as ⍨:

      /⍨1 2 3
SYNTAX ERROR
      /⍨1 2 3
      ^^

      /DUP 1 2 3
SYNTAX ERROR
      /DUP 1 2 3
      ^^

However, in IBM APL2 I get the same (see attached screenshot),

The problem seems to be caused by the ambiguity of / and friends (i.e. ⌿, \,
and).
You can work around this with a wrapper around /:

      REPL←{ ⍺ / ⍵ }   ⍝ disambiguates / to mean replicate and not reduce
      3 REPL 1 2 3
1 1 1 2 2 2 3 3 3

      REPL ⍨ 1 2 3
1 2 2 3 3 3


      1 2 3 REPL 1 2 3   ⍝ same as
REPL ⍨ 1 2 3
1 2 2 3 3 3



Best Regards,
Jürgen



On 5/31/22 2:18 AM, hudson@hudsonlacerda.com wrote:
Hi.

I get "SYNTAX ERROR" messages for /⍨ or ⌿⍨ :

/⍨⍳3
⌿⍨⍳3

Regards,
Hudson


Attachment: Duplicate-APL2.png
Description: PNG image


reply via email to

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