|
From: | Dr . Jürgen Sauermann |
Subject: | Re: Niladic functions vs niladic lambdas |
Date: | Thu, 8 Jun 2023 19:44:03 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 |
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] |