RosettaCodeData/Task/Y-combinator/Mathematica/y-combinator.math

4 lines
174 B
Text
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
Y = Function[f, #[#] &[Function[g, f[g[g][##] &]]]];
factorial = Y[Function[f, If[# < 1, 1, # f[# - 1]] &]];
2016-12-05 22:15:40 +01:00
fibonacci = Y[Function[f, If[# < 2, #, f[# - 1] + f[# - 2]] &]];