|
From: | Juergen Sauermann |
Subject: | Re: [Bug-apl] This looks wrong |
Date: | Thu, 07 Aug 2014 14:20:27 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 |
Hi Jay,
the functions are called λ1. λ2, ... for the first, second, ... lambda. However the names above are not entered into the symbol table, therefore you can't call them via their names. The function bodies can't be displayed with ⎕CR, but may show up in error messages: ∇foo [1] bar←{ ++ } [2] bar [3] ∇ foo SYNTAX ERROR bar[1] λ←++ ^ ^ All lambdas return a value which is called λ. The full (and simple) truth about lambdas in GNU APL is this: At tokenization time a text string like { body } is converted into a defined function named λ1 (for the first lambda), λ2 for the second lambda, and so on: [0] λ←header [1] λ←body where header is constructed from the symbols ⍺, ⍶, ⍵, ⍹, and χ that appear in the body. Thus header is λ1 for niladic lambdas, λ1 ⍵ for monadic lambdas, and so on. Some of the things I said before could be wrong because I was mentally still in the state before the change to make niladic lambdas execute immediately. /// Jürgen On 08/07/2014 01:04 PM, Jay Foad wrote: What function is it? How can I execute that function? The only reasonable answers I can think of are "it's the function {1⊣⎕←2}" and "you can execute it by typing f and hitting ENTER", but that's clearly not true because when I type f and hit ENTER I don't see the number 2 printed to the session: f 1 Thanks, Jay. On 7 August 2014 11:44, Juergen Sauermann <address@hidden> wrote:The reason why ⎕NC shows 2 below is because 'f' is a variable whose current value is a function. /// Jürgen On 08/07/2014 10:52 AM, Jay Foad wrote: So the only benefit of the GNU APL approach is that it allows the definition of niladic functions by assigning from a lambda. I don't understand. You can't use assignment to name a niladic lambda in GNU APL, because it will be evaluated before the assignment happens: f←{1⊣⎕←2} 2 f 1 ⎕NC'f' ⍝ it's an array, not a function 2 Jay. |
[Prev in Thread] | Current Thread | [Next in Thread] |