diff options
| author | chirvasitua <stuart-little@users.noreply.github.com> | 2021-01-12 09:37:35 -0500 |
|---|---|---|
| committer | chirvasitua <stuart-little@users.noreply.github.com> | 2021-01-12 09:37:35 -0500 |
| commit | da5121aa0d0cd10bfc219aa84a09d9528b65cdcb (patch) | |
| tree | 3bb7461bbe5e8a22e00a052aa46029f39c56301e /challenge-033/stuart-little/haskell | |
| parent | b00c8c4f9ff06c18683a5e5380b03585f3301e43 (diff) | |
| download | perlweeklychallenge-club-da5121aa0d0cd10bfc219aa84a09d9528b65cdcb.tar.gz perlweeklychallenge-club-da5121aa0d0cd10bfc219aa84a09d9528b65cdcb.tar.bz2 perlweeklychallenge-club-da5121aa0d0cd10bfc219aa84a09d9528b65cdcb.zip | |
1st commit on 033_haskell
Diffstat (limited to 'challenge-033/stuart-little/haskell')
| -rwxr-xr-x | challenge-033/stuart-little/haskell/ch-1.hs | 13 | ||||
| -rwxr-xr-x | challenge-033/stuart-little/haskell/ch-2.hs | 14 |
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-033/stuart-little/haskell/ch-1.hs b/challenge-033/stuart-little/haskell/ch-1.hs new file mode 100755 index 0000000000..b862cbe4e0 --- /dev/null +++ b/challenge-033/stuart-little/haskell/ch-1.hs @@ -0,0 +1,13 @@ +#!/usr/bin/env runghc + +-- run <script> <space-separated file paths> + +import System.Environment (getArgs,) +import Control.Monad (liftM,) +import Data.Char (toLower,) +import Data.List.Utils (countElem,) + +main = do + files <- getArgs + text <- liftM ((map toLower).concat) $ sequence $ map readFile files + mapM_ putStrLn $ map (\c-> [c] ++ ": " ++ (show $ countElem c text)) ['a'..'z'] diff --git a/challenge-033/stuart-little/haskell/ch-2.hs b/challenge-033/stuart-little/haskell/ch-2.hs new file mode 100755 index 0000000000..14979da343 --- /dev/null +++ b/challenge-033/stuart-little/haskell/ch-2.hs @@ -0,0 +1,14 @@ +#!/usr/bin/env runghc + +-- run <script> <size of the mult_table> + +import System.Environment (getArgs,) +import Control.Monad (liftM,) + +pad :: Int -> String -> String +pad nr str = (replicate ((-) nr $ length str) ' ') ++ str + +main = do + n <- liftM (read::String->Int) $ liftM head getArgs + let ln = length $ show (n*n) + mapM_ putStrLn $ map unwords $ map (\x -> map (\y -> if (y<x) then (replicate ln ' ') else (pad ln (show (x*y)))) [1..n]) [1..n] |
