mirror of
https://github.com/fluencelabs/redis
synced 2025-07-26 14:01:56 +00:00
deps
hiredis
jemalloc
linenoise
lua
doc
etc
src
test
README
bisect.lua
cf.lua
echo.lua
env.lua
factorial.lua
fib.lua
fibfor.lua
globals.lua
hello.lua
life.lua
luac.lua
printf.lua
readonly.lua
sieve.lua
sort.lua
table.lua
trace-calls.lua
trace-globals.lua
xd.lua
COPYRIGHT
HISTORY
INSTALL
Makefile
README
Makefile
src
tests
utils
.gitignore
00-RELEASENOTES
BUGS
CONTRIBUTING
COPYING
Changelog
INSTALL
MANIFESTO
Makefile
README
redis.conf
runtest
sentinel.conf
33 lines
707 B
Lua
33 lines
707 B
Lua
-- function closures are powerful
|
|
|
|
-- traditional fixed-point operator from functional programming
|
|
Y = function (g)
|
|
local a = function (f) return f(f) end
|
|
return a(function (f)
|
|
return g(function (x)
|
|
local c=f(f)
|
|
return c(x)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
|
|
-- factorial without recursion
|
|
F = function (f)
|
|
return function (n)
|
|
if n == 0 then return 1
|
|
else return n*f(n-1) end
|
|
end
|
|
end
|
|
|
|
factorial = Y(F) -- factorial is the fixed point of F
|
|
|
|
-- now test it
|
|
function test(x)
|
|
io.write(x,"! = ",factorial(x),"\n")
|
|
end
|
|
|
|
for n=0,16 do
|
|
test(n)
|
|
end
|