This file contains 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() { | |
var queue = [], paused = false, results; | |
this.test = function(name, fn) { | |
queue.push(function() { | |
results = document.getElementById("results"); | |
results = assert(true, name).appendChild( | |
document.createElement("ul")); | |
fn(); | |
}); | |
runTest(); |
This file contains 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 st-branch() { | |
local branch remote ahead behind | |
if [[ -n $1 ]]; then | |
remote=$1 | |
else | |
remote="upstrm" | |
fi | |
git for-each-ref --format="%(refname:short)" refs/heads refs/remotes | \ | |
while read branch | |
do |
This file contains 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
(define t-size | |
(lambda (t) | |
(if (t-empty? t) | |
0 | |
(+ 1 | |
(t-size (t-left t)) | |
(t-size (t-right t)))) )) | |
(define t-size-r | |
(lambda (t) |
This file contains 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
(define t-post-order | |
(lambda (t) | |
(if (t-empty? t) | |
'() | |
(append (t-post-order (t-left t)) | |
(t-post-order (t-right t)) | |
(list (t-value t)))) )) | |
(define t-post-order-r | |
(lambda (t) |
This file contains 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
(define t-in-order | |
(lambda (t) | |
(if (t-empty? t) | |
'() | |
(append (t-in-order (t-left t)) | |
(list (t-value t)) | |
(t-in-order (t-right t)))) )) | |
(define t-in-order-r | |
(lambda (t) |
This file contains 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
(define t-pre-order | |
(lambda (t) | |
(if (t-empty? t) | |
'() | |
(append (list (t-value t)) | |
(t-pre-order (t-left t)) | |
(t-pre-order (t-right t)))) )) | |
(define t-pre-order-r |
This file contains 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
(define (bst-insert e bst) | |
(cond | |
[(t-empty? bst) (t-node e t-empty t-empty)] | |
[(< e (t-value bst)) | |
(t-node | |
(t-value bst) | |
(bst-insert e (t-left bst)) | |
(t-right bst))] | |
[else | |
(t-node |
This file contains 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
(define my-tree | |
(t-node 1 | |
(t-node 2 | |
(t-node 4 t-empty t-empty) | |
(t-node 5 | |
(t-node 7 t-empty t-empty) | |
(t-node 8 t-empty t-empty))) | |
(t-node 3 | |
t-empty | |
(t-node 6 |
This file contains 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
(define t-empty #f) | |
(define t-value car) | |
(define t-left cadr) | |
(define t-right caddr) | |
(define (t-node value l-node r-node) | |
(list value l-node r-node)) | |
(define (t-empty? node) | |
(equal? node t-empty)) |
This file contains 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
(require racket/tcp) | |
(let-values ([(inp outp) (tcp-connect "racket-lang.org" 80)]) | |
(display "GET / HTTP/1.0\n\n" outp) | |
(close-output-port outp) | |
(let ([o (open-output-string)]) | |
(let aux ([r (read inp)]) | |
(if (eof-object? r) | |
(display (get-output-string o)) | |
(begin (display r o) |