bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] Monadic form of ↓


From: Louis de Forcrand
Subject: Re: [Bug-apl] Monadic form of ↓
Date: Tue, 10 Oct 2017 20:06:15 +0200

Since the subject has been brought up, how about using it as the analog of first (monadic take), but instead unboxing the last element of an array in ravel order?

I don’t think this can generally be done on an array X in a more concise way than 
first reverse ravel X
or
(shape X) pick X
which I suppose are both slower than a primitive could be.
This might be considered trivial as well though.

Just a suggestion!
Louis

On 10 Oct 2017, at 18:46, Juergen Sauermann <address@hidden> wrote:

Hi Elias,

I believe ↓ for 1↓ is too trivial to be useful.

Unoccupied variants of APL primitives (like monadic ↓ or monadic =) are
a very scarce resource that we should not use for trivial things.

/// Jürgen


On 10/09/2017 11:06 AM, Elias Mårtenson wrote:
I was thinking about the usefulness of a monadic ↓ in terms of the new regexp feature. In the current version, when using subexpressions, the return value is always 1+the number of subexpressions, where the first one is always the full matched string. Monadic ↓ would be a neat way of dropping that part.

In any case, my point is that monadic ↓ should do something useful. I guess split is one such useful thing.

In GNU APL, I'd use ⊂⍤1 to achieve Split. Is that the most efficient way?

Regards,
Elias

On 9 October 2017 at 16:58, Jay Foad <address@hidden> wrote:
On 9 October 2017 at 04:56, Elias Mårtenson <address@hidden> wrote:
Currently, monadic ↑ acts as if it was called dyadically with 1 as its left argument,

That's not quite true:

      ⍴⍴1↑'ABC'
1
      ⍴⍴↑'ABC'
0

while monadic ↓ raises a VALENCE ERROR. In almost every single case where I have used ↓, it has been in the form 1↓X. Is there a reason why the monadic form is not allowed?

FYI in Dyalog APL monadic ↓ is Split:

      ↓3 3⍴⎕A
┌───┬───┬───┐
│ABC│DEF│GHI│
└───┴───┴───┘

I believe this came from STSC's NARS.

Jay.



reply via email to

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