diff options
| author | woclass <inkydragon@users.noreply.github.com> | 2018-12-03 20:30:45 +0800 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-03 20:30:45 +0800 | 
| commit | cd7816a2be62b0dcd2aca181d1aadd68b8e4d5d7 (patch) | |
| tree | f75c300c92d40e29bf59f83775aec019b45e56e7 /haskell.html.markdown | |
| parent | 440247a59706603bd980016821ecd6a72a6182d1 (diff) | |
| parent | 1fd955ae6479650b987a54a93b09507bfdf06954 (diff) | |
Merge pull request #1 from adambard/master
Update from Upstream
Diffstat (limited to 'haskell.html.markdown')
| -rw-r--r-- | haskell.html.markdown | 17 | 
1 files changed, 10 insertions, 7 deletions
| diff --git a/haskell.html.markdown b/haskell.html.markdown index 266cf11b..90d47c27 100644 --- a/haskell.html.markdown +++ b/haskell.html.markdown @@ -124,6 +124,9 @@ last [1..5] -- 5  fst ("haskell", 1) -- "haskell"  snd ("haskell", 1) -- 1 +-- pair element accessing does not work on n-tuples (i.e. triple, quadruple, etc) +snd ("snd", "can't touch this", "da na na na") -- error! see function below +  ----------------------------------------------------  -- 3. Functions  ---------------------------------------------------- @@ -159,8 +162,8 @@ fib 1 = 1  fib 2 = 2  fib x = fib (x - 1) + fib (x - 2) --- Pattern matching on tuples: -foo (x, y) = (x + 1, y + 2) +-- Pattern matching on tuples +sndOfTriple (_, y, _) = y -- use a wild card (_) to bypass naming unused value  -- Pattern matching on lists. Here `x` is the first element  -- in the list, and `xs` is the rest of the list. We can write @@ -203,11 +206,11 @@ foo = (4*) . (10+)  foo 5 -- 60  -- fixing precedence --- Haskell has an operator called `$`. This operator applies a function  --- to a given parameter. In contrast to standard function application, which  --- has highest possible priority of 10 and is left-associative, the `$` operator  +-- Haskell has an operator called `$`. This operator applies a function +-- to a given parameter. In contrast to standard function application, which +-- has highest possible priority of 10 and is left-associative, the `$` operator  -- has priority of 0 and is right-associative. Such a low priority means that --- the expression on its right is applied as the parameter to the function on its left. +-- the expression on its right is applied as a parameter to the function on its left.  -- before  even (fib 7) -- false @@ -223,7 +226,7 @@ even . fib $ 7 -- false  -- 5. Type signatures  ---------------------------------------------------- --- Haskell has a very strong type system, and every valid expression has a type.  +-- Haskell has a very strong type system, and every valid expression has a type.  -- Some basic types:  5 :: Integer | 
