diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-01-08 22:08:36 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-08 22:08:36 +0000 |
| commit | dbdaa1078bbfd1ef54ffa1315daaca18a0a93b99 (patch) | |
| tree | bbb5b17e11ae0153bd4a621d009e6177c5bf5b46 | |
| parent | ab9b4fc2506779b67d119259ecbd0cf7408af43c (diff) | |
| parent | bb384d7eb996edcf5ef5889c3ead95a19604d892 (diff) | |
| download | perlweeklychallenge-club-dbdaa1078bbfd1ef54ffa1315daaca18a0a93b99.tar.gz perlweeklychallenge-club-dbdaa1078bbfd1ef54ffa1315daaca18a0a93b99.tar.bz2 perlweeklychallenge-club-dbdaa1078bbfd1ef54ffa1315daaca18a0a93b99.zip | |
Merge pull request #3182 from stuart-little/stuart-little_004_haskell
1st commit on 004_haskell
| -rwxr-xr-x | challenge-004/stuart-little/haskell/ch-1.hs | 15 | ||||
| -rwxr-xr-x | challenge-004/stuart-little/haskell/ch-2.hs | 12 |
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 |
