Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/Variables/Haskell/variables-1.hs
Normal file
11
Task/Variables/Haskell/variables-1.hs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
foobar = 15
|
||||
|
||||
f x = x + foobar
|
||||
where foobar = 15
|
||||
|
||||
f x = let foobar = 15
|
||||
in x + foobar
|
||||
|
||||
f x = do
|
||||
let foobar = 15
|
||||
return $ x + foobar
|
||||
7
Task/Variables/Haskell/variables-2.hs
Normal file
7
Task/Variables/Haskell/variables-2.hs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
main = do
|
||||
s <- getLine
|
||||
print (s, s)
|
||||
|
||||
-- The above is equivalent to:
|
||||
|
||||
main = getLine >>= \s -> print (s, s)
|
||||
4
Task/Variables/Haskell/variables-3.hs
Normal file
4
Task/Variables/Haskell/variables-3.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
funkshun True x = x + 1
|
||||
funkshun False x = x - 1
|
||||
|
||||
foobar = funkshun True 5 + funkshun False 5 -- 6 + 4
|
||||
4
Task/Variables/Haskell/variables-4.hs
Normal file
4
Task/Variables/Haskell/variables-4.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
funkshun m = case foo m of
|
||||
[a, b] -> a - b
|
||||
a : b : c : rest -> a + b - c + sum rest
|
||||
a -> sum a
|
||||
3
Task/Variables/Haskell/variables-5.hs
Normal file
3
Task/Variables/Haskell/variables-5.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
signum x | x > 0 = 1
|
||||
| x < 0 = -1
|
||||
| otherwise = 0
|
||||
10
Task/Variables/Haskell/variables-6.hs
Normal file
10
Task/Variables/Haskell/variables-6.hs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
dotProduct :: [Int] -> [Int] -> Int
|
||||
dotProduct ns ms = sum $ zipWith (+) ns ms
|
||||
-- Without the type signature, dotProduct would
|
||||
-- have a more general type.
|
||||
|
||||
foobar :: Num a => a
|
||||
foobar = 15
|
||||
-- Without the type signature, the monomorphism
|
||||
-- restriction would cause foobar to have a less
|
||||
-- general type.
|
||||
Loading…
Add table
Add a link
Reference in a new issue