aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-03-22 09:31:10 -0400
committerchirvasitua <stuart-little@users.noreply.github.com>2021-03-22 19:13:59 -0400
commita7e6c4eca6c5e02cd847bb32e4fa49a96abdadb2 (patch)
tree3d21ff899e32030903e6d38a7e166c123eb6d0e1
parent7c2d89ebc351875ef67e4e351cbb8d813852d8fe (diff)
downloadperlweeklychallenge-club-a7e6c4eca6c5e02cd847bb32e4fa49a96abdadb2.tar.gz
perlweeklychallenge-club-a7e6c4eca6c5e02cd847bb32e4fa49a96abdadb2.tar.bz2
perlweeklychallenge-club-a7e6c4eca6c5e02cd847bb32e4fa49a96abdadb2.zip
1st commit on 105_haskell
-rwxr-xr-xchallenge-105/stuart-little/haskell/ch-1.hs14
-rwxr-xr-xchallenge-105/stuart-little/haskell/ch-2.hs22
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-105/stuart-little/haskell/ch-1.hs b/challenge-105/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..3f1647091f
--- /dev/null
+++ b/challenge-105/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,14 @@
+#!/usr/bin/env runghc
+
+-- run <script> <exponent> <number>
+
+import System.Environment (getArgs)
+
+nthRoot :: Int -> Int -> Double
+nthRoot xp nr = let rootFloor = head $ dropWhile (\x -> (x+1)^xp <= nr) [1..] in
+ if (rootFloor ^ xp == nr) then fromIntegral rootFloor
+ else exp (((log $ fromIntegral nr))/(fromIntegral xp))
+
+main = do
+ (xp:nr:_) <- getArgs >>= return . map (read::String->Int)
+ print $ nthRoot xp nr
diff --git a/challenge-105/stuart-little/haskell/ch-2.hs b/challenge-105/stuart-little/haskell/ch-2.hs
new file mode 100755
index 0000000000..dcfc71a4c2
--- /dev/null
+++ b/challenge-105/stuart-little/haskell/ch-2.hs
@@ -0,0 +1,22 @@
+#!/usr/bin/env runghc
+
+-- run <script> <name>
+
+import Data.Char (toLower,toUpper)
+import System.Environment (getArgs)
+
+ellis :: Char -> String -> String
+ellis c name = (c:"o-") ++ if (c == (toLower $ head name))
+ then (tail name)
+ else (c:"") ++ (tail name)
+
+verse :: String -> String
+verse name = let capName = ((toUpper $ head name):(tail name)) in
+ capName ++ ", " ++ capName ++ ", " ++ (ellis 'b' capName) ++ "\n"
+ ++ "Bonana-fanna " ++ (ellis 'f' capName) ++ "\n"
+ ++ "Fee fi " ++ (ellis 'm' capName) ++ "\n"
+ ++ capName ++ "!"
+
+main = do
+ (name:_) <- getArgs
+ putStrLn $ verse name