diff options
author | Vojta Svoboda <vojtasvoboda.cz@gmail.com> | 2015-10-08 22:15:32 +0200 |
---|---|---|
committer | Vojta Svoboda <vojtasvoboda.cz@gmail.com> | 2015-10-08 22:15:32 +0200 |
commit | 838701b917bb914f3483b6e9233920a752d20f82 (patch) | |
tree | a430654109b2f8e6a47eddf057f86d73630314a7 /purescript.html.markdown | |
parent | 4d619e9b0fc4a061fa720b47b22068c8661e9be6 (diff) | |
parent | abd7444f9e5343f597b561a69297122142881fc8 (diff) |
Merge branch 'master' into translation/json-cs
Diffstat (limited to 'purescript.html.markdown')
-rw-r--r-- | purescript.html.markdown | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/purescript.html.markdown b/purescript.html.markdown index 6bff7545..a006cdff 100644 --- a/purescript.html.markdown +++ b/purescript.html.markdown @@ -70,12 +70,12 @@ true && (9 >= 19 || 1 < 2) -- true -- Safe access return Maybe a head [1,2,3] -- Just (1) -tail [3,2,1] -- Just ([2,1]) +tail [3,2,1] -- Just ([2,1]) init [1,2,3] -- Just ([1,2]) last [3,2,1] -- Just (1) -- Random access - indexing [3,4,5,6,7] !! 2 -- Just (5) --- Range +-- Range 1..5 -- [1,2,3,4,5] length [2,2,2] -- 3 drop 3 [5,4,3,2,1] -- [2,1] @@ -129,10 +129,10 @@ first :: [Number] -> Number first (x:_) = x first [3,4,5] -- 3 second :: [Number] -> Number -second (_:y:_) = y +second (_:y:_) = y second [3,4,5] -- 4 sumTwo :: [Number] -> [Number] -sumTwo (x:y:rest) = (x+y) : rest +sumTwo (x:y:rest) = (x+y) : rest sumTwo [2,3,4,5,6] -- [5,4,5,6] -- sumTwo doesn't handle when the array is empty or just have one @@ -161,7 +161,7 @@ ecoTitle {title: "The Quantum Thief"} -- Object does not have property author -- Lambda expressions (\x -> x*x) 3 -- 9 -(\x y -> x*x + y*y) 4 5 -- 41 +(\x y -> x*x + y*y) 4 5 -- 41 sqr = \x -> x*x -- Currying @@ -187,7 +187,7 @@ foldr (+) 0 (1..10) -- 55 sum (1..10) -- 55 product (1..10) -- 3628800 --- Testing with predicate +-- Testing with predicate any even [1,2,3] -- true all even [1,2,3] -- false |