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
(set-char-whitespace "\n") | |
(set-char-whitespace "\r") | |
(set-char-whitespace "\t") | |
(set-char-whitespace "\v") | |
(set-char-terminating ")") | |
(set-char-terminating "(") | |
(set-char-terminating "\"") | |
(set read-until (lambda (stream char) |
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
do | |
local i | |
i = 0 | |
local s | |
s = 0 | |
do | |
::top3:: | |
-- ignored | |
do | |
local _451 |
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
(set-char-whitespace "\n") | |
(set-char-whitespace "\r") | |
(set-char-whitespace "\t") | |
(set-char-whitespace "\v") | |
(set-char-terminating ")") | |
(set-char-terminating "(") | |
(set-char-terminating "\"") | |
(set read-until (lambda (stream char) |
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 compile(exp, env, dest) | |
if isnull(exp) or isnumber(exp) or isstring(exp) then | |
return putdest(dest, tolua(exp)) | |
elseif issymbol(exp) then | |
if is_bound(env, exp) then | |
return putdest(dest, exp.str) | |
else | |
return putdest(dest, string.format("_G[%q]", exp.str)) | |
end | |
elseif ispair(exp) then |
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 (backquote-1 x) | |
(if (atom? x) | |
(list 'quote x) | |
(if (eq (first x) 'unquote) | |
(second x) | |
(if (eq (first x) 'backquote) | |
(backquote-1 (backquote-1 (second x))) | |
(if (atom? (first x)) | |
(list 'cons (backquote-1 (first x)) (backquote-1 (rest x))) | |
(if (eq (first (first x)) 'unquote-splice) |
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
-- This is a test of Gist. | |
fact :: Integer -> Integer | |
fact 0 = 1 | |
fact n = n * fact (n-1) | |
main = putStrLn (show (fact 100)) |
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
def normalize(word): | |
return word.lower() | |
def coordinates(word): | |
word = normalize(word) | |
coords = [0] * 26 | |
for char in word: | |
coords[ord(char) - ord('a')] += 1 | |
return tuple(coords) |
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
def all_equal(iterable): | |
it = iter(iterable) | |
try: | |
first = it.next() | |
return all(x == first for x in it) | |
except StopIteration: | |
return True | |
def median(seq, key=None): | |
sorted_seq = sorted(seq, key=key) |
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
def all_equal(iterable): | |
it = iter(iterable) | |
try: | |
first = it.next() | |
return all(x == first for x in it) | |
except StopIteration: | |
return True | |
def median(seq, key=None): | |
sorted_seq = sorted(seq, key=key) |
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
def all_equal(iterable): | |
it = iter(iterable) | |
first = next(it, None) | |
return all(x == first for x in it) | |
def median(seq, key=lambda x: x): | |
return sorted(seq, key=key)[len(seq) / 2] | |
def partition(seq, pivot, key=lambda x: x): | |
left, middle, right = [], [], [] |