diff options
author | C. Bess <cbess@company.com> | 2015-11-09 17:55:53 -0600 |
---|---|---|
committer | C. Bess <cbess@company.com> | 2015-11-09 17:55:53 -0600 |
commit | df0992d72c2a28f140e6ff9681c505f36e19249a (patch) | |
tree | 508aa3abe4c25b957dca442560d9c95c9b1fc97a /livescript.html.markdown | |
parent | afc5ea14654e0e9cd11c7ef1b672639d12418bad (diff) | |
parent | c460e1fafa0e9b4edc6a5cb35b970bb5cc030a81 (diff) |
Merge remote-tracking branch 'adambard/master'
Conflicts:
swift.html.markdown
Diffstat (limited to 'livescript.html.markdown')
-rw-r--r-- | livescript.html.markdown | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/livescript.html.markdown b/livescript.html.markdown index 429b91cb..9235f5ce 100644 --- a/livescript.html.markdown +++ b/livescript.html.markdown @@ -166,7 +166,7 @@ not false # => true ######################################################################## ## 3. Functions -######################################################################## +######################################################################## # Since LiveScript is functional, you'd expect functions to get a nice # treatment. In LiveScript it's even more apparent that functions are @@ -219,8 +219,8 @@ identity 1 # => 1 # Operators are not functions in LiveScript, but you can easily turn # them into one! Enter the operator sectioning: -divide-by-2 = (/ 2) -[2, 4, 8, 16].map(divide-by-2) .reduce (+) +divide-by-two = (/ 2) +[2, 4, 8, 16].map(divide-by-two) .reduce (+) # Not only of function application lives LiveScript, as in any good @@ -229,7 +229,7 @@ double-minus-one = (- 1) . (* 2) # Other than the usual `f . g` mathematical formulae, you get the `>>` # and `<<` operators, that describe how the flow of values through the -# functions. +# functions. double-minus-one = (* 2) >> (- 1) double-minus-one = (- 1) << (* 2) @@ -248,8 +248,8 @@ reduce = (f, xs, initial) --> xs.reduce f, initial # The underscore is also used in regular partial application, which you # can use for any function: div = (left, right) -> left / right -div-by-2 = div _, 2 -div-by-2 4 # => 2 +div-by-two = div _, 2 +div-by-two 4 # => 2 # Last, but not least, LiveScript has back-calls, which might help @@ -344,7 +344,7 @@ kitten.hug! # => "*Mei (a cat) is hugged*" ## Further reading There's just so much more to LiveScript, but this should be enough to -get you started writing little functional things in it. The +get you started writing little functional things in it. The [official website](http://livescript.net/) has a lot of information on the language, and a nice online compiler for you to try stuff out! |