aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-01-21 02:36:59 +0000
committerGitHub <noreply@github.com>2021-01-21 02:36:59 +0000
commitf4f39d15a89ef06e298c0512b79e6e466fd38691 (patch)
treeadbf949db6e38cc5a228b14dc633b6394c77f982
parentffe2a9b1fd8049652612216b9b9d7d90d9ff2362 (diff)
parentda03fbf8fde2c60cbbaef42ca47f6345f71e487a (diff)
downloadperlweeklychallenge-club-f4f39d15a89ef06e298c0512b79e6e466fd38691.tar.gz
perlweeklychallenge-club-f4f39d15a89ef06e298c0512b79e6e466fd38691.tar.bz2
perlweeklychallenge-club-f4f39d15a89ef06e298c0512b79e6e466fd38691.zip
Merge pull request #3329 from stuart-little/stuart-little_044_haskell
1st commit on 044_haskell
-rwxr-xr-xchallenge-044/stuart-little/haskell/ch-1.hs6
-rwxr-xr-xchallenge-044/stuart-little/haskell/ch-2.hs16
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-044/stuart-little/haskell/ch-1.hs b/challenge-044/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..15edf3a4df
--- /dev/null
+++ b/challenge-044/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,6 @@
+#!/usr/bin/env runghc
+
+-- run <script>
+
+main = do
+ putStrLn $ "123-45-67+89=" ++ (show $ 123-45-67+89)
diff --git a/challenge-044/stuart-little/haskell/ch-2.hs b/challenge-044/stuart-little/haskell/ch-2.hs
new file mode 100755
index 0000000000..b75885bfab
--- /dev/null
+++ b/challenge-044/stuart-little/haskell/ch-2.hs
@@ -0,0 +1,16 @@
+#!/usr/bin/env runghc
+
+-- run <script> <number to get or nothing to default to 200>
+
+import Data.List.Extra (headDef,)
+import System.Environment (getArgs,)
+
+doubleOrAdd1 :: Int -> [Int]
+doubleOrAdd1 nr
+ |nr==1 =[1]
+ |even nr = nr:(doubleOrAdd1 $ div nr 2)
+ |odd nr = nr:(doubleOrAdd1 $ (-) nr 1)
+
+main = do
+ nr <- getArgs >>= return.(read::String->Int).(headDef "200")
+ print $ reverse $ doubleOrAdd1 nr