aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-004/stuart-little/haskell/ch-1.hs15
-rwxr-xr-xchallenge-004/stuart-little/haskell/ch-2.hs12
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-004/stuart-little/haskell/ch-1.hs b/challenge-004/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..ee75934358
--- /dev/null
+++ b/challenge-004/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,15 @@
+#!/usr/bin/env runghc
+
+-- run <script> in the directory where it resides
+
+{-# LANGUAGE DataKinds #-}
+
+import System.IO (IOMode( ReadMode ), withFile, hFileSize,)
+import System.Environment (getProgName,)
+import Numeric.Rounded (RoundingMode( TowardZero ), Rounded,)
+
+main = do
+ progName <- getProgName
+ filesize <- withFile progName ReadMode hFileSize
+ putStrLn $ "File size: " ++ show filesize
+ putStrLn $ take ((fromInteger filesize) + 1) $ show (pi :: Rounded TowardZero 3000)
diff --git a/challenge-004/stuart-little/haskell/ch-2.hs b/challenge-004/stuart-little/haskell/ch-2.hs
new file mode 100755
index 0000000000..9768acb0e2
--- /dev/null
+++ b/challenge-004/stuart-little/haskell/ch-2.hs
@@ -0,0 +1,12 @@
+#!/usr/bin/env runghc
+
+-- run <script> <string> <path-to-file> where the string contains all of your letters, in any order
+
+import System.Environment (getArgs,)
+import Data.List ((\\),)
+import Data.Char (toLower,)
+
+main = do
+ (llist:file:_) <- getArgs
+ content <- readFile file
+ mapM_ putStrLn $ filter (\w -> (map toLower w) \\ (map toLower llist) == "") $ lines content