diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-01-10 11:36:28 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-10 11:36:28 +0000 |
| commit | 845536cc7a8cff2165026fe3b6373a85f4092d91 (patch) | |
| tree | 3a54c7bd8b391b431dbed7b95521f18930afa387 | |
| parent | 5ce2cd05a7d8a22822bd24a5a751fb8c7b379aa5 (diff) | |
| parent | 3fcefbeb854c3a8dd07a8cae0610ab0a659da678 (diff) | |
| download | perlweeklychallenge-club-845536cc7a8cff2165026fe3b6373a85f4092d91.tar.gz perlweeklychallenge-club-845536cc7a8cff2165026fe3b6373a85f4092d91.tar.bz2 perlweeklychallenge-club-845536cc7a8cff2165026fe3b6373a85f4092d91.zip | |
Merge pull request #3201 from stuart-little/stuart-little_067_haskell
1st commit on 067_haskell
| -rwxr-xr-x | challenge-067/stuart-little/haskell/ch-1.hs | 10 | ||||
| -rwxr-xr-x | challenge-067/stuart-little/haskell/ch-2.hs | 14 |
2 files changed, 24 insertions, 0 deletions
diff --git a/challenge-067/stuart-little/haskell/ch-1.hs b/challenge-067/stuart-little/haskell/ch-1.hs new file mode 100755 index 0000000000..1cf9e7377d --- /dev/null +++ b/challenge-067/stuart-little/haskell/ch-1.hs @@ -0,0 +1,10 @@ +#!/usr/bin/env runghc + +-- run <script> <max combinations_size> + +import System.Environment (getArgs,) +import Combinatorics (tuples,) + +main = do + (max:size:_) <- getArgs + mapM_ print $ tuples (read size::Int) [1..read max::Int] diff --git a/challenge-067/stuart-little/haskell/ch-2.hs b/challenge-067/stuart-little/haskell/ch-2.hs new file mode 100755 index 0000000000..bfac195f7a --- /dev/null +++ b/challenge-067/stuart-little/haskell/ch-2.hs @@ -0,0 +1,14 @@ +#!/usr/bin/env runghc + +-- run <script> <digit_string> + +import System.Environment (getArgs,) +import Data.Maybe (fromMaybe,) + +combos :: Eq a => [a] -> [(a,[b])] -> [[b]] +combos as dict = sequence $ map (fromMaybe []) $ map (flip lookup dict) as + +main = do + (nr:_) <- getArgs + let dict = zip ['1'..'9'] ["_@","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"] + putStrLn $unwords $ combos nr dict |
