diff options
| author | chirvasitua <stuart-little@users.noreply.github.com> | 2021-01-12 18:18:29 -0500 |
|---|---|---|
| committer | chirvasitua <stuart-little@users.noreply.github.com> | 2021-01-12 18:18:29 -0500 |
| commit | 26e97ac94644e4dfdd7420259b054fed20d4cdbb (patch) | |
| tree | df80188e5b984ad79ea752850931978bbeec51b6 | |
| parent | 4189e0d8c2ea360cd3528920ad992735b2437bce (diff) | |
| download | perlweeklychallenge-club-26e97ac94644e4dfdd7420259b054fed20d4cdbb.tar.gz perlweeklychallenge-club-26e97ac94644e4dfdd7420259b054fed20d4cdbb.tar.bz2 perlweeklychallenge-club-26e97ac94644e4dfdd7420259b054fed20d4cdbb.zip | |
1st commit on 030,068_haskell
| -rwxr-xr-x | challenge-030/stuart-little/haskell/ch-1.hs | 9 | ||||
| -rwxr-xr-x | challenge-030/stuart-little/haskell/ch-2.hs | 8 | ||||
| -rwxr-xr-x | challenge-068/stuart-little/haskell/ch-1.hs | 16 | ||||
| -rwxr-xr-x | challenge-068/stuart-little/haskell/ch-2.hs | 16 |
4 files changed, 49 insertions, 0 deletions
diff --git a/challenge-030/stuart-little/haskell/ch-1.hs b/challenge-030/stuart-little/haskell/ch-1.hs new file mode 100755 index 0000000000..262938f8ad --- /dev/null +++ b/challenge-030/stuart-little/haskell/ch-1.hs @@ -0,0 +1,9 @@ +#!/usr/bin/env runghc + +-- run <script> + +import System.Environment (getArgs,) +import Data.Time.Calendar (dayOfWeek,fromGregorian,DayOfWeek( Sunday ),) + +main = do + mapM_ print $ filter (\d -> Sunday == (dayOfWeek d)) $ map (\y -> fromGregorian y 12 25) [2019..2100] diff --git a/challenge-030/stuart-little/haskell/ch-2.hs b/challenge-030/stuart-little/haskell/ch-2.hs new file mode 100755 index 0000000000..3c7fd77178 --- /dev/null +++ b/challenge-030/stuart-little/haskell/ch-2.hs @@ -0,0 +1,8 @@ +#!/usr/bin/env runghc + +-- run <script> + +import System.Environment (getArgs,) + +main = do + mapM_ print [(x,y,12-x-y) | x <- [1..10], y <- [1..10], x + y < 12] diff --git a/challenge-068/stuart-little/haskell/ch-1.hs b/challenge-068/stuart-little/haskell/ch-1.hs new file mode 100755 index 0000000000..3907763688 --- /dev/null +++ b/challenge-068/stuart-little/haskell/ch-1.hs @@ -0,0 +1,16 @@ +#!/usr/bin/env runghc + +-- run <script> <space-separated 0-1_words, one word per row> + +import System.Environment (getArgs,) +import Data.List (transpose,) + +zeroRows :: Ord a => [[a]] -> [[a]] +zeroRows mat = map (\l -> replicate (length l) (minimum l)) mat + +main = do + mat <- getArgs + putStrLn ((replicate 40 '-') ++ "\nInitial matrix:") + mapM_ putStrLn mat + putStrLn ((replicate 40 '-') ++ "\nTransformed matrix:") + mapM_ putStrLn $ zipWith (zipWith min) (zeroRows mat) (transpose $ zeroRows $ transpose mat) diff --git a/challenge-068/stuart-little/haskell/ch-2.hs b/challenge-068/stuart-little/haskell/ch-2.hs new file mode 100755 index 0000000000..0a7cef3474 --- /dev/null +++ b/challenge-068/stuart-little/haskell/ch-2.hs @@ -0,0 +1,16 @@ +#!/usr/bin/env runghc + +-- run <script> <space-separated list entries> + +import System.Environment (getArgs,) +import Data.List.Utils (join,) + +reorder :: [a] -> [a] +reorder xs + |length xs <= 2 =xs + |otherwise =(head xs:l:(reorder m)) where + (m,(l:_)) = splitAt (length xs - 2) $ tail xs + +main = do + args <- getArgs + putStrLn $ join " -> " $ reorder args |
