aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-01-13 03:16:54 +0000
committerGitHub <noreply@github.com>2021-01-13 03:16:54 +0000
commit8ad5a160d6fc344c435145a7574ab9d8b095cd15 (patch)
tree7b106b0fbf2650810f3f1e1ed3e705d038e8f439
parent2442c2cc39af612e6a4ab0bea92348df84c583c0 (diff)
parentda5121aa0d0cd10bfc219aa84a09d9528b65cdcb (diff)
downloadperlweeklychallenge-club-8ad5a160d6fc344c435145a7574ab9d8b095cd15.tar.gz
perlweeklychallenge-club-8ad5a160d6fc344c435145a7574ab9d8b095cd15.tar.bz2
perlweeklychallenge-club-8ad5a160d6fc344c435145a7574ab9d8b095cd15.zip
Merge pull request #3234 from stuart-little/stuart-little_033_haskell
1st commit on 033_haskell
-rwxr-xr-xchallenge-033/stuart-little/haskell/ch-1.hs13
-rwxr-xr-xchallenge-033/stuart-little/haskell/ch-2.hs14
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]