remove examples

dev-elider-3
Matthew Butterick 9 years ago
parent 10f90c7bc2
commit d19e5f6b89

@ -1 +0,0 @@
#lang reader (submod "nothing.rkt" reader)

@ -1,39 +0,0 @@
#lang racket
(provide (all-from-out racket))
(module reader syntax/module-reader
br/ex/nothing/nothing)
#|
#lang racket
(provide (all-from-out racket))
(module reader racket/base
(provide read read-syntax))
|#
#|
(module nothing racket
(provide (all-from-out racket))
(module reader syntax/module-reader
br/ex/nothing))
|#
#|
#lang racket
(module reader syntax/module-reader
#:language '(submod br/ex/nothing semantics))
(module semantics racket
(provide (all-from-out racket)))
(sleep 100000)
|#

@ -1,10 +0,0 @@
#lang s-exp "expander.rkt"
"asdf"
41
1+2i
;; but not foo

@ -1,11 +0,0 @@
#lang br
(provide (rename-out [simple-module-begin #%module-begin])
#%datum #%top-interaction)
(define #'(simple-module-begin expr ...)
#'(#%module-begin
(define lines (list expr ...))
(display (format "Expressions = ~a" (length lines)))
(define numbers (filter number? lines))
(unless (zero? (length numbers))
(displayln (format ", numbers = ~a" (length numbers)))
(apply + numbers))))

@ -1,61 +0,0 @@
#lang br
(require racket/function)
(provide (except-out (all-from-out br) + *)
(rename-out [my+ +] [my* *]) )
(define ( largs rargs)
(let ([lenlargs (length largs)]
[lenrargs (length rargs)])
(cond
[(zero? lenlargs)
(map (compose1 inexact->exact floor) rargs)]
[(= lenlargs lenrargs)
(map min
largs rargs)])))
(define (my* largs rargs)
(let ([lenlargs (length largs)]
[lenrargs (length rargs)])
(cond
[(= lenlargs lenrargs)
(map * largs rargs)]
[(= 1 lenlargs)
(map (curry * (car largs)) rargs)]
[(= 1 lenrargs)
(my* rargs largs)]
[else
(error 'length-error)])))
(define (my+ largs rargs)
(let ([lenlargs (length largs)]
[lenrargs (length rargs)])
(cond
[(= lenlargs lenrargs)
(map + largs rargs)]
[(= 1 lenlargs)
(map (curry + (car largs)) rargs)]
[(= 1 lenrargs)
(my+ rargs largs)]
[else
(error 'length-error)])))
(module reader br
(provide read-syntax)
(define (read-syntax src-path src-port)
(define operators '(+ *))
(define src-exprs (for/list ([ln (in-lines src-port)]
#:when (regexp-match #px"\\w" ln))
(format-datum '(begin ~a) ln)))
(with-syntax ([(src-expr ...) src-exprs])
(syntax->datum #'(module rapl "rapl.rkt"
(displayln 'src-expr) ...)))))
#;(module+ test
(require rackunit)
(check-equal? (+ '(4) '(7)) '(11))
(check-equal? (+ '(3) '(2 4 11 7 5)) '(5 7 14 10 8))
(check-equal? (+ '(6 3 8 1) '(3)) '(9 6 11 4))
(check-equal? (+ '(6 3 8 1) '(3 6 1 8)) '(9 9 9 9))
(check-exn exn:fail? (λ _ (+ '(6 8 1) '(3 6 1 8)))))

@ -1,7 +0,0 @@
#lang reader (submod "rapl.rkt" reader)
1 3 3 7 * 8.41
8.41
5 8.41

@ -1,3 +0,0 @@
#lang reader "reader.rkt"
This is a terrible idea, and I should know because I invented it.

@ -1,9 +0,0 @@
#lang br
(provide read-syntax)
(define (read-syntax src in)
(syntax-let ([#'src-str (port->string in)])
#'(module no-name racket
(define (scramble str)
(list->string (shuffle (string->list str))))
(regexp-replace* #px"\\w+" src-str scramble))))

@ -1,3 +0,0 @@
#lang reader "stack-compiler.rkt"
(* (/ 25 14 (expt 5 2)) (/ 2 3 1) (* 10 12 15))

@ -1,33 +0,0 @@
#lang br
(provide #%top-interaction) ; activates the REPL
;; reader goes first and
;; 1) converts surface syntax into Rackety expressions (wrapping in `(inst ...)`)
;; 2) creates a module specifying semantics source (in this case, same module)
(provide read-syntax)
(define (read-syntax src-path src-input-port)
(define expr-datums (for/list ([src-line (in-lines src-input-port)]
#:when (regexp-match #px"\\w" src-line))
(format-datum '~a src-line)))
(syntax-let ([#'(expr-stx ...) expr-datums]) ; ok to bind with non-syntax
#'(module stack-compiler-module "stack-compiler.rkt"
expr-stx ...)))
;; semantics always start with #%module-begin, which unwraps the content of the module and rewraps it
(provide (rename-out [stack-module-begin #%module-begin]))
(define #'(stack-module-begin expr ...)
#'(#%module-begin
(stackify (quote expr)) ...))
(define (stackify quoted-expr)
(define pushes
(let loop ([x quoted-expr])
(cond
[(list? x)
(match-define (list op args ...) x)
(append (make-list (sub1 (length args)) op) (flatten (map loop args)))]
[else x])))
(for-each displayln (map (λ(p) (format "push ~a" p)) (reverse pushes))))

@ -1,21 +0,0 @@
#lang reader "stack.rkt"
push 15
push 12
push 10
push *
push *
push 1
push 3
push 2
push /
push /
push 2
push 5
push expt
push 14
push 25
push /
push /
push *
push *

@ -1,62 +0,0 @@
#lang br
(provide #%top-interaction) ; activates the REPL
;; reader goes first and
;; 1) converts surface syntax into Rackety expressions (wrapping in `(inst ...)`)
;; 2) creates a module specifying semantics source (in this case, same module)
(provide read-syntax)
(define (read-syntax src-path src-input-port)
(define inst-datums (for/list ([src-line (in-lines src-input-port)]
#:when (regexp-match #px"\\w" src-line))
(format-datum '(inst ~a) src-line)))
(syntax-let ([#'(inst-stx ...) inst-datums]) ; ok to bind with non-syntax
#'(module stack-lang-module "stack.rkt"
inst-stx ...)))
(define stack empty)
;; semantics always start with #%module-begin, which unwraps the content of the module and rewraps it
(provide (rename-out [stack-module-begin #%module-begin]))
(define #'(stack-module-begin instructions ...)
#'(#%module-begin
instructions ...
(first stack)))
;; then file is processed like a normal Racket file.
(provide inst)
(define (inst . args)
(if (<= 1 (length args) 2)
(let ([proc (first args)])
(apply proc (cdr args)))
(void)))
(provide push)
(define (push arg)
(display "push: ")
(cond
[(procedure? arg)
(displayln (format "got ~a, replacing ~a and ~a with result" arg (first stack) (second stack) ))
(set! stack (cons (arg (first stack) (second stack)) (cddr stack)))]
[else (displayln (format "storing value ~a" arg))
(set! stack (cons arg stack))])
(displayln stack))
;; exercises
(provide pop)
(define (pop)
(display "pop: ")
(displayln (format "got ~a" (car stack)))
(set! stack (cdr stack))
(displayln stack))
(provide swap)
(define (swap)
(display "swap: ")
(displayln (format "~a and ~a" (first stack) (second stack)))
(set! stack (list* (second stack) (first stack) (cddr stack)))
(displayln stack))

@ -1,37 +0,0 @@
#lang br
(module reader br
(define (read-syntax src-path src-port)
(define src-strs (port->lines src-port))
(define (make-datum str) (format-datum '(dispatch ~a) str))
(define src-exprs (map make-datum src-strs))
(inject-syntax ([#'(list src-expr ...) src-exprs])
#'(module stacker-mod "stacker-lang.rkt"
src-expr ...)))
(provide read-syntax))
(define #'(stacker-module-begin reader-line ...)
#'(#%module-begin
reader-line ...
(display (first stack))))
(provide (rename-out [stacker-module-begin #%module-begin]))
(define stack (list 0 0))
(define (push num) (set! stack (cons num stack)))
(define (dispatch arg-1 [arg-2 #f])
(cond
[(number? arg-2) (push arg-2)]
[else
(define op arg-1)
(define op-result (op (first stack) (second stack)))
(set! stack (cons op-result (drop stack 2)))]))
#;(define dispatch
(case-lambda
[(push num) (push num)]
[(stack-op)
(define op-result (stack-op (first stack) (second stack)))
(set! stack (cons op-result (drop stack 2)))]))
(provide #%top-interaction)

@ -1,6 +0,0 @@
#lang reader (submod "stacker-lang.rkt" reader)
push 4
push 8
+
push 3
*
Loading…
Cancel
Save