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
;; An Emacs Lisp port of Darius Bacon's list comprehension macro. | |
(setq lexical-binding t) | |
(defmacro for (bindings body) | |
(declare (indent defun)) | |
(expand-for bindings body '(lambda () ()))) | |
(defun expand-for (bindings body rest-var) | |
(if (null bindings) |
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 list is either () or (head, list). | |
# list = () | (head, list) | |
def make_list(xs): return (xs[0], make_list(xs[1:])) if xs else () | |
L = make_list('abcd') | |
## L | |
#. ('a', ('b', ('c', ('d', ())))) | |
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
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |