bug-apl
[Top][All Lists]
Advanced

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

Re: Niladic functions vs niladic lambdas


From: Kacper Gutowski
Subject: Re: Niladic functions vs niladic lambdas
Date: Thu, 8 Jun 2023 19:28:52 +0200

On Thu, 8 Jun 2023 at 17:38, Emmanuel Charpentier wrote:

It seems that niladic lambdas are treated like constants.

In GNU APL lambda is dyadic if it contains a reference to ⍺ or monadic if it uses ⍵. There is no way to distinguish a call of niladic lambda from a definition of niladic lambda in assignment, so the moment you write nts←{...} it gets evaluated and nts becomes a regular variable holding its result rather than a function. Jürgen wanted to depart as little as possible from normal semantics of defined functions when introducing lambda notation.

FWIW, running the same code in a Dyalog APL Jupyter notebook gives similar results :   

(...) 
t2 ← nts
⍞←'Spent time : ',⍕(t2-t1)÷1000
In Dyalog, on the other hand, all lambdas are always ambivalent. They can be called with either one or two arguments regardless of how they are defined, but there are no niladic lambdas at all. What your code actually does is calling the function train (t2-t1) with the argument of ÷1000 (t1 and t2 are functions, not values). Both t1 and t2 are evaluated at the same time here, not when you alias nts to them.

As you can see, it can be confusing either way.

-k

reply via email to

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