Advertisement
tinyevil

Untitled

Feb 10th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. fixpoint :: (X->X)->X
  2. fixpoint = /*magic*/
  3.  
  4. f :: Int -> Int
  5. f x = x * 2
  6. print (fixpoint f) // prints "0"
  7.  
  8. g :: String -> String
  9. g s = "Hello, " ++ s
  10. print (fixpoint f) // error, no fixed point
  11.  
  12. foo :: (nat->nat)->(nat->nat)
  13. foo f =
  14. \n -> if n == 0 then 1 else n * f (n - 1)
  15.  
  16. bar :: nat->nat
  17. bar = fixpoint foo //????
  18. //actually, bar is a function computing factorial
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement