http://code.fed.wiki/assets/pages/lambda-talk-in-a-frame/repl.html HEIGHT 5000
{div {@ class="block"} _h1 λtalk out of λtank _p {b LT} is a very reduced fork of the {b lambdatalk|?view=coding}'s engine, working in any HTML document, out of its native wiki environmemnt, lambdatank|?view=coding3. _p Following this pattern {textarea {@ style="width:100%; height:60px; border:0; "} <pre class="mini"> editable MINI code </pre><pre></pre> } _p you get a block where can be edited any LT code followed by its evaluation. _p Currently {b LT} comes with four special forms, [{b lambda, if, def, '}], a reduced set of MATH and HTML/CSS primitives and the smallest set of WORD, SENTENCE, ARRAY and GRAPHIC primitives. {prewrap {b MATH} [ '=', '<', '>', '+', '-', '*', '/', 'sqrt', 'long_add', 'long_mult' ] {b HTML/CSS} [ '@, 'div', 'span', 'a', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'table', 'tr', 'td', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'b', 'i', 'u', 'center', 'br', 'hr', 'blockquote', 'del', 'sup', 'sub', 'code', 'img', 'pre', 'audio', 'source', 'svg', 'path', 'circle', 'animateMotion', 'mpath' ] {b WORD} [ 'W.equal?', 'W.empty?', 'W.slice' ] {b SENTENCE} [ 'S.empty?', 'S.slice' ] {b ARRAY} [ 'A.new', 'A.empty?', 'A.get', 'A.set!', 'A.slice', 'A.disp' ] {b GRAPHIC} [ 'turtle' ] ... extendable in line } _p The implementation of the {b LT} evaluator is constructed in such a way that the special forms {b lambda & def} are evaluated before the other forms, which are evaluated from the inside out. _p And so, for instance, the following LT code {pre (def hypo (lambda (:a :b) (sqrt (+ (* :a :a) (* :b :b))) )) (hypo 3 4) } _p is evaluated in this order: _ul 1) the {b lambda} expression is replaced by a function reference, say {b #123} {pre (def hypo #123) (hypo 3 4) } _ul 2) the {b def} expression is replaced by the name {pre hypo (hypo 3 4) } _ul 3) the application {b (hypo 3 4)} is evaluated from inside out {pre 0: (hypo 3 4) 1: (#123 3 4) 2: ((lambda (:a :b) (sqrt (+ (* :a :a) (* :b :b)))) 3 4) 3: (sqrt (+ (* 3 3) (* 4 4))) 4: (sqrt (+ 9 16)) 5: (sqrt 25) 6: 5 } _p Let's go! _p {i alain marty 2022/02/14} } {div {@ class="block"} <h1>html/css</h1> <pre class="mini"> (div (@ style="font:bold 2.0em papyrus;") hello world ) (img (@ src="http://lambdaway.free.fr/lambdawalks/data/amelie_poulain.jpg" width="100%" )) (center amélie poulain (b loves) ze lambada.) (p I say hello to (b my (i brave) new) (u world).) (div (@ style="font:normal 4.0em georgia; text-align:center;") λ(sup λ(sup λ(sub λ(sup λ(sub λ(sup λ(sup λ(sub λ(sup λ)))))))))) (pre some code √(span (@ style="border-top:1px solid;") 3(sup 2) + 4(sup 2)) -> 5 ) (table (tr (td (b item)) (td (b quant)) (td (b price)) (td (b quant*price))) (tr (td one) (td 123) (td 10) (td (* 123 10))) (tr (td two) (td 456) (td 100) (td (* 456 100))) (tr (td three) (td 789) (td 1000) (td (* 789 1000))) (tr (td ) (td ) (td total) (td (b (+ (* 123 10) (* 456 100) (* 789 1000))))) ) (p with these CSS rules:) table '{ width:100% } td '{ padding:5px; text-align:right; background:#ddd; color:#f00; font:normal 1.1em courier; } MUSIC (audio (@ controls style="width:100%; height:20px;") (source (@ src="http://b2b3.free.fr/musique/Wiegenlied.m4a" )) ) </pre><pre></pre> } {div {@ class="block"} <h1>maths</h1> <pre class="mini"> '(def φ (/ (+ 1 (sqrt 5)) 2)) -> (def φ (/ (+ 1 (sqrt 5)) 2)) '(φ) -> (φ) (if (> 1 0) then yes else no) (if (< 1 0) then yes else no) (def add (lambda (:a :b) :a + :b = (+ :a :b))) (add 3 4) (def sign (lambda (:x) (if (< :x 0) then :x is negative else (if (> :x 0) then :x is positive else :x is nul)))) (sign -1) (sign 0) (sign 1) (def fac (lambda (:n) (if (= :n 0) then 1 else (* :n (fac (- :n 1)))))) (fac 6) </pre><pre></pre> } {div {@ class="block"} <h1>words</h1> <pre class="mini"> (def HW helloworld) (W.equal? (HW) x) (W.empty? (HW)) (W.empty? ) (W.slice 0 5 (HW)) (W.slice 5 -0 (HW)) (def W.first (lambda (:w) (W.slice 0 1 :w))) (def W.rest (lambda (:w) (W.slice 1 -0 :w))) (W.first (HW)) (W.rest (HW)) (def W.length (lambda (:w) (if (W.empty? (W.rest :w)) then 1 else (+ 1 (W.length (W.rest :w)))))) (W.length (HW)) (def W.reverse (lambda (:w) (if (W.empty? (W.rest :w) ) then (W.first :w) else (W.reverse (W.rest :w))(W.first :w)))) (W.reverse (HW)) (def W.split (lambda (:w) (if (W.empty? (W.rest :w)) then (W.first :w) else (W.first :w) (W.split (W.rest :w))))) (W.split (HW)) </pre><pre></pre> } {div {@ class="block"} <h1>sentences</h1> <pre class="mini"> (def HBNW hello brave new world) (S.empty? (HBNW)) (S.empty? ) (def S.first (lambda (:w) (S.slice 0 1 :w))) (def S.rest (lambda (:w) (S.slice 1 -0 :w))) (S.first (HBNW)) (S.rest (HBNW)) (def S.length (lambda (:w) (if (S.empty? (S.rest :w)) then 1 else (+ 1 (S.length (S.rest :w)))))) (S.length (HBNW)) (def S.reverse (lambda (:w) (if (S.empty? (S.rest :w) ) then (S.first :w) else (S.reverse (S.rest :w)) (S.first :w)))) (S.reverse (HBNW)) </pre><pre></pre> } {div {@ class="block"} <h1>arrays</h1> <pre class="mini"> '(def A (A.new hello brave new world)) -> (def A (A.new hello brave new world)) (def A.first (lambda (:a) (A.get 0 :a))) (def A.rest (lambda (:a) (A.slice 1 -0 :a))) (A.disp (A)) (A.empty? (A)) (A.empty? (A.new)) (A.get 1 (A)) (A.first (A)) (A.disp (A.rest (A))) (A.disp (A.slice 1 3 (A))) (A.disp (A.set! 0 goodbye (A))) (A.disp (A.set! 2 old (A))) (def sort (lambda (:a) (sort.r :a (A.new)) )) (def sort.i (lambda (:x :a) (if (A.empty? :a) then (A.new :x) else (if (<= :x (A.first :a)) then (A.addfirst! :x :a) else (A.addfirst! (A.first :a) (sort.i :x (A.rest :a))) )))) (def sort.r (lambda (:a1 :a2) (if (A.empty? :a1) then :a2 else (sort.r (A.rest :a1) (sort.i (A.first :a1) :a2)) ))) (prewrap (def B (A.new 24095 97964 13152 50347 32683 56704 79688 77844 89693 94472 13330 37052 38915 69203 17440 53788 50825 52384 66915 70961 26953 22381 72673 98200 19077 8327 28541 90029 49148 39815 89561 53288 87515 46769 90428 89834 30840 21174 74865 84265 73895 94236 27388 76751 10098 6898 68875 12975 70830 87397 84286 41329 98483 88289 23861 62112 49113 16370 9448 94424 36475 33178 84503 71158 61488 67715 45820 27210 91575 45698 5791 27539 51708 35326 40325 56742 74208 4395 48426 18317 19939 10025 99125 58069 20504 83555 57448 56057 19803 35124 86357 96927 42539 46063 42133 57138 35779 87455 68753 70372)) (A.disp (B)) '(A.disp (sort (B))) -> (A.disp (sort (B))) ) </pre><pre></pre> } {div {@ class="block"} <h1>λ-calc</h1> <pre class="mini"> (def TRUE (lambda (:a :b) :a)) (def FALSE (lambda (:a :b) :b)) (def IF (lambda (:a :b :c) (:a :b :c))) (def PAIR (lambda (:a :b :c) (:c :a :b))) (def LEFT (lambda (:c) (:c TRUE))) (def RIGHT (lambda (:c) (:c FALSE))) (def NIL (lambda (:a) TRUE)) (def ISNIL (lambda (:c) (:c (lambda (:a :b) FALSE)))) (def JB (PAIR james bond)) (LEFT (JB)) (RIGHT (JB)) (ISNIL (JB)) (ISNIL NIL) (def L (PAIR a (PAIR b (PAIR c (PAIR d NIL))))) (def DISP (lambda (:l) ((IF (ISNIL :l) (lambda (:l) ) (lambda (:l) (LEFT :l) (DISP (RIGHT :l)))) :l))) (DISP (L)) (def REV (lambda (:l) (_REV.r :l NIL))) (def _REV.r (lambda (:a :b) ((IF (ISNIL :a) (lambda (:a :b) :b) (lambda (:a :b) (_REV.r (RIGHT :a) (PAIR (LEFT :a) :b)))) :a :b))) (DISP (REV (L))) (def LENGTH (lambda (:l) ((IF (ISNIL :l) (lambda (:l) 0) (lambda (:l) (+ 1 (LENGTH (RIGHT :l))))) :l))) (LENGTH (L)) (def CONCAT (lambda (:a :b) ((IF (ISNIL :b) (lambda (:a :b) :a) (lambda (:a :b) (CONCAT (PAIR (LEFT :b) :a) (RIGHT :b)))) :a :b))) (DISP (CONCAT (L) (REV (L)))) NUMBERS (def EQ? (lambda (:a :b) (if (= :a :b) then TRUE else FALSE))) (def FACTORIAL (lambda (:n) ((IF (EQ? :n 1) (lambda (:n) 1) (lambda (:n) (long_mult :n (FACTORIAL (- :n 1))))) :n))) (FACTORIAL 6) (FACTORIAL 20) (pre (@ style="margin:0; padding:0; white-space:pre-wrap; word-wrap:break-word;") (FACTORIAL 100) ) (def SERIE (lambda (:a :b :s) ((IF (EQ? :a :b) (lambda (:a :b :s) (PAIR :a NIL)) (lambda (:a :b :s) (PAIR :a (SERIE (+ :a :s) :b :s)))) :a :b :s))) (DISP (SERIE 0 10 2)) (* (DISP (SERIE 1 10 1))) (def MAP (lambda (:f :s) ((IF (ISNIL :s) (lambda (:f :s) NIL) (lambda (:f :s) (PAIR (:f (LEFT :s)) (MAP :f (RIGHT :s))))) :f :s))) (DISP (MAP (lambda (:i) (* :i :i)) (SERIE 0 20 2))) (def HANOI (lambda (:n :from :to :via) ((IF (EQ? :n 0) (lambda (:n :from :to :via) ) (lambda (:n :from :to :via) (HANOI (- :n 1) :from :via :to) (br) move :n from tower :from to tower :to (HANOI (- :n 1) :via :to :from) )) :n :from :to :via))) (HANOI 5 A B C) HILBERT (def left (lambda (:d :n) ((IF (EQ? :n 0) (lambda (:d :n) ) (lambda (:d :n) T90 (right :d (- :n 1)) M:d T-90 (left :d (- :n 1)) M:d (left :d (- :n 1)) T-90 M:d (right :d (- :n 1)) T90 )) :d :n))) (def right (lambda (:d :n) ((IF (EQ? :n 0) (lambda (:d :n) ) (lambda (:d :n) T-90 (left :d (- :n 1)) M:d T90 (right :d (- :n 1)) M:d (right :d (- :n 1)) T90 M:d (left :d (- :n 1)) T-90 )) :d :n))) (svg (@ width="350px" height="350px") (path (@ id="spline" d="M (turtle 20 20 0 (left 10 5))" fill="transparent" stroke="#fff" stroke-width="1" )) (circle (@ cx="0" cy="0" r="5" fill="#f00" stroke="#f00") (animateMotion (@ dur="100s" repeatCount="indefinite" rotate="auto") (mpath (@ xlink:href="#spline")) )) MUSIC (audio (@ controls style="width:100%; height:20px;") (source (@ src="http://b2b3.free.fr/musique/Wiegenlied.m4a" )) ) ... and so on. ) </pre><pre></pre> } {style table { width:100% } td { padding:5px; text-align:right; background:#ddd; color:#f00; font:normal 1.1em courier; } } {script // INTERFACE setTimeout( function() { var minis = document.getElementsByClassName('mini'); for (var i=0; i< minis.length; i++) { mini( minis[i] ); minis[i].setAttribute( 'contenteditable', true ); minis[i].addEventListener ( 'keyup', function() { return mini(this) } ) } }, 1); var mini = function (obj) { var s = obj.innerText, bal = MINI.balance(s); obj.nextElementSibling.innerHTML = (bal.left === bal.right) ? MINI.evaluate( s ) : 'unbalanced expression [' + bal.left + '|' + bal.right + ']' }; // EVAL var MINI = (function() { var DICT = {}; var regexp = /\(([^\s()]*)(?:[\s]*)([^()]*)\)/g; var evaluate = function(s) { s = preprocessing(s); s = eval_quotes(s); s = eval_lambdas(s); s = eval_defs(s); s = eval_ifs(s); s = eval_applications(s); s = postprocessing(s); return s }; var eval_applications = function(s) { // nested (first rest) while (s !== (s = s.replace(regexp, eval_application))); return s; }; var eval_application = function() { var f = arguments[1] || "", r = arguments[2] || ""; return DICT.hasOwnProperty(f)? DICT[f].apply(null, [r]) : "[" + f + " " + r + "]"; }; var eval_lambdas = function(s) { while (s !== (s = s.replace(catch_abstraction(s,"lambda"), eval_lambda))); return s }; var eval_defs = function(s) { while (s !== (s = s.replace(catch_abstraction(s,"def"), eval_def))); return s }; var eval_ifs = function(s) { while (s !== (s = s.replace(catch_abstraction(s,"if"), eval_if))); return s }; var eval_quotes = function(s) { while (s !== (s = s.replace(catch_abstraction(s,"quote"), eval_quote))); return s }; var catch_abstraction = function(s,symb) { // (symbol ...) var start = s.indexOf("("+symb); if (start == -1) return "none"; var nb = 1, index = start; while (nb > 0) { index++; if (index > 100000) alert( "oops catch_index > 10000" ) if (s.charAt(index) == "(") nb++; else if (s.charAt(index) == ")") nb--; } return s.substring(start, index+1) }; var eval_lambda = function(s) { // "(lambda (args) body)" s = s.trim() .replace(/\s+/g, " ") .substring(8) // "(lambda " .replace( /\)$/, ""); // "(args) body" var index = s.indexOf(")"), argStr = s.substring(1, index).trim(), args = argStr === "" ? [] : argStr.split(" "), body = s.substring( argStr.length+2 ).trim(), name = "#" + Math.random(); body = eval_lambdas(body); DICT[name] = function() { var valStr = arguments[0].trim().replace(/\s+/g, " "), vals = valStr === "" ? [] : valStr.split(" "), bod = body.trim(); if (vals.length < args.length) { // 1) partial call for (var i = 0; i < vals.length; i++) bod = bod.replace(RegExp(args[i], "g"), vals[i]); var _args_ = args.slice(vals.length).join(" "); bod = eval_lambda("(lambda (" + _args_ + ") " + bod + ")"); } else if (vals.length === args.length) { // 2) total call for (var i=0; i < args.length; i++) bod = bod.replace( RegExp(args[i], "g"), vals[i] ); } else { // 3) extra -> the last one var _vals_ = vals.slice(0,args.length); _vals_[args.length-1] = vals.slice(args.length-1,vals.length).join(' '); for (var i=0; i < args.length; i++) bod = bod.replace( RegExp(args[i], "g"), _vals_[i] ); } bod = eval_ifs(bod); return eval_applications(bod); }; return name }; var eval_def = function(s) { // "(def name body)" s = s.trim() .replace(/\s+/g, " ") .substring(5) // "(def " .replace( /\)$/, ""); // "name body" var index = s.indexOf(" "); var name = s.substring(0, index).trim(); var body = s.substring(index).trim(); body = eval_defs(body); if (body.charAt(0) === "#") { DICT[name] = DICT[body]; } else { body = eval_applications(body); DICT[name] = function() { return body; }; } return (name.charAt(0) === "_")? "" : name }; var eval_if = function(s) { // (if bool then one else two) s = s.trim() .replace(/\s+/g, " ") .substring(4) // "(if " .replace( /\)$/, ""); // "bool then one else two" s = eval_ifs(s); var index1 = s.indexOf( 'then' ), index2 = s.indexOf( 'else' ), bool = s.substring(0,index1).trim(), one = s.substring(index1+5,index2).trim(), two = s.substring(index2+5).trim(); return (eval_applications(bool) === 'true')? one : two }; var eval_quote = function(s) { // (quote ...) s = s.trim() .substring(7) // "(quote " .replace( /\)$/, ""); // "..." // s = eval_quotes(s); var name = '_¥_' + Math.random(); // _¥_ some umprobable word DICT[name] = s; return name }; var preprocessing = function(s) { // '(+ 1 2) -> (quote (+ 1 2)) s = s.replace(/'\(/g, "(quote "); return s }; var postprocessing = function(s) { s = s.replace( /_¥_[^\s]*/g, function(s) { return '(' + DICT[s] + ')' } ) return s }; var balance = function(s) { var strt = s.match(/\(/g), stop = s.match(/\)/g); strt = strt ? strt.length : 0; stop = stop ? stop.length : 0; return { left:strt, right:stop }; }; return { DICT, evaluate, balance } })(); // en MINI // DICTIONARY var htmltags = [ 'div', 'span', 'a', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'table', 'tr', 'td', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'b', 'i', 'u', 'center', 'br', 'hr', 'blockquote', 'del', 'sup', 'sub', 'code', 'img', 'pre', 'audio', 'source', 'svg', 'path', 'circle', 'animateMotion', 'mpath' ]; MINI.DICT['@'] = function() { return '@@' + arguments[0].trim() + '@@' } ; for (var i=0; i< htmltags.length; i++) { // (div (@ attributs)texte) MINI.DICT[htmltags[i]] = function(tag) { // tag = div return function() { var args = arguments[0].trim(); // args = @@attributs@@texte, don't supertrim for pre var attr = args.match( /@@[\s\S]*?@@/ ); // attr[0] = @@attributs@@ if (attr == null) { // args = texte return '<'+tag+'>'+args+'</'+tag+'>'; // <div>texte</div> } else { args = args.replace( attr[0], '' ).trim(); // args = texte attr = attr[0].replace(/^@@/, '').replace(/@@$/, ''); // attr = attributs return '<'+tag+' '+attr+'>'+args+'</'+tag+'>'; // <div attributs>texte</div> } } }(htmltags[i]); } MINI.DICT['prewrap'] = function () { var args = arguments[0]; return '(pre (@ style="word-wrap: break-word; white-space:pre-wrap;")' + args + ')' }; MINI.DICT["="] = function() { var a = arguments[0].trim().replace(/\s+/g, " ").split(" "), x = Number(a[0]), y = Number(a[1]); return (!(x < y) && !(y < x)) }; MINI.DICT["<"] = function() { var a = arguments[0].trim().replace(/\s+/g, " ").split(" "), x = Number(a[0]), y = Number(a[1]); return (x < y) }; MINI.DICT["<="] = function() { var a = arguments[0].trim().replace(/\s+/g, " ").split(" "), x = Number(a[0]), y = Number(a[1]); return (x <= y) }; MINI.DICT[">"] = function() { var a = arguments[0].trim().replace(/\s+/g, " ").split(" "), x = Number(a[0]), y = Number(a[1]); return (x > y) }; MINI.DICT['+'] = function() { return arguments[0].trim().replace(/\s+/g, " ").split(' ').reduce( (a,b) => Number(a)+Number(b) , 0 ) }; MINI.DICT['*'] = function() { return arguments[0].trim().replace(/\s+/g, " ").split(' ').reduce( (a,b) => a*b , 1 ) }; MINI.DICT['-'] = function() { var args = arguments[0].trim().replace(/\s+/g, " ").split(' '); return args[0]-args[1] }; MINI.DICT['/'] = function() { var args = arguments[0].trim().replace(/\s+/g, " ").split(' '); return args[0]/args[1] }; MINI.DICT['sqrt'] = function() { return Math.sqrt( arguments[0].trim() ) }; MINI.DICT['long_add'] = function () { var args = arguments[0].trim().replace(/\s+/g, " ").split(' '), a = args[0].split("").reverse(), b = args[1].split("").reverse(), n = Math.max(a.length, b.length), c = [], d = 0; for (var i=0; i < n; i++) { c[i] = (a[i] | 0) + (b[i] | 0) + d; if (c[i] > 9) { c[i] -= 10; d = 1; } else { d = 0; } } if (d === 1) c.push(1); return c.reverse().join('') }; MINI.DICT['long_mult'] = function () { var args = arguments[0].trim().replace(/\s+/g, " ").split(' '), a = args[0].split("").reverse(), b = args[1].split("").reverse(), c = []; for ( var i1 = 0; i1 < a.length; i1++ ) { for ( var i2 = 0; i2 < b.length; i2++ ) { var j = i1 + i2; c[j] = a[i1] * b[i2] + (c[j] | 0); if ( c[j] > 9 ) { var f = Math.floor( c[j] / 10 ); c[j] -= f * 10; c[j+1] = f + (c[j+1] | 0); } } } return c.reverse().join("") }; MINI.DICT['turtle'] = function () { var draw = function(str) { // {turtle x0 y0 a0 M100 T90 M50 T-45 ...} var args = str.split(' '); var x0 = parseFloat(args[0]), y0 = parseFloat(args[1]), a0 = parseFloat(args[2]), poly = []; poly.push( [x0, y0, a0] ); for (var i=3; i < args.length; i++) { var act = args[i].charAt(0), val = parseFloat(args[i].substring(1)); if (act === 'M') { var p = poly[poly.length-1], a = p[2] * Math.PI / 180.0, x = p[0] + val * Math.sin(a), y = p[1] + val * Math.cos(a); poly.push( [x,y,p[2]] ) } else { var p = poly.pop(); poly.push( [p[0],p[1],p[2]+val] ) } } for (var pol = '', i=0; i < poly.length; i++) pol += Math.round(poly[i][0]) + ' ' + Math.round(poly[i][1]) + ' '; return pol }; return draw( arguments[0].trim().replace(/\s+/g, " ") ); }; // WORDS MINI.DICT["W.equal?"] = function() { var a = arguments[0].trim().replace(/\s+/g, " ").split(' '); return a[0] === a[1]; }; MINI.DICT['W.empty?'] = function() { var a = arguments[0].trim(); return (a === ''); }; MINI.DICT['W.slice'] = function() { var a = arguments[0].trim().replace(/\s+/g, " ").split(' '), w = a[2], i0 = parseInt(a[0]), i1 = parseInt(a[1]); i1 = (i1 > 0) ? i1 : w.length+i1; return w.slice(i0,i1); }; // SENTENCES MINI.DICT['S.empty?'] = function() { var a = arguments[0].trim(); return (a === ''); }; MINI.DICT['S.slice'] = function() { var args = arguments[0].trim().replace(/\s+/g, " ").split(' '), i0 = parseInt(args.shift()), i1 = parseInt(args.shift()), s = args; i1 = (i1 > 0) ? i1 : args.length+i1; return s.slice(i0,i1).join(' '); }; // ARRAYS var ARR = {} MINI.DICT['A.new'] = function () { // (A.new a b c d) var args = arguments[0].trim().replace(/\s+/g, " "), name = '#' + Math.random(); ARR[name] = (args != '')? args.split(' ') : []; return name; }; var isARR = function (z) { return (z !== '' && z.charAt(0) === '#') }; MINI.DICT['A.disp'] = function () { var args = arguments[0].trim(), str = ''; var rdisp = function( a ) { for (var i=0; i<ARR[a].length; i++) { if (isARR(ARR[a][i])) { str += '['; rdisp( ARR[a][i] ); str = str.substring(0, str.length-1) + '],'; } else str += ARR[a][i] + ','; } return str.substring(0, str.length-1) ; }; return (isARR(args))? '[' + rdisp( args ) + ']' : args; }; MINI.DICT['A.empty?'] = function () { var args = arguments[0].trim(); return (ARR[args].length < 1); }; MINI.DICT['A.length'] = function () { // {#.length z} var args = arguments[0].trim(); // z return (isARR(args))? ARR[args].length : 0; }; MINI.DICT['A.get'] = function () { // {#.item i z} var args = arguments[0].trim().replace(/\s+/g, " ").split(' '); return (isARR(args[1]))? ARR[args[1]][args[0]] : args[1]; }; MINI.DICT['A.set!'] = function () { // {#.set! i v z} var args = arguments[0].trim().replace(/\s+/g, " ").split(' '); ARR[args[2]][args[0]] = args[1]; return args[2]; }; MINI.DICT['A.addfirst!'] = function () { // {#.unshift! v z} var args = arguments[0].trim().replace(/\s+/g, " ").split(' '); ARR[args[1]].unshift( args[0] ); return args[1]; }; MINI.DICT['A.slice'] = function () { // (A.slice i0 i1 array) var args = arguments[0].trim().replace(/\s+/g, " ").split(' '), i0 = parseInt(args.shift()), i1 = parseInt(args.shift()), name = '#' + Math.random(); i1 = (i1 > 0) ? i1 : ARR[args].length+i1; ARR[name] = ARR[args].slice(i0,i1); return name; }; // and so on ... } {style body { background:#444; color:#fff; } #page_frame, #page_content, .page_menu { background:transparent; color:#fff; border:0; box-shadow:0 0 0; } /* only inside lambdatank #page_frame { margin-left:0; width:600px; } #page_content { width:2800px; } */ pre { position:relative; z-index:1; overflow-x: scroll; padding:10px; background:#555; color:#fff; } .block { display:inline-block; width:380px; height:2000px; vertical-align:top; padding:5px; overflow-x:scroll; } table { width:100%; background:#fff; } td { text-align:right; background:#ddd; color:#f00; padding:5px; font:normal 1.1em courier; } pre { box-shadow:0 0 8px #000; padding:10px; } .mini { box-shadow:0 0 0; background:#444; color:#fff; margin: 0 0 -10px 0; opacity:0.5} .mini:hover { opacity:1; } }