Skip to content

Instantly share code, notes, and snippets.

U = -> it it
U U
/*
$ lsc infinite-loop.ls
Failed at: infinite-loop.ls
RangeError: Maximum call stack size exceeded
*/
@AyaMorisawa
AyaMorisawa / project-eular-001.ls
Last active August 29, 2015 14:14
Project Eular 001 LiveScript
global <<< require \prelude-ls
[1 til 1000] |> (filter -> it % 3 == 0 || it % 5 == 0) |> sum |> console.log
/*
$ lsc project-eular-001.ls
233168
*/
@AyaMorisawa
AyaMorisawa / project-eular-002.ls
Created February 6, 2015 13:29
Project Eular 002 LiveScript
global <<< require \prelude-ls
gen-list-while = (f, max) ->
list = []
i = 0
while f(i) < max then f(i++) |> list.push
list
memoize = (memo, f) -> shell = (n) -> memo[n] ?= f shell, n
app = express!
server = http.createServer app
io = require \socket.io .listen do
server
origins: 'hoge.jp:*'
@AyaMorisawa
AyaMorisawa / clone.ls
Created February 11, 2015 13:31
Clone in LiveScript
a = name: 'alice'
console.log a.name
b = ^^a
console.log b.name
b.name = 'bob'
console.log b.name
console.log a.name
usersA = [ id: 4872, name: 'alice' ]
usersB = [ id: 2849, name: 'bob' ]
users = (usersA ++ usersB) |> sort-by (.id)
console.log users
Y = (r) -> ((f) -> f f)((f) -> r (x) -> f f x)
@AyaMorisawa
AyaMorisawa / !Num.ls
Last active August 29, 2015 14:16
Num.ls
Num.ls
List.ls
@AyaMorisawa
AyaMorisawa / !Str.ls
Created February 25, 2015 14:25
Str.ls
Str.ls