aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-01-20 21:54:10 -0500
committerchirvasitua <stuart-little@users.noreply.github.com>2021-01-20 21:54:10 -0500
commit4a0cbd42c5089a5bd7b5393c88de52464bf2a389 (patch)
tree07b7f8acabc60ddc7c95d3e2581468fb52af4d39
parentf4f39d15a89ef06e298c0512b79e6e466fd38691 (diff)
downloadperlweeklychallenge-club-4a0cbd42c5089a5bd7b5393c88de52464bf2a389.tar.gz
perlweeklychallenge-club-4a0cbd42c5089a5bd7b5393c88de52464bf2a389.tar.bz2
perlweeklychallenge-club-4a0cbd42c5089a5bd7b5393c88de52464bf2a389.zip
1st commit on 028_haskell
-rwxr-xr-xchallenge-028/stuart-little/haskell/ch-1.hs21
-rwxr-xr-xchallenge-028/stuart-little/haskell/ch-2.hs16
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-028/stuart-little/haskell/ch-1.hs b/challenge-028/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..372290f2ed
--- /dev/null
+++ b/challenge-028/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,21 @@
+#!/usr/bin/env runghc
+
+-- run <script> <file-path>
+
+import System.Directory (getFileSize,)
+import System.Environment (getArgs,)
+import System.IO (IOMode( ReadMode ),openFile,)
+import qualified Data.ByteString as B
+import qualified Data.ByteString.UTF8 as B
+
+main = do
+ pth <- getArgs >>= return . head
+ fs <- getFileSize pth
+ hand <- openFile pth ReadMode
+ cont <- B.hGetContents hand
+ let tp = if elem B.replacement_char $ B.toString cont
+ then "binary"
+ else "text"
+ putStrLn $ if fs==0 then "empty file"
+ else tp ++ " file"
+
diff --git a/challenge-028/stuart-little/haskell/ch-2.hs b/challenge-028/stuart-little/haskell/ch-2.hs
new file mode 100755
index 0000000000..7111ddee84
--- /dev/null
+++ b/challenge-028/stuart-little/haskell/ch-2.hs
@@ -0,0 +1,16 @@
+#!/usr/bin/env runghc
+
+-- run <script>
+
+import Data.Time (getZonedTime,formatTime,defaultTimeLocale,)
+import System.Console.ANSI (clearScreen,cursorUp,)
+import System.Time.Extra (sleep,)
+
+main :: IO ()
+main = do
+ clearScreen
+ cursorUp 1
+ tm <- getZonedTime
+ putStrLn $ formatTime defaultTimeLocale "%T" tm
+ sleep 1
+ main