Use of Local Variables in Lambdas (Direct Functions) ?
Hi, reading GNU APL documentation, in the section 2.7 "2.7 Direct Functions (Lambdas)", It states that lambdas do not support multiple expressions (amongst other features). If this is the case, what purpose does allowing local variable declarations serve? Allowing SUM ← { ⍺ + ⍵ ;C;D } .. but not allowing multiple statements prevents assigning to C or D, or really using them at all, so what is the purpose of allowing their declaration? Please forgive me if I am missing something obvious here. Thanks, -Russ
Re: Use of Local Variables in Lambdas (Direct Functions) ?
I have created many one-liners that use local variables. On Fri, Jul 9, 2021, 6:38 PM Russtopia wrote: > Hi, reading GNU APL documentation, in the section 2.7 "2.7 Direct > Functions (Lambdas)", > > It states that lambdas do not support multiple expressions (amongst other > features). If this is the case, what purpose does allowing local variable > declarations serve? > > Allowing > > SUM ← { ⍺ + ⍵ ;C;D } > > .. but not allowing multiple statements prevents assigning to C or D, or > really using them at all, so what is the purpose of allowing their > declaration? Please forgive me if I am missing something obvious here. > > Thanks, > > -Russ > > >
Bugs (perhaps?) in behaviour of )COPY, )PCOPY with named lambda fns
I have noticed what I believe are some inconsistencies (bugs?) with how GNU APL handles reloading/overwriting/erasing of symbols which are 'trad fns' versus 'lambda fns'. Consider the following )DUMP file: --8<-- #!/usr/local/bin/apl --script ⍝⍝ ⍝ sink.apl 2021-07-09 20:04:14 (GMT-8) ⍝ ⍝⍝ Life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵} ∇a←MatToVecArray M ⍝⍝ Return rows in M as an array of vectors ⍝⍝ lambda (dfn) version: {(⊂⍺){⍺[⍵;]}¨⍳≢⍵} ⍝⍨M a←{⊂M[⍵;]}¨⍳≢M ∇ --8<-- The above will )LOAD and )LOAD a second time, without error (as I presume it totally overwrites the current WS). However, )COPY or )PCOPY will give an error for the 'Life' function if it is already loaded into the current WS: )copy sink Life DUMPED 2021-07-09 20:04:14 (GMT-8) )copy sink Life DUMPED 2021-07-09 20:04:14 (GMT-8) SYNTAX ERROR Life←λ1 ^^ Regular 'trad fns' can be re-loaded into the current WS without issue. If I add in ⎕EX 'Life' to sink.apl above the definition, )COPY and PCOPY will now succeed; but if I )DUMP this WS back to file, the ⎕EX is not part of the )DUMP output so problems will re-occur. As an final note, as an APL newcomer: When is it preferable to use ⎕EX instead of )ERASE ?) Thanks, -Russ