LiveScript mode

export concatMap = (f, xs) --> fold ((memo, x) -> append memo, f x), [], xs
 
1
# LiveScript mode for CodeMirror
2
# The following script, prelude.ls, is used to
3
# demonstrate LiveScript mode for CodeMirror.
4
#   https://github.com/gkz/prelude-ls
5
6
export objToFunc = objToFunc = (obj) ->
7
  (key) -> obj[key]
8
9
export each = (f, xs) -->
10
  if typeof! xs is \Object
11
    for , x of xs then f x
12
  else
13
    for x in xs then f x
14
  xs
15
16
export map = (f, xs) -->
17
  f = objToFunc f if typeof! f isnt \Function
18
  type = typeof! xs
19
  if type is \Object
20
    {[key, f x] for key, x of xs}
21
  else
22
    result = [f x for x in xs]
23
    if type is \String then result * '' else result
24
25
export filter = (f, xs) -->
26
  f = objToFunc f if typeof! f isnt \Function
27
  type = typeof! xs
28
  if type is \Object
29
    {[key, x] for key, x of xs when f x}

MIME types defined: text/x-livescript.

The LiveScript mode was written by Kenneth Bentley.