mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
Some documentation
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
|
/* --- Accessing document elements ------------------------------------------ */
|
||||||
|
|
||||||
function element(id) {
|
function element(id) {
|
||||||
return document.getElementById(id);
|
return document.getElementById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- JSONP ---------------------------------------------------------------- */
|
||||||
|
|
||||||
// Inspired by the function jsonp from
|
// Inspired by the function jsonp from
|
||||||
// http://www.west-wind.com/Weblog/posts/107136.aspx
|
// http://www.west-wind.com/Weblog/posts/107136.aspx
|
||||||
// See also http://niryariv.wordpress.com/2009/05/05/jsonp-quickly/
|
// See also http://niryariv.wordpress.com/2009/05/05/jsonp-quickly/
|
||||||
@@ -124,7 +128,7 @@ function filter(p,xs) {
|
|||||||
return ys;
|
return ys;
|
||||||
}
|
}
|
||||||
|
|
||||||
function implode(cs) {
|
function implode(cs) { // array of strings to string
|
||||||
/*
|
/*
|
||||||
var s="";
|
var s="";
|
||||||
for(var i=0;i<cs.length;i++)
|
for(var i=0;i<cs.length;i++)
|
||||||
@@ -147,11 +151,12 @@ function map(f,xs) {
|
|||||||
return ys;
|
return ys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// map in continuation passing style
|
||||||
|
function mapc(f,xs,cont) { mapc_from(f,xs,0,[],cont); }
|
||||||
|
|
||||||
function mapc_from(f,xs,i,ys,cont) {
|
function mapc_from(f,xs,i,ys,cont) {
|
||||||
if(i<xs.length)
|
if(i<xs.length)
|
||||||
f(xs[i],function(y){ys[i]=y;mapc_from(f,xs,i+1,ys,cont)});
|
f(xs[i],function(y){ys[i]=y;mapc_from(f,xs,i+1,ys,cont)});
|
||||||
else
|
else
|
||||||
cont(ys);
|
cont(ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapc(f,xs,cont) { mapc_from(f,xs,0,[],cont); }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user