aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-01-08 11:45:48 -0500
committerchirvasitua <stuart-little@users.noreply.github.com>2021-01-08 11:45:48 -0500
commitbb384d7eb996edcf5ef5889c3ead95a19604d892 (patch)
tree15ee7e384531248bb62bb7e1ea936323afcde298
parent3e42a8e7ab9f8e43eed7f07a3f76e3e8ab3e561a (diff)
downloadperlweeklychallenge-club-bb384d7eb996edcf5ef5889c3ead95a19604d892.tar.gz
perlweeklychallenge-club-bb384d7eb996edcf5ef5889c3ead95a19604d892.tar.bz2
perlweeklychallenge-club-bb384d7eb996edcf5ef5889c3ead95a19604d892.zip
1st commit on 004_haskell
-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