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
;; extending the y combinator to handle mutual recursion, for zacts | |
(define (y . funcs) | |
((lambda (x) (x x)) | |
(lambda (x) | |
(map (lambda (g) | |
(lambda args | |
(apply (apply g (x x)) args))) | |
funcs)))) |
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
(save-module-excursion | |
(lambda () | |
(set-current-module (resolve-module '(web client))) | |
(eval '(define (extend-request r k v . additional) | |
(let ((r (build-request (request-uri r) | |
#:method (request-method r) | |
#:version (request-version r) | |
#:headers | |
(assoc-set! (copy-tree (request-headers r)) | |
k v) |
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 raellear-lgrep (regexp &optional files confirm) | |
(interactive | |
(progn | |
(grep-compute-defaults) | |
(cond | |
((and grep-command (equal current-prefix-arg '(16))) | |
(list (read-from-minibuffer "Run: " grep-command | |
nil nil 'grep-history))) | |
((not grep-template) | |
(error "grep.el: No `grep-template' available")) |
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-module (angels-and-devils) | |
#:export (milestone devil angel)) | |
;; See the paper "call-with-current-continuation patterns" | |
(define future '()) | |
(define past '()) | |
(define-syntax-rule (push var val) | |
(set! var (cons val var))) |
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
;; Vectorish syntactic parameterize for jcowan using only syntax rules | |
(define-syntax define-syntax-rule | |
(syntax-rules () | |
((_ (name . patterns) template) | |
(define-syntax name | |
(syntax-rules () | |
((_ . patterns) | |
template)))))) |
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
;; Scheme version of try ... in ... unless ... from the paper | |
;; Exceptional Syntax by Benton and Kennedy | |
(define-syntax try | |
(syntax-rules (in unless) | |
((try (var val) body ... ((tag handler ...) ...)) | |
((catch #t | |
(lambda () (let ((v val)) | |
(lambda (k) (k v)))) | |
(lambda (t . args) |
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
;; First of all, notice that | |
(call/cc (lambda (k) e)) = (call/cc (lambda (k) (k e))) ; -- {1} | |
;; the type of call/cc a.k.a peirces law gives you the free theorem | |
(f (call/cc g)) = (call/cc (lambda (k) (f (g (compose k f))))) ;; -- {Free} | |
;; Continuations don't compose | |
(compose k k2) = k2 ;; {No Compose} | |
;; If a continuation is not used, we lose the form | |
If k not in e, then | |
(call/cc (lambda (k) (k e))) = (call/cc (lambda (k) e)) [k not in e] = e ;; -- {no-op} |
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 (sxml transform)) | |
(define (subst var val exp) | |
(cond ((pair? exp) | |
(cons (subst var val (car exp)) | |
(subst var val (cdr exp)))) | |
((eqv? var exp) val) | |
(else exp))) | |
(define *env* |
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 Data.List (tails) | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
-- <Fuco> heh, this is a nice problem: Given a string A, figure out if string B | |
-- contains any anagram of A as substring. Example: A = abc, B = de[cab]fh | |
-- -> true | |
xs `hasAnagramSubsequence` ys = any (check initialMap) (tails xs) | |
where initialMap = tabulate ys |
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
(defmacro kingpatzer/log-cmd (&rest rest) | |
"This wraps the body in error checking and prints start and stop information to the message buffer. This requires a variable named 'output' be defined in context that tells us what to print." | |
`(progn | |
(message "**** Starting %s ****" (concat output)) | |
(with-demoted-errors ,@rest) | |
(message "*** Finishing %s ****\n" (concat output)))) |
OlderNewer