Skip to content

Instantly share code, notes, and snippets.


Ian Price ijp

  • Aberdeen, Scotland
View GitHub Profile
ijp /
Last active May 17, 2020
Road to Yokozuna - Slohyo prototype
class StdioLogger(object):
def log(self, msg):
class NullLogger(object):
def log(self, msg):
View foo.txt
~/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'
# 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):
View foo.el
(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"
View clear.scm
(use-modules (system repl command))
(define-meta-command ((clear module) repl)
Removes all current bindings."
(let ((mod (current-module)))
(module-for-each (lambda (k v)
(module-remove! mod k))
View galex.el
;; 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))
View fib.el
(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)))
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):
i = l.index(obj)
except ValueError:
View palindrome.scm
(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 '())))
View last2.scm
;;; jffmcc's solution
(define (Last2Equal? L)
(cond ((> (length L) 2) (Last2Equal? (cdr L)))
((= (length L) 2) (equal? (car L) (cadr L)))
(else #f)))
;;; Alternative Solutions
;;; Compute length only once
(define (drop n l)