Discussion:
[Bug-apl] Monadic form of ↓
Elias Mårtenson
2017-10-09 03:56:12 UTC
Permalink
Currently, monadic ↑ acts as if it was called dyadically with 1 as its left
argument, 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?

And if not, would it make sense to add as an extension? Since the current
behaviour is to raise an error there should be no backwards-compatibility
issues.

Regards,
Elias
Jay Foad
2017-10-09 08:58:11 UTC
Permalink
Post by Elias MÃ¥rtenson
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
Post by Elias MÃ¥rtenson
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.
Elias Mårtenson
2017-10-09 09:06:32 UTC
Permalink
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
Post by Jay Foad
Post by Elias MÃ¥rtenson
Currently, monadic ↑ acts as if it was called dyadically with 1 as its
left argument,
⍮⍮1↑'ABC'
1
⍮⍮↑'ABC'
0
while monadic ↓ raises a VALENCE ERROR. In almost every single case where
Post by Elias MÃ¥rtenson
I have used ↓, it has been in the form 1↓X. Is there a reason why the
monadic form is not allowed?
↓3 3⍮⎕A
┌───┬───┬───┐
│ABC│DEF│GHI│
└───┮───┮───┘
I believe this came from STSC's NARS.
Jay.
Jay Foad
2017-10-09 09:32:44 UTC
Permalink
Post by Elias MÃ¥rtenson
In GNU APL, I'd use ⊂⍀1 to achieve Split. Is that the most efficient way?
Either that or ⊂[2] (or in general ⊂[n] where n is the rank of the
argument).
Elias Mårtenson
2017-10-09 09:39:20 UTC
Permalink
Post by Jay Foad
Post by Elias MÃ¥rtenson
In GNU APL, I'd use ⊂⍀1 to achieve Split. Is that the most efficient way?
Either that or ⊂[2] (or in general ⊂[n] where n is the rank of the
argument).
Thank you. I learned something new today. I didn't realise that ⊂ accepted
an axis argument.

Regards,
Elias
Juergen Sauermann
2017-10-10 16:46:51 UTC
Permalink
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<font face="Helvetica, Arial, sans-serif">Hi Elias,<br>
<br>
I believe ↓ for 1↓ is too trivial to be useful.<br>
<br>
Unoccupied variants of APL primitives (like monadic ↓ or monadic =)
are<br>
a very scarce resource that we should not use for trivial things.<br>
</font><br>
/// Jürgen<br>
<br>
<br>
<div class="moz-cite-prefix">On 10/09/2017 11:06 AM, Elias Mårtenson
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CADtN0W+E1UoE+vbPQCB4-***@mail.gmail.com">
<div dir="ltr">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.
<div><br>
</div>
<div>In any case, my point is that monadic ↓ should do something
useful. I guess split is one such useful thing.</div>
<div><br>
</div>
<div>In GNU APL, I'd use ⊂⍤1 to achieve Split. Is that the most
efficient way?</div>
<div><br>
</div>
<div>Regards,</div>
<div>Elias</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 9 October 2017 at 16:58, Jay Foad <span
dir="ltr">&lt;<a href="mailto:***@gmail.com"
target="_blank" moz-do-not-send="true">***@gmail.com</a>&gt;</span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote"><span class="">On 9 October
2017 at 04:56, Elias Mårtenson <span dir="ltr">&lt;<a
href="mailto:***@gmail.com" target="_blank"
moz-do-not-send="true">***@gmail.com</a>&gt;</span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Currently, monadic ↑ acts as if it
was called dyadically with 1 as its left
argument,</div>
</blockquote>
<div><br>
</div>
</span>
<div>That's not quite true:</div>
<div>
<div><br>
</div>
<div>      ⍴⍴1↑'ABC'</div>
<div>1</div>
<div>      ⍴⍴↑'ABC'</div>
<div>0</div>
</div>
<span class="">
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr"> 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?</div>
</blockquote>
<div><br>
</div>
</span>
<div>FYI in Dyalog APL monadic ↓ is Split:</div>
<div>
<div><br>
</div>
<div>      ↓3 3⍴⎕A</div>
<div>┌───┬───┬───┐</div>
<div>│ABC│DEF│GHI│</div>
<div>└───┴───┴───┘</div>
</div>
<div><br>
</div>
<div>I believe this came from STSC's NARS.<span
class="HOEnZb"><font color="#888888"><br>
</font></span></div>
<span class="HOEnZb"><font color="#888888">
<div><br>
</div>
<div>Jay.</div>
</font></span></div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>
Louis de Forcrand
2017-10-10 18:06:15 UTC
Permalink
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
Post by Juergen Sauermann
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
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
Post by Jay Foad
Currently, monadic ↑ acts as if it was called dyadically with 1 as its left argument,
⍮⍮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?
↓3 3⍮⎕A
┌───┬───┬───┐
│ABC│DEF│GHI│
└───┮───┮───┘
I believe this came from STSC's NARS.
Jay.
Juergen Sauermann
2017-10-11 12:52:27 UTC
Permalink
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<font face="Helvetica, Arial, sans-serif">Hi Louis,<br>
<br>
I believe the problem is not finding useful applications for the
not yet exploited valence variants of APL primitives.<br>
Every such extension of the APL syntax creates a new
incompatibility and should be avoided in the first place.<br>
<br>
If I remember correctly then there was only one case so far where
a primitive in GNU APL was extended beyond what<br>
IBM APL2 provides: monadic ⍳ for higher ranks (taken from Dyalog
APL). That extension was actually simplifying APL because<br>
it was removing a historical limitation of monadic ⍳ and made it
more general. Using <b>↓</b> for <font face="Courier New,
Courier, monospace"><b>¯1↑</b></font> is, IMHO, not entirely
convincing<br>
and could confuse people more than it helps.<br>
<br>
Best Regards,<br>
/// Jürgen<br>
<br>
</font><br>
<div class="moz-cite-prefix">On 10/10/2017 08:06 PM, Louis de
Forcrand wrote:<br>
</div>
<blockquote type="cite"
cite="mid:7AA368E3-80EB-416F-BC27-***@bluewin.ch">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
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?
<div><br>
</div>
<div>I don’t think this can generally be done on an array X in a
more concise way than </div>
<div>first reverse ravel X</div>
<div>or</div>
<div>(shape X) pick X</div>
<div>which I suppose are both slower than a primitive could be.</div>
<div>This might be considered trivial as well though.</div>
<div><br>
</div>
<div>Just a suggestion!</div>
<div>Louis</div>
<div>
<div><br>
On 10 Oct 2017, at 18:46, Juergen Sauermann &lt;<a
href="mailto:***@t-online.de"
moz-do-not-send="true">***@t-online.de</a>&gt;
wrote:<br>
<br>
</div>
<blockquote type="cite">
<div>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8">
<font face="Helvetica, Arial, sans-serif">Hi Elias,<br>
<br>
I believe ↓ for 1↓ is too trivial to be useful.<br>
<br>
Unoccupied variants of APL primitives (like monadic ↓ or
monadic =) are<br>
a very scarce resource that we should not use for trivial
things.<br>
</font><br>
/// Jürgen<br>
<br>
<br>
<div class="moz-cite-prefix">On 10/09/2017 11:06 AM, Elias
Mårtenson wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CADtN0W+E1UoE+vbPQCB4-***@mail.gmail.com">
<div dir="ltr">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.
<div><br>
</div>
<div>In any case, my point is that monadic ↓ should do
something useful. I guess split is one such useful
thing.</div>
<div><br>
</div>
<div>In GNU APL, I'd use ⊂⍤1 to achieve Split. Is that
the most efficient way?</div>
<div><br>
</div>
<div>Regards,</div>
<div>Elias</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 9 October 2017 at 16:58, Jay
Foad <span dir="ltr">&lt;<a
href="mailto:***@gmail.com" target="_blank"
moz-do-not-send="true">***@gmail.com</a>&gt;</span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote"><span class="">On 9
October 2017 at 04:56, Elias Mårtenson <span
dir="ltr">&lt;<a
href="mailto:***@gmail.com"
target="_blank" moz-do-not-send="true">***@gmail.com</a>&gt;</span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Currently, monadic ↑ acts
as if it was called dyadically with 1 as
its left argument,</div>
</blockquote>
<div><br>
</div>
</span>
<div>That's not quite true:</div>
<div>
<div><br>
</div>
<div>      ⍴⍴1↑'ABC'</div>
<div>1</div>
<div>      ⍴⍴↑'ABC'</div>
<div>0</div>
</div>
<span class="">
<div><br>
</div>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr"> 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?</div>
</blockquote>
<div><br>
</div>
</span>
<div>FYI in Dyalog APL monadic ↓ is Split:</div>
<div>
<div><br>
</div>
<div>      ↓3 3⍴⎕A</div>
<div>┌───┬───┬───┐</div>
<div>│ABC│DEF│GHI│</div>
<div>└───┴───┴───┘</div>
</div>
<div><br>
</div>
<div>I believe this came from STSC's NARS.<span
class="HOEnZb"><font color="#888888"><br>
</font></span></div>
<span class="HOEnZb"><font color="#888888">
<div><br>
</div>
<div>Jay.</div>
</font></span></div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>
Blake McBride
2017-10-12 10:11:15 UTC
Permalink
On Wed, Oct 11, 2017 at 7:52 AM, Juergen Sauermann <
Post by Juergen Sauermann
Hi Louis,
....
Every such extension of the APL syntax creates a new incompatibility and
should be avoided in the first place.
.....
Agreed!

Loading...