aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-01-20 17:31:01 -0500
committerchirvasitua <stuart-little@users.noreply.github.com>2021-01-20 17:31:01 -0500
commitda03fbf8fde2c60cbbaef42ca47f6345f71e487a (patch)
tree0761a3f50653110ff454a5bf5dafee397436a4ce
parent56877338c2addcd41e2a8685b205f505963827b2 (diff)
downloadperlweeklychallenge-club-da03fbf8fde2c60cbbaef42ca47f6345f71e487a.tar.gz
perlweeklychallenge-club-da03fbf8fde2c60cbbaef42ca47f6345f71e487a.tar.bz2
perlweeklychallenge-club-da03fbf8fde2c60cbbaef42ca47f6345f71e487a.zip
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