aboutsummaryrefslogtreecommitdiff
path: root/challenge-073/stuart-little/haskell/ch-2.hs
blob: 79b2d3b5487d00e4b8e995c65cf2b1d07dba8005 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env runghc

-- run as <script> <space-separated numbers>

import System.Environment (getArgs,)
import Data.List (inits,)

condmin xs
  |last xs == minimum xs =0
  |otherwise =minimum xs
  
condmins xs = map condmin $ drop 1 $ inits xs
       
main = do  
  args <- getArgs  
  putStrLn $ unwords $ map show $ condmins $ map (read::String->Int) args