gt22

Untitled

Sep 28th, 2020 (edited)
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. triple x = 3 * x
  2. sgn x | x > 0 = 1
  3. | x < 0 = -1
  4. | otherwise = 0
  5.  
  6. nor :: Bool -> Bool -> Bool
  7. nor False False = True
  8. nor _ _ = False
  9.  
  10. nand :: Bool -> Bool -> Bool
  11. nand True True = False
  12. nand _ _ = True
  13.  
  14. fib 0 = 0
  15. fib 1 = 1
  16. fib n = fib (n - 1) + fib (n - 2)
  17.  
  18. fib' n = fib'' 0 1 n
  19. where fib'' a _ 0 = a
  20. fib'' a b n = fib'' b (a+b) (n-1)
  21.  
  22.  
  23. fac' _ 0 = 1
  24. fac' f n = n * f (n - 1)
  25. fac = fix fac'
  26.  
  27.  
  28. sumsq = on (+) (^2)
Add Comment
Please, Sign In to add comment