--

strlen :: String -> Int
strlen [] = 0
strlen (x:xs) = 1 + strlen xs

strlenA = length
strlenB = sum . map (const 1)
strlenC = foldr (+) 0 . map (const 1)


factA 0 = 1
factA n = n * (factA (n-1))


factB n = product [1..n]


ncopiesA :: Num a => a -> b -> [b]
ncopiesA 0 x = []
ncopiesA n x = x : (ncopiesA (n-1) x)

ncopiesB n x = map (const x) [1..n]

ncopiesC n x = [ x | y <- [1..n] ]

ncopiesD n x = take n (repeat x)

powerA x 0 = 1
powerA x 1 = x
powerA x n = x * (powerA x (n-1))


powerB x n = product (ncopiesA n x)



str2int :: String -> Int
str2int =
   sum .
   map (uncurry (*)) .
   explist .
   map (\ z -> z -(ord '0')) .
   map ord

explist zs =
  zip zs [ powerA 10 x | x <- reverse [0 .. n-1] ]
    where n = length zs

explistB = fst . foldr g ([],1)
  where z `g` (zs,n) = ((z,n) : zs, n * 10)

------------------------------------------------------------

--