Last active
March 16, 2019 16:21
-
-
Save zetavg/7368c7725bd93ec6d7cb71804334d8ce to your computer and use it in GitHub Desktop.
Haskell imitate of http://bit.ly/nix_pills-fixed_point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fix = \f -> let r = f r in r -- retuns f (f (f (f (f ...)))), sounds like infinile loop? | |
data D = D { | |
a :: Int, | |
b :: Int, | |
c :: Int | |
} deriving (Show) | |
d = (\self -> D 1 (a self + 1) (a self + b self)) -- Can reference itself! | |
-- ^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ | |
-- a b=a+1 c=a+b | |
fix d -- => D {a = 1, b = 2, c = 3} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment