bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] A couple of bugs, and a question on the power operator


From: Louis de Forcrand
Subject: Re: [Bug-apl] A couple of bugs, and a question on the power operator
Date: Mon, 15 Aug 2016 21:54:22 -0400

I'm sorry, _I_ misunderstood the manual. I did not know that Dyalog dfns were always dyadic / ambivalent.

If I understand correctly then, in F {pow} G, G's left argument is _always_ the result of the power operator if G is true. Its right argument then is _always_ the result of the previous iteration. Is that correct?

If it is, I believe always ambivalent lambdas would be convenient (aside from possible implementation problems), but not at all essential; it's probably rare to check something about the previous iteration without comparing it to the current one. But wouldn't have been simpler to model them as ambivalent from the ground up?

Louis

On 15 Aug 2016, at 08:22, Jay Foad <address@hidden> wrote:

The manual is here, see page 145: http://docs.dyalog.com/15.0/Dyalog%20APL%20Language%20Reference%20Guide.pdf

I'm not sure where Louis got the information about monadic G. I assure you that Dyalog APL does not examine G to see if it's monadic or dyadic. It always tries to apply G dyadically.

Jay.

On 15 August 2016 at 12:30, Juergen Sauermann <address@hidden> wrote:
Hi Jay,

I see. Maybe I misunderstood Louis,s email from last Saturday completely?
The way I read this email was that in Dyalog APL version 15 you can have
a monadic condition function G in F⍣G . Quote from the email:


The Dyalog 15.0 manual states that the power operator can take a
function right argument. In this case, that function can be
either monadic or dyadic, and can be a lambda.
If it’s monadic:

  (F⍣G) ⍵  ←→  ⍵ ←   F ⍵  until          G ⍵
⍺ (F⍣G) ⍵  ←→  ⍵ ← ⍺ F ⍵  until          G ⍵

If it’s dyadic:

  (F⍣G) ⍵  ←→  ⍵ ←   F ⍵  until  (  F ⍵) G ⍵
⍺ (F⍣G) ⍵  ←→  ⍵ ← ⍺ F ⍵  until  (⍺ F ⍵) G ⍵

(Note that G is checked before the first time F is executed.)

I don't know if that statement is correct or not, but if it is then I would prefer to not
introduce this "monadic case" in GNU APL for the reasons explained earlier.

Thanks,
Jürgen


On 08/15/2016 10:16 AM, Jay Foad wrote:
On 13 August 2016 at 13:05, Juergen Sauermann <address@hidden> wrote:
In "Mastering Dyalog APL" I haven't found the monadic case for the right function argument
G of the power operator. In that book G seems to be always dyadic. So the monadic case looks
like a new Dyalog invention. And, if it is defined like you say, IMHO not the ultimate wisdom.

There is no "monadic case". G is always applied dyadically, and if it happens to be a strictly monadic function then you'll get a SYNTAX ERROR:

      ⎕FX'r←g y' 'r←g>10' ⍝ g is strictly monadic
      2 g 4 ⍝ applying it dyadically gives an error
SYNTAX ERROR
      (+⍨⍣g)1 ⍝ power operator tries to apply g dyadically
SYNTAX ERROR

In general, Dyalog APL never examines a function operand to see whether it is monadic or dyadic, in order to treat them differently.

Jay.



reply via email to

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