aboutsummaryrefslogtreecommitdiff
path: root/challenge-250/deadmarshal/haskell/ch1.hs
blob: f5cf72a15e6af8ef0c2d932cfa0a5a40092c6b0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Ch1 where

smallestIndex :: Integral a => [a] -> a
smallestIndex xs =
  aux $ zip [0..] xs
  where
    aux [] = -1
    aux ((i,e):tl)
      | mod i 10 == e = i
      | otherwise = aux tl

main :: IO ()
main = do
  print $ smallestIndex [0,1,2]
  print $ smallestIndex [4,3,2,1]
  print $ smallestIndex [1,2,3,4,5,6,7,8,9,0]