diff options
| author | chirvasitua <stuart-little@users.noreply.github.com> | 2021-01-15 20:02:55 -0500 |
|---|---|---|
| committer | chirvasitua <stuart-little@users.noreply.github.com> | 2021-01-15 20:02:55 -0500 |
| commit | c543d6e10f5e722a1b7967bb1153537cd8061a67 (patch) | |
| tree | b96a5e67ebf8c9a8a5aee34e4c6a6f8006fadae1 /challenge-031 | |
| parent | cd6c653837dc0099b652ddba92cacb8e89b979d6 (diff) | |
| download | perlweeklychallenge-club-c543d6e10f5e722a1b7967bb1153537cd8061a67.tar.gz perlweeklychallenge-club-c543d6e10f5e722a1b7967bb1153537cd8061a67.tar.bz2 perlweeklychallenge-club-c543d6e10f5e722a1b7967bb1153537cd8061a67.zip | |
1st commit on 031_haskell
Diffstat (limited to 'challenge-031')
| -rwxr-xr-x | challenge-031/stuart-little/haskell/ch-1.hs | 10 | ||||
| -rwxr-xr-x | challenge-031/stuart-little/haskell/ch-2.hs | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/challenge-031/stuart-little/haskell/ch-1.hs b/challenge-031/stuart-little/haskell/ch-1.hs new file mode 100755 index 0000000000..a2fecfdb20 --- /dev/null +++ b/challenge-031/stuart-little/haskell/ch-1.hs @@ -0,0 +1,10 @@ +#!/usr/bin/env runghc + +-- run <script> <numerator> <denominator> + +import Data.List (isSuffixOf,) +import System.Environment (getArgs,) + +main = do + (num:den:_) <- getArgs >>= return.(map (read::String->Float)) + putStrLn $ (\w -> if isSuffixOf "Infinity" w then "You divided by zero." else w) $ show $ (/) num den diff --git a/challenge-031/stuart-little/haskell/ch-2.hs b/challenge-031/stuart-little/haskell/ch-2.hs new file mode 100755 index 0000000000..6146e4d444 --- /dev/null +++ b/challenge-031/stuart-little/haskell/ch-2.hs @@ -0,0 +1,15 @@ +#!/usr/bin/env runghc + +-- run <script> <variable_name> <integer> + +import System.Environment (getArgs,) + +data NamedVar = NV { name :: String + , value :: Int + } deriving (Show) + +main = do + (nm,val) <- getArgs >>= return.(\(a:b:_) -> (a,(read b::Int))) + let var :: NamedVar + var = NV {name=nm, value=val} + putStrLn $ "Your variable is named " ++ (show $ name var) ++ " and its value is " ++ (show $ value var) ++ "." |
