All pastes #2092538 Raw Edit

Unnamed

public text v1 · immutable
#2092538 ·published 2011-10-22 13:26 UTC
rendered paste body
module Main where

main::IO()
main = undefined

pow1 :: (Num a1, Num a) => a -> a1 -> a
pow1 b e
 | (b == 0) = 0
 | (e == 0) = 1
 | otherwise = b * (pow1 b (e - 1))
 
pow2 :: (Num a, Fractional a1, Integral a1) => a -> a1 -> a
pow2 b e
 | (b == 0) = 0
 | (e == 0) = 1
 | (e == 1) = b
 | (even e) = 1
 | otherwise = pow2 (b * b) (e/2)
 
mod1 :: Integral a => ((a -> a -> a) -> t1 -> t) -> t1 -> t 
mod1 a m
 | otherwise = a mod m