Skip to content

Instantly share code, notes, and snippets.

@ragnard
Last active August 17, 2017 13:27
Show Gist options
  • Save ragnard/eff51d6afd36f79d1558cdd7951a9fc4 to your computer and use it in GitHub Desktop.
Save ragnard/eff51d6afd36f79d1558cdd7951a9fc4 to your computer and use it in GitHub Desktop.
tail recursion
(defun count-down (n)
(if (= n 0)
done
(count-down (- n 1))))
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
functor
import
System(showInfo:Show)
Boot_Time at 'x-oz://boot/Time'
define
fun {CountDown N}
if N = 0 then
N
else
{CountDown (N - 1)}
end
end
for I in 1..10 do
local
T0={Boot_Time.getMonotonicTime}
{Show {CountDown 1000000}}
T1={Boot_Time.getMonotonicTime}
in
{Show (T1-T0) div 1000000}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment