|
From: | Emmanuel Charpentier |
Subject: | Niladic functions vs niladic lambdas |
Date: | Thu, 08 Jun 2023 17:37:59 +0200 |
User-agent: | Evolution 3.46.4-2 |
Dear list,
It seems that niladic lambdas are treated like constants.
Rough and naïve illustration : pasting this :
⍝ What about niladic functions and lambdas ?
⍝ Example of a numeric timestamp generator
⍝ Simplifying assumptions : we want to measure about a few minutes
⍝ and not around midnight...
⍝ Start afresh
)clear
⍝ Function
∇ R ← NTS
R ← 24 60 60 1000 ⊥ ¯4↑⎕TS
∇
⍝ Try it
T1 ← NTS
⍝ Wait a few seconds
)host sleep 2
T2 ← NTS
⍞←'Spent Time : ',⍕(T2-T1)÷1000
⍝ Lambda
nts ← {24 60 60 1000 ⊥ ¯4↑⎕TS}
⍝ Try it
t1 ← nts
⍝ Wait a few seconds
)host sleep 2
t2 ← nts
⍞←'Spent time : ',⍕(t2-t1)÷1000
in a gnu-apl
buffer gives :
CLEAR WS
0
Spent Time : 2.002
0
Spent time : 0
Why ?
Bonus question : what causes the impression of the 0
s ?
Sincerely,
-- Emmanuel Charpentier
[Prev in Thread] | Current Thread | [Next in Thread] |