Skip to content

Instantly share code, notes, and snippets.

@killme2008
Created October 28, 2015 06:18
Show Gist options
  • Select an option

  • Save killme2008/27dd8186d77c4c054496 to your computer and use it in GitHub Desktop.

Select an option

Save killme2008/27dd8186d77c4c054496 to your computer and use it in GitHub Desktop.
y and z combinator in elixir
y = fn (f) ->
(fn (x) ->
f.(x.(x))
end).(
fn (x) ->
f.(x.(x))
end)
end
z = fn (f) ->
(fn (x) ->
f.(fn (y) ->
x.(x).(y)
end)
end).(
fn (x) ->
f.(fn (y) ->
x.(x).(y)
end)
end)
end
mod = z.(
fn(mod) ->
fn(m) ->
fn(n) ->
if n<=m do
mod.(m-n).(n)
else
m
end
end
end
end)
mod.(100).(7)
mod.(100).(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment