|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- Preliminary.
-- 2011nov17
-- (find-es "haskell")
-- (find-angg ".emacs" "hugs")
-- (find-hugsbasefile "Prelude.hs")
-- (find-hugsbasefile "Prelude.hs" "Standard list functions")
plus1 x = x + 1
-- mycar :: [Int] -> Int
mycar [] = 99
mycar (a:b) = a
merge a b = merge' a b []
-- (find-hugsbasefile "Prelude.hs" "max x y")
merge' [] [] c = c
merge' (a:as) [] c = merge' as [] (c ++ [a])
merge' [] (b:bs) c = merge' [] bs (c ++ [b])
merge' (a:as) (b:bs) c | a < b = merge' as (b:bs) (c ++ [a])
| otherwise = merge' (a:as) bs (c ++ [b])
doubleSmallNumber x = if x > 100
then x
else x*2
doubleSmallNumber' x = (if x > 100 then x else x*2) + 1
{-
* (eepitch-ghci)
* (eepitch-kill)
* (eepitch-ghci)
:load mergesort.hs
let lostNumbers = [4,8,15,16,23,42]
lostNumbers
[1,2,3,4] ++ [9,10,11,12]
"hello" ++ " " ++ "world"
['w','o'] ++ ['o','t']
'A':" SMALL CAT"
5:[1,2,3,4,5]
-}
{-
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
ghci
:load mergesort.hs
:t merge
merge [20, 30, 40] []
merge [] [20, 30, 40]
merge [22, 24, 50] [20, 30, 40]
:t plus1
plus1 20
:t mycar
mycar [20, 30, 40]
mycar []
:t []
:t [20, 30, 40]
:?
-- http://learnyouahaskell.com/starting-out
True && False
True && True
False || True
not False
not (True && True)
5 == 5
1 == 0
5 /= 5
5 /= 4
"hello" == "hello"
5 + "llama"
min 9 10
min 3.4 3.2
max 100 101
succ 9 + max 5 4 + 1
(succ 9) + (max 5 4) + 1
min 3.4 4
* (eepitch-ghci)
* (eepitch-kill)
* (eepitch-ghci)
:load mergesort.hs
:t merge
merge [20, 30, 40] []
merge [] [20, 30, 40]
merge [22, 24, 50] [20, 30, 40]
-}