1 -- LML original: Sandra Foubister, 1990 2 -- Haskell translation: Colin Runciman, May 1991 3 4 module Diff(diff, bcroot, square) where 5 6 square :: Int -> Int 7 square n = n*n 8 9 diff :: Int -> Int -> Int 10 diff a b = if a>b then a-b else b-a 11 12 bcroot :: Int -> Int 13 bcroot n = root' 0 n 14 where root' a b = if a+1>=b then b 15 else if s<n then root' m b 16 else if n<s then root' a m 17 else m 18 where 19 m = (a+b) `div` 2 20 s = m*m 21 22 23