Ian Price ijp

View fixes.scm
1 2 3 4 5 6 7 8 9 10
(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)
View mutual.scm
1 2 3 4 5 6 7 8 9
;; 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))))
View comb4.scm
1 2 3 4 5 6 7 8 9 10
(import (rnrs)
(ijputils boxes)
(ice-9 match))
 
;; Big picture: Two boxes
;; - first = pointer
;; - second = thunk
 
(define (create-graph l)
(let lp ((l l))
View foo.scm
1 2 3 4 5 6 7 8 9 10
(import (rnrs)
(for (only (srfi :1) break) expand))
 
(define-syntax foo
(lambda (stx)
(define (no-vals f befores)
(let ((temps (generate-temporaries befores)))
#`(lambda #,temps
(#,f #,@(map list befores temps)))))
(define (yes-vals f befores afters)
View fix.scm
1 2 3 4 5 6 7 8 9 10
;;; shift-reset fixed point combinator
(use-modules (ice-9 control))
 
(define (fix f)
(reset
(let ((g (shift k (k k))))
(lambda (x)
((f (g g)) x)))))
 
(define fact
View wingoquiz.scm
1 2 3 4 5 6 7 8 9 10
(define (discriminate f)
(define first? #t)
(define k #f)
(define (discriminator)
(define (return x) x)
(let ((x
(f (lambda (x)
(when first?
(set! first? #f)
(set! return (call/cc (lambda (resume)
View asdf.scm
1 2 3 4 5 6 7 8 9
(define-syntax ck
(syntax-rules (quote)
((ck () 'v) v) ; yield the value on empty stack
 
((ck (((op ...) ea ...) . s) 'v) ; re-focus on the other argument, ea
(ck-arg s (op ... 'v) ea ...))
 
((ck s (op ea ...)) ; Focus: handling an application;
(ck-arg s (op) ea ...)))) ; check if args are values
View lc.scm
1 2 3 4 5 6 7 8 9 10
;;; Lambda calculus interpreter with precomputed free variables
(use-modules (srfi srfi-1)
(srfi srfi-9)
(ice-9 match))
 
;;; Set Type
(define set list)
(define member? member)
(define (union s1 s2)
(lset-union eqv? s1 s2))
View 20worst.org

(Possibly) The Twenty (or so) Worst Things People have Done to Each Other

Taken from Steven Pinker’s: The Better Angels of Our Nature p.235

Rank Cause Century Death toll Death toll: mid-20th-century equivalent Adjusted Rank
1 Second World War 20th 55,000,000 55,000,000 9
2 Mao Zedong (mostly government-caused famine) 20th 40,000,000 40,000,000 11
3 Mongol Conquests 13th 40,000,000 278,000,000 2
4 An Lushan Revolt 8th 36,000,000 429,000,000 1
View origami.v
1 2 3 4 5 6 7 8 9 10
(* Working Through Jeremy Gibbons' article Origami Programming in Coq *)
Require Import Coq.Logic.FunctionalExtensionality.
Require Import Coq.Program.Basics.
Open Scope program_scope. (* for ∘ composition operator *)
 
Inductive list (X:Type) : Type :=
| nil : list X
| cons : X -> list X -> list X.
 
Definition is_nil (X:Type) (l:list X) : bool :=
Something went wrong with that request. Please try again.