Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/livescri...
File: index.html
<!doctype html>
[0] Fix | Delete
[1] Fix | Delete
<title>CodeMirror: LiveScript mode</title>
[2] Fix | Delete
<meta charset="utf-8"/>
[3] Fix | Delete
<link rel=stylesheet href="../../doc/docs.css">
[4] Fix | Delete
[5] Fix | Delete
<link rel="stylesheet" href="../../lib/codemirror.css">
[6] Fix | Delete
<link rel="stylesheet" href="../../theme/solarized.css">
[7] Fix | Delete
<script src="../../lib/codemirror.js"></script>
[8] Fix | Delete
<script src="livescript.js"></script>
[9] Fix | Delete
<style>.CodeMirror {font-size: 80%;border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
[10] Fix | Delete
<div id=nav>
[11] Fix | Delete
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
[12] Fix | Delete
[13] Fix | Delete
<ul>
[14] Fix | Delete
<li><a href="../../index.html">Home</a>
[15] Fix | Delete
<li><a href="../../doc/manual.html">Manual</a>
[16] Fix | Delete
<li><a href="https://github.com/codemirror/codemirror">Code</a>
[17] Fix | Delete
</ul>
[18] Fix | Delete
<ul>
[19] Fix | Delete
<li><a href="../index.html">Language modes</a>
[20] Fix | Delete
<li><a class=active href="#">LiveScript</a>
[21] Fix | Delete
</ul>
[22] Fix | Delete
</div>
[23] Fix | Delete
[24] Fix | Delete
<article>
[25] Fix | Delete
<h2>LiveScript mode</h2>
[26] Fix | Delete
<form><textarea id="code" name="code">
[27] Fix | Delete
# LiveScript mode for CodeMirror
[28] Fix | Delete
# The following script, prelude.ls, is used to
[29] Fix | Delete
# demonstrate LiveScript mode for CodeMirror.
[30] Fix | Delete
# https://github.com/gkz/prelude-ls
[31] Fix | Delete
[32] Fix | Delete
export objToFunc = objToFunc = (obj) ->
[33] Fix | Delete
(key) -> obj[key]
[34] Fix | Delete
[35] Fix | Delete
export each = (f, xs) -->
[36] Fix | Delete
if typeof! xs is \Object
[37] Fix | Delete
for , x of xs then f x
[38] Fix | Delete
else
[39] Fix | Delete
for x in xs then f x
[40] Fix | Delete
xs
[41] Fix | Delete
[42] Fix | Delete
export map = (f, xs) -->
[43] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[44] Fix | Delete
type = typeof! xs
[45] Fix | Delete
if type is \Object
[46] Fix | Delete
{[key, f x] for key, x of xs}
[47] Fix | Delete
else
[48] Fix | Delete
result = [f x for x in xs]
[49] Fix | Delete
if type is \String then result * '' else result
[50] Fix | Delete
[51] Fix | Delete
export filter = (f, xs) -->
[52] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[53] Fix | Delete
type = typeof! xs
[54] Fix | Delete
if type is \Object
[55] Fix | Delete
{[key, x] for key, x of xs when f x}
[56] Fix | Delete
else
[57] Fix | Delete
result = [x for x in xs when f x]
[58] Fix | Delete
if type is \String then result * '' else result
[59] Fix | Delete
[60] Fix | Delete
export reject = (f, xs) -->
[61] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[62] Fix | Delete
type = typeof! xs
[63] Fix | Delete
if type is \Object
[64] Fix | Delete
{[key, x] for key, x of xs when not f x}
[65] Fix | Delete
else
[66] Fix | Delete
result = [x for x in xs when not f x]
[67] Fix | Delete
if type is \String then result * '' else result
[68] Fix | Delete
[69] Fix | Delete
export partition = (f, xs) -->
[70] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[71] Fix | Delete
type = typeof! xs
[72] Fix | Delete
if type is \Object
[73] Fix | Delete
passed = {}
[74] Fix | Delete
failed = {}
[75] Fix | Delete
for key, x of xs
[76] Fix | Delete
(if f x then passed else failed)[key] = x
[77] Fix | Delete
else
[78] Fix | Delete
passed = []
[79] Fix | Delete
failed = []
[80] Fix | Delete
for x in xs
[81] Fix | Delete
(if f x then passed else failed)push x
[82] Fix | Delete
if type is \String
[83] Fix | Delete
passed *= ''
[84] Fix | Delete
failed *= ''
[85] Fix | Delete
[passed, failed]
[86] Fix | Delete
[87] Fix | Delete
export find = (f, xs) -->
[88] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[89] Fix | Delete
if typeof! xs is \Object
[90] Fix | Delete
for , x of xs when f x then return x
[91] Fix | Delete
else
[92] Fix | Delete
for x in xs when f x then return x
[93] Fix | Delete
void
[94] Fix | Delete
[95] Fix | Delete
export head = export first = (xs) ->
[96] Fix | Delete
return void if not xs.length
[97] Fix | Delete
xs.0
[98] Fix | Delete
[99] Fix | Delete
export tail = (xs) ->
[100] Fix | Delete
return void if not xs.length
[101] Fix | Delete
xs.slice 1
[102] Fix | Delete
[103] Fix | Delete
export last = (xs) ->
[104] Fix | Delete
return void if not xs.length
[105] Fix | Delete
xs[*-1]
[106] Fix | Delete
[107] Fix | Delete
export initial = (xs) ->
[108] Fix | Delete
return void if not xs.length
[109] Fix | Delete
xs.slice 0 xs.length - 1
[110] Fix | Delete
[111] Fix | Delete
export empty = (xs) ->
[112] Fix | Delete
if typeof! xs is \Object
[113] Fix | Delete
for x of xs then return false
[114] Fix | Delete
return yes
[115] Fix | Delete
not xs.length
[116] Fix | Delete
[117] Fix | Delete
export values = (obj) ->
[118] Fix | Delete
[x for , x of obj]
[119] Fix | Delete
[120] Fix | Delete
export keys = (obj) ->
[121] Fix | Delete
[x for x of obj]
[122] Fix | Delete
[123] Fix | Delete
export len = (xs) ->
[124] Fix | Delete
xs = values xs if typeof! xs is \Object
[125] Fix | Delete
xs.length
[126] Fix | Delete
[127] Fix | Delete
export cons = (x, xs) -->
[128] Fix | Delete
if typeof! xs is \String then x + xs else [x] ++ xs
[129] Fix | Delete
[130] Fix | Delete
export append = (xs, ys) -->
[131] Fix | Delete
if typeof! ys is \String then xs + ys else xs ++ ys
[132] Fix | Delete
[133] Fix | Delete
export join = (sep, xs) -->
[134] Fix | Delete
xs = values xs if typeof! xs is \Object
[135] Fix | Delete
xs.join sep
[136] Fix | Delete
[137] Fix | Delete
export reverse = (xs) ->
[138] Fix | Delete
if typeof! xs is \String
[139] Fix | Delete
then (xs / '')reverse! * ''
[140] Fix | Delete
else xs.slice!reverse!
[141] Fix | Delete
[142] Fix | Delete
export fold = export foldl = (f, memo, xs) -->
[143] Fix | Delete
if typeof! xs is \Object
[144] Fix | Delete
for , x of xs then memo = f memo, x
[145] Fix | Delete
else
[146] Fix | Delete
for x in xs then memo = f memo, x
[147] Fix | Delete
memo
[148] Fix | Delete
[149] Fix | Delete
export fold1 = export foldl1 = (f, xs) --> fold f, xs.0, xs.slice 1
[150] Fix | Delete
[151] Fix | Delete
export foldr = (f, memo, xs) --> fold f, memo, xs.slice!reverse!
[152] Fix | Delete
[153] Fix | Delete
export foldr1 = (f, xs) -->
[154] Fix | Delete
xs.=slice!reverse!
[155] Fix | Delete
fold f, xs.0, xs.slice 1
[156] Fix | Delete
[157] Fix | Delete
export unfoldr = export unfold = (f, b) -->
[158] Fix | Delete
if (f b)?
[159] Fix | Delete
[that.0] ++ unfoldr f, that.1
[160] Fix | Delete
else
[161] Fix | Delete
[]
[162] Fix | Delete
[163] Fix | Delete
export andList = (xs) ->
[164] Fix | Delete
for x in xs when not x
[165] Fix | Delete
return false
[166] Fix | Delete
true
[167] Fix | Delete
[168] Fix | Delete
export orList = (xs) ->
[169] Fix | Delete
for x in xs when x
[170] Fix | Delete
return true
[171] Fix | Delete
false
[172] Fix | Delete
[173] Fix | Delete
export any = (f, xs) -->
[174] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[175] Fix | Delete
for x in xs when f x
[176] Fix | Delete
return yes
[177] Fix | Delete
no
[178] Fix | Delete
[179] Fix | Delete
export all = (f, xs) -->
[180] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[181] Fix | Delete
for x in xs when not f x
[182] Fix | Delete
return no
[183] Fix | Delete
yes
[184] Fix | Delete
[185] Fix | Delete
export unique = (xs) ->
[186] Fix | Delete
result = []
[187] Fix | Delete
if typeof! xs is \Object
[188] Fix | Delete
for , x of xs when x not in result then result.push x
[189] Fix | Delete
else
[190] Fix | Delete
for x in xs when x not in result then result.push x
[191] Fix | Delete
if typeof! xs is \String then result * '' else result
[192] Fix | Delete
[193] Fix | Delete
export sort = (xs) ->
[194] Fix | Delete
xs.concat!sort (x, y) ->
[195] Fix | Delete
| x > y => 1
[196] Fix | Delete
| x < y => -1
[197] Fix | Delete
| _ => 0
[198] Fix | Delete
[199] Fix | Delete
export sortBy = (f, xs) -->
[200] Fix | Delete
return [] unless xs.length
[201] Fix | Delete
xs.concat!sort f
[202] Fix | Delete
[203] Fix | Delete
export compare = (f, x, y) -->
[204] Fix | Delete
| (f x) > (f y) => 1
[205] Fix | Delete
| (f x) < (f y) => -1
[206] Fix | Delete
| otherwise => 0
[207] Fix | Delete
[208] Fix | Delete
export sum = (xs) ->
[209] Fix | Delete
result = 0
[210] Fix | Delete
if typeof! xs is \Object
[211] Fix | Delete
for , x of xs then result += x
[212] Fix | Delete
else
[213] Fix | Delete
for x in xs then result += x
[214] Fix | Delete
result
[215] Fix | Delete
[216] Fix | Delete
export product = (xs) ->
[217] Fix | Delete
result = 1
[218] Fix | Delete
if typeof! xs is \Object
[219] Fix | Delete
for , x of xs then result *= x
[220] Fix | Delete
else
[221] Fix | Delete
for x in xs then result *= x
[222] Fix | Delete
result
[223] Fix | Delete
[224] Fix | Delete
export mean = export average = (xs) -> (sum xs) / len xs
[225] Fix | Delete
[226] Fix | Delete
export concat = (xss) -> fold append, [], xss
[227] Fix | Delete
[228] Fix | Delete
export concatMap = (f, xs) --> fold ((memo, x) -> append memo, f x), [], xs
[229] Fix | Delete
[230] Fix | Delete
export listToObj = (xs) ->
[231] Fix | Delete
{[x.0, x.1] for x in xs}
[232] Fix | Delete
[233] Fix | Delete
export maximum = (xs) -> fold1 (>?), xs
[234] Fix | Delete
[235] Fix | Delete
export minimum = (xs) -> fold1 (<?), xs
[236] Fix | Delete
[237] Fix | Delete
export scan = export scanl = (f, memo, xs) -->
[238] Fix | Delete
last = memo
[239] Fix | Delete
if typeof! xs is \Object
[240] Fix | Delete
then [memo] ++ [last = f last, x for , x of xs]
[241] Fix | Delete
else [memo] ++ [last = f last, x for x in xs]
[242] Fix | Delete
[243] Fix | Delete
export scan1 = export scanl1 = (f, xs) --> scan f, xs.0, xs.slice 1
[244] Fix | Delete
[245] Fix | Delete
export scanr = (f, memo, xs) -->
[246] Fix | Delete
xs.=slice!reverse!
[247] Fix | Delete
scan f, memo, xs .reverse!
[248] Fix | Delete
[249] Fix | Delete
export scanr1 = (f, xs) -->
[250] Fix | Delete
xs.=slice!reverse!
[251] Fix | Delete
scan f, xs.0, xs.slice 1 .reverse!
[252] Fix | Delete
[253] Fix | Delete
export replicate = (n, x) -->
[254] Fix | Delete
result = []
[255] Fix | Delete
i = 0
[256] Fix | Delete
while i < n, ++i then result.push x
[257] Fix | Delete
result
[258] Fix | Delete
[259] Fix | Delete
export take = (n, xs) -->
[260] Fix | Delete
| n <= 0
[261] Fix | Delete
if typeof! xs is \String then '' else []
[262] Fix | Delete
| not xs.length => xs
[263] Fix | Delete
| otherwise => xs.slice 0, n
[264] Fix | Delete
[265] Fix | Delete
export drop = (n, xs) -->
[266] Fix | Delete
| n <= 0 => xs
[267] Fix | Delete
| not xs.length => xs
[268] Fix | Delete
| otherwise => xs.slice n
[269] Fix | Delete
[270] Fix | Delete
export splitAt = (n, xs) --> [(take n, xs), (drop n, xs)]
[271] Fix | Delete
[272] Fix | Delete
export takeWhile = (p, xs) -->
[273] Fix | Delete
return xs if not xs.length
[274] Fix | Delete
p = objToFunc p if typeof! p isnt \Function
[275] Fix | Delete
result = []
[276] Fix | Delete
for x in xs
[277] Fix | Delete
break if not p x
[278] Fix | Delete
result.push x
[279] Fix | Delete
if typeof! xs is \String then result * '' else result
[280] Fix | Delete
[281] Fix | Delete
export dropWhile = (p, xs) -->
[282] Fix | Delete
return xs if not xs.length
[283] Fix | Delete
p = objToFunc p if typeof! p isnt \Function
[284] Fix | Delete
i = 0
[285] Fix | Delete
for x in xs
[286] Fix | Delete
break if not p x
[287] Fix | Delete
++i
[288] Fix | Delete
drop i, xs
[289] Fix | Delete
[290] Fix | Delete
export span = (p, xs) --> [(takeWhile p, xs), (dropWhile p, xs)]
[291] Fix | Delete
[292] Fix | Delete
export breakIt = (p, xs) --> span (not) << p, xs
[293] Fix | Delete
[294] Fix | Delete
export zip = (xs, ys) -->
[295] Fix | Delete
result = []
[296] Fix | Delete
for zs, i in [xs, ys]
[297] Fix | Delete
for z, j in zs
[298] Fix | Delete
result.push [] if i is 0
[299] Fix | Delete
result[j]?push z
[300] Fix | Delete
result
[301] Fix | Delete
[302] Fix | Delete
export zipWith = (f,xs, ys) -->
[303] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[304] Fix | Delete
if not xs.length or not ys.length
[305] Fix | Delete
[]
[306] Fix | Delete
else
[307] Fix | Delete
[f.apply this, zs for zs in zip.call this, xs, ys]
[308] Fix | Delete
[309] Fix | Delete
export zipAll = (...xss) ->
[310] Fix | Delete
result = []
[311] Fix | Delete
for xs, i in xss
[312] Fix | Delete
for x, j in xs
[313] Fix | Delete
result.push [] if i is 0
[314] Fix | Delete
result[j]?push x
[315] Fix | Delete
result
[316] Fix | Delete
[317] Fix | Delete
export zipAllWith = (f, ...xss) ->
[318] Fix | Delete
f = objToFunc f if typeof! f isnt \Function
[319] Fix | Delete
if not xss.0.length or not xss.1.length
[320] Fix | Delete
[]
[321] Fix | Delete
else
[322] Fix | Delete
[f.apply this, xs for xs in zipAll.apply this, xss]
[323] Fix | Delete
[324] Fix | Delete
export compose = (...funcs) ->
[325] Fix | Delete
->
[326] Fix | Delete
args = arguments
[327] Fix | Delete
for f in funcs
[328] Fix | Delete
args = [f.apply this, args]
[329] Fix | Delete
args.0
[330] Fix | Delete
[331] Fix | Delete
export curry = (f) ->
[332] Fix | Delete
curry$ f # using util method curry$ from livescript
[333] Fix | Delete
[334] Fix | Delete
export id = (x) -> x
[335] Fix | Delete
[336] Fix | Delete
export flip = (f, x, y) --> f y, x
[337] Fix | Delete
[338] Fix | Delete
export fix = (f) ->
[339] Fix | Delete
( (g, x) -> -> f(g g) ...arguments ) do
[340] Fix | Delete
(g, x) -> -> f(g g) ...arguments
[341] Fix | Delete
[342] Fix | Delete
export lines = (str) ->
[343] Fix | Delete
return [] if not str.length
[344] Fix | Delete
str / \\n
[345] Fix | Delete
[346] Fix | Delete
export unlines = (strs) -> strs * \\n
[347] Fix | Delete
[348] Fix | Delete
export words = (str) ->
[349] Fix | Delete
return [] if not str.length
[350] Fix | Delete
str / /[ ]+/
[351] Fix | Delete
[352] Fix | Delete
export unwords = (strs) -> strs * ' '
[353] Fix | Delete
[354] Fix | Delete
export max = (>?)
[355] Fix | Delete
[356] Fix | Delete
export min = (<?)
[357] Fix | Delete
[358] Fix | Delete
export negate = (x) -> -x
[359] Fix | Delete
[360] Fix | Delete
export abs = Math.abs
[361] Fix | Delete
[362] Fix | Delete
export signum = (x) ->
[363] Fix | Delete
| x < 0 => -1
[364] Fix | Delete
| x > 0 => 1
[365] Fix | Delete
| otherwise => 0
[366] Fix | Delete
[367] Fix | Delete
export quot = (x, y) --> ~~(x / y)
[368] Fix | Delete
[369] Fix | Delete
export rem = (%)
[370] Fix | Delete
[371] Fix | Delete
export div = (x, y) --> Math.floor x / y
[372] Fix | Delete
[373] Fix | Delete
export mod = (%%)
[374] Fix | Delete
[375] Fix | Delete
export recip = (1 /)
[376] Fix | Delete
[377] Fix | Delete
export pi = Math.PI
[378] Fix | Delete
[379] Fix | Delete
export tau = pi * 2
[380] Fix | Delete
[381] Fix | Delete
export exp = Math.exp
[382] Fix | Delete
[383] Fix | Delete
export sqrt = Math.sqrt
[384] Fix | Delete
[385] Fix | Delete
# changed from log as log is a
[386] Fix | Delete
# common function for logging things
[387] Fix | Delete
export ln = Math.log
[388] Fix | Delete
[389] Fix | Delete
export pow = (^)
[390] Fix | Delete
[391] Fix | Delete
export sin = Math.sin
[392] Fix | Delete
[393] Fix | Delete
export tan = Math.tan
[394] Fix | Delete
[395] Fix | Delete
export cos = Math.cos
[396] Fix | Delete
[397] Fix | Delete
export asin = Math.asin
[398] Fix | Delete
[399] Fix | Delete
export acos = Math.acos
[400] Fix | Delete
[401] Fix | Delete
export atan = Math.atan
[402] Fix | Delete
[403] Fix | Delete
export atan2 = (x, y) --> Math.atan2 x, y
[404] Fix | Delete
[405] Fix | Delete
# sinh
[406] Fix | Delete
# tanh
[407] Fix | Delete
# cosh
[408] Fix | Delete
# asinh
[409] Fix | Delete
# atanh
[410] Fix | Delete
# acosh
[411] Fix | Delete
[412] Fix | Delete
export truncate = (x) -> ~~x
[413] Fix | Delete
[414] Fix | Delete
export round = Math.round
[415] Fix | Delete
[416] Fix | Delete
export ceiling = Math.ceil
[417] Fix | Delete
[418] Fix | Delete
export floor = Math.floor
[419] Fix | Delete
[420] Fix | Delete
export isItNaN = (x) -> x isnt x
[421] Fix | Delete
[422] Fix | Delete
export even = (x) -> x % 2 == 0
[423] Fix | Delete
[424] Fix | Delete
export odd = (x) -> x % 2 != 0
[425] Fix | Delete
[426] Fix | Delete
export gcd = (x, y) -->
[427] Fix | Delete
x = Math.abs x
[428] Fix | Delete
y = Math.abs y
[429] Fix | Delete
until y is 0
[430] Fix | Delete
z = x % y
[431] Fix | Delete
x = y
[432] Fix | Delete
y = z
[433] Fix | Delete
x
[434] Fix | Delete
[435] Fix | Delete
export lcm = (x, y) -->
[436] Fix | Delete
Math.abs Math.floor (x / (gcd x, y) * y)
[437] Fix | Delete
[438] Fix | Delete
# meta
[439] Fix | Delete
export installPrelude = !(target) ->
[440] Fix | Delete
unless target.prelude?isInstalled
[441] Fix | Delete
target <<< out$ # using out$ generated by livescript
[442] Fix | Delete
target <<< target.prelude.isInstalled = true
[443] Fix | Delete
[444] Fix | Delete
export prelude = out$
[445] Fix | Delete
</textarea></form>
[446] Fix | Delete
<script>
[447] Fix | Delete
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
[448] Fix | Delete
theme: "solarized light",
[449] Fix | Delete
lineNumbers: true
[450] Fix | Delete
});
[451] Fix | Delete
</script>
[452] Fix | Delete
[453] Fix | Delete
<p><strong>MIME types defined:</strong> <code>text/x-livescript</code>.</p>
[454] Fix | Delete
[455] Fix | Delete
<p>The LiveScript mode was written by Kenneth Bentley.</p>
[456] Fix | Delete
[457] Fix | Delete
</article>
[458] Fix | Delete
[459] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function