2012/06/18 14:45:18 | (82.249.211.39) {h1 lisp} {h6 ... et javascript !} {p sources :} {ul {a {@ href:http://en.wikipedia.org/wiki/Lisp_%28programming_language%29;} Lisp programming language}} {ul {a {@ href:http://www.i-programmer.info/programming/javascript/2380-javascript-data-structures-a-lisp-like-list.html;} list & tree }} {ul {a {@ href:http://kybernetikos.github.com/Javathcript/;} Javathcript }} {ul {a {@ href:http://mitpress.mit.edu/sicp/full-text/book/book.html;} Structure and interpretation of computer programs}} {ul {a {@ href:http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/;} abelson-sussman-lectures}} {hr } {submit {@ code:code; value:display;}} {span {@ id:display; border:1px solid grey;} ???} {hr } {pre {@ id:code;} //°° var cons = function (a,b) { return {first:a, rest: b}; }; var list_str = 'List : '; var tree_str = 'Tree : '; var displayList = function (list) { if ( list === null ) return; list_str += list.first + ', '; displayList(list.rest); }; function displayTree(tree) { if( tree === null ) return; if ( tree.first.first === undefined ) { tree_str += tree.first + ', '; } else { displayTree( tree.first ); } displayTree( tree.rest ); } var list = function(){ // facilitate list creation var ret = null; var n = arguments.length - 1; for ( var x = n; x >= 0; x-- ) { ret = cons( arguments[x], ret ); } return ret; }; ///////////////////////// // 1) creating a list : var mylist = cons("D",null); mylist = cons("C",mylist); mylist = cons("B",mylist); mylist = cons("A",mylist); // 2) creating a list by concatenation of the calls : var mylist = cons("A", cons("B", cons("C", cons("D",null) ) ) ); // 3) creating a list with list() function var mylist = list( "A", "B", "C", "D" ); ///////////////////////// // 1) creating a tree : var mytree = cons( cons( cons("A",null), cons("B",null) ), cons( cons("C",null), cons("D",null) ) ); displayList( mylist ); displayTree( mytree ); $('display').innerHTML = list_str + ' | ' + tree_str; //°°} {ul {a {@ href:http://www.cs.sfu.ca/CourseCentral/310/pwfong/Lisp;} philippewong} : le cours} {ul {a {@ href:http://www.gigamonkeys.com/book/;}Peter Seibel} : le livre} {ul {a {@ href:http://pspace.org/articles/68-the-untyped-lambda-calculus;} pspace.org}} {ul50 | {a {@ href:http://pspace.org/downloads/lambda_slides.pdf;} lambda-calcul} : un pdf} {ul50 | {a {@ href:http://pspace.org/downloads/lambda_paper.pdf;} lambda-calcul} : un papier} {ul {a {@ href:http://www.psg.com/~dlamkins/sl/chapter03.html;} Essential Lisp in Twelve Lessons}} {ul {a {@ href:http://www.ducklet.com/jisp/;} Lisp implementation in Javascript}} {ul {a {@ href:http://courses.cs.vt.edu/~cs1104/LISP/lisp.html;} Lisp in Javascript}} {ul {a {@ href:http://lambda-the-ultimate.org/node/892;} A Lisp to Javascript Compiler in 100 Lines}} {ul {a {@ href:http://www.marcbelmont.com/lisp-interpreter-in-javascript-with-jquery;} Lisp interpreter in Javascript with jQuery}} {ul {a {@ href:http://eloquentjavascript.net/;} eloquentjavascript}} {ul {a {@ href:http://yuiblog.com/crockford/;} yuiblog.com/crockford}} {ul {a {@ href:http://en.wikipedia.org/wiki/Lambda_calculus;} Lambda_calculus}} {ul {a {@ href:https://files.nyu.edu/cb125/public/Lambda/;} Lambda}} {ul {a {@ href:http://stackoverflow.com/questions/3865335/what-is-a-lambda-language;} what-is-a-lambda-language}} {ul {a {@ href:http://zefredz.frimouvy.org/dotclear/index.php?2008/05/01/210-un-peu-de-lisp-en-javascript;} un-peu-de-lisp-en-javascript}} {ul {a {@ href:http://javascript.crockford.com/javascript.html;} javascript.crockford.com}} {ul {a {@ href:http://www.algo.be/logo1/le-logo-en-bref.html;} le-logo-en-bref}} {ul {a {@ href:http://www.hunlock.com/blogs/Mastering_Javascript_Arrays;} Mastering Javascript Arrays} : puissant !} {ul {a {@ href:http://code.google.com/p/jslibs/wiki/JavascriptTips;} JavascriptTips}} {ul {a {@ href:http://www.json.org/js.html;} JSON}}