mypower.hs 171 B

1234567891011
  1. -- Slide 15
  2. e1 x n = case n of
  3. 0 -> 1
  4. _ -> x * e1 x (n - 1)
  5. e2 x n =
  6. if n == 0
  7. then 1
  8. else if even n
  9. then e2 (x * x) (div n 2)
  10. else x * e2 (x * x) (div n 2)