Skip to content

Instantly share code, notes, and snippets.

@nyuichi
Created April 19, 2012 15:08
Show Gist options
  • Save nyuichi/2421541 to your computer and use it in GitHub Desktop.
Save nyuichi/2421541 to your computer and use it in GitHub Desktop.
Iota by hiromu1996
#!/usr/bin/env gosh
(define (usage)
(format (current-error-port)
"Usage: ~a [source file]\n" *program-name*)
(exit 2))
(define s
(lambda (x) (lambda (y) (lambda (z) ((x z) (y z))))))
(define k
(lambda (x) (lambda (y) x)))
(define (iota source)
(if (eq? #\* (read-char source)) ((iota source) (iota source))
(lambda (x) ((x s) k))))
(define (church input)
(map (string->list input)
(let (succ (lambda (x) ((if (zero? x) (lambda (y) (lambda (z) z)) (lambda (y) (lambda (z) (y (succ (- x 1))))))))))))
(define (unchurch output)
())
(define (main args)
(if (null? (cdr args))
(usage)
(port-for-each
(lambda (input)
(print (unchurch ((iota
(open-input-file (car (cdr args))))
(church input)))))
read-line)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment