This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Streams were equipped with plus and bind, I removed bind and added join and narrow. | |
| I also added yield which returns the yielded substitution map for the stream (if any) | |
| and step which advances teh computation (was: calling the thunk). | |
| join, like plus, interleaves execution of its two streams. As soon as one yields, the | |
| yielded value is used to narrow the search space of the other stream. | |
| For any stream A, we have: | |
| A = (plus (yield A) (step A)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## {{{ http://code.activestate.com/recipes/577859/ (r1) | |
| #!/usr/bin/env python | |
| # | |
| # Copyright (c) 2011 Jan Kaliszewski (zuo). All rights reserved. | |
| # Licensed under the MIT License. | |
| # | |
| # Python 2.5+/3.x-compatibile. | |
| # | |
| # The newest version of this module should be downloadable from: | |
| # https://github.com/zuo/Zuo-s-Recipes-and-Drafts/blob/master/auxmethods.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; from the great http://arcanesentiment.blogspot.com/2011/08/anaphoric-macro-defining-macro.html | |
| (defmacro defanaphoric (name original &key settable) | |
| "Define NAME as a macro like ORIGINAL, but binding IT to the result of the first argument. | |
| If SETTABLE is true, IT will be a symbol-macro which can be set with SETF." | |
| (let ((whole (gensym "WHOLE")) | |
| (arglist (swank-backend:arglist original))) | |
| `(defmacro ,name (&whole ,whole ,@arglist) | |
| ,(format nil "Like ~S, except binds the result of ~S to IT (via ~S) for the scope of the ~A.~A" | |
| original |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| class MRISC | |
| def run(code) | |
| tokens = code.gsub(/(\*.*?\*)|[^a-z0-9,-;@\._]/,'').split(';') | |
| @vars,stack,i = {:_pc=>-1,:_oc=>0},[],0 | |
| tokens.map!{|t| t.chars.first=='@' ? (@vars[t.to_sym]=i-1;nil) : (i+=1;t.split(',').map{|e|numeric?(e) ? e.to_i : e.to_sym})}.compact! | |
| while @vars[:_pc] < tokens.size-1 | |
| @vars[:_pc] += 1 | |
| @vars[:_oc] += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| split(leaf,_,leaf,leaf). | |
| split(bst(L,A,R),X,L1,bst(L2,A,R)) :- A > X, split(L,X,L1,L2). | |
| split(bst(L,A,R),X,bst(L,A,R1),R2) :- A < X, split(R,X,R1,R2). | |
| insert(bst(L,A,R),X,bst(LX,A,R)) :- A > X, insert(L,X,LX). | |
| insert(bst(L,A,R),X,bst(L,A,RX)) :- A < X, insert(R,X,RX). | |
| insert(T,X,bst(L,X,R)) :- split(T,X,L,R). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function insertInlineConsole() { | |
| try {InlineConsole.addConsole()} | |
| catch (e) { | |
| var timeout = arguments.callee.timeout; | |
| if (!timeout) | |
| timeout = arguments.callee.timeout = new Date().getTime() + 10*1000; | |
| if (timeout > new Date().getTime()) | |
| setTimeout("insertInlineConsole()", 100); | |
| return; | |
| } |