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
import Prelude hiding (lookup) | |
import Data.Maybe | |
type Nat = Int -- !! | |
type Baire = Nat -> Maybe Nat | |
encode :: [Maybe Nat] -> Nat | |
encode = undefined |
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
class StdioLogger(object): | |
def log(self, msg): | |
print(msg) | |
class NullLogger(object): | |
def log(self, msg): | |
pass | |
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
~/src/guile $ make | |
/usr/bin/make all-recursive | |
make[1]: Entering directory `/home/ian/src/guile' | |
Making all in lib | |
make[2]: Entering directory `/home/ian/src/guile/lib' | |
/usr/bin/make all-recursive | |
make[3]: Entering directory `/home/ian/src/guile/lib' | |
make[4]: Entering directory `/home/ian/src/guile/lib' | |
make[4]: Nothing to be done for `all-am'. | |
make[4]: Leaving directory `/home/ian/src/guile/lib' |
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
# a sketch of how Scheme fluids/parameters would work in python | |
obarray = {} | |
class Manager(object): | |
def __init__(self, parameter, value): | |
self.parameter = parameter | |
self.value = value | |
def __enter__(self): |
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
(defun my-erc-quit (s) | |
(or s (concat "brb " (aref my-erc-quit-reasons (random (length my-erc-quit-reasons)))))) | |
(setq erc-part-reason 'my-erc-quit) | |
(setq erc-quit-reason 'my-erc-quit) | |
(setq my-erc-quit-reasons | |
["proving riemann hypothesis" | |
"cleaning the augean stables" | |
"inventing something better than sliced bread" |
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
(use-modules (system repl command)) | |
(define-meta-command ((clear module) repl) | |
"clear | |
Removes all current bindings." | |
(let ((mod (current-module))) | |
(module-for-each (lambda (k v) | |
(module-remove! mod k)) | |
mod))) |
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
;; not tested | |
(defun galex-assoc-string (regexp alist) | |
(catch 'done | |
(while alist | |
(cond ((consp (car alist)) | |
(if (string-match regexp (caar alist)) | |
(throw 'done (car alist)))) | |
((stringp (car alist)) | |
(if (string-match regexp (car alist)) |
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
(setq fib (lambda () | |
(let* ((b (cdddr fib)) | |
(s (apply '+ b))) | |
(setcdr (cddr fib) (list (cadr b) s)) | |
(throw 'result s)) | |
0 1)) | |
(defun fib () (catch 'result (funcall fib))) | |
(fib) |
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 rindex_func(func, l): | |
for (i,obj) in reversed(list(enumerate(l))): ## Boo! list() | |
if func(obj): | |
return i | |
return None | |
def only_as_suffix(obj, l): | |
try: | |
i = l.index(obj) | |
except ValueError: |
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 (make-palindrome l) | |
(define (loop l suffix) | |
(if (null? (cdr l)) | |
(cons (car l) suffix) | |
(cons (car l) | |
(loop (cdr l) (cons (car l) suffix))))) | |
(if (null? l) | |
#f ; arbitrary choice | |
(loop l '()))) |
NewerOlder