blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
171
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
8
| license_type
stringclasses 2
values | repo_name
stringlengths 6
82
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 13
values | visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 1.59k
594M
⌀ | star_events_count
int64 0
77.1k
| fork_events_count
int64 0
33.7k
| gha_license_id
stringclasses 12
values | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_language
stringclasses 46
values | src_encoding
stringclasses 14
values | language
stringclasses 2
values | is_vendor
bool 2
classes | is_generated
bool 1
class | length_bytes
int64 4
7.87M
| extension
stringclasses 101
values | filename
stringlengths 2
149
| content
stringlengths 4
7.87M
| has_macro_def
bool 2
classes |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c534d584ce08864f4424a7b178414db07c94261d | 2bf41fe232306e93a9d81db551f2fbe6c28c4e04 | /k2/examples/ocean.rkt | 2575f85931246989dd57b8a222a136a327b0d818 | []
| no_license | Cbranson14/TS-Languages | ad3e80d09bac64bd040688a1e19729b13dbb5064 | ad868614ef07346ca06b85c9c69a4935dc16da33 | refs/heads/master | 2020-06-23T22:07:20.650428 | 2019-07-19T20:54:35 | 2019-07-19T20:54:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 973 | rkt | ocean.rkt | #lang racket
(require ts-kata-util)
#;
(module fish racket
(require ts-kata-util)
(define-example-code k2/lang/ocean/fish
fish-1
(red fish))
(define-example-code k2/lang/ocean/fish
fish-2
(blue fish))
(define-example-code k2/lang/ocean/fish
fish-3
(beside
(red fish)
(blue fish)))
(define-example-code k2/lang/ocean/fish
fish-4
(above
(red fish)
(blue fish)))
(define-example-code k2/lang/ocean/fish
fish-5
(beside
(above
(red fish)
(blue fish))
(green fish))))
#;
(require 'fish)
#;
(provide
(all-from-out 'fish))
| false |
a2163b343109069c4c681abbdd920ad441834189 | d2fc383d46303bc47223f4e4d59ed925e9b446ce | /courses/2017/fall/301/notes/20.rkt | 801fe5281c03fe89634833240f063d26ba45a3ac | []
| no_license | jeapostrophe/jeapostrophe.github.com | ce0507abc0bf3de1c513955f234e8f39b60e4d05 | 48ae350248f33f6ce27be3ce24473e2bd225f6b5 | refs/heads/master | 2022-09-29T07:38:27.529951 | 2022-09-22T10:12:04 | 2022-09-22T10:12:04 | 3,734,650 | 14 | 5 | null | 2022-03-25T14:33:29 | 2012-03-16T01:13:09 | HTML | UTF-8 | Racket | false | false | 6,540 | rkt | 20.rkt | #lang racket/base
(require racket/list)
;; Rule 1
;; E [ call/cc V ] --> E [ V (λ (x) E[x]) ]
;; Rule 2
;; E [ call/cc V ] --> E [ V (kont E) ]
;; E [ (kont E') V ] --> E' [ V ]
;;;; Simple Examples
(call/cc (λ (k) (k 12))) ;; => 12
;; k = (λ (x) (+ 3 x))
(+ 3 (call/cc (λ (k) (k 12)))) ;; => 15
(+ 3 (let/cc k (k 12))) ;; => 15
(+ 3 (let/cc k (+ 10 (k 12)))) ;; => 15
;;;; Exception Handling
(define the-exception-handler
(λ (x)
(printf "An exception was not caught: ~e\n" x)
(exit 1)))
(define (throw v)
(the-exception-handler v))
(define (catch body-block handler-fun)
(let/cc where-i-was
(define last-handler the-exception-handler)
(set! the-exception-handler
(λ (x)
(where-i-was (handler-fun x))))
(define answer (body-block))
(set! the-exception-handler last-handler)
answer))
(define (my-divide x y)
(if (zero? y)
(throw "Division by zero")
(/ x y)))
#;(let ()
(my-divide 6 (- 7 7))) ;; => returns exception
(let ()
(+ 5
(catch (λ () (+ 6 (my-divide 6 (- 7 7))))
(λ (x)
(printf "Caught exception: ~e\n" x)
0))))
;; => 5
(let ()
(+ 5
(catch (λ () (+ 6 (my-divide 6 (- 7 6))))
(λ (x)
(printf "Caught exception: ~e\n" x)
0))))
;; => 17
;;;; Back-tracking
;; one-of : list of stuff -> one of the stuff
;; Returns the stuff so that the program doesn't fail
#;(let ()
(define how-many-times-called 0)
(define (one-of l)
(set! how-many-times-called
(add1 how-many-times-called))
(cond
[(= how-many-times-called 1) (first l)]
[(= how-many-times-called 2) (third l)]
[else (error 'one-of "I don't know")]))
(define (fail)
(error 'fail "You failed, fix the implemention of one-of")))
(define (one-of l)
(cond
[(empty? l)
(fail)]
[else
(let/cc come-back-here
(define orig-fail fail)
(set! fail
(λ ()
(set! fail orig-fail)
(come-back-here (one-of (rest l)))))
(first l))]))
(define fail
(λ () (error 'fail "No choice works")))
(let ()
(define a (one-of (list 4 5 6)))
(define b (one-of (list 3 7 9)))
(printf "\tA = ~a, B = ~a\n" a b)
(when (not (= (+ a b) 13))
(fail))
(format "The answer is: ~a ~a" a b))
;; => The answer is: 4 9
;; => The answer is: 6 7
;;;; Generator
(let ()
(define where-multiples-of-eight-was #f)
(define (multiples-of-eight)
(let/cc current-call-site
(define (return v)
(set! current-call-site
(let/cc where-i-was
(set! where-multiples-of-eight-was where-i-was)
(current-call-site v))))
(cond
[where-multiples-of-eight-was
(where-multiples-of-eight-was current-call-site)]
[else
(for ([i (in-naturals)])
(return (* i 8)))])))
(list (multiples-of-eight)
(multiples-of-eight)
(multiples-of-eight)
(multiples-of-eight)
(multiples-of-eight)))
;; => 0, 8, 16, 24, 32
(define (make-generator work)
(define where-work-was #f)
(define (the-generator)
(let/cc current-call-site
(define (return v)
(set! current-call-site
(let/cc where-i-was
(set! where-work-was where-i-was)
(current-call-site v))))
(cond
[where-work-was
(where-work-was current-call-site)]
[else
(work return)])))
the-generator)
(let ()
(define multiples-of-eight
(make-generator
(λ (return)
(for ([i (in-naturals)])
(return (* i 8))))))
(list (multiples-of-eight)
(multiples-of-eight)
(multiples-of-eight)
(multiples-of-eight)
(multiples-of-eight)))
;; => 0, 8, 16, 24, 32
(let ()
(define even-numbers-minus-two-gen
(make-generator
(λ (return)
(for ([i (in-naturals)])
(when (even? i)
(return (- (* i 2) 2)))))))
(list (even-numbers-minus-two-gen)
(even-numbers-minus-two-gen)
(even-numbers-minus-two-gen)
(even-numbers-minus-two-gen)
(even-numbers-minus-two-gen)
(even-numbers-minus-two-gen)))
;;;; Threads
(define THREADS empty)
(define (make-process thread-body)
(set! THREADS (append THREADS (list thread-body))))
(define (yield)
(let/cc remember-where-it-was
(make-process remember-where-it-was)
(switch-to-another-thread)))
(define (process-exit)
(switch-to-another-thread))
(define (switch-to-another-thread)
(cond
[(empty? THREADS)
(original-call-to-the-kernel)]
[else
(define next-thread (first THREADS))
(set! THREADS (rest THREADS))
(next-thread)]))
(define original-call-to-the-kernel #f)
(define (start-the-kernel!)
(let/cc my-caller
(set! original-call-to-the-kernel my-caller)
(switch-to-another-thread)))
(let ()
(make-process
(λ ()
(for ([i (in-range 10)])
(printf "Process A looked at ~a\n" i)
(yield))
(process-exit)))
(make-process
(λ ()
(for ([i (in-range 30 40)])
(printf "Process B looked at ~a\n" i)
(yield))
(process-exit)))
(printf "About to start the kernel\n")
(start-the-kernel!)
(printf "Kernel is done\n"))
(define (real-printf fmt args)
;; 64 means "do a printf"
(yield 64 fmt args))
;;;; Web Programming
(require web-server/servlet-env
web-server/servlet
web-server/http)
;; add-two-numbers.com
(define (get-a-number label)
(string->number
(extract-binding/single
'thenum
(request-bindings
(send/suspend
(λ (new-url-for-here)
(send/back
(response/xexpr
`(body
(h1 ,(format "What is the ~a number?" label))
(form ([action ,new-url-for-here])
(input ([type "text"] [name "thenum"]))
(input ([type "submit"]))))))))))))
(define (add-two-numbers.com)
(serve/servlet
(λ (req)
(define x (get-a-number "First"))
(define y (get-a-number "Second"))
(define ans (+ x y))
(send/back
(response/xexpr
`(body
(h1 ,(format "The answer is ~a" ans))))))))
(define (add-many-numbers.com)
(serve/servlet
(λ (req)
(define how-many (get-a-number "How Many"))
(define ans
(for/sum ([i (in-range how-many)])
(get-a-number (number->string i))))
(send/back
(response/xexpr
`(body
(h1 ,(format "The answer is ~a" ans))))))))
(add-many-numbers.com)
| false |
5dbde7e5e31542901c1365cb3452ad54cb6cb0d4 | 71060ffeffa3469ec44ba661b04118b487fc0602 | /ch_2_derivatives.rkt | df4c1b76119f05203f8ddc5299cdd2de6a28c9ca | []
| no_license | ackinc/sicp | 18741d3ffc46041ecd08021d57a50702be2e0f92 | 4ee2250f8b7454fb88bc27edb41a1349d7a3016c | refs/heads/master | 2021-09-13T08:55:37.171840 | 2018-04-27T10:02:08 | 2018-04-27T10:02:08 | 114,095,803 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 2,726 | rkt | ch_2_derivatives.rkt | #lang racket
(define (deriv exp v)
(cond ((number? exp) 0)
((variable? exp) (if (same-variable? exp v) 1 0))
((sum? exp) (make-sum (deriv (addend exp) v)
(deriv (augend exp) v)))
((product? exp) (make-sum (make-product (multiplicand exp)
(deriv (multiplier exp) v))
(make-product (multiplier exp)
(deriv (multiplicand exp) v))))
; ex 2.56
((pow? exp) (cond ((same-variable? v (exponent exp)) (error "deriv: unimplemented for this type of expression" exp))
(else (let ((b (base exp))
(e (exponent exp)))
(make-product (make-product e (make-pow b (make-sum e -1)))
(deriv b v))))))
(else (error "deriv: invalid expression type" exp))))
(define (variable? v) (symbol? v))
(define (same-variable? v1 v2) (and (variable? v1) (variable? v2) (eq? v1 v2)))
(define (=number? exp num)
(and (number? exp) (= exp num)))
(define (make-sum exp1 exp2)
(cond ((=number? exp1 0) exp2)
((=number? exp2 0) exp1)
((and (number? exp1) (number? exp2)) (+ exp1 exp2))
(else (list '+ exp1 exp2))))
(define (sum? exp) (and (list? exp) (eq? (car exp) '+)))
(define (addend sum-exp) (cadr sum-exp))
;(define (augend sum-exp) (caddr sum-exp))
; ex 2.57
(define (augend sum-exp)
(if (null? (cdddr sum-exp))
(caddr sum-exp)
(cons '+ (cddr sum-exp))))
(define (make-product exp1 exp2)
(cond ((or (=number? exp1 0) (=number? exp2 0)) 0)
((=number? exp1 1) exp2)
((=number? exp2 1) exp1)
((and (number? exp1) (number? exp2)) (* exp1 exp2))
(else (list '* exp1 exp2))))
(define (product? exp) (and (list? exp) (eq? (car exp) '*)))
(define (multiplier prod-exp) (cadr prod-exp))
;(define (multiplicand prod-exp) (caddr prod-exp))
; ex 2.57
(define (multiplicand prod-exp)
(if (null? (cdddr prod-exp))
(caddr prod-exp)
(cons '* (cddr prod-exp))))
(define (square x) (* x x))
(define (fast-exp b n)
(cond ((= n 0) 1)
((even? n) (fast-exp (square b) (/ n 2)))
(else (* b (fast-exp b (- n 1))))))
; ex 2.56
(define (make-pow base exp)
(cond ((or (=number? base 0) (=number? base 1)) base)
((=number? exp 0) 1)
((=number? exp 1) base)
((and (number? base) (number? exp)) (fast-exp base exp))
(else (list '^ base exp))))
(define (pow? exp) (and (list? exp) (eq? (car exp) '^)))
(define (base pow-exp) (cadr pow-exp))
(define (exponent pow-exp) (caddr pow-exp)) | false |
bfa4863827063d8db294c07b497fc3331034755f | 9611e3784cc65b8ff07798c9c4de98b54cc90990 | /kernel/src/core/equivalence-under-mutation.rkt | f8829fb8509c9c29fac1ab5e3d6a20a077a51717 | []
| no_license | mikeurbach/kernel-racket | d9551e21420bb1e2c59a73af10da07a57f36dc12 | 2db5a91009877f20e58ee8343ee96a3bbe3b2cee | refs/heads/master | 2022-10-23T11:42:59.739043 | 2020-06-09T02:41:22 | 2020-06-09T02:41:22 | 169,695,648 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 60 | rkt | equivalence-under-mutation.rkt | #lang racket
(provide kernel-eq?)
(define kernel-eq? eq?)
| false |
ed67922a43035fe28473e0a07925724247ea20e6 | 9db1a54c264a331b41e352365e143c7b2b2e6a3e | /code/chapter_3/internal-sum.rkt | 161268fcca09d9ccb3a4104fbab931b529078405 | []
| no_license | magic3007/sicp | 7103090baa9a52a372be360075fb86800fcadc70 | b45e691ae056410d0eab57d65c260b6e489a145b | refs/heads/master | 2021-01-27T10:20:28.743896 | 2020-06-05T15:17:10 | 2020-06-05T15:17:10 | 243,478,192 | 4 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 876 | rkt | internal-sum.rkt | #lang racket
(define maxn 1000000000)
(define (lowbit x) (bitwise-and x (- x)))
(define (ask hs x)
(if (= x 0) 0
(+ (hash-ref hs x 0) (ask hs (- x (lowbit x))))))
(define (update hs x val)
(when (<= x maxn)
(begin (hash-set*! hs x (+ (hash-ref hs x 0) val))
(update hs (+ x (lowbit x)) val))))
(define a (make-hash))
(define b (make-hash))
(define (query x)
(- (* (add1 x) (ask a x)) (ask b x)))
(define (loop m)
(unless (eq? m 0)
(let ([op (read)])
(match op
[1 (let-values ([(l r val) (values (read) (add1 (read)) (read))])
(update a l val)
(update a r (- val))
(update b l (* l val))
(update b r (* r (- val))))]
[0 (let-values ([(l r) (values (sub1 (read)) (read))])
(displayln (- (query r) (query l))))])
(loop (sub1 m)))))
(loop (read)) | false |
bafd81ee0806f824d4caed06baa9b47f44eac40d | 453869ca6ccd4c055aa7ba5b09c1b2deccd5fe0c | /tests/struct/super-required.rkt | d2facf6ac1ba723c69c07a93295078c56919c422 | [
"MIT"
]
| permissive | racketscript/racketscript | 52d1b67470aaecfd2606e96910c7dea0d98377c1 | bff853c802b0073d08043f850108a57981d9f826 | refs/heads/master | 2023-09-04T09:14:10.131529 | 2023-09-02T16:33:53 | 2023-09-02T16:33:53 | 52,491,211 | 328 | 16 | MIT | 2023-09-02T16:33:55 | 2016-02-25T02:38:38 | Racket | UTF-8 | Racket | false | false | 397 | rkt | super-required.rkt | #lang racket/base
(require "p.rkt")
;; fixes pr #272
;; was getting arity mismatch err bc imported super struct's fields are counted
;; (there are subsequent errors as well if arity check is disabled)
;; (real-world example where this shows up is promises)
(define-struct (p2 p) ())
(displayln (p2 1))
(displayln (p 2))
(displayln (p? (p 2)))
(displayln (p? (make-p 2)))
(displayln (p? (p2 2)))
| false |
399f12fa8d7c2dd58e529e0ee1541ce13be0a416 | 18c43eeddbad12cdeb1d1325b763aefdb6190c36 | /syntax-classes-doc/scribblings/syntax-classes.scrbl | 52326c2d5837259a592376df3340e225f08fd8e0 | []
| no_license | iitalics/syntax-classes | 73ed169b7c8bab62240a36605affba2c73f2aab0 | fe1e1399b3c68c899f7613589d5f7835a16f370f | refs/heads/master | 2020-03-20T22:40:35.763551 | 2016-12-07T22:38:59 | 2016-12-07T22:38:59 | 137,809,899 | 0 | 0 | null | 2018-06-18T21:45:54 | 2018-06-18T21:45:54 | null | UTF-8 | Racket | false | false | 9,818 | scrbl | syntax-classes.scrbl | #lang scribble/manual
@(require (for-label racket/base
racket/contract
racket/function
racket/struct-info
syntax/parse
syntax/parse/class/local-value
syntax/parse/class/paren-shape
syntax/parse/class/struct-id
syntax/parse/experimental/template)
scribble/eval)
@(define (guide-tech . pre-content)
(apply tech #:doc '(lib "scribblings/guide/guide.scrbl") pre-content))
@(define (syntax-tech . pre-content)
(apply tech #:doc '(lib "syntax/scribblings/syntax.scrbl") pre-content))
@(define (syntax-class-tech . pre-content)
(apply tech #:doc '(lib "syntax/scribblings/syntax.scrbl") #:key "syntax class" pre-content))
@(define (make-syntax-class-eval)
(let ([eval ((make-eval-factory '()))])
(eval '(require (for-syntax racket/base
syntax/parse
syntax/parse/class/local-value
syntax/parse/class/struct-id
syntax/parse/experimental/template)
syntax/parse
syntax/parse/class/paren-shape))
eval))
@(define-syntax-rule (syntax-class-examples body ...)
(examples #:eval (make-syntax-class-eval)
body ...))
@title{More Syntax Classes}
This library provides additional @syntax-class-tech{syntax classes} for use with
@racketmodname[syntax/parse].
@section{Locally bound transformer bindings}
@defmodule[syntax/parse/class/local-value]
@defform[#:kind "syntax class"
(local-value @#,elem{[@racket[_predicate?]]} @#,elem{[@racket[#:failure-message _failure-message]]})
#:contracts ([_predicate? @#,elem{@racket[(any/c . -> . any/c)] = @racket[(const #t)]}]
[_failure-message @#,elem{@racket[(or/c string? #f)] = @racket[#f]}])]{
A @syntax-class-tech{syntax class} for parsing identifiers bound to @guide-tech{transformer bindings}. It
parses an identifier, then calls @racket[syntax-local-value] on it and binds the result to an
attribute named @tt{local-value}.
If @racket[_predicate?] is specified, then @racket[_predicate?] will be applied to the result of
@racket[syntax-local-value], and if the result is @racket[#f], then the syntax class will fail to
match.
If the identifier is not bound to a @guide-tech{transformer binding}, or if the binding does not
satisfy @racket[_predicate?], then @racket[_failure-message] will be used as the error message, if it
is supplied.
@(syntax-class-examples
(define-syntax print-local
(syntax-parser
[(_ id:local-value)
(println (attribute id.local-value))
#'(void)]))
(define-syntax something 42)
(print-local something)
(define-syntax print-local-string
(syntax-parser
[(_ {~var id (local-value string?)})
(println (attribute id.local-value))
#'(void)]))
(print-local-string something)
(define-syntax print-local-string/message
(syntax-parser
[(_ {~var id (local-value string? #:failure-message "identifier was not bound to a string")})
(println (attribute id.local-value))
#'(void)]))
(print-local-string/message something))}
@section{Lists and pairs with @racket['paren-shape]}
@defmodule[syntax/parse/class/paren-shape]
@defform[#:kind "syntax class" (paren-shape shape)
#:contracts ([shape any/c])]{
Parses any syntax object that has a @racket['paren-shape] syntax property with a value @racket[equal?]
to @racket[shape].
@history[#:added "1.1"]}
@defidform[#:kind "syntax class" paren-shape/parens]{
Parses any syntax object that either has @racket[#f] for the @racket['paren-shape] syntax property or
does not have a @racket['paren-shape] syntax property at all.
@history[#:added "1.1"]}
@defidform[#:kind "syntax class" paren-shape/brackets]{
Parses any syntax object that has @racket[#\[] for the @racket['paren-shape] syntax property.
@history[#:added "1.1"]}
@defidform[#:kind "syntax class" paren-shape/braces]{
Parses any syntax object that has @racket[#\{] for the @racket['paren-shape] syntax property.
@history[#:added "1.1"]}
@defform[#:kind "pattern expander" (~parens H-pattern . S-pattern)]{
A @syntax-tech{pattern expander} that parses a list or pair that either has @racket[#f] for the
@racket['paren-shape] syntax property or does not have a @racket['paren-shape] syntax property at all.
@(syntax-class-examples
(syntax-parse #'(1 2 . "three")
[(~parens a ... . rst)
(cons #'(a ...) #'rst)])
(eval:alts (syntax-parse #'{1 2 . "three"}
[(~parens a ... . rst)
(cons #'(a ...) #'rst)])
(syntax-parse (syntax-property #'{1 2 . "three"} 'paren-shape #\{)
[(~parens a ... . rst)
(cons #'(a ...) #'rst)])))
@history[#:added "1.1"]}
@defform[#:kind "pattern expander" [~brackets H-pattern . S-pattern]]{
A @syntax-tech{pattern expander} that parses a list or pair that has @racket[#\[] for the
@racket['paren-shape] syntax property.
@(syntax-class-examples
(eval:alts (syntax-parse #'[1 2 . "three"]
[[~brackets a ... . rst]
(cons #'(a ...) #'rst)])
(syntax-parse (syntax-property #'[1 2 . "three"] 'paren-shape #\[)
[[~brackets a ... . rst]
(cons #'(a ...) #'rst)]))
(syntax-parse #'(1 2 . "three")
[[~brackets a ... . rst]
(cons #'(a ...) #'rst)]))
@history[#:added "1.1"]}
@defform[#:kind "pattern expander" {~braces H-pattern . S-pattern}]{
A @syntax-tech{pattern expander} that parses a list or pair that has @racket[#\{] for the
@racket['paren-shape] syntax property.
@(syntax-class-examples
(eval:alts (syntax-parse #'{1 2 . "three"}
[{~braces a ... . rst}
(cons #'(a ...) #'rst)])
(syntax-parse (syntax-property #'{1 2 . "three"} 'paren-shape #\{)
[{~braces a ... . rst}
(cons #'(a ...) #'rst)]))
(syntax-parse #'(1 2 . "three")
[{~braces a ... . rst}
(cons #'(a ...) #'rst)]))
@history[#:added "1.1"]}
@section{Structure type transformer bindings}
@defmodule[syntax/parse/class/struct-id]
@defidform[#:kind "syntax class" struct-id]{
A @syntax-class-tech{syntax class} for parsing
@seclink["structinfo" #:doc '(lib "scribblings/reference/reference.scrbl")]{structure type transformer
bindings}. Like the @racket[local-value] syntax class, it will parse an identifier, then call
@racket[syntax-local-value] on it to get a value. This syntax class will only match if the resulting
value satisfies @racket[struct-info?], and it will then bind a set of attributes:
@itemlist[
@item{The @tt{info} attribute is bound to the list form of the @racket[struct-info?] value (that is,
the value produced by calling @racket[extract-struct-info] on the transformer value).}
@item{The @tt{descriptor-id} attribute is bound to an identifier that is bound to the structure
type’s descriptor, or @racket[#f] if none is known.}
@item{The @tt{constructor-id} attribute is bound to an identifier that is bound to the structure
type’s constructor, or @racket[#f] if none is known.}
@item{The @tt{predicate-id} attribute is bound to an identifier that is bound to the structure
type’s predicate, or @racket[#f] if none is known.}
@item{The @tt{all-fields-visible?} attribute is bound to @racket[#t] if all structure fields are
visible to the macro, otherwise it is @racket[#f].}
@item{The @tt{num-fields} attribute is bound to an exact, nonnegative integer that describes the
number of visible fields the structure type has, including supertype fields.}
@item{The @tt{accessor-id} attribute is an attribute of @syntax-tech{ellipsis depth} 1 that is bound
to identifiers bound to accessors for all visible structure fields, including supertype
fields.}
@item{The @tt{mutator-id} attribute is like @tt{accessor-id}, except that it contains identifiers
bound to mutators instead of accessors. It is guaranteed to have the same number of elements
as @tt{accessor-id}; however, the value will be @racket[#f] for each non-mutable field.}
@item{The @tt{supertype-id} attribute is bound to an identifier or a boolean. If it is an
identifier, then the identifier is a structure type transformer binding for the structure’s
supertype. If it is @racket[#t], then the structure has no supertype. If it is @racket[#f],
then the structure’s supertype is unknown.}
@item{The @tt{num-supertype-fields} attribute is like @tt{num-fields}, except that it only counts
supertype fields, not fields that belong to the structure type itself.}
@item{The @tt{num-own-fields} attribute is like @tt{num-fields}, except that it does not count
supertype fields, only fields that belong to the structure type itself.}
@item{The @tt{own-accessor-id} attribute is like @tt{accessor-id}, except that it does not include
supertype fields, only fields that belong to the structure type itself.}
@item{The @tt{own-mutator-id} attribute is like @tt{mutator-id} combined with the
supertype-excluding behavior of @tt{own-accessor-id}.}]
Due to the nature of the @tt{mutator-id} attribute, it can be useful to use @racket[template] from
@racketmodname[syntax/parse/experimental/template] instead of @racket[syntax] when using mutator ids.
@(syntax-class-examples
(define-syntax struct-accessors+mutators
(syntax-parser
[(_ id:struct-id)
(template
'((id.accessor-id (?? id.mutator-id #f))
...))]))
(struct foo (bar [baz #:mutable] qux))
(struct-accessors+mutators foo))}
| true |
eab33184f2e085225a4daffce3b4c11acabea791 | 4d204d78919b942b9174bce87efa922ef2f630ed | /itscaleb/ch01/1.44.rkt | 013f6cb9cdf76e3097558e19151c69e0db87d601 | []
| no_license | SeaRbSg/SICP | 7edf9c621231c0348cf3c7bb69789afde82998e4 | 2df6ffc672e9cbf57bed4c2ba0fa89e7871e22ed | refs/heads/master | 2016-09-06T02:11:30.837100 | 2015-07-28T21:21:37 | 2015-07-28T21:21:37 | 20,213,338 | 0 | 2 | null | null | null | null | UTF-8 | Racket | false | false | 199 | rkt | 1.44.rkt | #lang racket
(require rackunit)
(define (smooth f dx)
(lambda (x)
(/ (+ (f (- x dx))
(f x)
(f (+ x dx)))
3)))
(check-equal?
((smooth (lambda (x) (* x 2)) 1) 2)
4) | false |
1f513a7067f416f059d538681d0bb93cba9c3d76 | a3673e4bb7fa887791beabec6fd193cf278a2f1a | /lib/racket-docs/types/desc.rkt | e66a39043f6de71fadc4479c18214e6b002c7f4d | []
| no_license | FDWraith/Racket-Docs | f0be2e0beb92f5d4f8aeeca3386240045a03e336 | 7eabb5355c19a87337f13287fbe3c10e10806ae8 | refs/heads/master | 2021-01-25T10:16:51.207233 | 2018-04-16T22:28:33 | 2018-04-16T22:28:33 | 123,346,280 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 6,055 | rkt | desc.rkt | #lang racket
(provide type-summary
type-label
type-label/union)
(require "struct.rkt"
"../utils/gen.rkt")
#;(define-docs summary-recur-limit
[Signature: Nat]
[Purpose: #<<"
How many layers of sub-types will be used in a type summary or label,
before ... is used. Prevents unnecessary or infinite recursion.
"
])
(define summary-recur-limit 8)
#;(define-docs (type-summary type)
[Signature: Type -> String]
[Purpose: "A detailed summary of the type, useful for debugging."]
[Examples:
(type-summary (λ () (primitive "String"))) => "String"
(type-summary (labeled-type [Union/parsed (λ () (primitive "Pos"))
(λ () 0)] "Nat")) =>
"[Union Pos '0]"
(type-label (labeled-type (λ () (primitive "PosInt")) "Pos")) => "Pos"])
(define (type-summary type)
(type-summary/acc type summary-recur-limit))
(define (type-summary/acc type recurs-left)
(cond
[(zero? recurs-left) "..."]
[else
(type-summary/recur type
(- summary-recur-limit recurs-left)
(λ (_) #true)
(curryr type-summary/acc (sub1 recurs-left)))]))
#;(define-docs (type-label type)
[Signature: Type -> String]
[Purpose: "A brief label of the type, useful for displaying to the user."]
[Examples:
(type-label (λ () (primitive "String"))) => "String"
(type-label (labeled-type [Union/parsed (λ () (primitive "Pos"))
(λ () 0)] "Nat")) => "Nat"
(type-label (labeled-type (λ () (primitive "PosInt")) "Pos")) => "Pos"])
(define (type-label type)
(type-label/acc type summary-recur-limit))
(define (type-label/acc type recurs-left)
(cond
[(labeled-type? type) (labeled-type-label type)]
[(zero? recurs-left) "..."]
[else (type-summary/recur type
(- summary-recur-limit recurs-left)
show-in-intersection-label?
(curryr type-label/acc (sub1 recurs-left)))]))
#;(define-docs (type-label/union type)
[Signature: Type -> [Listof String]]
[Purpose: #<<"
A brief label of the type, or possible subtypes of the type if it's a union.
"
]
[Examples:
(type-label/union (λ () (primitive "String"))) => '("String")
(type-label/union [Union/parsed (λ () (primitive "String"))
(λ () (primitive "Nat"))]) =>
'("String" "Nat")
(type-label (labeled-type (λ () (primitive "PosInt")) "Pos")) => "PosInt"
(type-label/union
(labeled-type (labeled-type [Union/parsed (λ () (primitive "Pos"))
(λ () 0)] "Nat") "Natural")) =>
'("Nat")])
(define (type-label/union type)
(define type+ (type))
(cond
[(union? type+) (map type-label (union-subs type+))]
[else (list (type-label type))]))
#;(define-docs (show-in-intersection-label? x)
[Signature: Type -> Boolean]
[Purpose: #<<"
Whether this type should be shown in a type label,
if it's in an intersection with other types.
"
])
(define (show-in-intersection-label? x)
(cond
[(labeled-type? x) #true]
[else
(define x+ (x))
(cond
[(intersection? x+)
(andmap show-in-intersection-label? (intersection-subs x+))]
[(union? x+)
(andmap show-in-intersection-label? (union-subs x+))]
[(expr? x+) #false]
[(forall? x+)
(show-in-intersection-label? ((forall-get-type x+) Nothing/parsed))]
[else #true])]))
#;(define-docs (type-summary/recur type eid sub-filter sub-summary)
[Signature: Type Nat [Type -> Bool] [Type -> String] -> String]
[Purpose: #<<"
A summary of the type. Fills in parameterized types with the primitive "X@eid",
ignores intersection sub-types which return false in @sub-filter
(pretends that they don't exist), and summarizes sub-types via @sub-summary.
"
]
[Examples:
(type-summary/recur (λ () (primitive "String")) (λ (x) "foo")) => "String"
(type-summary/recur Nat (λ (x) "foo")) => "[Intersection foo foo]"])
(define (type-summary/recur type eid sub-filter sub-summary)
(define type+ (type))
(cond
[(primitive? type+) (primitive-label type+)]
[(intersection? type+)
(define all-intersection-subs (intersection-subs type+))
(define filtered-intersection-subs
(filter sub-filter (intersection-subs type+)))
(define intersection-subs*
(cond
[(empty? all-intersection-subs) '()]
[(empty? filtered-intersection-subs)
(list (first all-intersection-subs))]
[else filtered-intersection-subs]))
(cond
[(empty? intersection-subs*) "Any"]
[(empty? (rest intersection-subs*))
(sub-summary (first intersection-subs*))]
[else
(format "[Intersection ~a]"
(string-join (remove-duplicates (map sub-summary
intersection-subs*))
" "))])]
[(union? type+)
(cond
[(empty? (union-subs type+)) "Nothing/Unknown"]
[(empty? (rest (union-subs type+)))
(sub-summary (first (union-subs type+)))]
[else
(format "[Union ~a]"
(string-join (remove-duplicates (map sub-summary
(union-subs type+)))
" "))])]
[(func? type+)
(format "[~a -> ~a]"
(string-join (map sub-summary (func-params type+)) " ")
(sub-summary (func-out type+)))]
[(forall? type+)
(define eparam (λ () (primitive (format "X~a" eid))))
(format "{All ~a} ~a"
(sub-summary eparam)
(sub-summary ((forall-get-type type+) eparam)))]
[(expr-func? type+)
(format "(~a)" (string-join (map sub-summary type+) " "))]
[else (datum->string type+)]))
| false |
63a31637656509875f0d8280fb9424d81a0f998e | 4919215f2fe595838a86d14926c10717f69784e4 | /lessons/Introducing-the-Design-Recipe/worksheets/Design-Recipe-Rocket-Height.scrbl | 0fab524ae2c8b1e19e80ca7baa9d944a626b3521 | []
| no_license | Emmay/curr | 0bae4ab456a06a9d25fbca05a25aedfd5457819b | dce9cede1e471b0d12ae12d3121da900e43a3304 | refs/heads/master | 2021-01-18T08:47:20.267308 | 2013-07-15T12:23:41 | 2013-07-15T12:23:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,709 | scrbl | Design-Recipe-Rocket-Height.scrbl | #lang curr/lib
@title{Design Recipe for Rocket-height}
@worksheet{@design-recipe-exercise["rocket-height" "A rocket blasts off, traveling at 7 meters per second. Write a function called " @code{rocket-height} " that takes in the number of seconds that have passed since the rocket took off, and which produces the height of the rocket at that time."]}
@;worksheet{
@; A rocket blasts off, traveling at 7 meters per second. Write a function called @code{rocket-height} that takes in the number of seconds that have passed since the rocket took off, and which produces the height of the rocket at that time.
@;worksheet-segment{I. Contract + Purpose Statement}
@;Every contract has three parts:
@;contract-exercise["11" #:name "rocket-height" #:domain "number" #:range "number"]
@;;@fill-in-the-blank[#:id "12" #:label "Purpose" #:answer "Takes the number of seconds passed since take-off, and produces the current height"]
@;worksheet-segment{II. Give Examples}
@;Write two examples of your function in action
@;example-with-text["rocket-height-1"
@; #:example1 "rocket-height 0"
@; #:example2 "(* 7 0)"]
@;example-with-text["rocket-height-2"
@; #:example1 "rocket-height 4"
@; #:example2 "(* 7 4)"]
@;worksheet-segment{III. Function Header}
@;Write the function Header, giving variable names to all your input values.
@;function-exercise["rocket-height"
@; #:name "rocket-height"
@; #:args "time"
@; #:body "(* 7 time)"]} | false |
85dd0dd89ffa19c1d76e4a9f8af1124f48fa8185 | 93b116bdabc5b7281c1f7bec8bbba6372310633c | /plt/tspl/codes/ch6/string.rkt | 065b200025e639a36850833a501915ccfd4f944d | []
| no_license | bianyali/BookList | ac84aa5931ced43f99269f881e009644ce68bb49 | ef64c71ac5da235bfab98336e2deb049e8c35b67 | refs/heads/master | 2021-01-17T10:13:20.341278 | 2015-12-29T04:45:53 | 2015-12-29T04:45:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 47 | rkt | string.rkt | ; Section 6.7
#lang racket
(make-string 10)
| false |
bd166fdf3f3018b526ac4788621f4bd4ceb884ed | 38bc0fc604c69927021ce4b619e42d8219e1214f | /main.scrbl | b59bf56e89293bf3a07aa1791efc96564aefce04 | [
"Apache-2.0"
]
| permissive | DavidAlphaFox/resyntax | 4f4d18367a98e4b535e5a7b10563368ecbb5309d | 0c957be4eb2cd17601dee90fe4dd4d748de73ef5 | refs/heads/master | 2023-07-01T01:27:18.922334 | 2021-07-02T01:29:10 | 2021-07-02T01:29:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 3,629 | scrbl | main.scrbl | #lang scribble/manual
@(require (for-label racket/base
syntax/parse)
scribble/bnf)
@title{Resyntax}
@defmodule[resyntax]
Resyntax is a refactoring tool for Racket. The tool can be guided by @deftech{refactoring rules},
which are macro-like functions defined in terms of @racket[syntax-parse] that specify how to search
for and refactor different coding patterns. Resyntax comes with a standard set of refactoring rules
that improve code written in @racket[@#,hash-lang[] @#,racketmodname[racket/base]]. For example,
consider the following program:
@(racketmod
#:file "my-program.rkt"
racket/base
(define (swap x y)
(let ([t (unbox x)])
(set-box! x (unbox y))
(set-box! y t))))
This program uses @racket[let] unnecessarily. The @racket[let] expression can be replaced with a
@racket[define] form, reducing the indentation of the code. Resyntax is capable of detecting and
automatically fixing this issue. Running @exec{resyntax fix --file my-program.rkt} rewrites the above
to the following:
@(racketmod
#:file "my-program.rkt"
racket/base
(define (swap x y)
(define t (unbox x))
(set-box! x (unbox y))
(set-box! y t)))
To see a list of suggestions that Resyntax would apply, use @exec{resyntax analyze} instead of
@exec{resyntax fix}. Each suggestion includes an explanation of why the change is being recommended.
@bold{This tool is extremely experimental.} Do not attempt to incorporate it into your projects yet.
For now, the refactoring suggestions produced by @racketmodname[resyntax] are best viewed as glimpses
into one possible distant future of static analysis for Racket. Feedback, questions, and ideas are all
greatly appreciated and are best directed at the @hyperlink[github-repository-url]{GitHub repository}.
@table-of-contents[]
@(define github-repository-url "https://github.com/jackfirth/resyntax/")
@section[#:tag "cli"]{The Resyntax Command-Line Interface}
Resyntax provides a command-line @exec{resyntax} tool for analyzing and refactoring code. The tool has
two commands: @exec{resyntax analyze} for analyzing code without changing it, and @exec{resyntax fix}
for fixing code by applying Resyntax's suggestions.
Note that at present, Resyntax is limited in what files it can fix. Resyntax only analyzes files with
the @exec{.rkt} extension where @tt{#lang racket/base} is the first line in file.
@subsection{Running @exec{resyntax analyze}}
The @exec{resyntax analyze} command accepts flags for specifying what modules to analyze. After
analysis, suggestions are printed in the console. Any of the following flags can be specified any
number of times:
@itemlist[
@item{@exec{--file} @nonterm{file-path} --- A file to anaylze.}
@item{@exec{--directory} @nonterm{directory-path} --- A directory to anaylze, including
subdirectories.}
@item{@exec{--package} @nonterm{package-name} --- An installed package to analyze.}]
@subsection{Running @exec{resyntax fix}}
The @exec{resyntax fix} command accepts the same flags as @exec{resyntax analyze} for specifying what
modules to fix. After analysis, fixes are applied and a summary is printed.
@itemlist[
@item{@exec{--file} @nonterm{file-path} --- A file to fix.}
@item{@exec{--directory} @nonterm{directory-path} --- A directory to fix, including
subdirectories.}
@item{@exec{--package} @nonterm{package-name} --- An installed package to fix.}]
If two suggestions try to fix the same code, one of them will be rejected. At present, the best way to
handle overlapping fixes is to run Resyntax multiple times until no fixes are rejected.
| false |
d9122674d2ef1c6cd4d878718d71434f50f526b0 | 1397f4aad672004b32508f67066cb7812f8e2a14 | /plot-test/plot/tests/axis-transform-tests.rkt | 5fbfe2b892b3fefd0d381ac494657100ffc0def9 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | racket/plot | 2da8d9f8159f28d0a9f540012e43457d490d36da | b0da52632c0369058887439345eb90cbf8e99dae | refs/heads/master | 2023-07-14T07:31:23.099585 | 2023-07-04T12:53:33 | 2023-07-04T12:53:33 | 27,409,837 | 39 | 29 | NOASSERTION | 2023-07-04T12:56:50 | 2014-12-02T01:50:35 | Racket | UTF-8 | Racket | false | false | 21,772 | rkt | axis-transform-tests.rkt | #lang racket
(require rackunit
plot
plot/utils
racket/draw
racket/runtime-path
"helpers.rkt")
(x-axis-ticks? #f)
(y-axis-ticks? #f)
(define (do-plot1 output-fn)
(parameterize ([plot-x-transform log-transform])
(output-fn(list (function values 1 5)
(function cos 1 5 #:color 3)))))
(define (do-plot2 output-fn)
(parameterize ([plot-x-transform cbrt-transform])
(output-fn (list (function values -2 2)
(function cos -2 2 #:color 3)))))
(define (do-plot3 output-fn)
(parameterize ([plot-x-transform log-transform]
[plot-y-transform cbrt-transform])
(define xs (nonlinear-seq 1 5 20 log-transform))
(define ys (nonlinear-seq -1 5 20 cbrt-transform))
(output-fn (points (map vector xs ys)))))
(define-values (do-plot4 do-plot5 do-plot6)
(let ([trans1 (hand-drawn-transform 25)]
[trans2 (hand-drawn-transform 100)])
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq -2 2 20 trans1))
(define ys (nonlinear-seq -2 2 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot7 do-plot8)
(let ([trans1 (stretch-transform -1/2 1/2 4)]
[trans2 (stretch-transform -1/2 1/2 1/4)])
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(output-fn (list (y-axis -1/2) (y-axis 1/2)
(x-axis -1/2) (x-axis 1/2)
(function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq -2 2 20 trans1))
(define ys (nonlinear-seq -2 2 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot9 do-plot10 do-plot11)
(let ()
(define trans1 (axis-transform-compose id-transform (stretch-transform -1 1 1/4)))
(define trans2 (axis-transform-compose (stretch-transform -1 1 1/4) id-transform))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis -1) (y-axis 1)
(function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis -1) (y-axis 1)
(function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq -2 2 20 trans1))
(define ys (nonlinear-seq -2 2 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot12 do-plot13 do-plot14)
(let ()
(define t1 (stretch-transform -2 -1 4))
(define t2 (stretch-transform 1 2 4))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform (axis-transform-compose t1 t2)]
[plot-x-ticks (ticks-add (plot-x-ticks) '(-1 1))])
(output-fn (list (y-axis -2) (y-axis -1)
(y-axis 1) (y-axis 2)
(function values -3 3)
(function cos -3 3 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform (axis-transform-compose t2 t1)]
[plot-x-ticks (ticks-add (plot-x-ticks) '(-1 1))])
(output-fn (list (y-axis -2) (y-axis -1)
(y-axis 1) (y-axis 2)
(function values -3 3)
(function cos -3 3 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform (axis-transform-compose t2 t1)]
[plot-y-transform (axis-transform-compose t1 t2)])
(define xs (nonlinear-seq -3 3 20 (axis-transform-compose t2 t1)))
(define ys (nonlinear-seq -3 3 20 (axis-transform-compose t1 t2)))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot15 do-plot16 do-plot17)
(let ()
(define t1 (stretch-transform -2 0 4))
(define t2 (stretch-transform -1 1 1/4))
(define t3 (stretch-transform 2 3 4))
(define trans1 (axis-transform-compose (axis-transform-compose t3 t2) t1))
(define trans2 (axis-transform-compose (axis-transform-compose t2 t1) t3))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis -2) (y-axis 0)
(y-axis -1) (y-axis 1)
(y-axis 2) (y-axis 3)
(function values -3 4)
(function cos -3 4 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis -2) (y-axis 0)
(y-axis -1) (y-axis 1)
(y-axis 2) (y-axis 3)
(function values -3 4)
(function cos -3 4 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq -3 4 20 trans1))
(define ys (nonlinear-seq -3 4 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot18 do-plot19 do-plot20)
(let ()
(define trans1 (axis-transform-compose (stretch-transform 2 3 4) log-transform))
(define trans2 (axis-transform-compose log-transform (stretch-transform 2 3 4)))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis 2) (y-axis 3)
(function values 1 5)
(function cos 1 5 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis 2) (y-axis 3)
(function values 1 5)
(function cos 1 5 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq 1 5 20 trans1))
(define ys (nonlinear-seq 1 5 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot21 do-plot22)
(let ()
(define trans (collapse-transform -1 1))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans])
(output-fn (list (y-axis 1)
(function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans]
[plot-y-transform trans])
(define xs (nonlinear-seq -2 2 20 trans))
(output-fn (points (map vector xs xs))))))))
(define-values (do-plot23 do-plot24 do-plot25)
(let ()
(define trans1 (axis-transform-compose (collapse-transform 2 3) log-transform))
(define trans2 (axis-transform-compose log-transform (collapse-transform 2 3)))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis 3)
(function values 1 5)
(function cos 1 5 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis 3)
(function values 1 5)
(function cos 1 5 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq 1 5 20 trans1))
(define ys (nonlinear-seq 1 5 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot26 do-plot27 do-plot28)
(let ()
(define trans1 (axis-transform-compose (stretch-transform -1 1 4)
(collapse-transform -1/2 1/2)))
(define trans2 (axis-transform-compose (collapse-transform -1/2 1/2)
(stretch-transform -1 1 4)))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis -1) (y-axis 1)
(y-axis -1/2) (y-axis 1/2)
(function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis -1) (y-axis 1)
(y-axis -1/2) (y-axis 1/2)
(function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq -2 2 20 trans1))
(define ys (nonlinear-seq -2 2 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot29 do-plot30 do-plot31)
(let ()
(define trans1 (axis-transform-compose (collapse-transform -1 1) (collapse-transform -1/2 1/2)))
(define trans2 (axis-transform-compose (collapse-transform -1/2 1/2) (collapse-transform -1 1)))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis 1) (y-axis 1/2)
(function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis 1) (y-axis 1/2)
(function values -2 2)
(function cos -2 2 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq -2 2 20 trans1))
(define ys (nonlinear-seq -2 2 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define (do-plot32 output-fn)
(parameterize ([plot-x-transform (collapse-transform -1 1)])
(output-fn (function values 0 2))))
(define (do-plot33 output-fn)
(parameterize ([plot-x-transform (collapse-transform -1 1)])
(output-fn (function values -2 0))))
(define (do-plot34 output-fn)
(parameterize ([plot-x-transform (axis-transform-append id-transform log-transform 0.1)])
(output-fn (function sin -4 4))))
(define-values (do-plot35 do-plot36)
(let ()
(define trans (axis-transform-append id-transform log-transform 2))
(define ticks (log-ticks #:base 10))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans]
[plot-x-ticks ticks])
(output-fn (list (function values 1 15)
(function cos 1 15 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans]
[plot-y-transform trans])
(define xs (nonlinear-seq 1 15 20 trans))
(output-fn (points (map vector xs xs))))))))
(define-values (do-plot37 do-plot38 do-plot39)
(let ()
(define t1 (stretch-transform 2 3 4))
(define t2 (stretch-transform 7 8 4))
(define trans1 (axis-transform-compose (axis-transform-append t1 t2 5) log-transform))
(define trans2 (axis-transform-compose log-transform (axis-transform-append t1 t2 5)))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (for/list ([x (in-list '(2 3 7 8))]) (y-axis x))
(function values 1 9)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (for/list ([x (in-list '(2 3 7 8))]) (y-axis x))
(function values 1 9)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq 1 9 50 trans1))
(define ys (nonlinear-seq 1 9 50 trans2))
(output-fn (points (map vector xs ys))))))))
(define-values (do-plot40 do-plot41 do-plot42 do-plot43 do-plot44 do-plot45)
(let ()
(define trans1 (axis-transform-append log-transform id-transform 5))
(define trans2 (axis-transform-append id-transform log-transform 5))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis 5)
(function values 6 10)
(function cos 6 10 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis 5)
(function values 6 10)
(function cos 6 10 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq 6 10 20 trans1))
(define ys (nonlinear-seq 6 10 20 trans2))
(output-fn (points (map vector xs ys)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis 5)
(function values 1 4)
(function cos 1 4 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis 5)
(function values 1 4)
(function cos 1 4 #:color 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq 1 4 20 trans1))
(define ys (nonlinear-seq 1 4 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define (do-plot46 output-fn)
(parameterize ([plot-x-transform (axis-transform-compose (collapse-transform 2 6)
log-transform)]
[plot-x-ticks (ticks-add (log-ticks) '(2 6))])
(output-fn (list (y-axis 2) (y-axis 6)
(function values 1 10)))))
(define-values (do-plot47 do-plot48 do-plot49)
(let ()
(define trans1 (axis-transform-bound log-transform 0.1 5))
(define trans2 (axis-transform-bound (stretch-transform 1 2 4) 1 2))
(values
(lambda (output-fn)
(parameterize ([plot-x-transform trans1])
(output-fn (list (y-axis 0.1) (y-axis 5)
(function values -3 9)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans2])
(output-fn (list (y-axis 1) (y-axis 2)
(function values 0 3)))))
(lambda (output-fn)
(parameterize ([plot-x-transform trans1]
[plot-y-transform trans2])
(define xs (nonlinear-seq -3 9 20 trans1))
(define ys (nonlinear-seq 0 3 20 trans2))
(output-fn (points (map vector xs ys))))))))
(define-runtime-path at1-data "./test-data/at1.dat")
(define-runtime-path at2-data "./test-data/at2.dat")
(define-runtime-path at3-data "./test-data/at3.dat")
(define-runtime-path at4-data "./test-data/at4.dat")
(define-runtime-path at5-data "./test-data/at5.dat")
(define-runtime-path at6-data "./test-data/at6.dat")
(define-runtime-path at7-data "./test-data/at7.dat")
(define-runtime-path at8-data "./test-data/at8.dat")
(define-runtime-path at9-data "./test-data/at9.dat")
(define-runtime-path at10-data "./test-data/at10.dat")
(define-runtime-path at11-data "./test-data/at11.dat")
(define-runtime-path at12-data "./test-data/at12.dat")
(define-runtime-path at13-data "./test-data/at13.dat")
(define-runtime-path at14-data "./test-data/at14.dat")
(define-runtime-path at15-data "./test-data/at15.dat")
(define-runtime-path at16-data "./test-data/at16.dat")
(define-runtime-path at17-data "./test-data/at17.dat")
(define-runtime-path at18-data "./test-data/at18.dat")
(define-runtime-path at19-data "./test-data/at19.dat")
(define-runtime-path at20-data "./test-data/at20.dat")
(define-runtime-path at21-data "./test-data/at21.dat")
(define-runtime-path at22-data "./test-data/at22.dat")
(define-runtime-path at23-data "./test-data/at23.dat")
(define-runtime-path at24-data "./test-data/at24.dat")
(define-runtime-path at25-data "./test-data/at25.dat")
(define-runtime-path at26-data "./test-data/at26.dat")
(define-runtime-path at27-data "./test-data/at27.dat")
(define-runtime-path at28-data "./test-data/at28.dat")
(define-runtime-path at29-data "./test-data/at29.dat")
(define-runtime-path at30-data "./test-data/at30.dat")
(define-runtime-path at31-data "./test-data/at31.dat")
(define-runtime-path at32-data "./test-data/at32.dat")
(define-runtime-path at33-data "./test-data/at33.dat")
(define-runtime-path at34-data "./test-data/at34.dat")
(define-runtime-path at35-data "./test-data/at35.dat")
(define-runtime-path at36-data "./test-data/at36.dat")
(define-runtime-path at37-data "./test-data/at37.dat")
(define-runtime-path at38-data "./test-data/at38.dat")
(define-runtime-path at39-data "./test-data/at39.dat")
(define-runtime-path at40-data "./test-data/at40.dat")
(define-runtime-path at41-data "./test-data/at41.dat")
(define-runtime-path at42-data "./test-data/at42.dat")
(define-runtime-path at43-data "./test-data/at43.dat")
(define-runtime-path at44-data "./test-data/at44.dat")
(define-runtime-path at45-data "./test-data/at45.dat")
(define-runtime-path at46-data "./test-data/at46.dat")
(define-runtime-path at47-data "./test-data/at47.dat")
(define-runtime-path at48-data "./test-data/at48.dat")
(define-runtime-path at49-data "./test-data/at49.dat")
(define axis-transform-tests
(test-suite
"axis-transform-tests"
(test-case "test case 1" (check-draw-steps do-plot1 at1-data))
(test-case "test case 2" (check-draw-steps do-plot2 at2-data))
(test-case "test case 3" (check-draw-steps do-plot3 at3-data))
(test-case "test case 4" (check-draw-steps do-plot4 at4-data))
(test-case "test case 5" (check-draw-steps do-plot5 at5-data))
(test-case "test case 6" (check-draw-steps do-plot6 at6-data))
(test-case "test case 7" (check-draw-steps do-plot7 at7-data))
(test-case "test case 8" (check-draw-steps do-plot8 at8-data))
(test-case "test case 9" (check-draw-steps do-plot9 at9-data))
(test-case "test case 10" (check-draw-steps do-plot10 at10-data))
(test-case "test case 11" (check-draw-steps do-plot11 at11-data))
(test-case "test case 12" (check-draw-steps do-plot12 at12-data))
(test-case "test case 13" (check-draw-steps do-plot13 at13-data))
(test-case "test case 14" (check-draw-steps do-plot14 at14-data))
(test-case "test case 15" (check-draw-steps do-plot15 at15-data))
(test-case "test case 16" (check-draw-steps do-plot16 at16-data))
(test-case "test case 17" (check-draw-steps do-plot17 at17-data))
(test-case "test case 18" (check-draw-steps do-plot18 at18-data))
(test-case "test case 19" (check-draw-steps do-plot19 at19-data))
(test-case "test case 20" (check-draw-steps do-plot20 at20-data))
(test-case "test case 21" (check-draw-steps do-plot21 at21-data))
(test-case "test case 22" (check-draw-steps do-plot22 at22-data))
(test-case "test case 23" (check-draw-steps do-plot23 at23-data))
(test-case "test case 24" (check-draw-steps do-plot24 at24-data))
(test-case "test case 25" (check-draw-steps do-plot25 at25-data))
(test-case "test case 26" (check-draw-steps do-plot26 at26-data))
(test-case "test case 27" (check-draw-steps do-plot27 at27-data))
(test-case "test case 28" (check-draw-steps do-plot28 at28-data))
(test-case "test case 29" (check-draw-steps do-plot29 at29-data))
(test-case "test case 30" (check-draw-steps do-plot30 at30-data))
(test-case "test case 31" (check-draw-steps do-plot31 at31-data))
(test-case "test case 32" (check-draw-steps do-plot32 at32-data))
(test-case "test case 33" (check-draw-steps do-plot33 at33-data))
(test-case "test case 34" (check-draw-steps do-plot34 at34-data))
(test-case "test case 35" (check-draw-steps do-plot35 at35-data))
(test-case "test case 36" (check-draw-steps do-plot36 at36-data))
(test-case "test case 37" (check-draw-steps do-plot37 at37-data))
(test-case "test case 38" (check-draw-steps do-plot38 at38-data))
(test-case "test case 39" (check-draw-steps do-plot39 at39-data))
(test-case "test case 40" (check-draw-steps do-plot40 at40-data))
(test-case "test case 41" (check-draw-steps do-plot41 at41-data))
(test-case "test case 42" (check-draw-steps do-plot42 at42-data))
(test-case "test case 43" (check-draw-steps do-plot43 at43-data))
(test-case "test case 44" (check-draw-steps do-plot44 at44-data))
(test-case "test case 45" (check-draw-steps do-plot45 at45-data))
(test-case "test case 46" (check-draw-steps do-plot46 at46-data))
(test-case "test case 47" (check-draw-steps do-plot47 at47-data))
(test-case "test case 48" (check-draw-steps do-plot48 at48-data))
(test-case "test case 49" (check-draw-steps do-plot49 at49-data))))
(module+ test
(require rackunit/text-ui)
(run-tests axis-transform-tests))
| false |
9e2e5b9061c8a58d19deb1c9012b83db69ece804 | 4cc0edb99a4c5d945c9c081391ae817b31fc33fd | /pousse/pousse.rkt | 9d735b4276d26970cbc45427cdb00dcca4cdeed2 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | racket/games | c8eaa92712405890cd1db19b8ba32b1620d885b8 | eba5c6fa54c524871badb8b0e205fe37640d6c3e | refs/heads/master | 2023-08-19T00:41:23.930448 | 2023-07-24T23:29:05 | 2023-07-24T23:29:05 | 27,138,761 | 54 | 33 | NOASSERTION | 2020-05-04T13:46:50 | 2014-11-25T17:59:40 | Racket | UTF-8 | Racket | false | false | 39,750 | rkt | pousse.rkt | #lang racket
(require "utils.rkt"
"board.rkt"
"board-size.rkt"
"../show-scribbling.rkt"
racket/gui
(prefix-in robot: "robot.rkt"))
(provide game@)
(define game@
(unit
(import)
(export)
;; Graphical size of a cell in pixels
(define cell-size 40)
;; x/o font size (points)
(define font-size 24)
;; Automated players
(define x-player #f)
(define o-player #f)
;; Built-in program players
(define-struct robot (name player))
(define robots (list (make-robot "Stupid (always B1)"
(lambda (n moves)
(sleep 1)
'(B 1)))
(make-robot "Smart (30-sec strategy)"
robot:robot)))
(define (local-file f)
(build-path (collection-path "games" "pousse") f))
;;; Game State ;;;
(define board (new-board (current-board-size)))
(define history (new-history))
(define current-player x)
(define playing? #f) ; lock out board clicks when running an automated player
(define winner #f)
(define loser #f)
(define moves null)
;; For moving back and forth in the history:
(define past-state null)
(define future-state null)
(define (convert-move s)
(list (string->symbol (string (char-downcase (string-ref s 0))))
(string->number (substring s 1 (string-length s)))))
;;; More Utilities ;;;
(define (get-state)
(list board moves current-player history winner loser))
;; The move functions
(define (mk-push! side side-char)
(lambda (i)
(send canvas animate-push side i current-player)
(set! future-state null)
(set! past-state (cons (get-state) past-state))
(set! board (push board side i current-player))
(set! moves (append moves (list (format "~a~a" side-char (add1 i)))))
(set! current-player (other-player current-player))
(send clock-timer reset)
(send canvas repaint)))
(define push-left! (mk-push! 'left #\L))
(define push-right! (mk-push! 'right #\R))
(define push-top! (mk-push! 'top #\T))
(define push-bottom! (mk-push! 'bottom #\B))
(define (check-winner)
(let ([v (find-winner board)])
(when v
(set! winner v))))
(define (check-loser)
(when (find-board-in-history board history)
(set! loser (other-player current-player))))
(define (in-straight? board v i j)
(let ([n (current-board-size)])
(or (andmap (lambda (x) x)
(n-map n (lambda (j) (eq? (board-cell board i j) v))))
(andmap (lambda (x) x)
(n-map n (lambda (i) (eq? (board-cell board i j) v)))))))
;; past! and future! rewind or un-rewind the game:
(define-values (past! future!)
(let ([set-past (lambda (x) (set! past-state x))]
[set-future (lambda (x) (set! future-state x))])
(values
(lambda () (time-travel! (lambda () past-state) (lambda () future-state)
set-past set-future))
(lambda ()
(time-travel! (lambda () future-state) (lambda () past-state)
set-future set-past)))))
(define (time-travel! get-src get-dest set-src! set-dest!)
;; If it's a person versus a robot, and it's the person's turn, then
;; skip past the robot's turn. Cancel a running robot. If the game
;; is over because a person lost (by repeating a board position)
;; back up just once.
(define skip-robot (and (or x-player o-player)
; Robot running?
(not (send canvas kill-robot))
; Person lost?
(not (and loser
(eq? loser (if x-player o x))))))
(set-dest! (cons (get-state) (get-dest)))
(when skip-robot
(set-dest! (cons (car (get-src)) (get-dest))))
(let ([a ((if skip-robot cadr car) (get-src))])
(set-src! ((if skip-robot cddr cdr) (get-src)))
(set! board (car a))
(set! moves (cadr a))
(set! current-player (caddr a))
(set! history (cadddr a))
(set! winner (list-ref a 4))
(set! loser (list-ref a 5)))
(send canvas repaint)
(send canvas refresh-controls))
;; Used to reset a game (via the "Setup..." dialog)
(define (init-game size)
(current-board-size size)
(set! board (new-board size))
(set! history (new-history))
(set! past-state null)
(set! current-player x)
(set! winner #f)
(set! loser #f)
(set! moves null)
(set! future-state null)
(set-canvas-size))
;; Restart for regular playing mode
(define (reset-game size)
(init-game size)
(send canvas repaint)
(send clock-timer reset)
(send canvas do-next-action))
;;; GUI ;;;
(define animate-step 2/10)
(define animate-delay 0.05)
(define red (make-object color% "RED"))
(define green (make-object color% "GREEN"))
(define black (make-object color% "BLACK"))
(define gray (make-object color% "GRAY"))
(define white (make-object color% "WHITE"))
(define the-font (make-object font% font-size 'decorative 'normal 'bold))
(define the-pen (send the-pen-list find-or-create-pen "GRAY" 1 'solid))
(define transparent-brush (send the-brush-list find-or-create-brush "WHITE" 'transparent))
(define solid-brush (send the-brush-list find-or-create-brush "GRAY" 'solid))
(define watch-cursor (make-object cursor% 'watch))
; The canvas (drawing/event area) class
(define pousse-canvas%
(class canvas%
(init-rest args)
(inherit get-dc)
(define dc #f)
(define do-kill-robot (lambda () #f)) ; installed by refresh-controls
(public*
[kill-robot (lambda () (do-kill-robot))]
[draw-box
; Draw a string in a box
(lambda (i j str)
(when str
(let-values ([(w h d s) (send dc get-text-extent str)])
(send dc draw-text str
(+ (* i cell-size) (/ (- cell-size w) 2))
(+ (* j cell-size) (/ (- cell-size h) 2))))))]
[do-next-action
(lambda ()
;; See if anything interesting happened, then call refresh-controls (below)
(check-loser)
(check-winner)
(set! history (extend-history board history))
(refresh-controls))]
[refresh-controls
;; Update the GUI to reflect the current game state, and run
;; aa program player if it's time.
(lambda ()
(send history-text show-moves)
(send clock show (not (or winner loser)))
(if (or loser winner)
(begin
;; Game over
(enable-arrows)
(repaint)
(send status set-label
(format "Game over: ~a ~a!"
(if (equal? (or winner loser) x) "X" "O")
(if winner "wins" "loses")))
(send clock show #f))
;; Check for automated player
(let* ([killed? 'not-yet]
[action void]
[lock (make-semaphore 1)]
[run-player-in-background
;; Lots of messy stuff for calling the OS to run a player. The
;; kill-robot method is installed for killing of the player process.
(lambda (player)
(let ([result #f]
[done (make-semaphore)]
[player-custodian (make-custodian)])
(parameterize ([current-eventspace
(parameterize ([current-custodian player-custodian])
(make-eventspace))])
(queue-callback
(lambda ()
(let ([move (player
;; board size
(current-board-size)
;; change move representation:
(map convert-move moves))])
(semaphore-wait lock)
(set! result move)
(set! killed? #f)
(semaphore-post lock)
(semaphore-post done)))))
;; Install the process killer. Must return #f
;; if the robot is already done.
(set! do-kill-robot (lambda ()
(semaphore-wait lock)
(begin0
(if (eq? killed? 'not-yet)
(begin
(custodian-shutdown-all player-custodian)
(set! killed? #t)
(set! result #f)
(semaphore-post done))
#f)
(semaphore-post lock))))
;; Wait for a response (or kill)...
(send canvas set-cursor watch-cursor)
(semaphore-wait done)
(custodian-shutdown-all player-custodian) ;; just in case
(send canvas set-cursor #f)
(when result
(unless (and (list? result)
(= 2 (length result))
(symbol? (car result))
(regexp-match "^[tblrTBLR]$" (symbol->string (car result)))
(number? (cadr result))
(<= 1 (cadr result) (current-board-size)))
(error 'play "unacceptable reply: ~a" result))
(let* ([d (char-upcase (string-ref (symbol->string (car result)) 0))]
[p (cadr result)])
(set! action
(lambda ()
(case d
[(#\T) (push-top! (sub1 p))]
[(#\B) (push-bottom! (sub1 p))]
[(#\L) (push-left! (sub1 p))]
[(#\R) (push-right! (sub1 p))])))))))]
[run-player
;; A wrapper for monitoring the program player in a GRacket thread.
;; Also handle the possibility that something goes wrong.
(lambda (robot who)
(send status set-label (format "~a: running ~a"
who
(robot-name robot)))
(let ([s (make-semaphore)])
(thread (lambda ()
(with-handlers ([void (lambda (exn)
(message-box
"Error"
(format
(string-append
"There was an error running the "
"program player for ~a.\n"
"We'll assume a default move, T1.\n"
"Here is the error message:\n~a")
who
(if (exn? exn)
(exn-message exn)
exn))
#f '(ok))
(set! action (lambda () (push-top! 0))))])
(run-player-in-background (robot-player robot)))
(semaphore-post s)))
(set! playing? #t)
(enable-arrows)
;; Handle GUI events while we wait...
(yield s)
(set! playing? #f))
(unless killed?
(send status set-label "")
(action)
(do-next-action)))])
;; Run a program? Let a person play?
(cond
[(and (eq? current-player x) x-player) (run-player x-player "X")]
[(and (eq? current-player o) o-player) (run-player o-player "O")]
[else (send status set-label (format "~a's turn (click a number)"
(if (eq? current-player x) "X" "O")))
(enable-arrows)]))))])
;; Animation state
(define tracking-i 0) ;; for tracking mouse clicks
(define tracking-j 0)
(define tracking-highlight? #f)
(define pushpiece #f) ;; piece being pushed onto board, #f for none
(define pushrow -1) ;; row being pushed, -1 for none
(define pushcol -1) ;; col being pushed, -1 for none
(define pushdown? #t) ;; left or top push?
(define amt 0) ;; displacement for push, between -1 and 1
(public*
[do-draw
;;;;;;;;;;;;;;;;;;;; Draw the Board ;;;;;;;;;;;;;;;;;;;;;;;
(lambda ()
(let ([n (current-board-size)])
(send dc clear)
(send dc set-pen the-pen)
(send dc set-font the-font)
(send dc set-text-foreground gray)
(n-times (+ n 2)
(lambda (i)
(when (<= 1 i (add1 n))
(send dc draw-line cell-size (* i cell-size)
(* (+ n 1) cell-size) (* i cell-size))
(send dc draw-line (* i cell-size) cell-size
(* i cell-size) (* (+ n 1) cell-size)))
(when (<= 1 i n)
(let ([draw-box
(lambda (i j s)
(if (and tracking-highlight?
(= i tracking-i)
(= j tracking-j))
(begin
(send dc set-text-foreground white)
(send dc set-brush solid-brush)
(send dc draw-ellipse
(+ 2 (* i cell-size))
(+ 2 (* j cell-size))
(- cell-size 4)
(- cell-size 4))
(draw-box i j s)
(send dc set-brush transparent-brush)
(send dc set-text-foreground gray))
(draw-box i j s)))])
(draw-box i 0 (number->string i))
(draw-box 0 i (number->string i))
(draw-box i (add1 n) (number->string i))
(draw-box (add1 n) i (number->string i))))))
(send dc set-text-foreground black)
(n-times n
(lambda (i)
(n-times n (lambda (j)
(let ([v (board-cell board i j)])
(when (and (eq? winner v)
(in-straight? board v i j))
(send dc set-text-foreground green))
(when (eq? loser v)
(send dc set-text-foreground red))
(draw-box (+ i 1
;; Need to offset for animation?
(if (= j pushrow)
(if (let ([step (if pushdown? -1 1)])
(let loop ([i i])
(cond
[(or (= i -1) (= i n)) #t]
[(eq? (board-cell board i j) none) #f]
[else (loop (+ i step))])))
amt
0)
0))
(+ j 1
;; Need to offset for animation?
(if (= i pushcol)
(if (let ([step (if pushdown? -1 1)])
(let loop ([j j])
(cond
[(or (= j -1) (= j n)) #t]
[(eq? (board-cell board i j) none) #f]
[else (loop (+ j step))])))
amt
0)
0))
(cond
[(eq? v none) #f]
[(eq? v x) "x"]
[(eq? v o) "o"]))
(when (or (eq? winner v) (eq? loser v))
(send dc set-text-foreground black)))))))
(when pushpiece
(draw-box (if (>= pushrow 0)
(if pushdown?
amt
(+ n 1 amt))
(+ 1 pushcol))
(if (>= pushcol 0)
(if pushdown?
amt
(+ n 1 amt))
(+ 1 pushrow))
(cond
[(eq? pushpiece x) "x"]
[(eq? pushpiece o) "o"])))))])
(define bitmap #f)
(public*
[repaint (lambda ()
(set! pushpiece #f)
(set! pushcol -1)
(set! pushrow -1)
(unless dc
(set! bitmap (make-object bitmap%
(* (+ (current-board-size) 2) cell-size)
(* (+ (current-board-size) 2) cell-size)))
(set! dc (make-object bitmap-dc% bitmap)))
(do-draw)
(on-paint))]
[new-bitmap (lambda ()
(set! bitmap #f)
(set! dc #f))]
[animate-push (lambda (side pos player)
(let ([n (current-board-size)])
(set! pushpiece player)
(set! pushrow (if (memq side '(right left))
pos
-1))
(set! pushcol (if (memq side '(top bottom))
pos
-1))
(set! pushdown? (memq side '(left top)))
(set! tracking-i (if (memq side '(top bottom))
(add1 pushcol)
(if pushdown? 0 (add1 n))))
(set! tracking-j (if (memq side '(right left))
(add1 pushrow)
(if pushdown? 0 (add1 n))))
(set! tracking-highlight? #t)
(let loop ([a 0])
(set! amt ((if pushdown? + -) a))
(do-draw)
(send (get-dc) draw-bitmap bitmap 0 0)
(sleep animate-delay)
(if (= a 1)
(set! tracking-highlight? #f) ;; expects redraw triggered afterwards...
(loop (+ a animate-step))))))])
(override*
[on-paint (lambda ()
(when bitmap
(send (get-dc) draw-bitmap bitmap 0 0)))]
;;;;;;;;;;;;;;;;;;;; Handle Clicks ;;;;;;;;;;;;;;;;;;;;;;;
[on-event (lambda (e)
;; There are a lot of reasons why you might not be allowed to click...
(cond
[(and (not winner) (not loser)
(or (send e button-down?)
(send e dragging?)
(send e button-up?))
(not playing?)
(not (if (eq? current-player x) x-player o-player)))
(let ([i (inexact->exact (floor (/ (send e get-x) cell-size)))]
[j (inexact->exact (floor (/ (send e get-y) cell-size)))])
(cond
[(send e button-down?)
(set! tracking-i i)
(set! tracking-j j)
(set! tracking-highlight? #t)
(repaint)]
[(send e moving?)
(let ([th? tracking-highlight?])
(set! tracking-highlight? (and
(= tracking-i i)
(= tracking-j j)))
(unless (eq? th? tracking-highlight?)
(repaint)))]
[(send e button-up?)
(if (and (= tracking-i i)
(= tracking-j j))
(let ([n (current-board-size)])
(when (cond
[(and (= j 0) (<= 1 i n)) (push-top! (sub1 i)) #t]
[(and (= j (add1 n)) (<= 1 i n)) (push-bottom! (sub1 i)) #t]
[(and (= i 0) (<= 1 j n)) (push-left! (sub1 j)) #t]
[(and (= i (add1 n)) (<= 1 j n)) (push-right! (sub1 j)) #t]
[else #f]) ; not on a number
; Check for win/loss, run automated player
(do-next-action)))
(when tracking-highlight?
(set! tracking-highlight? #f)
(repaint)))]))]
[else
(when tracking-highlight?
(set! tracking-highlight? #f)
(repaint))]))])
(apply super-make-object args)))
;; Create the GUI interface with the above pieces ;;
; Instantiate the canvas in a frame (= a top-level window)
(define frame (new (class frame%
(augment*
[can-close? (lambda () (inner #t can-close?))]
;; Close the frame => exit the program
;; No fancy "Quit" menus here!
[on-close (lambda () (inner (void) on-close) (exit))])
(super-new))
[label "Pousse"] [style '(metal no-resize-border)]))
;; Panels are for GUI item layout (auto geometry management)
(define h-layout-panel (make-object horizontal-panel% frame))
(send h-layout-panel spacing 5)
(define game-panel (make-object vertical-panel% h-layout-panel))
(send game-panel stretchable-width #f)
(define history-panel (make-object vertical-panel% h-layout-panel))
;; Make the left and right arrow buttons
(define button-panel (make-object horizontal-panel% game-panel))
(send button-panel stretchable-height #f)
(define left-panel (make-object vertical-panel% button-panel))
(define past-button (make-object button% (make-object bitmap% (local-file "left.gif"))
button-panel (lambda (b e) (past!))))
(define future-button (make-object button% (make-object bitmap% (local-file "right.gif"))
button-panel (lambda (b e) (future!))))
(define right-panel (make-object vertical-panel% button-panel))
(define clock (make-object message% "00:00" right-panel))
(send left-panel min-width (send clock min-width)) ; layout trick
(send right-panel set-alignment 'right 'bottom)
(define clock-timer (make-object
(class timer%
(define init 0)
(define dinged 0)
(rename-super [super-start start])
(public* [reset (lambda ()
(send clock set-label "00:00")
(set! dinged 0)
(set! init (current-seconds)))])
(override*
[notify
(lambda ()
(let* ([v (- (current-seconds) init)])
;; Ring bell once at 30 seconds, twice at 60 seconds
(when (send clock is-shown?)
(when (>= v 30)
(unless (> dinged 0) (bell) (set! dinged 1))
(when (>= v 60)
(unless (> dinged 1) (bell) (bell) (set! dinged 2)))))
(let ([v (if (>= v 3600) ; more than an hour
(quotient v 3600)
v)])
(send clock set-label
(format "~a~a:~a~a"
(quotient v 600)
(modulo (quotient v 60) 10)
(quotient (modulo v 60) 10)
(modulo v 10))))))]
[start (lambda ()
(set! init (current-seconds))
(super-start 1000 #f))])
(super-make-object))))
(send clock-timer start)
;; This procedure is called to enable/disable the arrow buttons
(define (enable-arrows)
(let ([ok? (lambda (state)
(and ;; Something to rewind to?
(pair? state)
;; Is it program vs. program?
(not (and x-player o-player))
;; If we're playing a program, can we rewind twice?
(or (not (or x-player o-player))
(pair? (cdr state)))))])
(send past-button enable (ok? past-state))
(send future-button enable (ok? future-state))))
;; Make the status line
(define status (make-object message% "Pousse" game-panel))
(send status stretchable-width #t)
;; Make the canvas for drawing the game board
(define canvas (make-object pousse-canvas% game-panel))
; The canvas should stretch/shrink to fit the board
(define (set-canvas-size)
(let ([n (current-board-size)])
(send canvas min-client-width (* (+ n 2) cell-size))
(send canvas min-client-height (* (+ n 2) cell-size))
(send canvas new-bitmap)))
(set-canvas-size)
(send canvas focus)
; Make a text window for showing the board history to the right.
; Uses the built-in text editor in GRacket, adding a show-moves
; method to refresh the window after a move or rewind.
(make-object message% "Moves" history-panel)
(define history-canvas (make-object editor-canvas% history-panel #f '(no-hscroll)))
(define history-text (make-object (class text%
(inherit begin-edit-sequence end-edit-sequence
erase insert delete change-style hide-caret
set-position line-start-position line-end-position)
; Ignore all user actions:
(override* [on-char (lambda (e) (void))] [on-event (lambda (e) (void))])
(public*
[show-moves
(lambda ()
(begin-edit-sequence)
(erase)
(change-style (make-object style-delta% 'change-normal))
(change-style (make-object style-delta% 'change-family 'swiss))
(for-each
(lambda (m) (insert m) (insert #\newline))
(if (null? future-state)
moves
(cadr (list-ref future-state (sub1 (length future-state))))))
(delete) ; delete that last newline
(if (null? moves)
(set-position 0)
(let* ([past-move (sub1 (length moves))]
[start (line-start-position past-move)])
(change-style (send
(make-object style-delta% 'change-bold)
set-delta-foreground "BLUE")
start
(line-end-position past-move))
(set-position start)))
(end-edit-sequence))])
(super-make-object)
(hide-caret #t))))
(send history-canvas set-editor history-text)
(send history-canvas min-client-width 30)
;; Setup and miscellaneous buttons at the bottom
(define misc-panel (make-object horizontal-panel% frame))
(send misc-panel stretchable-height #f)
(make-object button% "Help" misc-panel (lambda (b e) (help)))
(make-object button% "Setup..." misc-panel (lambda (b e) (setup)))
(make-object vertical-pane% misc-panel) ; spacer
;; Makes the setup dialog. Options dialogs are always a pain.
(define (make-setup-dialog)
(define d (make-object dialog% "Pousse Setup" frame 300 200))
(define config-panel (make-object vertical-panel% d))
(define game-panel (make-object vertical-panel% config-panel))
(define (make-player name)
(letrec ([p (make-object vertical-panel% game-panel '(border))]
[m (make-object choice% (format "~a Player:" name) '("Person" "Program") p
(lambda (m e)
(send l enable (positive? (send m get-selection)))
(enable-ok)))]
[l (make-object list-box% "Programs:" (map robot-name robots) p
(lambda (l e) (enable-ok)))])
(send l enable #f)
(values m l)))
(define board-size (make-object slider% "Board Size:" 3 20 game-panel void (current-board-size)))
(define-values (x-kind x-robot) (make-player "X"))
(define-values (o-kind o-robot) (make-player "O"))
(define button-panel (make-object horizontal-pane% d))
(define load-button (make-object button% "Add a Player Program..." button-panel
(lambda (b e)
(with-handlers ([void
(lambda (exn)
(message-box "Error"
(format "There was an error:\n~a"
(if (exn? exn)
(exn-message exn)
exn))))])
(let ([f (get-file "Get Player Program" d)])
(when f
(let ([player (dynamic-require f 'robot)])
(let ([name (get-text-from-user "Player Name"
"Player Program Name:"
d
(let-values ([(base name dir?)
(split-path f)])
(path->string name)))])
(when name
(set! robots (append robots
(list (make-robot name player))))
(send x-robot set (map robot-name robots))
(send o-robot set (map robot-name robots)))))))))))
(define spacer (make-object vertical-pane% button-panel))
(define cancel-button (make-object button% "Cancel" button-panel
(lambda (b e) (send d show #f))))
(define ok-button (make-object button% "Start" button-panel
;; Callback procedure invoked when the button is hit:
(lambda (b e)
(send d show #f)
(send canvas kill-robot) ; in case a robot was running
(queue-callback
(lambda ()
(let ([get-robot
(lambda (l)
(list-ref robots
(send l get-selection)))]
[size (send board-size get-value)])
(if (zero? (send x-kind get-selection))
(set! x-player #f) ; person player
(set! x-player (get-robot x-robot)))
(if (zero? (send o-kind get-selection))
(set! o-player #f) ; person player
(set! o-player (get-robot o-robot)))
(reset-game size)))))
'(border)))
(define enable-ok (lambda () (send ok-button enable (and
(or (zero? (send x-kind get-selection))
(send x-robot get-selection))
(or (zero? (send o-kind get-selection))
(send o-robot get-selection))))))
(send button-panel set-alignment 'right 'center)
(send button-panel stretchable-height #f)
d)
(define setup-dialog (make-setup-dialog))
(define setup-once? #f)
(define (setup)
(unless setup-once?
(send setup-dialog center)
(set! setup-once? #t))
(send setup-dialog show #t))
;; Help or source code window:
(define help
(show-scribbling
'(lib "games/scribblings/games.scrbl")
"pousse"))
; Draw initial board
(send canvas repaint)
; Arrow buttons initially enabled?
(enable-arrows)
; Don't allowing resizing the frame. Everything fits just right.
(send frame stretchable-width #f)
(send frame stretchable-height #f)
; Show the frame - we're off and running, now!
(send frame show #t)
; Take the first action.
(send canvas do-next-action)
; Loop forever (handling events). Frame's on-close callback method will exit.
(yield (make-semaphore 0))))
| false |
b9d8a5993b12cc8af9af4758ca3e49a078ce4bdf | 657061c0feb2dcbff98ca7a41b4ac09fe575f8de | /Racket/Exercises/Week5/03_digits_list.rkt | c80aa62299fb03158ec1313ba87ef5d9c0dea65c | []
| no_license | vasil-pashov/FunctionalProgramming | 77ee7d9355329439cc8dd89b814395ffa0811975 | bb998a5df7b715555d3272c3e39b0a7481acf80a | refs/heads/master | 2021-09-07T19:31:05.031600 | 2018-02-27T20:50:44 | 2018-02-27T20:50:44 | 108,046,015 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 238 | rkt | 03_digits_list.rkt | #lang racket
(define (digits-list number)
(define (digits-list-helper number rez)
(if (= number 0)
rez
(digits-list-helper (quotient number 10) (cons (remainder number 10) rez))))
(digits-list-helper number '())) | false |
8f3c79323aae5ef0df5a0dd5d3fcb9829a567c51 | 804e0b7ef83b4fd12899ba472efc823a286ca52d | /old/gst/mm/gen-base.rkt | 44514786551f34ee0b7e0ed1313ae0c9eafc51f2 | []
| no_license | cha63506/CRESTaceans | 6ec436d1bcb0256e17499ea9eccd5c034e9158bf | a0d24fd3e93fc39eaf25a0b5df90ce1c4a96ec9b | refs/heads/master | 2017-05-06T16:59:57.189426 | 2013-10-17T15:22:35 | 2013-10-17T15:22:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 2,161 | rkt | gen-base.rkt | #lang racket
(require "../../../../bindings/gstreamer/gstreamer.rkt"
(planet bzlib/thread:1:0))
(provide (all-defined-out))
(define (restartable-evt-loop bin)
(define bus (gst_element_get_bus bin))
(define (unref m #:is-error? [is-error? #f])
(when is-error? (printf "error/warning:~n") (extract-and-print-error m))
(gst_message_unref_w m))
(define/contract (handle-a-message)
(-> boolean?)
(let ([message (gst_bus_timed_pop bus 0)])
(cond
[message (let ([type (gst_message_type message)])
(match type
['eos (printf "eos~n") (unref message) #f]
[(or 'warning 'error) (unref message #:is-error? #t) #f]
[_ (printf "else: ~a~n" type) (unref message) #t]))]
[else #t])))
(define (pause-bin/switch port)
(printf "Pausing...~n")
(gst_element_set_state bin GST_STATE_PAUSED)
(let ([udpsink (gst_bin_get_by_name* bin "udpsink")])
(g_object_set udpsink "port" port)))
(define (restart-bin)
(printf "Restarting...~n")
(gst_element_set_state bin GST_STATE_PLAYING))
(let loop ([paused? #f])
(receive/match
[(list (? thread? t) 'pause/switch-port (? integer? port))
(pause-bin/switch port)
(loop #t)]
[(list (? thread? t) 'restart)
(restart-bin)
(loop #f)]
[after 0
(if paused?
(loop paused?)
(if (handle-a-message)
(loop paused?)
(gst_element_set_state bin GST_STATE_NULL)))]
)))
(define (make-starter command)
(λ ()
(thread (λ ()
(with-gst-init
#f
(let-values ([(bin error) (gst_parse_launch command)])
(gst_element_set_state bin GST_STATE_PLAYING)
(restartable-evt-loop bin)
(gst_element_set_state bin GST_STATE_NULL)
(gst_object_unref bin)))))))
(define (p/s thd port)
(thread-send thd (list (current-thread) 'pause/switch-port port)))
(define (restart thd)
(thread-send thd (list (current-thread) 'restart))) | false |
608ec2791014a6b780b79e465eeb1cfbaf011016 | 1b35cdffa859023c346bed5fcac5a9be21b0a5a6 | /polyglot-doc/polyglot/scribblings/reference/cli.scrbl | 14c3e7d690e0af754959ad6434ce4e8dfd70e5fa | [
"MIT"
]
| permissive | zyrolasting/polyglot | dd8644425756c87357c1b425670f596be708104d | d27ca7fe90fd4ba2a6c5bcd921fce89e72d2c408 | refs/heads/master | 2021-07-03T01:09:33.887986 | 2021-01-01T16:17:57 | 2021-01-01T16:17:57 | 204,181,797 | 95 | 6 | MIT | 2020-05-26T13:44:19 | 2019-08-24T16:18:07 | Racket | UTF-8 | Racket | false | false | 6,779 | scrbl | cli.scrbl | #lang scribble/manual
@require[@for-label[polyglot file-watchers unlike-assets unlike-assets/logging]]
@title{@tt{polyglot} CLI}
To simplify use, Polyglot comes with a @tt{polyglot} CLI that acts as a
front-end to the @racketmodname[polyglot] collection. You can also use @tt{raco
polyglot} for backwards compatibility.
The @tt{build}, @tt{demo} and @tt{develop} commands forward events
from @racket[unlike-assets-logger] to STDOUT. The @tt{build} and
@tt{demo} commands report the number of warnings and errors
encountered during processing.
@section{@tt{polyglot start}: Start a Project}
@verbatim[#:indent 2]|{
$ polyglot start -f my-functional-website
$ polyglot start my-imperative-website
}|
The @tt{start} command creates a project directory with the given name
in the working directory. By default, the project will use
@racket[polyglot/imperative%] and include some supported starter
code. If you specify @litchar{-f} or @litchar{--functional}, the
project will reflect use of @racket[polyglot/functional%] instead.
@section{@tt{polyglot build}: Build a Project Once}
The @tt{build} command accepts a path as an argument and attempts to
build a project using a workflow. If a workflow cannot be determined,
the @tt{build} command will try to use @racket[polyglot/imperative%]
for backwards-compatibility reasons. If the path is a relative path,
it will be converted to a complete path relative to the current
working directory.
The behavior will vary slightly if you specify a directory or a file.
@subsection{Specifying a Directory}
@verbatim[#:indent 2]|{
$ polyglot build my-website
}|
When you specify a directory, the @tt{build} command will try to
require @racket[polyglot+%] from @tt{my-website/.polyglotrc.rkt},
falling back to @racket[polyglot/imperative%] on failure. It will then
instantiate the selected workflow class, and start processing
from @tt{my-website/assets/index.md}.
@subsection{Specifying an Asset File}
@verbatim[#:indent 2]|{
$ polyglot build my-website/assets/styles/styles.css
}|
When you specify a file, the @tt{build} command will require
@racket[polyglot+%] from the @tt{.polyglotrc.rkt} in the nearest
project directory, falling back to @racket[polyglot/imperative%] on
failure. It will then instantiate the selected workflow class, and
start processing from the asset specified in the command line.
@section{@tt{polyglot develop}: Build a Project Live}
The @tt{develop} command builds a project once, then rebuilds your
website in response to changes in assets detected using
@racket[robust-watch]. It will stop when you press Control-C.
@verbatim[#:indent 2]|{
$ polyglot develop my-website
}|
The @tt{develop} command will also start a local development server
unless @tt{-n} or @tt{-}@tt{-no-server} is specified. You can also
set a port using @tt{-p}/@tt{-}@tt{-port}, or use the default of
@racket[8080].
@verbatim[#:indent 2]|{
$ polyglot develop -p 6790 my-website
$ polyglot develop -n my-website # Server won't start
}|
The process that monitors and rebuilds assets operates independently of the
server. If you do not start the development server, the @tt{develop} command
will still rebuild assets in response to changes.
The rules for how the @tt{develop} command treats paths are the same
as the @tt{build} command.
You can specify a delay, in milliseconds, that must elapse after the last
detected change in assets before the command tries rebuilding your site. By
default, this is 500 milliseconds. You can use this to aggregate changes and
avoid triggering too many builds when saving changes rapidly in your project.
@verbatim[#:indent 2]|{
$ polyglot develop --delay 1000 my-website
}|
@section{@tt{polyglot demo}: Build Demo Project}
@verbatim[#:indent 2]|{
$ polyglot demo
}|
The @tt{demo} command is a special case of @tt{build} that targets the README
from Polyglot's own source code. The distribution directory will appear in
the working directory. This command is meant to verify that a Polyglot
installation is supported on the target platform and is working as intended.
@section{@tt{polyglot publish}: Publish to S3}
The @tt{publish} command builds a project once, then writes the
contents of a project's @tech{distribution directory} to an AWS S3
bucket. The rules for how the @tt{publish} command treats paths are
the same as the @tt{build} command.
@verbatim[#:indent 2]|{
$ polyglot publish my-website my-bucket
}|
Before you use this command, @bold{read this entire section.} If you
do not agree with ANY of it, then use the AWS CLI or the
@racketmodname[aws/s3] library to publish your website.
Use the @litchar{-d} or @litchar{--dry-run} switch to
avoid writing content to S3 and instead merely report
what the command would otherwise do to the bucket.
@verbatim[#:indent 2]|{
$ polyglot publish -d my-website my-bucket
}|
Use the @litchar{-r} or @litchar{--region} switch to
change the applicable S3 region.
@verbatim[#:indent 2]|{
$ polyglot publish -r us-east-2 my-website my-bucket
}|
Use the @litchar{--delete-diff} switch to delete all objects in the S3
bucket that are not part of the distribution uploaded to the
bucket. Most people won't need this.
@verbatim[#:indent 2]|{
$ polyglot publish --delete-diff my-website my-bucket
}|
@subsection{Assumptions}
@itemlist[
@item{The bucket is configured for static web hosting.}
@item{HTML files should never be cached.}
@item{All other files should be cached forever.}
]
@subsection{Process}
@itemlist[#:style 'ordered
@item{Authenticate against AWS with @racket[read-keys/aws-cli].}
@item{Read all keys in the bucket and compare them to the local contents of the dist directory. Remember the elements that are remote but not local.}
@item{Uploads the contents of the dist directory to the root of the bucket, overwriting any objects that already exist.}
@item{If @racket[--delete-diff] is set on the command, delete from the bucket the objects marked in Step 2.}]
@bold{If you want to ensure no broken links, then do not ever use
@racket[--delete-diff]}. You'll only want to use that option if the
space savings and hygiene are actually worth it, and if
@italic{everything} in the bucket that you need for your website is
produced by a Polyglot build.
@section{Shared Command Options}
Some command-line flags may be specified after @tt{polyglot} but
before a subcommand.
Use the @litchar{-v} or @litchar{--verbose} option to include debug
level events from @racket[unlike-assets-logger] in STDOUT.
@verbatim[#:indent 2]|{
$ polyglot -v build some-site
}|
Use the @litchar{-b} or @litchar{--by-module} option with a path
to a Racket module to forcibly use that module in place of a project's
@tt{.polyglotrc.rkt}.
@verbatim[#:indent 2]|{
$ polyglot -b /etc/polyglot.d/shared-config.rkt build some-site
}|
| false |
6e9c8c03f2dc79a1e6425218ed20d2a774a7b2d0 | 94c038f61575ec72929634d05bfa369f524462f1 | /old-mk-cps/a9-skmonads/map-join-xform-other-monad-4d.rkt | 0b4da5592a25b8f79b7df8dec4ad3883389d0029 | [
"MIT"
]
| permissive | jasonhemann/mk-search-w-continuations | b53026134db8224f71ebc5c442d12f1d29a0b303 | aa37bf956fee875b9f503ea3364876ec6fd48580 | refs/heads/master | 2021-08-04T10:13:31.479834 | 2021-07-27T16:31:55 | 2021-07-27T16:31:55 | 236,832,420 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 3,911 | rkt | map-join-xform-other-monad-4d.rkt | #lang racket
(define (ore-inner-dk c dk)
(λ (c2)
(disj c c2 dk)))
(define (ore-outer-dk exp^^ s c dk)
(λ (c)
(ee exp^^ s (ore-inner-dk c dk))))
(define (ande-dk c exp^^ dk)
(λ (c)
(bind c exp^^ dk)))
(define (dunno-dk dk k)
(λ (c)
(dk c k)))
(define (disj-dk c2 dk)
(λ (c k)
(disj c2 c (dunno-dk dk k))))
(define (disj-fk c2 dk sk fk)
(λ (k)
(c2 dk sk fk k)))
(define (succeed-c s)
(λ (dk sk fk k)
(sk s fk k)))
(define (fail-c)
(λ (dk sk fk k)
(fk k)))
(define (alwayso-c s)
(λ (dk sk fk k)
(ee `(disj (succeed) (alwayso)) s (dunno-dk dk k))))
(define (disj-c c c2)
(λ (dk sk fk k)
(c (disj-dk c2 dk)
sk
(disj-fk c2 dk sk fk)
k)))
(define (ee exp s dk)
(match exp
[`(ore ,exp^ ,exp^^) (ee exp^ s (ore-outer-dk exp^^ s c dk))]
[`(ande ,exp^ ,exp^^) (ee exp^ s (ande-dk c exp^^))]
[`(succeed) (dk (succeed-c s))]
[`(fail) (dk (fail-c))]
[`(alwayso) (dk (alwayso-c s))]))
(define (disj c c2 dk)
(dk (disj-c c c2)))
(define (bind-dk exp dk)
(λ (c k)
(bind c exp (dunno-dk dk k))))
(define (bind-sk exp dk sk)
(λ (s fk k)
(ee exp s (resume-comp-dk dk sk fk k))))
;; Neat that this takes all the state in which to run a computation first,
;; and then later takes the computation to run
(define (resume-comp-dk dk sk fk k)
(λ (c)
(c dk sk fk k)))
(define (bind c exp dk)
(dk (λ (dk sk fk k)
(c (bind-dk exp dk)
(bind-sk exp dk sk)
fk
k))))
(define (looper n exp s dk sk fk k)
(match n
[`Z (ee exp s (resume-comp-dk dk sk fk k))] ;; could be changed to a () base case.
[`(S ,n^) (looper n^ exp s dk sk fk (λ (dk) (ee exp s (resume-comp-dk dk sk fk k))))]))
(looper '<n> '<exp> '<s> '<dk> '<sk> '<fk> '<k>)
;; (= ,t1 x)
;; inlining functions used only once
;; notice that there's an issue with using delay the way we've done it.
;; identity monad
;; (define id-unit (λ (x) x))
;; (define id-bind (λ (m f) (f m)))
;; Eval takes 4 arguments
;; computations take 4 arguments
;; sks take 3 arguments
;; dks take 2 arguments
;; fks take 1 arguments
;; (define (mdelay e)
;; (λ () e))
;; (define (mdelay e k)
;; (k (λ (dk sk fk k)
;; (dk e k))))
;; could be g, could be (ee g)
;; (define (disj $1 $2)
;; (match $1
;; [(null? $1) $2]
;; [(pair? $1) (cons (car $1) (disj (cdr $1) $2))]
;; [(procedure? $1) (λ () (disj $2 ($1)))]))
;; (define (unit s k)
;; (k (λ (dk sk fk k)
;; (sk s fk k))))
;; (define (fail k)
;; (k (λ (dk sk fk k)
;; (fk k))))
;; ;; (define (map f m^)
;; ;; (bind m^ (λ (a) (unit (f a)))))
;; ;; (define (join mm^)
;; ;; (bind mm^ identity))
;; (define kons (λ (a fk) (cons a (fk))))
;; (define nill (λ () '()))
;; (define identity (λ (c) c))
;; (define (looper n k)
;; (if (zero? n)
;; (k (λ (c k) (c <dk> <sk> <fk> k)))
;; (k (λ (c k) (looper (sub1 n) (λ (dk) (c dk <sk> <fk> k)))))))
;; (looper <n> (λ (dk) (ee <exp> <s> (λ (c) (dk c <k>)))))
;; (ee <exp> (λ (c) ))
;; ((looper 30) (ee '(disj (a 20) (d 5)) '()))
;; (looper 30 (λ (dk) (ee '(disj (a 20) (d 5)) '() (λ (v) (dk v (empty-k))))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define (a n)
;; (λ (dk sk fk)
;; (apply-dk dk (b n))))
;; (define (b n)
;; (λ (dk sk fk)
;; (apply-dk dk (c n))))
;; (define (c n)
;; (λ (dk sk fk)
;; (apply-dk dk (disj (unit n) (a (add1 n))))))
;; (define (d n)
;; (λ (dk sk fk)
;; (apply-dk dk (e n))))
;; (define (e n)
;; (λ (dk sk fk)
;; (apply-dk dk (disj (unit n) (d (add1 n))))))
;; (ee '(ore (succeed) (fail)) '() (λ (k) (looper 0 (λ (l) (l (λ (v) v))) )))
;; ((looper 10) fail)
;; ((looper 30) (disj (a 20) (d 5)))
;; ((looper 30) (bind (a 5) b))
| false |
5eacb2b1f081bc55fdca98d86c12111afe4946c1 | d496f55be3026bc79b5c890d9e82be893af87867 | /ex3.22.queue-internal-state.rkt | 2719c0e486a5fcc3a42bc16f5486196d50a599f6 | []
| no_license | juraseg/sicp-racket | db42053f1f66c799ec320ab5a85698d98588674e | 75577291b5aa716d88fdbff11aa449ab9ee515b1 | refs/heads/master | 2021-06-05T01:18:57.541530 | 2018-06-08T09:12:47 | 2018-06-08T09:12:47 | 16,341,327 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,628 | rkt | ex3.22.queue-internal-state.rkt | #lang racket
(define (make-queue)
(let ((front-ptr null)
(rear-ptr null))
(define (set-front-ptr! item) (set front-ptr item))
(define (set-rear-ptr! item) (set rear-ptr item))
(define (empty-queue?) (null? front-ptr))
(define (front-queue)
(if (empty-queue?)
(error "FRONT is called with empty queue")
(mcar front-ptr)))
(define (insert-queue! item)
(let ((new-pair (mcons item null)))
(cond ((empty-queue?)
(set! front-ptr new-pair)
(set! rear-ptr new-pair)
front-ptr)
(else
(set-mcdr! rear-ptr new-pair)
(set! rear-ptr new-pair)
front-ptr))))
(define (delete-queue!)
(cond ((empty-queue?)
(error "DELETE! is called with empty queue"))
(else
(set! front-ptr (mcdr front-ptr)))))
(define (dispatch m)
(cond ((eq? m 'empty-queue?) (empty-queue?))
((eq? m 'front-queue) (front-queue))
((eq? m 'insert-queue!) insert-queue!)
((eq? m 'delete-queue!) (delete-queue!))))
dispatch))
(define (empty-queue? queue)
(queue 'empty-queue?))
(define (front-queue queue)
(queue 'front-queue))
(define (insert-queue! queue item)
((queue 'insert-queue!) item)
queue)
(define (delete-queue! queue)
(queue 'delete-queue!))
(define x (make-queue))
(empty-queue? x)
(insert-queue! x 1)
(empty-queue? x)
(front-queue x)
(insert-queue! x 2)
(empty-queue? x)
(front-queue x)
(delete-queue! x)
(empty-queue? x)
(front-queue x)
(delete-queue! x)
(empty-queue? x) | false |
b66b73906ddc47a695e4e8a72ece855454bda2e3 | 66f1ec563c7c89f1b36974f9d7af194b4ccb3fb1 | /extend/protobuf/bigint.rkt | 5905d5f829ffe6b93595416290713e81d70b3d78 | [
"MIT"
]
| permissive | Hallicopter/racket-protobuf | fb62aeb46e4815955fc45217d65f3b5e075a06b0 | 63311d4d1ab8774f94abeb7d6893204d6680f259 | refs/heads/main | 2023-03-18T20:01:08.365899 | 2021-03-14T16:16:46 | 2021-03-14T16:16:46 | 347,669,156 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 254 | rkt | bigint.rkt | #lang racket/base
;; Generated using protoc-gen-racket v1.1.1
(require (lib "protobuf/syntax") "../../google/protobuf/descriptor.rkt")
(define-message-extension
field-options
(optional primitive:uint32 max-size 76884 10))
(provide (all-defined-out))
| false |
83f6389cefad3d5d381682be549a8f6d70d6056f | 1e5823e43e8460ede9e1c6fd62d3d09bff4b5ef6 | /existential type/existential type.rkt | d960ce371f670344fb257435932fe6c19a138de9 | []
| no_license | lvilnis/miscellaneous | 9891db5cac4587b47d5823fb3973daf3f3214cc4 | 5023edd5da9024908b7e402037b51437a03b0447 | refs/heads/master | 2021-01-19T05:03:53.186312 | 2012-05-09T07:26:24 | 2012-05-09T07:26:24 | 3,770,721 | 0 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 2,870 | rkt | existential type.rkt | #lang typed/racket
;; we wish to encode the following abstract data type:
;; (Exists (a) (List a (a -> Integer)))
(: id (All (a) (a -> a)))
(define (id x) x)
;;(define: xy : (All (Y) ((All (a) ((List a (a -> Integer)) -> Y)) -> Y))
;; (plambda: (Y) ([f : (All (a) ((List a (a -> Integer)) -> Y))])
;; ((inst f Integer) `(,3 ,id))))
;; this one doesn't work since the types get expanded before macro can be applied
(define-syntax Exists
(syntax-rules ()
((Exists (X) T)
(All (Y) ((All (X) (T -> Y)) -> Y)))))
(define-syntax define-existential:
(syntax-rules ()
((define-existential: id _ (Exists (X) T) representation-type body ...)
(define: id : (All (Y) ((All (X) (T -> Y)) -> Y))
(plambda: (Y) ([f : (All (X) (T -> Y))])
((inst f representation-type) (begin body ...)))))))
;; add match existential form to be easiest way of unpacking...
;; (match xy [(exists (X) `(,state ,to-int)) (to-int state)])
(define-syntax unpack-existential:
(syntax-rules ()
((unpack-existential: : return-type id [type-variable] [term _ term-type] body ...)
(#{ id @ return-type }
#{ (plambda: (type-variable)
([arg : term-type])
(begin
(match-define term arg)
body ...))
:: (All (type-variable) (term-type -> return-type)) }))))
(define-existential: xy : (Exists (a) (List a (a -> Integer)))
Integer `(,3 ,id))
(: bool-to-int (Boolean -> Integer))
(define (bool-to-int b) (if b 1 0))
(define-existential: xy2 : (Exists (a) (List a (a -> Integer)))
Boolean `(,#t ,bool-to-int))
(: string-to-int (String -> Integer))
(define (string-to-int s) (string-length s))
(define-existential: xy3 : (Exists (a) (List a (a -> Integer)))
String `(,"hello" ,string-to-int))
(define (test)
(unpack-existential: : Integer
xy
[b]
[`(,state ,to-int) : (List b (b -> Integer))]
(to-int state)))
(: unpack-and-get-int ((All (Y) ((All (a) ((List a (a -> Integer)) -> Y)) -> Y)) -> Integer))
(define (unpack-and-get-int packed)
(unpack-existential: : Integer
packed
[b]
[`(,state ,to-int) : (List b (b -> Integer))]
(to-int state)))
;; looks like inst-ing xy causes the quantifier
;; to be renamed. this shouldnt matter...
;; note that we need the "inst Integer" part, so there has to be some inference
;; step to figure out the hidden type at first....
;; ok now i got it working....
;; and after rebuild its broken. it appears to depend on me first getting it working with
;; lambdas, mispelling "term" as "val", and then it just magic-tizes and works.
;; this means (All (Y) ((All (a) ((List a (a -> Integer)) -> Y)) -> Y)
;; we need a package type:
;; (Exists (X) T) = (All (Y) ((All (X) (T -> Y)) -> Y)
;; we need a "pack" function
;; (: pack (All (S) ((All (X))))) | true |
e9c6e5a75e9d230b4b10eb50fff4a7a83d48472b | e872962b1fb9b3c4b78e739e603e878bd29bde7c | /libgit2/include/types.rkt | 72913dcc54d82e632ff9c29678a0bffa3b35b2e4 | [
"MIT"
]
| permissive | LiberalArtist/libgit2 | f0e266a85e205df30f6fab1c7876a6e3d85e9ba6 | af2670e94f8fa9b74aab98590c40bbd282fa0292 | refs/heads/main | 2023-08-06T23:40:18.395064 | 2023-07-08T19:23:25 | 2023-07-08T19:23:25 | 165,514,201 | 0 | 0 | MIT | 2019-01-13T14:21:34 | 2019-01-13T14:21:34 | null | UTF-8 | Racket | false | false | 5,811 | rkt | types.rkt | #lang racket
(require ffi/unsafe
"../private/base.rkt")
;; TODO: refactor away this module;
;; keep type definitions with uses
;; TODO: fix the "this is wrong"s enums
(provide _git_time_t
_git_off_t
_git_object_t
_git_odb
git_odb?
_git_odb_backend
_git_odb_object
_git_refdb
_git_refdb_backend
_git_repository
git_repository?
_git_object
_git_object/null
_git_revwalk
_git_tag
_git_blob
_git_blob/null
_git_commit
_git_tree_entry
_git_tree_entry/null
_git_tree
_git_tree/null
_git_treebuilder
_git_index
_git_index/null
_git_index_conflict_iterator
_git_config
_git_config_backend
_git_reflog_entry
_git_reflog
_git_note
_git_packbuilder
_git_time
_git_time-pointer
_git_signature-pointer
_git_signature-pointer/null
_git_reference
_git_reference/null
_git_reference_iterator
_git_transaction
_git_annotated_commit
_git_annotated_commit/null
_git_status_list
_git_rebase
_git_reference_t
_git_branch_t
_git_filemode_t
_git_refspec
_git_remote
_git_transport
_git_push
_git_transfer_progress
_git_transfer_progress-pointer
_git_transfer_progress_cb
_git_transport_message_cb
_git_cert_t
_git_cert
_git_transport_certificate_check_cb
_git_submodule
_git_submodule_update_t
_git_submodule_ignore_t
_git_submodule_recurse_t
_git_writestream
_git_blame ;; not from types.h
_git_diff ;; not from types.h
_git_merge_result ;; not from types.h
_git_patch) ;; not from types.h
(define _git_time_t _int64)
(define _git_off_t _int64)
(define-enum _git_object_t
#:base _fixint
[GIT_OBJECT_ANY -2]
[GIT_OBJECT_INVALID -1]
[GIT_OBJECT_COMMIT 1]
[GIT_OBJECT_TREE 2]
[GIT_OBJECT_BLOB 3]
[GIT_OBJECT_TAG 4]
[GIT_OBJECT_OFS_DELTA 6]
[GIT_OBJECT_REF_DELTA 7])
(define-cpointer-type _git_odb)
(define-cpointer-type _git_odb_backend)
(define-cpointer-type _git_odb_object)
(define-cpointer-type _git_refdb)
(define-cpointer-type _git_refdb_backend)
(define-cpointer-type _git_repository)
;; not here: _git_worktree
(define-cpointer-type _git_object)
(define-cpointer-type _git_revwalk)
(define-cpointer-type _git_tag)
(define-cpointer-type _git_blob)
(define-cpointer-type _git_commit)
(define-cpointer-type _git_tree_entry)
(define-cpointer-type _git_tree)
(define-cpointer-type _git_treebuilder)
(define-cpointer-type _git_index)
;; not here: _git_index_iterator
(define-cpointer-type _git_index_conflict_iterator)
(define-cpointer-type _git_config)
(define-cpointer-type _git_config_backend)
(define-cpointer-type _git_reflog_entry)
(define-cpointer-type _git_reflog)
(define-cpointer-type _git_note)
(define-cpointer-type _git_packbuilder)
(define-cstruct _git_time
([time _git_time_t]
[offset _int]))
(define-cstruct _git_signature
([name _string]
[email _string]
[when _git_time]))
(define-cpointer-type _git_reference)
(define-cpointer-type _git_reference_iterator)
(define-cpointer-type _git_transaction)
(define-cpointer-type _git_annotated_commit)
(define-cpointer-type _git_status_list)
(define-cpointer-type _git_rebase)
(define-enum _git_reference_t
[GIT_REFERENCE_INVALID 0]
[GIT_REFERENCE_DIRECT 1]
[GIT_REFERENCE_SYMBOLIC 2]
[GIT_REFERENCE_ALL
(bitwise-ior GIT_REFERENCE_DIRECT GIT_REFERENCE_SYMBOLIC)])
(define-enum _git_branch_t
[GIT_BRANCH_LOCAL 1]
[GIT_BRANCH_REMOTE 2]
[GIT_BRANCH_ALL
(bitwise-ior GIT_BRANCH_LOCAL GIT_BRANCH_REMOTE)])
(define-enum _git_filemode_t
[GIT_FILEMODE_UNREADABLE 0]
[GIT_FILEMODE_TREE #o0040000]
[GIT_FILEMODE_BLOB #o0100644]
[GIT_FILEMODE_BLOB_EXECUTABLE #o0100755]
[GIT_FILEMODE_LINK #o0120000]
[GIT_FILEMODE_COMMIT #o0160000])
(define-cpointer-type _git_refspec)
(define-cpointer-type _git_remote)
(define-cpointer-type _git_transport)
(define-cpointer-type _git_push)
;; not here: _git_remote_callbacks
(define-cstruct _git_transfer_progress
([total_objects _uint]
[indexed_objects _uint]
[received_objects _uint]
[local_objects _uint]
[total_deltas _uint]
[indexed_deltas _uint]
[received_bytes _size]))
(define _git_transfer_progress_cb
(_fun _git_transfer_progress-pointer _bytes -> _int))
(define _git_transport_message_cb
(_fun _string _int _bytes -> _int))
(define-enum _git_cert_t
GIT_CERT_NONE
GIT_CERT_X509
GIT_CERT_HOSTKEY_LIBSSH2
GIT_CERT_STRARRAY)
(define-cstruct _git_cert
([cert_type _git_cert_t]))
(define _git_transport_certificate_check_cb
(_fun _git_cert-pointer _int _string _bytes -> _int))
(define-cpointer-type _git_submodule)
(define-enum _git_submodule_update_t
GIT_SUBMODULE_UPDATE_DEFAULT
GIT_SUBMODULE_UPDATE_CHECKOUT
GIT_SUBMODULE_UPDATE_REBASE
GIT_SUBMODULE_UPDATE_MERGE
GIT_SUBMODULE_UPDATE_NONE)
(define-enum _git_submodule_ignore_t
#:base _fixint
[GIT_SUBMODULE_IGNORE_UNSPECIFIED -1]
[GIT_SUBMODULE_IGNORE_NONE 1]
GIT_SUBMODULE_IGNORE_UNTRACKED
GIT_SUBMODULE_IGNORE_DIRTY
GIT_SUBMODULE_IGNORE_ALL)
(define-enum _git_submodule_recurse_t
GIT_SUBMODULE_RECURSE_NO
GIT_SUBMODULE_RECURSE_YES
GIT_SUBMODULE_RECURSE_ONDEMAND)
;; TODO _git_writestream is a public struct
(define-cpointer-type _git_writestream)
;; not here: _git_mailmap
(define-cpointer-type _git_blame)
(define-cpointer-type _git_diff)
(define-cpointer-type _git_merge_result)
(define-cpointer-type _git_patch)
| false |
0e7a9ff4ab9b67cb015492940272e78ff6343b52 | 7e15b782f874bcc4192c668a12db901081a9248e | /eopl/ch2/ex-2.30.rkt | 3232c10aa461670b5705d98e9ae775f771652c91 | []
| no_license | Javran/Thinking-dumps | 5e392fe4a5c0580dc9b0c40ab9e5a09dad381863 | bfb0639c81078602e4b57d9dd89abd17fce0491f | refs/heads/master | 2021-05-22T11:29:02.579363 | 2021-04-20T18:04:20 | 2021-04-20T18:04:20 | 7,418,999 | 19 | 4 | null | null | null | null | UTF-8 | Racket | false | false | 2,258 | rkt | ex-2.30.rkt | #lang eopl
(require "../common.rkt")
(require "../test-utils.rkt")
(define (identifier? s)
(and (symbol? s)
(not (eq? s 'lambda))))
(define-datatype lc-exp lc-exp?
(var-exp
(var identifier?))
(lambda-exp
(bound-var identifier?)
(body lc-exp?))
(app-exp
(rator lc-exp?)
(rand lc-exp?)))
(define (unparse-lc-exp-to-string exp)
(cases lc-exp exp
(var-exp (var)
(symbol->string var))
(lambda-exp (var body)
(format "(lambda (~A) ~A)"
var
(unparse-lc-exp-to-string body)))
(app-exp (rator rand)
(format "(~A ~A)"
(unparse-lc-exp-to-string rator)
(unparse-lc-exp-to-string rand)))))
(define (parse-expression datum)
(cond ((identifier? datum)
(var-exp datum))
((not (list? datum))
(eopl:error 'parse-expression
"unexpected data, not a list: ~A" datum))
((null? datum)
(eopl:error 'parse-expression
"unexpected data, empty list"))
; datum must be a non-empty list starting from here
((eqv? (car datum) 'lambda)
(assert (= (length datum) 3)
"an lambda expression needs exactly 3 elements")
(lambda-exp
(car (cadr datum))
(parse-expression (caddr datum))))
(else
(assert (= (length datum) 2)
"an application needs exactly 2 elements")
(app-exp
(parse-expression (car datum))
(parse-expression (cadr datum))))))
(define (report-invalid-concrete-syntax datum)
(eopl:error 'parse-expression
"invalid concrete syntax: ~A" datum))
(define lc-exp1
(parse-expression
'((lambda (a) (a b)) c)))
(define lc-exp2
(parse-expression
'(lambda (x)
(lambda (y)
((lambda (x)
(x y))
x)))))
(out (unparse-lc-exp-to-string lc-exp1)
; ((lambda (a) (a b)) c)
(unparse-lc-exp-to-string lc-exp2)
; (lambda (x) (lambda (y) ((lambda (x) (x y)) x)))
)
; error 1: wrong type
; (parse-expression 1)
; error 2: empty list
; (parse-expression '())
; errpr 3: call lambda with wrong length
; (parse-expression '(lambda (x) foo bar))
; error 4: application with wrong length
; (parse-expression '(a b c d))
| false |
ef38bc7f73ed4b4fc5ed7bfc7a4ed157eaf277a0 | 76df16d6c3760cb415f1294caee997cc4736e09b | /rosette-benchmarks-3/rtr/benchmarks/boxroom/translated.rkt | 019f33d2fd7ba339ca06d6b4aef590df47b14e02 | [
"MIT"
]
| permissive | uw-unsat/leanette-popl22-artifact | 70409d9cbd8921d794d27b7992bf1d9a4087e9fe | 80fea2519e61b45a283fbf7903acdf6d5528dbe7 | refs/heads/master | 2023-04-15T21:00:49.670873 | 2021-11-16T04:37:11 | 2021-11-16T04:37:11 | 414,331,908 | 6 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 2,037 | rkt | translated.rkt | #lang rosette
(require "../../verif_libraries/ivl.rkt")
(require racket/include)(require racket/undefined)
(define USE_BV false)
(define BVSIZE 6)(include (file "../../verif_libraries/array.rkt"))
(include (file "../../verif_libraries/basicobject.rkt"))
(include (file "../../verif_libraries/bool.rkt"))
(include (file "../../verif_libraries/fixnum.rkt"))
(include (file "../../verif_libraries/float.rkt"))
(include (file "../../verif_libraries/hash.rkt"))
(include (file "../../verif_libraries/helper.rkt"))
(include (file "../../verif_libraries/ids.rkt"))
(include (file "../../verif_libraries/integer.rkt"))
(include (file "../../verif_libraries/kernel.rkt"))
;;; OBJECT STRUCT:
(struct object ([classid][objectid] [size #:auto #:mutable] [contents #:auto #:mutable] [vec #:auto #:mutable] [id #:auto #:mutable] [value #:auto #:mutable] ) #:transparent)
;;; ARGUMENT DEFINITIONS:
; Initialize f of type Folder
(define f
(let ([f (object 7 (new-obj-id))])
f))
; Initialize struct self of type UserFile
(define self
(let ([self (object 8 (new-obj-id))])
self))
;;; FUNCTION DEFINITIONS:
(define (UserFile_inst_move self target_folder #:block [BLK (void)])
(let ()
(begin
(let ([self self][input target_folder])(begin ; Initialize output of type Folder
(define output
(let ([output (object 7 (new-obj-id))])
output))(assume (obj-id-eq (let ([self self])(begin(define c (object 6 (UserFile_inst_folder (object-objectid self) )))c)) input )) output))
(return (let ([self self])(begin ; Initialize b of type false or true
(define-symbolic* b boolean?)
b)))
)))
(define-symbolic UserFile_inst_folder (~> integer? integer?))
;;;RETURN VALUE:
(define b (UserFile_inst_move self f))
;;;VERIFIED ASSERTION:
(verify #:assume (assert (and )) #:guarantee (assert (unless (stuck? b) (obj-id-eq f (let ([self self])(begin(define c (UserFile_inst_folder (object-objectid self) )) c)) ))))
#|
Class Name->Class ID
Hash->0
Class->1
Array->2
Fixnum->3
Bignum->3
Integer->3
Float->4
Boolean->5
RDL::Verify->6
Folder->7
UserFile->8
|#
| false |
c5988897b4864dcb1d5cbe2aa36fbc8596604381 | 37f4e719355c5cf5cf607bd3715c734de6962adb | /lisp-code/2.高阶函数(comebine f1 f2 n)/2.高阶函数(comebine f1 f2 n).rkt | 7e0ab154c20d5e884b2fd72964f361b6eda97189 | []
| no_license | Miao-er/LISP-SICP-PKU | 4135f506fe5d5e93d213b75f7302b00c9a5df465 | 516ed112c59cd9513d9192bd8123394ad564d53f | refs/heads/master | 2023-06-14T14:39:48.502501 | 2021-07-14T16:00:52 | 2021-07-14T16:00:52 | 385,995,903 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 625 | rkt | 2.高阶函数(comebine f1 f2 n).rkt | #lang racket
(define (square x) (* x x))
(define (inc x) (+ x 1))
(define (db x) (* x 2))
(define (combine f1 f2 n)
(define (fun) (lambda (x) (f1 (f2 x))))
(define (count n)
(if(= n 0)
(lambda (x) x)
(if(= n 1)
(lambda (x) ((fun) x))
(lambda (x) ((fun) ((count (- n 1)) x))))))
(count n))
((combine square inc 1) 2)
((combine square inc 2) 3)
((combine db inc 3) 2)
((combine inc inc 4) 3)
(display "********") (newline)
(define (myloop)
(let ((n (read))
(x (read)))
(if (eq? n eof)
(void)
(begin (display ((combine inc square n) x))
(newline) (myloop)))))
(myloop) | false |
171a6d8712c27e047f35fc380bb07cf3ce99fb69 | ac4ca55162c3d5fe4076576875571e49d62177bd | /typed/measures-with-dimensions/measures/typed-operations-1.rkt | 49220077d89b4876ad6fc9c19dc2b8351f2577eb | []
| no_license | capfredf/measures-with-dimensions | 7e5a7a2880da3fc29072ee941adc721a2c58ca57 | fc6c78f79ac89cf488a5ccc5fc20391bd254886c | refs/heads/master | 2021-12-14T17:08:51.789250 | 2020-07-17T23:34:41 | 2020-07-18T00:39:44 | 184,127,137 | 0 | 0 | null | 2019-04-29T18:59:42 | 2019-04-29T18:59:41 | null | UTF-8 | Racket | false | false | 12,924 | rkt | typed-operations-1.rkt | #lang sweet-exp typed/racket
provide m+ m+/lenient m- m1/ mexpt m*/scalar m*/vector m* mabs
require "../dimensions/dimension-struct.rkt"
"../dimensions/dimension-operations.rkt"
"../units/unit-struct.rkt"
"../units/unit-operations.rkt"
"measure-struct.rkt"
"0-1-measures.rkt"
"../vector-operations.rkt"
"../preds.rkt"
"../untyped-utils.rkt"
(: measure->real-measure : (All (d) [(Measureof Any (Unitof d)) -> (Measureof Real (Unitof d))]))
(define (measure->real-measure m)
(struct-copy measure m
[number (assert (measure-number m) real?)]))
(: m+ : (All (d) (case-> [-> (Measureof 0 Dimensionless-Unit)]
[-> (U (Measureof Real (Unitof d)) (Unitof d))
(U (Measureof Real (Unitof d)) (Unitof d)) *
(Measureof Real (Unitof d))]
[-> (U (Measureof Number (Unitof d)) (Unitof d))
(U (Measureof Number (Unitof d)) (Unitof d)) *
(Measureof Number (Unitof d))]
[-> (Measureof Vec (Unitof d))
(Measureof Vec (Unitof d)) *
(Measureof Vec (Unitof d))]
[-> (Measureof Num/Vec (Unitof d))
(Measureof Num/Vec (Unitof d)) *
(Measureof Num/Vec (Unitof d))]
[-> Real Real * (Measureof Real Dimensionless-Unit)]
[-> Number Number * (Measureof Number Dimensionless-Unit)]
[-> VectorTop VectorTop * Vector-Measure]
[-> Measureish Measureish * Measure]
[-> Measureish * Measure]
)))
(define m+
(case-lambda
[() 0-measure]
[(m1 . rst)
(define m1* : Measureish (cast (ann m1 Any) Measureish))
(define rst* (cast (ann rst Any) (Listof Measureish)))
(cond [(number? m1)
(apply (inst m+/lenient Dimensionless-Dimension) (number->measure m1) rst*)]
[(vector? m1)
(apply m+/lenient (vector->measure m1) rst*)]
[(unit? m1)
(apply m+/lenient (->measure m1) rst*)]
[(dimension? m1)
(apply m+/lenient (->measure (->unit m1)) rst*)]
[(measure? m1*)
(apply m+/lenient m1 rst*)]
[else (error 'm+ "expected Measure, given ~v" m1)])]
[ms (cond [(empty? ms) 0-measure]
[else (apply m+ (first ms) (rest ms))])]))
(: m+/lenient : (All (d) (case-> [-> (Measureof 0 Dimensionless-Unit)]
[-> (Measureof Real (Unitof d)) Measureish *
(Measureof Real (Unitof d))]
[-> (Measureof Number (Unitof d)) Measureish *
(Measureof Number (Unitof d))]
[-> (Measureof Vec (Unitof d)) Measureish *
(Measureof Vec (Unitof d))]
[-> (Measureof Num/Vec (Unitof d)) Measureish *
(Measureof Num/Vec (Unitof d))])))
(define m+/lenient
(case-lambda
[() 0-measure]
[(m1 . rst)
(let* ([rst : (Listof Measure) (map ->measure rst)])
(: u : (Unitof d))
(define u (measure-unit m1))
(: d : d)
(define d (unit-dimension u))
(define n1 (measure-number m1))
(cond [(real? n1)
(measure->real-measure
(apply (inst m+/scalar d) m1 (cast rst (Listof Number-Measure))))]
[(number? n1)
(apply (inst m+/scalar d) m1 (cast rst (Listof Number-Measure)))]
[else
(apply (inst m+/vector d) m1 (cast rst (Listof Vector-Measure)))]))]))
(: m+/scalar : (All (d) [-> (Measureof Num/Vec (Unitof d)) Number-Measure *
(Measureof Number (Unitof d))]))
(define (m+/scalar m1 . rst)
(: u : (Unitof d))
(define u (measure-unit m1))
(: u-Unit : Unit)
(define u-Unit (assert u Unit?))
(: d : d)
(define d (unit-dimension u))
(: d-Dim : Dimension)
(define d-Dim (assert d Dimension?))
(: sig-figs : Sig-Figs)
(define sig-figs (apply sig-fig-min
(measure-sig-figs m1)
(map (inst measure-sig-figs Number Unit Sig-Figs) rst)))
(: n : Number)
(define n
(for/sum : Number ([m : Number-Measure (in-list (cons (assert m1 number-measure?) rst))])
(unless (dimension=? (measure-dimension m) d-Dim)
(error 'm+ (string-append
"can't add two measures with different dimensions" "\n"
" given ~v and ~v") m1 m))
(define mc (convert m u-Unit))
(define n (Measure-number mc))
(unless (number? n)
(error 'm+ (string-append "can't add a number and a vector" "\n"
" given ~v and ~v") m1 mc))
n))
(measure n u sig-figs))
(: m+/vector : (All (d) [-> (Measureof Num/Vec (Unitof d)) Vector-Measure *
(Measureof Vec (Unitof d))]))
(define (m+/vector m1 . rst)
(: u : (Unitof d))
(define u (measure-unit m1))
(: u-Unit : Unit)
(define u-Unit (assert u Unit?))
(: d : d)
(define d (unit-dimension u))
(: d-Dim : Dimension)
(define d-Dim (assert d Dimension?))
(: sig-figs : Sig-Figs)
(define sig-figs (apply sig-fig-min
(measure-sig-figs m1)
(map (inst measure-sig-figs Vec Unit Sig-Figs) rst)))
(: vs : (Listof Vec))
(define vs
(for/list : (Listof Vec)
([m : Vector-Measure (in-list (cons (cast (ann m1 Any) Vector-Measure) rst))])
(unless (dimension=? (measure-dimension m) d-Dim)
(error 'm+ (string-append
"can't add two measures with different dimensions" "\n"
" given ~v and ~v") m1 m))
(define mc (convert m u-Unit))
(define n (Measure-number mc))
(unless (vector? n)
(error 'm+ (string-append "can't add a number and a vector" "\n"
" given ~v and ~v") m1 mc))
n))
(: length : Nonnegative-Fixnum)
(define length
(apply max (map vector-length vs)))
(: v : Vec)
(define v
(vector->immutable-vector
(for/vector : Vec #:length length #:fill 0
([i : Nonnegative-Integer (in-range length)])
(for/sum : Real ([v : Vec (in-list vs)])
(if (<= (sub1 (vector-length v)) i)
(vector-ref v i)
0)))))
(measure v u sig-figs))
(: m- : (All (d) (case-> [-> (U (Measureof Real (Unitof d)) (Unitof d))
(Measureof Real (Unitof d))]
[-> (U (Measureof Number (Unitof d)) (Unitof d))
(Measureof Number (Unitof d))]
[-> (Measureof Vec (Unitof d))
(Measureof Vec (Unitof d))]
[-> (U (Measureof Num/Vec (Unitof d)) (Unitof d))
(Measureof Num/Vec (Unitof d))]
[-> Real (Measureof Real Dimensionless-Unit)]
[-> Number (Measureof Number Dimensionless-Unit)]
[-> Vec Vector-Measure]
[-> Measureish Measure]
)))
(define (m- m)
(cond [(measure? m) (m-/measure m)]
[(unit? m) (m-/measure (->measure m))]
[(number? m) (m-/measure (number->measure m))]
[(vector? m) (m-/measure (vector->measure m))]
[else (m-/measure (->measure m))]))
(: m-/measure : (All (d) (case-> [-> (Measureof Real (Unitof d))
(Measureof Real (Unitof d))]
[-> (Measureof Number (Unitof d))
(Measureof Number (Unitof d))]
[-> (Measureof Vec (Unitof d))
(Measureof Vec (Unitof d))]
[-> (Measureof Num/Vec (Unitof d))
(Measureof Num/Vec (Unitof d))])))
(define (m-/measure m)
(: u : (Unitof d))
(define u (measure-unit m))
(define n (measure-number m))
(: sig-figs : Sig-Figs)
(define sig-figs (measure-sig-figs m))
(cond [(number? n)
(measure (- n) u sig-figs)]
[else
(measure (v* -1 n) u sig-figs)]))
(: m1/ : [-> Number-Measureish Number-Measure])
(define (m1/ m)
(let ([m (assert (->measure m) number-measure?)])
(: u : Unit)
(define u (measure-unit m))
(: n : Number)
(define n (measure-number m))
(: sig-figs : Sig-Figs)
(define sig-figs (measure-sig-figs m))
(measure (/ n)
(u1/ u)
sig-figs)))
(: mexpt : [-> Number-Measureish Number-Measureish Number-Measure])
(define (mexpt b e)
(let ([b (assert (->measure b) number-measure?)]
[e (assert (->measure e) number-measure?)])
(: n : Number)
(define n
(assert (measure-number (convert e 1-unit))
number?))
(measure (expt (measure-number b) n)
(uexpt (Measure-unit b) (assert (inexact->exact n) exact-rational?))
(sig-fig-min (Measure-sig-figs b)
(Measure-sig-figs e)))))
(: m*/scalar : [Number-Measure * -> Number-Measure])
;; Note: accepts Number-Measure, not Number-Measureish
(define (m*/scalar . args)
(define-values (ns us sfs)
(for/lists ([ns : (Listof Number)] [us : (Listof Unit)] [sfs : (Listof Sig-Figs)])
([m : Number-Measure (in-list args)])
(values (measure-number m)
(measure-unit m)
(measure-sig-figs m))))
(measure (apply * ns)
(apply u* us)
(apply sig-fig-min sfs)))
(: m*/vector : [Number-Measure Vector-Measure -> Vector-Measure])
;; Note: accepts _-Measure, not _-Measureish
(define (m*/vector nm vm)
(: vm.v : Vec)
(define vm.v (measure-number vm))
(: nm.n : Real)
(define nm.n (assert (measure-number nm) real?))
(measure (v* nm.n vm.v)
(u* (Measure-unit nm)
(Measure-unit vm))
(sig-fig-min (Measure-sig-figs nm)
(Measure-sig-figs vm))))
(: m*/no-special-case : (case-> [Number-Measure * -> Number-Measure]
[Measureish * -> Measure]))
(define (m*/no-special-case . args)
(let ([args (map ->measure args)])
(: vector-measure? : [Measure -> Boolean])
(define (vector-measure? m)
(vector? (measure-number m)))
(define-values (vectors scalars)
(partition vector-measure? args))
(define scalars*
(for/list : (Listof Number-Measure) ([scalar (in-list scalars)])
(assert scalar number-measure?)))
(match vectors
[(list)
(apply m*/scalar scalars*)]
[(list v)
(when (andmap number-measureish? args) (error 'm* "this should never happen"))
(m*/vector (apply m*/scalar scalars*) (cast v Vector-Measure))]
[vectors
(error 'm*
(string-append
"can't multiply 2 or more vectors together" "\n"
" use mdot or mcross instead" "\n"
" given: ~v")
vectors)])))
(: m* : (All (d) (case-> [Real (Unitof d) -> (Measureof Real (Unitof d))]
[Number (Unitof d) -> (Measureof Number (Unitof d))]
[Vec (Unitof d) -> (Measureof Vec (Unitof d))]
[Number-Measure * -> Number-Measure]
[Measureish * -> Measure])))
(define m*
(case-lambda
[(n u)
(cond [(unit? u)
(cond [(number? n) (make-measure n u)]
[(vector? n)
(make-measure (cast n Vec) u)]
[else
(m*/no-special-case n (assert u Unit?))])]
[else (m*/no-special-case n u)])]
[args (apply m*/no-special-case args)]))
(: mabs : (All (d) (case-> [-> (Measureof (U Positive-Real Negative-Real) (Unitof d))
(Measureof Positive-Real (Unitof d))]
[-> (Measureof Real (Unitof d))
(Measureof Nonnegative-Real (Unitof d))]
[-> Real-Measure Real-Measure])))
(define (mabs m)
(let ([m (->measure m)])
(make-measure (abs (measure-number m))
(measure-unit m)
(measure-sig-figs m))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(untyped-module*
[#:begin (require "../units/unit-struct.rkt" "measure-struct.rkt")]
[m* [Measureish * -> Measure]]
[m+ [Measureish * -> Measure]]
[m- [Measureish -> Measure]]
)
| false |
b60262f59f87ab9a0bcac7a1de2c758e9fbcbca0 | 0d501bdadd6239a56c24b9e03ddc9600c4981206 | /whalesong/current/parser/where-is-collects.rkt | 1db573a64c9771b1528cae005699b39e60397c12 | []
| no_license | soegaard/exercises | f9d03cef512df3fda8d916a8d202de39da0b333b | d1dfb80d9c4201e15b32afe88e5f49697297b162 | refs/heads/master | 2022-04-05T18:17:41.261287 | 2020-02-02T01:25:16 | 2020-02-02T01:25:16 | 2,202,190 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 539 | rkt | where-is-collects.rkt | #lang typed/racket/base
(require/typed racket/path
(normalize-path (Path -> Path)))
(require/typed typed/racket/base
(relative-path? (Any -> Boolean))
(find-executable-path (Path Path -> Path)))
(provide collects-path)
(define collects-path
(normalize-path
(let ([p (find-system-path 'collects-dir)])
(cond
[(relative-path? p)
(find-executable-path (find-system-path 'exec-file)
(find-system-path 'collects-dir))]
[else
p]))))
| false |
41228549d8ca12d4435a625da0bef805399dcf2f | 9209079c67b9efa4a8e619f0621165bac930c82d | /sicp/chapter2/ex-2.62(union-set).rkt | f927e8cc850856014cc94616e49b952467fc2c44 | []
| no_license | AlexMost/my-courses | c29c5c65bae36245443c8f95a076e6cdfb6703fe | 3d9148879399232312244d7b0b61a06690ee8cca | refs/heads/master | 2021-01-18T22:09:24.416646 | 2018-07-05T22:09:48 | 2018-07-05T22:09:48 | 21,182,354 | 2 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 486 | rkt | ex-2.62(union-set).rkt | #lang racket
(define (union-set set1 set2)
(cond [(null? set1) set2]
[(null? set2) set1]
[else
(let ([i1 (car set1)]
[i2 (car set2)])
(cond [(< i2 i1) (cons i2 (union-set set1 (cdr set2)))]
[(> i2 i1) (cons i1 (union-set (cdr set1) set2))]
[else (cons i1 (union-set (cdr set1) (cdr set2)))]))]))
; > (union-set '(1 2 3) '(2 5 7))
; '(1 2 3 7)
; > (union-set '(1 2 3 4) '(1 2 7 8))
; '(1 2 3 4 7 8) | false |
8f99520e8cfee5d8c2a12d298c1c6984077bdd05 | 898dceae75025bb8eebb83f6139fa16e3590eb70 | /pl1/asg2/osx-dist/lib/plt/assignment2-osx/collects/racket/vector.rkt | 6c94df2b831e6adda8117df0ba7c0e48a7b541e7 | []
| no_license | atamis/prog-hw | 7616271bd4e595fe864edb9b8c87c17315b311b8 | 3defb8211a5f28030f32d6bb3334763b2a14fec2 | refs/heads/master | 2020-05-30T22:17:28.245217 | 2013-01-14T18:42:20 | 2013-01-14T18:42:20 | 2,291,884 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 8,788 | rkt | vector.rkt | #lang racket/base
(provide vector-set*! vector-copy vector-map vector-map! vector-append
vector-take vector-drop vector-split-at
vector-take-right vector-drop-right vector-split-at-right
vector-filter vector-filter-not
vector-count vector-argmin vector-argmax
vector-member vector-memq vector-memv)
(require racket/unsafe/ops)
(define (vector-set*! v . pairs)
(unless (even? (length pairs))
(error 'vector-set*! "expected an even number of association elements, but received an odd number: ~e" pairs))
(let loop ([pairs pairs])
(unless (null? pairs)
(vector-set! v (car pairs) (cadr pairs))
(loop (cddr pairs)))))
;; unchecked version of `vector-copy'
;; used at the implementation of many functions in this file
(define (vector-copy* v start end)
(define new-v (make-vector (- end start)))
(vector-copy! new-v 0 v start end)
new-v)
(define (vector-copy v [start 0] [end (and (vector? v) (vector-length v))])
(unless (vector? v)
(raise-argument-error 'vector-copy "vector?" v))
(unless (exact-nonnegative-integer? start)
(raise-argument-error 'vector-copy "exact-nonnegative-integer?" start))
(let ([len (vector-length v)])
(cond
[(= len 0)
(unless (= start 0)
(raise-range-error 'vector-copy "vector" "starting " start v 0 0))
(unless (= end 0)
(raise-range-error 'vector-copy "vector" "ending " end v 0 0))
(vector)]
[else
(unless (and (<= 0 start len))
(raise-range-error 'vector-copy "vector" "starting " start v 0 len))
(unless (and (<= start end len))
(raise-range-error 'vector-copy "vector" "ending " end v start len 0))
(vector-copy* v start end)])))
;; do vector-map, putting the result in `target'
;; length is passed to save the computation
(define (vector-map/update f target length vs)
(for ([i (in-range length)])
(unsafe-vector-set!
target i
(apply f (map (lambda (vec) (unsafe-vector-ref vec i)) vs)))))
;; check that `v' is a vector
;; that `v' and all the `vs' have the same length
;; and that `f' takes |v + vs| args
;; uses name for error reporting
(define (varargs-check f v vs name)
(unless (procedure? f)
(apply raise-argument-error name "procedure?" 0 f v vs))
(unless (vector? v)
(apply raise-argument-error name "vector?" 1 f v vs))
(let ([len (unsafe-vector-length v)])
(for ([e (in-list vs)]
[i (in-naturals 2)])
(unless (vector? e)
(apply raise-argument-error name "vector?" e i f v vs))
(unless (= len (unsafe-vector-length e))
(raise
(make-exn:fail:contract
(format "~e: all vectors must have same size; ~a"
name
(let ([args (list* f v vs)])
(if ((length args) . < . 10)
(apply string-append
"arguments were:"
(for/list ([i (list* f v vs)])
(format " ~e" i)))
(format "given ~a arguments total"
(sub1 (length args))))))
(current-continuation-marks)))))
(unless (procedure-arity-includes? f (add1 (length vs)))
(raise-arguments-error name "mismatch between procedure arity and argument count"
"procedure" f
"expected arity" (add1 (length vs))))
len))
(define (vector-map f v . vs)
(let* ([len (varargs-check f v vs 'vector-map)]
[new-v (make-vector len)])
(vector-map/update f new-v len (cons v vs))
new-v))
(define (vector-map! f v . vs)
(define len (varargs-check f v vs 'vector-map!))
(vector-map/update f v len (cons v vs))
v)
;; check that `v' is a vector and that `f' takes one arg
;; uses name for error reporting
(define (one-arg-check f v name)
(unless (and (procedure? f) (procedure-arity-includes? f 1))
(raise-argument-error name "(any/c . -> . any/c)" 0 f)))
(define (vector-filter f v)
(one-arg-check f v 'vector-filter)
(list->vector (for/list ([i (in-vector v)] #:when (f i)) i)))
(define (vector-filter-not f v)
(one-arg-check f v 'vector-filter-not)
(list->vector (for/list ([i (in-vector v)] #:unless (f i)) i)))
(define (vector-count f v . vs)
(unless (procedure? f)
(raise-argument-error 'vector-count "procedure?" f))
(unless (procedure-arity-includes? f (add1 (length vs)))
(raise-arguments-error 'vector-count "mismatch between procedure arity and argument count"
"procedure" f
"expected arity" (add1 (length vs))))
(unless (and (vector? v) (andmap vector? vs))
(raise-argument-error
'vector-count "vector?"
(ormap (lambda (x) (and (not (list? x)) x)) (cons v vs))))
(if (pair? vs)
(let ([len (vector-length v)])
(if (andmap (lambda (v) (= len (vector-length v))) vs)
(for/fold ([c 0])
([i (in-range len)]
#:when
(apply f
(unsafe-vector-ref v i)
(map (lambda (v) (unsafe-vector-ref v i)) vs)))
(add1 c))
(raise-arguments-error 'vector-count "all vectors must have same size")))
(for/fold ([cnt 0]) ([i (in-vector v)] #:when (f i))
(add1 cnt))))
(define (check-vector/index v n name)
(unless (vector? v)
(raise-argument-error name "vector?" v))
(unless (exact-nonnegative-integer? n)
(raise-argument-error name "exact-nonnegative-integer?" n))
(let ([len (unsafe-vector-length v)])
(unless (<= 0 n len)
(raise-range-error name "vector" "" n v 0 len))
len))
(define (vector-take v n)
(check-vector/index v n 'vector-take)
(vector-copy* v 0 n))
(define (vector-drop v n)
(vector-copy* v n (check-vector/index v n 'vector-drop)))
(define (vector-split-at v n)
(let ([len (check-vector/index v n 'vector-split-at)])
(values (vector-copy* v 0 n) (vector-copy* v n len))))
(define (vector-take-right v n)
(let ([len (check-vector/index v n 'vector-take-right)])
(vector-copy* v (unsafe-fx- len n) len)))
(define (vector-drop-right v n)
(let ([len (check-vector/index v n 'vector-drop-right)])
(vector-copy* v 0 (unsafe-fx- len n))))
(define (vector-split-at-right v n)
(let ([len (check-vector/index v n 'vector-split-at-right)])
(values (vector-copy* v 0 (unsafe-fx- len n))
(vector-copy* v (unsafe-fx- len n) len))))
(define (vector-append . vs)
(let* ([lens (for/list ([e (in-list vs)] [i (in-naturals)])
(if (vector? e)
(unsafe-vector-length e)
(raise-argument-error 'vector-append "vector?" e i)))]
[new-v (make-vector (apply + lens))])
(let loop ([start 0] [lens lens] [vs vs])
(when (pair? lens)
(let ([len (car lens)] [v (car vs)])
(for ([i (in-range len)])
(unsafe-vector-set! new-v (+ i start) (unsafe-vector-ref v i)))
(loop (+ start len) (cdr lens) (cdr vs)))))
new-v))
;; copied from `racket/list'
(define (mk-min cmp name f xs)
(unless (and (procedure? f)
(procedure-arity-includes? f 1))
(raise-argument-error name "(any/c . -> . real?)" f))
(unless (and (vector? xs)
(< 0 (unsafe-vector-length xs)))
(raise-argument-error name "(and/c vector? (lambda (v) (positive? (vector-length v))))" xs))
(let ([init-min-var (f (unsafe-vector-ref xs 0))])
(unless (real? init-min-var)
(raise-result-error name "real?" init-min-var))
(if (unsafe-fx= (unsafe-vector-length xs) 1)
(unsafe-vector-ref xs 0)
(let-values ([(min* min-var*)
(for/fold ([min (unsafe-vector-ref xs 0)]
[min-var init-min-var])
([e (in-vector xs 1)])
(let ([new-min (f e)])
(unless (real? new-min)
(raise-result-error
name "real?" new-min))
(cond [(cmp new-min min-var)
(values e new-min)]
[else (values min min-var)])))])
min*))))
(define (vector-argmin f xs) (mk-min < 'vector-argmin f xs))
(define (vector-argmax f xs) (mk-min > 'vector-argmax f xs))
(define-syntax-rule (vm-mk name cmp)
(define (name val vec)
(unless (vector? vec)
(raise-argument-error 'name "vector?" 1 val vec))
(let ([sz (unsafe-vector-length vec)])
(let loop ([k 0])
(cond [(= k sz) #f]
[(cmp val
(unsafe-vector-ref vec k))
k]
[else (loop (unsafe-fx+ 1 k))])))))
(vm-mk vector-member equal?)
(vm-mk vector-memq eq?)
(vm-mk vector-memv eqv?)
| true |
4aba266fd64e7eb15e38bc8710cc7ee58996be2a | 6858cbebface7beec57e60b19621120da5020a48 | /15/3/3/17.rkt | 63fa40eb0e8516e4a44982544636763c51e91989 | []
| no_license | ponyatov/PLAI | a68b712d9ef85a283e35f9688068b392d3d51cb2 | 6bb25422c68c4c7717b6f0d3ceb026a520e7a0a2 | refs/heads/master | 2020-09-17T01:52:52.066085 | 2017-03-28T07:07:30 | 2017-03-28T07:07:30 | 66,084,244 | 2 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 132 | rkt | 17.rkt | (define (safe-to-transport? [a : Animal]) : boolean
(type-case Animal a
[armadillo (a?) a?]
[boa (l) (not (big-one? l))])) | false |
d4c22e3ff71b0abc543b93e670697f7f73421c1a | b08b7e3160ae9947b6046123acad8f59152375c3 | /Programming Language Detection/Experiment-2/Dataset/Train/Racket/loops-break.rkt | ef24a7db4f8358ffdb67016a0e15ec790edf7cc9 | []
| no_license | dlaststark/machine-learning-projects | efb0a28c664419275e87eb612c89054164fe1eb0 | eaa0c96d4d1c15934d63035b837636a6d11736e3 | refs/heads/master | 2022-12-06T08:36:09.867677 | 2022-11-20T13:17:25 | 2022-11-20T13:17:25 | 246,379,103 | 9 | 5 | null | null | null | null | UTF-8 | Racket | false | false | 156 | rkt | loops-break.rkt | #lang racket
(let loop ()
(let/ec break
(define a (random 20))
(displayln a)
(when (= a 10) (break))
(displayln (random 20))
(loop)))
| false |
5cf3544d5e6bb2e597792cb668c04372428d73f9 | b3dc4d8347689584f0d09452414ffa483cf7dcb3 | /rash/private/rashrc-lib.rkt | 8e1eb67e8bbc8b0326f3c6c59e642c2130e92a67 | [
"MIT",
"Apache-2.0"
]
| permissive | willghatch/racket-rash | 75e336d985bf59b4adfe5d5a7bd68d31cf2fe7db | 42460a283ce2d7296257b068505cd4649052f67c | refs/heads/master | 2023-06-17T16:16:26.126945 | 2023-02-24T18:13:25 | 2023-02-24T18:17:02 | 65,781,414 | 556 | 43 | NOASSERTION | 2021-03-09T17:17:29 | 2016-08-16T02:37:13 | Racket | UTF-8 | Racket | false | false | 8,440 | rkt | rashrc-lib.rkt | #lang racket/base
;; TODO - This is basically full of quick hacks to get a semi-decent repl.
;; Everything in this file should be replaced.
(provide
complete-paths
complete-commands
complete-namespaced
make-composite-completer
cwd-hack-box
basic-prompt
lame-prompt
current-prompt-function
current-rash-top-level-print-formatter
)
(require
racket/date
shell/mixed-pipeline
shell/utils/bourne-expansion-utils
(prefix-in sp- shell/pipeline)
"top-level-print.rkt"
"../prompt-helpers/git-info.rkt"
racket/list
racket/string
readline/pread
readline/readline
)
(require (for-syntax racket/base racket/string))
(define-syntax (fail-if-not-6.12+ stx)
(define vns (string-split (version) "."))
(if (or (> (string->number (car vns)) 6)
(and (equal? (string->number (car vns)) 6)
(>= (string->number (cadr vns)) 12)))
#'(void)
(raise-syntax-error 'rash "The Rash REPL can't be used with a Racket version below 6.12")))
(fail-if-not-6.12+)
;; Somehow completions are getting a different current directory.
;; Maybe they run in a different thread sometimes?
;; Let's hack around that.
(define cwd-hack-box (box (current-directory)))
(define (make-composite-completer . completers)
(λ (pat)
(flatten
(for/list ([c completers])
(c pat)))))
(define (complete-namespaced pat)
(with-handlers ([(λ _ #t) (λ (e) '())])
(define names (map symbol->string (namespace-mapped-symbols)))
(define qpat (string-append "^" (regexp-quote pat)))
(filter (λ (n) (regexp-match qpat n)) names)))
(define (complete-commands pat)
(with-handlers ([(λ _ #t) (λ (e) (eprintf "exn: ~a\n" e)'())])
(define path (getenv "PATH"))
(define path-parts (string-split path ":"))
(define files-on-path (flatten
(map (λ (d) (with-handlers ([(λ _ #t) (λ (e) '())])
(map (λ (p) (build-path d p))
(directory-list d))))
path-parts)))
(define commands (filter (λ (x) (with-handlers ([(λ _ #t) (λ (e) #f)])
(and (file-exists? x)
(member
'execute
(file-or-directory-permissions x)))))
files-on-path))
(define (basename p)
(path->string (car (reverse (explode-path p)))))
(define command-basenames (map basename commands))
(define qpat (string-append "^" (regexp-quote pat)))
(filter (λ (n) (regexp-match qpat n)) command-basenames)))
(define (complete-paths pstr)
(set-completion-append-character! #\null)
(with-handlers ([(λ _ #t) (λ e '())])
(parameterize ([current-directory (unbox cwd-hack-box)])
(let* ([cdir (current-directory)]
;; TODO - this isn't expanding $VARIABLES, apparently
;; because the $ character is treated as a delimiter
;; in libreadline.
[given-path/expanded (dollar-expand-dynamic pstr)]
[given-path (string->path given-path/expanded)]
[given-path-parts (explode-path given-path)]
[parts-but-last (drop-right given-path-parts 1)]
[last-part (car (reverse given-path-parts))]
[build (cond [(equal? pstr "/") (build-path "/")]
[(absolute-path? given-path)
(apply build-path parts-but-last)]
[else (apply build-path cdir parts-but-last)])]
[build (if (absolute-path? given-path)
(if (equal? pstr "/")
(build-path "/")
(apply build-path parts-but-last))
(apply build-path cdir parts-but-last))]
[listing (directory-list build)]
[possibles (filter (λ (p) (and (string-prefix? (path->string p)
(path->string last-part))))
listing)]
[possibles (map (λ (p) (apply build-path
(append parts-but-last (list p))))
possibles)]
[dir-exists-possibles (if (or (directory-exists? pstr)
(equal? pstr ""))
(map (λ (p) (build-path pstr p))
(directory-list pstr))
'())])
(map string->bytes/utf-8
(map (λ (p) (if (directory-exists? p)
(string-append p "/")
p))
(map path->string (append possibles dir-exists-possibles))))))))
(define (print-ret-maybe last-ret ret-number)
(let ([str ((current-rash-top-level-print-formatter) last-ret)])
(when (not (equal? str ""))
(printf "Result ~a:\n~a\n" ret-number str))))
;; TODO - use a library for these functions?
;; Or do I not want another dependency?
(define (mstyle n)
(λ (s) (format "\033[~am~a" n s)))
(define (mstyle2 n1 n2)
(λ (s) (format "\033[~a;~am~a" n1 n2 s)))
(define default-style (mstyle 0))
(define cyan (mstyle 36))
(define red (mstyle 31))
(define green (mstyle 32))
(define bblue (mstyle2 1 34))
(define windows? (equal? (system-type 'os) 'windows))
(define (git-info-with-style)
#|
TODO - getting git info may be slow depending on file system.
Eg. network mounts or busy file systems may make git info queries
unusably slow, or huge git histories may slow this down. I should
add some sort of timeout, or only give information that comes out
quickly.
|#
(define info (git-info))
(if info
(let ([branch (hash-ref info 'branch "?")]
[ahead (hash-ref info 'ahead 0)]
[behind (hash-ref info 'behind 0)]
[dirty (hash-ref info 'dirty? #f)]
[sub-dirty (hash-ref info 'submodule-dirty? #f)]
[untracked (hash-ref info 'untracked? #f)]
[remote-tracking? (hash-ref info 'remote-tracking? #f)]
[timeout (hash-ref info 'timeout? #t)])
(string-append
(default-style "[")
branch
(if (equal? 0 ahead)
""
(format "~a~a"
(default-style " ▲")
(cyan (if (number? ahead) ahead "?"))))
(if (equal? 0 behind)
""
(format "~a~a" (default-style " ▼")
(cyan (if (number? behind) behind "?"))))
(if (eq? #t dirty) (red " D") "")
(if (eq? #t sub-dirty) (red " S") "")
(if (eq? #t untracked) (red " U") "")
(if (eq? #f remote-tracking?) (default-style " N") "")
(if (eq? #t timeout) (red " Time-out") "")
(default-style "] ")))
""))
;; TODO - add path coloring like in megaprompt, maybe with some more info and color options
;; TODO - add path shortening to a maximum length, or more generally finding the
;; max length a prompt string should be and adjusting all parts to it...
(define (basic-prompt #:last-return-value [last-ret #f]
#:last-return-index [last-ret-n 0])
(when (> last-ret-n 0)
(print-ret-maybe last-ret last-ret-n))
(let* ([cdate (current-date)]
[chour (date-hour cdate)]
[cmin (date-minute cdate)]
[padded-min (if (< cmin 10)
(string-append "0" (number->string cmin))
cmin)])
(printf "~a:~a ~a~a~a\n"
(cyan chour) padded-min
(with-handlers ([(λ _ #t) (λ (e) (default-style "[git-info-error] "))])
(git-info-with-style))
(bblue (path->string (current-directory)))
(default-style ""))
;(current-prompt (string->bytes/utf-8 "➤ "))
(readline-prompt (string->bytes/utf-8 "> "))
))
(define (lame-prompt #:last-return-value [last-ret #f]
#:last-return-index [last-ret-n #f])
(print-ret-maybe last-ret last-ret-n)
;(printf ">")
(readline-prompt #"> ")
)
(define current-prompt-function (make-parameter (if windows?
lame-prompt
basic-prompt)))
| true |
8f4f83a2f9ae7145c450b8639b5c5e252d76b0f7 | 6b8bee118bda956d0e0616cff9ab99c4654f6073 | /doc/htdp/17.1.rkt | 500c9d62a5876b7bcf6f0a7448cc2b57cfef2471 | []
| no_license | skchoe/2012.Functional-GPU-Programming | b3456a92531a8654ae10cda622a035e65feb762d | 56efdf79842fc465770214ffb399e76a6bbb9d2a | refs/heads/master | 2016-09-05T23:42:36.784524 | 2014-05-26T17:53:34 | 2014-05-26T17:53:34 | 20,194,204 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,322 | rkt | 17.1.rkt | #lang racket
;; replace-eol-with : list-of-numbers list-of-numbers -> list-of-numbers
;; to construct a new list by replacing empty in alon1 with alon2
(define (replace-eol-with alon1 alon2)
(cond
((empty? alon1) alon2)
(else (cons (first alon1) (replace-eol-with (rest alon1) alon2)))))
;; hours->wages : list-of-numbers list-of-numbers -> list-of-numbers
;; to construct a new list by multiplying the corresponding items on
;; ASSUMPTION: the two lists are of equal length
;; alon1 and alon2
(define (hours->wages alon1 alon2)
(cond
((empty? alon1) empty)
(else (cons (weekly-wage (first alon1) (first alon2))
(hours->wages (rest alon1) (rest alon2))))))
;; weekly-wage : number number -> number
;; to compute the weekly wage from pay-rate and hours-worked
(define (weekly-wage pay-rate hours-worked)
(* pay-rate hours-worked))
;; list-pick : list-of-symbols N[>= 1] -> symbol
;; to determine the nth symbol from alos, counting from 1;
;; signals an error if there is no nth item
(define (list-pick alos n)
(cond
[(and (= n 1) (empty? alos)) (error 'list-pick "list too short")]
[(and (> n 1) (empty? alos)) (error 'list-pick "list too short")]
[(and (= n 1) (cons? alos)) (first alos)]
[(and (> n 1) (cons? alos)) (list-pick (rest alos) (sub1 n))])) | false |
c1686819934e7b065d111e4fe1b5a5c5d6d400a3 | 8ffdf1b02043d1a8bdeede2eb241c93099418560 | /examples/wordle.rkt | 1834de121cb4803425178a3f48cecbd428269451 | [
"MIT"
]
| permissive | stchang/racketscript-playground | b1fd5c55ac22180ef4effca3a7436dff1f52f42b | 11d085a8c2aef6803b4dec0f11359e570374e2ab | refs/heads/master | 2023-06-27T21:43:24.322084 | 2023-06-13T17:25:59 | 2023-06-13T17:25:59 | 124,291,355 | 0 | 0 | MIT | 2018-03-07T20:35:23 | 2018-03-07T20:35:23 | null | UTF-8 | Racket | false | false | 13,120 | rkt | wordle.rkt | #lang racket
(require racketscript/htdp/universe
racketscript/htdp/image
"wordle-words.rkt")
;; game constants
(define ALL-WORDS WORDLE-WORDS) ; see wordle-words.rkt
(define NUM-WORDS (length ALL-WORDS))
(define MAX-GUESSES 6)
(define WORD-LENGTH 5)
;; game state -----------------------------------------------------------------
;; Game State:
;; - guess: Listof lowercase strings
;; - current-guess: lowercase string
(struct game (guesses current-guess) #:transparent)
; use some global vars to keep code cleaner
(define ACTIVE-GAME #f)
(define ANSWER "")
(define (mk-start-state)
(set! ACTIVE-GAME #t)
(set! ANSWER (random-word))
(game '() ""))
(define (random-word)
(list-ref ALL-WORDS (random NUM-WORDS)))
(define (game-over? guesses)
(or (and (not (empty? guesses))
(string=? (car guesses) ANSWER))
(= (length guesses) MAX-GUESSES)))
(define (game-update-current g guess)
(game
(game-guesses g)
guess))
(define (game-submit-guess g)
(define guesses (game-guesses g))
(define current (game-current-guess g))
(define current-length (string-length current))
;; only accept if guess is correct length and in word list
(cond
[(and (= current-length 5) (member current ALL-WORDS))
(when (game-over? (cons current guesses))
(printf "ANSWER: ~a\n" (string-upcase ANSWER))
(set! ACTIVE-GAME #f))
(game (cons current guesses) "")]
[else g]))
(define (game-del-char g)
(define current (game-current-guess g))
(define current-length (string-length current))
(game-update-current g
(if (zero? current-length)
""
(substring current 0 (sub1 current-length)))))
(define (game-add-char g k)
(define current (game-current-guess g))
(define current-length (string-length current))
(game-update-current g
(if (= current-length 5)
current
(string-append current (string-downcase k)))))
;; game rendering constants ---------------------------------------------------
(define EMPTY-CANVAS (empty-scene 320 452))
(define WRONG-COLOR "black")
(define CORRECT-COLOR "dark green")
(define MAYBE-COLOR "medium yellow")
(define GUESS-TILE-HEIGHT 50)
(define GAP 8)
(define CHARGAP (rectangle GAP 0 'outline 'white))
(define LINEGAP (rectangle 0 GAP 'outline 'white))
(define BLANK (square GUESS-TILE-HEIGHT 'outline 'gray))
(define GUESS-CHAR-FONT-SIZE 32)
(define CURRENT-CHAR-VALID-COLOR "blue")
(define CURRENT-CHAR-INVALID-COLOR "black")
(define GUESS-CHAR-COLOR "white")
;; helper functions -----------------------------------------------------------
;; repeat : Duplicates the given `x` `n` times, in a list
(define (repeat x n) (for/list ([m n]) x))
;; img-join : combines given `imgs` lst, separated by `sep`, using `combiner` fn
;; - result begins and ends with sep
(define (img-join imgs sep combiner)
(for/fold ([img sep])
([i imgs])
(combiner img i sep)))
;; render fns -----------------------------------------------------------------
(define (render g)
(if ACTIVE-GAME
(render-active g)
(render-inactive g)))
(define (render-active g)
(define guesses (game-guesses g))
(define current (game-current-guess g))
(above
(render-guesses guesses)
(render-current current)
(render-blanks (- MAX-GUESSES (length guesses)))
(render-keyboard guesses)))
(define (render-inactive g)
(overlay/align "middle" "top"
(above/align "left"
(render-guesses (game-guesses g))
(text "ANSWER:" 10 'black)
(beside
(rectangle 20 0 'outline 'white)
(text (string-upcase ANSWER) GUESS-CHAR-FONT-SIZE CORRECT-COLOR)
(rectangle 40 0 'outline 'white)
(overlay
(text "PLAY AGAIN" KEYBOARD-FONT-SIZE 'black)
(rectangle 100 40 'outline 'black)))
LINEGAP
(text " Click or press ENTER to play again" KEYBOARD-FONT-SIZE 'black))
EMPTY-CANVAS))
;; render guesses --------------------
(define (render-guesses guesses)
(for/fold ([img LINEGAP])
([guess guesses])
;; last guess is first, so render bottom to top
(above LINEGAP
(render-guess guess)
img)))
;; word is string of WORD-LENGTH
(define (render-guess word)
(img-join
(for/list ([c word]
[col (compute-guess-colors word)])
(guesschar->tile c col))
CHARGAP
beside))
;; compute-guess-colors : string -> list of color
;; - input is a string of 5 chars
;; - output possible colors are CORRECT-COLOR, MAYBE-COLOR, OR WRONG-COLOR
(define (compute-guess-colors word)
;; remaining-letters is bookkeeping vector to track which letters in ANSWER
;; have been used (marked by USED-LETTER char) to color a guess letter
;; - gets reset before coloring each guess
;; TODO: better data structure for this?
;; - need both letters and position info
(define remaining-letters (list->vector (string->list ANSWER)))
;; compute guess colors in 2 passes
; 1) compute CORRECT letters first bc MAYBE colors depend on this
; partial-colors is vector where elements are either:
; - CORRECT-COLOR: for chars in correct position
; - WRONG-COLOR (temporarily)
; It's a temporary data structure that is result of first pass
(define partial-colors
(for/vector ([(c i) (in-indexed word)]
[expected ANSWER])
(cond [(char=? c expected)
(mark-used! remaining-letters i)
CORRECT-COLOR]
[else WRONG-COLOR])))
; 2) compute MAYBE or WRONG colors
; tile gets MAYBE-COLOR if in answer but not already in a correct position
(for/list ([col partial-colors]
[(c i) (in-indexed word)]
[expected ANSWER])
(cond [(equal? col CORRECT-COLOR) CORRECT-COLOR] ; dont touch already correct
[(vector-member c remaining-letters)
(mark-used! remaining-letters c)
MAYBE-COLOR]
[else WRONG-COLOR])))
; mark a letter in the answer as "used" when it's already handled
; to avoid double-counting
(define USED-LETTER "-")
;; mark-used: updates bookkeeping vector
;; vec: vector of chars, or USED-LETTER to indicate
;; c/i: char or index pos to update
(define (mark-used! vec c/i)
(if (number? c/i) ; update at exact index, if given
(vector-set! vec c/i USED-LETTER)
(for/first ([j (vector-length vec)] ; else must find the char
#:when (equal? (vector-ref vec j) c/i))
(vector-set! vec j USED-LETTER))))
;; input is (lowercase) char
(define (guesschar->tile c tile-color)
(overlay
(char->img c GUESS-CHAR-COLOR)
(mk-guess-tile tile-color)))
(define (char->img c color)
(text (char->string c) GUESS-CHAR-FONT-SIZE color))
(define (char->string c) (string-upcase (string c)))
(define (mk-guess-tile color)
(square GUESS-TILE-HEIGHT "solid" color))
;; render current --------------------
(define (render-current word)
(img-join
(append
(map
(if (member word ALL-WORDS)
valid-char->tile
char->tile)
(string->list word))
(repeat BLANK (- WORD-LENGTH (string-length word))))
CHARGAP
beside))
(define (char->tile c)
(overlay
(char->img c CURRENT-CHAR-INVALID-COLOR)
BLANK))
(define (valid-char->tile c)
(overlay
(char->img c CURRENT-CHAR-VALID-COLOR)
BLANK))
(define BLANK-WORD (render-current ""))
(define (render-blanks guesses-remaining)
(for/fold ([img LINEGAP])
([n (sub1 guesses-remaining)]) ; sub1 to account for current
(above img BLANK-WORD LINEGAP)))
;; render keyboard --------------------
(define KEYBOARD-1ST-ROW '(q w e r t y u i o p))
(define KEYBOARD-2ND-ROW '(a s d f g h j k l))
(define KEYBOARD-3RD-ROW '(z x c v b n m))
(define KEYBOARD
(list KEYBOARD-1ST-ROW
KEYBOARD-2ND-ROW
KEYBOARD-3RD-ROW))
(define KEY-HEIGHT 32)
(define KEYBOARD-FONT-SIZE 14)
(define ENTER-KEY
(overlay
(rectangle (* 1.5 KEY-HEIGHT) KEY-HEIGHT 'outline 'gray)
(text "ENTER" 10 'black)))
(define BACKSPACE-KEY
(overlay
(rectangle (* 1.5 KEY-HEIGHT) KEY-HEIGHT 'outline 'gray)
(text "Backspace" 8 'black)))
(define (render-keyboard guesses)
(above
(keys->img KEYBOARD-1ST-ROW guesses)
(keys->img KEYBOARD-2ND-ROW guesses)
(beside
ENTER-KEY
(keys->img KEYBOARD-3RD-ROW guesses)
BACKSPACE-KEY)))
(define (keys->img ks guesses)
(apply
beside
(for/list ([k ks])
(key->img k guesses))))
(define (key->img sym guesses)
(define tile-col (key-color (symbol->string sym) guesses))
(overlay
(text
(string-upcase (symbol->string sym))
KEYBOARD-FONT-SIZE
(if (equal? tile-col "white") "black" "white"))
(mk-key-tile tile-col)))
(define (mk-key-tile color)
(if (equal? color "white")
(square KEY-HEIGHT 'outline 'gray)
(square KEY-HEIGHT 'solid color)))
(define (key-color k guesses)
(cond
[(correct-char? k guesses) CORRECT-COLOR]
[(maybe-char? k guesses) MAYBE-COLOR]
[(wrong-char? k guesses) WRONG-COLOR]
[else "white"]))
;; k : 1 char string
;; guesses: list of string
;; returns true if letter k is in answer and some guess, in correct position
(define (correct-char? k guesses)
(for/or ([g guesses])
(for/or ([x g] [y ANSWER])
(and (equal? x y)
(equal? (string x) k)))))
;; k : 1 char string
;; guesses: list of string
;; returns true if letter k is in answer and some guess
(define (maybe-char? k guesses)
(and (string-contains? ANSWER k)
(for/or ([g guesses])
(string-contains? g k))))
;; k : 1 char string
;; guesses: list of string
;; returns true if letter k is in some guess but not in answer
(define (wrong-char? k guesses)
(and (for/or ([g guesses])
(string-contains? g k))
(not (string-contains? ANSWER k))))
;; process-char --------------------------------------------------------------------
(define (process-key g k)
(cond
[(key=? k "\r") ; return
(if ACTIVE-GAME
(game-submit-guess g)
(mk-start-state))]
[(key=? k "\b") ; backspace
(game-del-char g)]
[(valid-char? k) ; A-Z,a-z
(game-add-char g k)]
[else g]))
(define (valid-char? k)
(and (= 1 (string-length k))
(regexp-match? #px"[A-Za-z]" k)))
;; process mouse --------------------------------------------------------------
(define (handle-mouse g x y evt)
(cond
[(mouse=? evt "button-down")
(cond [(and (not ACTIVE-GAME) (mouse-play-again? (game-guesses g) y))
(mk-start-state)]
[(mouse-in-1st-row? x y) (game-add-char g (row1->char x))]
[(mouse-in-2nd-row? x y) (game-add-char g (row2->char x))]
[(mouse-in-3rd-row? x y) (game-add-char g (row3->char x))]
[(mouse-enter? x y) (game-submit-guess g)]
[(mouse-backspace? x y) (game-del-char g)]
[else g])]
[else g]))
(define KEYBOARD-Y-START 356)
(define KEYBOARD-Y1-START KEYBOARD-Y-START)
(define KEYBOARD-Y1-END (+ KEYBOARD-Y1-START KEY-HEIGHT))
(define KEYBOARD-Y2-START KEYBOARD-Y1-END)
(define KEYBOARD-Y2-END (+ KEYBOARD-Y2-START KEY-HEIGHT))
(define KEYBOARD-Y3-START KEYBOARD-Y2-END)
(define KEYBOARD-Y3-END (+ KEYBOARD-Y3-START KEY-HEIGHT))
(define KEYBOARD-Y-END KEYBOARD-Y3-END) ; should be 3 rows = 452
(define KEYBOARD-X1-START 0)
(define KEYBOARD-X1-END
(+ KEYBOARD-X1-START (* (length (first KEYBOARD)) KEY-HEIGHT)))
(define KEYBOARD-X2-START
(+ KEYBOARD-X1-START (/ KEY-HEIGHT 2)))
(define KEYBOARD-X2-END
(+ KEYBOARD-X2-START (* (length (second KEYBOARD)) KEY-HEIGHT)))
(define KEYBOARD-X3-START
(+ KEYBOARD-X2-START KEY-HEIGHT))
(define KEYBOARD-X3-END
(+ KEYBOARD-X3-START (* (length (third KEYBOARD)) KEY-HEIGHT)))
;; check roughly whether mouse clicking "play again" button
(define (mouse-play-again? guesses y)
;; adjust y upwards, depending on how many guesses were made
(define y-adjustment
(* (- MAX-GUESSES (length guesses))
(+ GUESS-TILE-HEIGHT GAP)))
(<= (- KEYBOARD-Y-START y-adjustment) y KEYBOARD-Y-END))
(define (mouse-in-1st-row? x y)
(and (< KEYBOARD-Y1-START y KEYBOARD-Y1-END)
(< KEYBOARD-X1-START x KEYBOARD-X1-END)))
(define (mouse-in-2nd-row? x y)
(and (< KEYBOARD-Y2-START y KEYBOARD-Y2-END)
(< KEYBOARD-X2-START x KEYBOARD-X2-END)))
(define (mouse-in-3rd-row? x y)
(and (< KEYBOARD-Y3-START y KEYBOARD-Y3-END)
(< KEYBOARD-X3-START x KEYBOARD-X3-END)))
(define (mouse-enter? x y) ; in 3rd row
(and (< KEYBOARD-Y3-START y KEYBOARD-Y3-END)
(< 0 x (* 1.5 KEY-HEIGHT))))
(define (mouse-backspace? x y) ; in 3rd row
(and (< KEYBOARD-Y3-START y KEYBOARD-Y3-END)
(< KEYBOARD-X3-END x (+ KEYBOARD-X3-END (* 1.5 KEY-HEIGHT)))))
(define (row1->char x)
(symbol->string
(list-ref (first KEYBOARD) (quotient x KEY-HEIGHT))))
(define (row2->char x)
(symbol->string
(list-ref (second KEYBOARD) (quotient (- x KEYBOARD-X2-START) KEY-HEIGHT))))
(define (row3->char x)
(symbol->string
(list-ref (third KEYBOARD) (quotient (- x KEYBOARD-X3-START) KEY-HEIGHT))))
;; start the game ----------------------------------------------------------
(big-bang (mk-start-state)
(to-draw render)
(on-key process-key)
(on-mouse handle-mouse)) | false |
caf38f34fcd2c0e03ed7e8e2423768d93c8d2388 | 04d3f2a238af3f50bff5a2fe2b5d8113cdceace8 | /software/big-o.rkt | 3da33d74eac6164d1b8698e770f3ef6cf1182edb | []
| no_license | neu-cs4800s13/public | 8571de8ad77ecfcd588b7cf89f508defcb3876f1 | 97f3bddba2d1ab44a0df32d8372b9861916ac615 | refs/heads/master | 2021-01-19T13:46:16.689367 | 2013-04-16T21:20:42 | 2013-04-16T21:20:42 | 7,541,574 | 1 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 957 | rkt | big-o.rkt | #lang racket
(provide O? random-number random-small-number random-big-number)
;; O? : (Number -> Number) (Number -> Number) Number Number
;; Optional fifth argument: (-> Number)
;; Checks if f(n) is in O(g(n)).
;; Specifically, tests for any (random) n > n0,
;; f(n) <= c * g(n).
(define (O? f g c n0 [choose-big-number random-big-number])
(define k (random-number))
(for/and {[trial (in-range 1 k)]}
(let {[n (+ n0 (choose-big-number))]}
(<= (f n) (* c (g n))))))
(define (random-number)
(+ 1 (random 10)))
(define (random-big-number)
(expt 10 (random-number)))
(define (random-small-number)
(random 10))
(module+ main
(require rackunit)
(check-equal?
(O? (lambda (n) (expt n 2)) (lambda (n) (expt n 3)) 1 1)
#true)
(check-equal?
(O? (lambda (n) (expt n 3)) (lambda (n) (expt n 2)) 1 1)
#false)
(check-equal?
(O? (lambda (n) (expt n 3)) (lambda (n) (expt n 2)) 1 1 random-small-number)
#false))
| false |
67e3aefe2b90d242c2f39e8b32212defb5cdb186 | 52c2225c9f44c0da28ca1fd44606a8d197c8eac8 | /EOPL/ch2/env-data-structure-test.rkt | 0f9d980d91696632b9ca0cb3555c59359226f929 | []
| no_license | alanzplus/EOPL | c74c1e9dd27c0580107fd860b88016320a6f231c | d7b06392d26d93df851d0ca66d9edc681a06693c | refs/heads/master | 2021-06-20T00:59:21.685904 | 2019-08-15T06:18:10 | 2019-08-15T07:06:53 | 147,045,798 | 8 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 381 | rkt | env-data-structure-test.rkt | #lang eopl
(require rackunit "env-data-structure.rkt")
(require rackunit/text-ui)
(define env-test
(test-suite
"Tests for env"
(check-equal? (empty-env) (list 'empty-env))
(check-equal?
(extend-env 'a 10 empty-env)
(list 'extend-env 'a 10 empty-env))
(check-equal?
(apply-env (extend-env 'a 10 empty-env) 'a)
10)))
(run-tests env-test)
| false |
b04c0616d2c56447b38552b52db322499969452a | 3e36e8e705b24acd5badca1ee64346774c3ee45a | /db-lib/db/util/geometry.rkt | 5c69e6e659f6f62824e3f53d838d7255b4ad1b40 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | racket/db | 91527b25740d1f19bac2ce46104eb05c1120eb99 | bcf2fe2e2c42ede54c0eea616334e432de1a4fa4 | refs/heads/master | 2023-08-29T21:00:14.532430 | 2022-07-25T23:05:44 | 2022-07-26T00:22:36 | 27,431,270 | 21 | 20 | NOASSERTION | 2022-09-03T19:45:06 | 2014-12-02T12:21:02 | Racket | UTF-8 | Racket | false | false | 825 | rkt | geometry.rkt | #lang racket/base
(require racket/contract/base
"private/geometry.rkt")
(provide/contract
[struct point ([x real?] [y real?])]
[struct line-string ([points (listof point?)])]
[struct polygon ([exterior linear-ring?]
[interiors (listof linear-ring?)])]
[struct multi-point ([elements (listof point?)])]
[struct multi-line-string ([elements (listof line-string?)])]
[struct multi-polygon ([elements (listof polygon?)])]
[struct geometry-collection ([elements (listof geometry2d?)])]
[line? (-> any/c boolean?)]
[linear-ring? (-> any/c boolean?)]
[geometry2d? (-> any/c boolean?)]
[geometry->wkb
(->* (geometry2d?)
(#:big-endian? any/c)
bytes?)]
[wkb->geometry
(->* (bytes?)
(exact-nonnegative-integer?
exact-nonnegative-integer?)
geometry2d?)])
| false |
2b0efce4b5af646d59470a313ba955af23062b95 | d0ea449400a715f50fd720c265d2b923c34bc464 | /digitama/unsafe/bitmap.rkt | ac206cd21797234a754fb13888f278842a366808 | []
| no_license | wargrey/psd | c3d69b8c7d6577cdac9be433be832e80d2bb32d4 | 73b16a52e0777250d02e977f7dcbd7c1d98ef772 | refs/heads/master | 2020-12-02T06:26:02.875227 | 2018-07-16T11:00:58 | 2018-07-16T11:00:58 | 96,830,933 | 1 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 4,111 | rkt | bitmap.rkt | #lang typed/racket/base
(require typed/racket/unsafe)
(require "../draw.rkt")
(module unsafe racket/base
(provide (all-defined-out))
(require racket/draw/unsafe/cairo)
(require racket/unsafe/ops)
(require (only-in racket/class send))
(require (only-in racket/draw make-bitmap))
(require (only-in racket/math exact-ceiling))
(define (planar-data->bitmap planar-data width height channels density)
(define-values (bmp surface) (make-argb-image width height density))
(define pixels (cairo_image_surface_get_data surface))
(define stride (cairo_image_surface_get_stride surface))
(when (unsafe-fx= channels 3) (bytes-fill! pixels #xFF))
(if (bytes? planar-data)
(case channels
[(3) (fill-argb-from-rgba! pixels planar-data width height stride fill-rgb!)]
[(4) (fill-argb-from-rgba! pixels planar-data width height stride fill-argb!)])
(case channels
[(3) (fill-argb-from-rgba*! pixels planar-data width height stride channels)]
[(4) (fill-argb-from-rgba*! pixels planar-data width height stride channels)]))
(cairo_surface_mark_dirty surface)
bmp)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-values (A R G B) (if (system-big-endian?) (values 0 1 2 3) (values 3 2 1 0)))
(define (fill-argb-from-rgba! pixels source width height stride fill-pixel!)
(define total (unsafe-fx* width height))
(let fill! ([src-idx 0])
(when (unsafe-fx< src-idx total)
(define row (unsafe-fxquotient src-idx width))
(define col (unsafe-fxremainder src-idx width))
(fill-pixel! pixels (unsafe-fx+ (unsafe-fx* row stride) (unsafe-fx* col 4)) source src-idx total)
(fill! (unsafe-fx+ src-idx 1)))))
(define (fill-argb-from-rgba*! pixels sources width height stride channels)
(let fill! ([rest sources] [row 0] [channel-idx 0])
(when (unsafe-fx< channel-idx channels)
(define channel (case channel-idx [(0) R] [(1) G] [(2) B] [else A]))
(define offset (unsafe-fx* row stride))
(define src (unsafe-car rest))
(let subfill! ([col 0])
(when (unsafe-fx< col width)
(define dest-idx (unsafe-fx+ offset (unsafe-fx* col 4)))
(unsafe-bytes-set! pixels (unsafe-fx+ dest-idx channel) (unsafe-bytes-ref src col))
(subfill! (unsafe-fx+ col 1))))
(if (unsafe-fx= (unsafe-fx+ row 1) height)
(fill! (unsafe-cdr rest) 0 (unsafe-fx+ channel-idx 1))
(fill! (unsafe-cdr rest) (unsafe-fx+ row 1) channel-idx)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (~size size density) (exact-ceiling (/ size density)))
(define (make-argb-image width height density)
(define img (make-bitmap (~size width density) (~size height density) #true #:backing-scale density))
(define surface (send img get-handle))
(when (not surface)
(raise-arguments-error 'planar-data->bitmap "image is too big"
"width" width "height" height
"density" density))
(values img surface))
(define (fill-rgb! pixels dest-idx source src-idx total)
(unsafe-bytes-set! pixels (unsafe-fx+ dest-idx R) (unsafe-bytes-ref source (unsafe-fx+ src-idx (unsafe-fx* total 0))))
(unsafe-bytes-set! pixels (unsafe-fx+ dest-idx G) (unsafe-bytes-ref source (unsafe-fx+ src-idx (unsafe-fx* total 1))))
(unsafe-bytes-set! pixels (unsafe-fx+ dest-idx B) (unsafe-bytes-ref source (unsafe-fx+ src-idx (unsafe-fx* total 2)))))
(define (fill-argb! pixels dest-idx source src-idx total)
(fill-rgb! pixels dest-idx source src-idx total)
(unsafe-bytes-set! pixels (unsafe-fx+ dest-idx A) (unsafe-bytes-ref source (unsafe-fx+ src-idx (unsafe-fx* total 3))))))
(unsafe-require/typed/provide
(submod "." unsafe)
[~size (-> Positive-Index Positive-Real Positive-Index)]
[planar-data->bitmap (-> (U Bytes (Listof Bytes)) Positive-Fixnum Positive-Fixnum Byte Positive-Real (Instance Bitmap%))])
| false |
4148690719ddab2ee7bbff2e36b23acc0a6e8c77 | 6582bfe2990716ee85fb69338aebf1abaa158bc0 | /brag-lib/brag/test/test-top-level-cut.rkt | 2483999a579022de38438cbc49a350df51960cd9 | [
"MIT"
]
| permissive | mbutterick/brag | 2a3962b8d4ed80488812caae870b852a44c247d8 | f52c2a80c9cb6840b96532c2ca1371d12aea61e7 | refs/heads/master | 2022-06-03T00:15:21.317870 | 2022-02-09T18:04:04 | 2022-02-09T18:04:04 | 82,710,347 | 67 | 15 | MIT | 2022-03-16T01:04:27 | 2017-02-21T17:57:12 | Racket | UTF-8 | Racket | false | false | 366 | rkt | test-top-level-cut.rkt | #lang racket/base
(require (prefix-in 1: brag/examples/top-level-cut-1)
(prefix-in 2: brag/examples/top-level-cut-2)
(prefix-in 3: brag/examples/top-level-cut-3)
brag/support
rackunit)
(check-equal? (1:parse-to-datum "x") '((sub "x")))
(check-equal? (2:parse-to-datum "x") '(("x")))
(check-equal? (3:parse-to-datum "x") '("x"))
| false |
0b2ebd5f466bc0e622096e99c8347e9293065da4 | bcd5720173bd10e7b22b7363b9ce7876e765091b | /tests/cmd.rkt | 4e9cf5ae2a8a75d7cf3759438a99888fd6e103e8 | []
| no_license | yixizhang/racket-gc | 6c42f72c1f394ab0297bafffadf84cea64686d3d | 9d7577fc57aff0fcd05363991819568feb18fef0 | refs/heads/master | 2021-01-20T12:35:12.949612 | 2013-09-13T18:06:33 | 2013-09-13T18:06:33 | 9,301,206 | 5 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 241 | rkt | cmd.rkt | #lang plai/gc2/mutator
(allocator-setup "collector.rkt" 512)
(import-primitives
current-command-line-arguments)
(define args (current-command-line-arguments))
(if (> (vector-length args) 0)
(vector-ref args 0)
(printf "no args\n")) | false |
c41bd0e73607804ff937c6c296d22004971f1e39 | c01a4c8a6cee08088b26e2a2545cc0e32aba897b | /contrib/medikanren/pieces-parts/rank-regulators-gene-lists.rkt | cdc434265b206cff518a3534a5539d8ae382ecab | [
"MIT"
]
| permissive | webyrd/mediKanren | c8d25238db8afbaf8c3c06733dd29eb2d7dbf7e7 | b3615c7ed09d176e31ee42595986cc49ab36e54f | refs/heads/master | 2023-08-18T00:37:17.512011 | 2023-08-16T00:53:29 | 2023-08-16T00:53:29 | 111,135,120 | 311 | 48 | MIT | 2023-08-04T14:25:49 | 2017-11-17T18:03:59 | Racket | UTF-8 | Racket | false | false | 105,514 | rkt | rank-regulators-gene-lists.rkt | #lang racket
(provide ards-genes
NGLY1-underexpressed
NGLY1-overexpressed)
(define ards-genes '("ENSEMBL:ENSG00000167972"
"ENSEMBL:ENSG00000198691"
"ENSEMBL:ENSG00000175164"
"ENSEMBL:ENSG00000278540"
"ENSEMBL:ENSG00000100412"
"ENSEMBL:ENSG00000162104"
"ENSEMBL:ENSG00000204305"
"ENSEMBL:ENSG00000135744"
"ENSEMBL:ENSG00000144891"
"ENSEMBL:ENSG00000180772"
"ENSEMBL:ENSG00000142208"
"ENSEMBL:ENSG00000148218"
"ENSEMBL:ENSG00000163631"
"ENSEMBL:ENSG00000085662"
"ENSEMBL:ENSG00000154188"
"ENSEMBL:ENSG00000091879"
"ENSEMBL:ENSG00000182718"
"ENSEMBL:ENSG00000134982"
"ENSEMBL:ENSG00000132703"
"ENSEMBL:ENSG00000023445"
"ENSEMBL:ENSG00000142515"
"ENSEMBL:ENSG00000026103"
"ENSEMBL:ENSG00000117560"
"ENSEMBL:ENSG00000240583"
"ENSEMBL:ENSG00000161798"
"ENSEMBL:ENSG00000006756"
"ENSEMBL:ENSG00000117601"
"ENSEMBL:ENSG00000149311"
"ENSEMBL:ENSG00000164904"
"ENSEMBL:ENSG00000171791"
"ENSEMBL:ENSG00000101144"
"ENSEMBL:ENSG00000010671"
"ENSEMBL:ENSG00000100300"
"ENSEMBL:ENSG00000149131"
"ENSEMBL:ENSG00000171860"
"ENSEMBL:ENSG00000106804"
"ENSEMBL:ENSG00000197405"
"ENSEMBL:ENSG00000149823"
"ENSEMBL:ENSG00000063180"
"ENSEMBL:ENSG00000164305"
"ENSEMBL:ENSG00000121691"
"ENSEMBL:ENSG00000105974"
"ENSEMBL:ENSG00000124813"
"ENSEMBL:ENSG00000149257"
"ENSEMBL:ENSG00000134057"
"ENSEMBL:ENSG00000170458"
"ENSEMBL:ENSG00000121594"
"ENSEMBL:ENSG00000101017"
"ENSEMBL:ENSG00000102245"
"ENSEMBL:ENSG00000026508"
"ENSEMBL:ENSG00000085063"
"ENSEMBL:ENSG00000129226"
"ENSEMBL:ENSG00000179776"
"ENSEMBL:ENSG00000100526"
"ENSEMBL:ENSG00000170835"
"ENSEMBL:ENSG00000001626"
"ENSEMBL:ENSG00000133019"
"ENSEMBL:ENSG00000196811"
"ENSEMBL:ENSG00000099622"
"ENSEMBL:ENSG00000122705"
"ENSEMBL:ENSG00000183813"
"ENSEMBL:ENSG00000188153"
"ENSEMBL:ENSG00000115966"
"ENSEMBL:ENSG00000167193"
"ENSEMBL:ENSG00000132693"
"ENSEMBL:ENSG00000118231"
"ENSEMBL:ENSG00000112062"
"ENSEMBL:ENSG00000101439"
"ENSEMBL:ENSG00000118523"
"ENSEMBL:ENSG00000168036"
"ENSEMBL:ENSG00000100448"
"ENSEMBL:ENSG00000166347"
"ENSEMBL:ENSG00000140465"
"ENSEMBL:ENSG00000140505"
"ENSEMBL:ENSG00000138061"
"ENSEMBL:ENSG00000160870"
"ENSEMBL:ENSG00000106258"
"ENSEMBL:ENSG00000196730"
"ENSEMBL:ENSG00000011465"
"ENSEMBL:ENSG00000159640"
"ENSEMBL:ENSG00000164825"
"ENSEMBL:ENSG00000197766"
"ENSEMBL:ENSG00000181019"
"ENSEMBL:ENSG00000213918"
"ENSEMBL:ENSG00000197635"
"ENSEMBL:ENSG00000164330"
"ENSEMBL:ENSG00000213694"
"ENSEMBL:ENSG00000078401"
"ENSEMBL:ENSG00000138798"
"ENSEMBL:ENSG00000197561"
"ENSEMBL:ENSG00000021355"
"ENSEMBL:ENSG00000066044"
"ENSEMBL:ENSG00000116016"
"ENSEMBL:ENSG00000133216"
"ENSEMBL:ENSG00000120915"
"ENSEMBL:ENSG00000130427"
"ENSEMBL:ENSG00000157554"
"ENSEMBL:ENSG00000157557"
"ENSEMBL:ENSG00000180210"
"ENSEMBL:ENSG00000117525"
"ENSEMBL:ENSG00000198734"
"ENSEMBL:ENSG00000117480"
"ENSEMBL:ENSG00000166147"
"ENSEMBL:ENSG00000151422"
"ENSEMBL:ENSG00000140285"
"ENSEMBL:ENSG00000160867"
"ENSEMBL:ENSG00000111206"
"ENSEMBL:ENSG00000115414"
"ENSEMBL:ENSG00000170345"
"ENSEMBL:ENSG00000154727"
"ENSEMBL:ENSG00000163288"
"ENSEMBL:ENSG00000128683"
"ENSEMBL:ENSG00000141448"
"ENSEMBL:ENSG00000168621"
"ENSEMBL:ENSG00000134812"
"ENSEMBL:ENSG00000265107"
"ENSEMBL:ENSG00000173221"
"ENSEMBL:ENSG00000147437"
"ENSEMBL:ENSG00000186810"
"ENSEMBL:ENSG00000167701"
"ENSEMBL:ENSG00000113580"
"ENSEMBL:ENSG00000082701"
"ENSEMBL:ENSG00000132518"
"ENSEMBL:ENSG00000145649"
"ENSEMBL:ENSG00000100453"
"ENSEMBL:ENSG00000148702"
"ENSEMBL:ENSG00000084754"
"ENSEMBL:ENSG00000019991"
"ENSEMBL:ENSG00000100644"
"ENSEMBL:ENSG00000189403"
"ENSEMBL:ENSG00000100292"
"ENSEMBL:ENSG00000125798"
"ENSEMBL:ENSG00000135486"
"ENSEMBL:ENSG00000257017"
"ENSEMBL:ENSG00000113905"
"ENSEMBL:ENSG00000176387"
"ENSEMBL:ENSG00000204389"
"ENSEMBL:ENSG00000204388"
"ENSEMBL:ENSG00000170606"
"ENSEMBL:ENSG00000070614"
"ENSEMBL:ENSG00000041982"
"ENSEMBL:ENSG00000090339"
"ENSEMBL:ENSG00000185745"
"ENSEMBL:ENSG00000171855"
"ENSEMBL:ENSG00000111537"
"ENSEMBL:ENSG00000006652"
"ENSEMBL:ENSG00000017427"
"ENSEMBL:ENSG00000146674"
"ENSEMBL:ENSG00000167779"
"ENSEMBL:ENSG00000104365"
"ENSEMBL:ENSG00000115008"
"ENSEMBL:ENSG00000125538"
"ENSEMBL:ENSG00000115594"
"ENSEMBL:ENSG00000136689"
"ENSEMBL:ENSG00000109471"
"ENSEMBL:ENSG00000134460"
"ENSEMBL:ENSG00000113520"
"ENSEMBL:ENSG00000136244"
"ENSEMBL:ENSG00000168685"
"ENSEMBL:ENSG00000169429"
"ENSEMBL:ENSG00000136634"
"ENSEMBL:ENSG00000169194"
"ENSEMBL:ENSG00000112115"
"ENSEMBL:ENSG00000150782"
"ENSEMBL:ENSG00000169245"
"ENSEMBL:ENSG00000125347"
"ENSEMBL:ENSG00000005884"
"ENSEMBL:ENSG00000169896"
"ENSEMBL:ENSG00000160255"
"ENSEMBL:ENSG00000115474"
"ENSEMBL:ENSG00000128052"
"ENSEMBL:ENSG00000171345"
"ENSEMBL:ENSG00000172037"
"ENSEMBL:ENSG00000148346"
"ENSEMBL:ENSG00000115850"
"ENSEMBL:ENSG00000131981"
"ENSEMBL:ENSG00000138039"
"ENSEMBL:ENSG00000105370"
"ENSEMBL:ENSG00000226979"
"ENSEMBL:ENSG00000160932"
"ENSEMBL:ENSG00000183918"
"ENSEMBL:ENSG00000277443"
"ENSEMBL:ENSG00000166949"
"ENSEMBL:ENSG00000165471"
"ENSEMBL:ENSG00000143384"
"ENSEMBL:ENSG00000014641"
"ENSEMBL:ENSG00000110492"
"ENSEMBL:ENSG00000095015"
"ENSEMBL:ENSG00000240972"
"ENSEMBL:ENSG00000138755"
"ENSEMBL:ENSG00000087245"
"ENSEMBL:ENSG00000149968"
"ENSEMBL:ENSG00000100985"
"ENSEMBL:ENSG00000005381"
"ENSEMBL:ENSG00000130830"
"ENSEMBL:ENSG00000125148"
"ENSEMBL:ENSG00000087250"
"ENSEMBL:ENSG00000171100"
"ENSEMBL:ENSG00000210195"
"ENSEMBL:ENSG00000185499"
"ENSEMBL:ENSG00000215182"
"ENSEMBL:ENSG00000136997"
"ENSEMBL:ENSG00000172936"
"ENSEMBL:ENSG00000109063"
"ENSEMBL:ENSG00000065534"
"ENSEMBL:ENSG00000116044"
"ENSEMBL:ENSG00000109320"
"ENSEMBL:ENSG00000100906"
"ENSEMBL:ENSG00000001167"
"ENSEMBL:ENSG00000089250"
"ENSEMBL:ENSG00000164867"
"ENSEMBL:ENSG00000161270"
"ENSEMBL:ENSG00000135318"
"ENSEMBL:ENSG00000111331"
"ENSEMBL:ENSG00000112038"
"ENSEMBL:ENSG00000089041"
"ENSEMBL:ENSG00000185624"
"ENSEMBL:ENSG00000007168"
"ENSEMBL:ENSG00000117450"
"ENSEMBL:ENSG00000106366"
"ENSEMBL:ENSG00000126759"
"ENSEMBL:ENSG00000197249"
"ENSEMBL:ENSG00000124102"
"ENSEMBL:ENSG00000121879"
"ENSEMBL:ENSG00000051382"
"ENSEMBL:ENSG00000171608"
"ENSEMBL:ENSG00000105851"
"ENSEMBL:ENSG00000170890"
"ENSEMBL:ENSG00000188257"
"ENSEMBL:ENSG00000116711"
"ENSEMBL:ENSG00000118495"
"ENSEMBL:ENSG00000011422"
"ENSEMBL:ENSG00000115896"
"ENSEMBL:ENSG00000075651"
"ENSEMBL:ENSG00000178209"
"ENSEMBL:ENSG00000266964"
"ENSEMBL:ENSG00000115138"
"ENSEMBL:ENSG00000186951"
"ENSEMBL:ENSG00000122862"
"ENSEMBL:ENSG00000100030"
"ENSEMBL:ENSG00000107643"
"ENSEMBL:ENSG00000169032"
"ENSEMBL:ENSG00000115718"
"ENSEMBL:ENSG00000184500"
"ENSEMBL:ENSG00000189002"
"ENSEMBL:ENSG00000135406"
"ENSEMBL:ENSG00000041357"
"ENSEMBL:ENSG00000197170"
"ENSEMBL:ENSG00000011304"
"ENSEMBL:ENSG00000073756"
"ENSEMBL:ENSG00000169398"
"ENSEMBL:ENSG00000105894"
"ENSEMBL:ENSG00000081237"
"ENSEMBL:ENSG00000113456"
"ENSEMBL:ENSG00000069974"
"ENSEMBL:ENSG00000080823"
"ENSEMBL:ENSG00000112619"
"ENSEMBL:ENSG00000173039"
"ENSEMBL:ENSG00000143839"
"ENSEMBL:ENSG00000102032"
"ENSEMBL:ENSG00000163914"
"ENSEMBL:ENSG00000067900"
"ENSEMBL:ENSG00000149489"
"ENSEMBL:ENSG00000196218"
"ENSEMBL:ENSG00000196154"
"ENSEMBL:ENSG00000163220"
"ENSEMBL:ENSG00000031698"
"ENSEMBL:ENSG00000111319"
"ENSEMBL:ENSG00000108691"
"ENSEMBL:ENSG00000108688"
"ENSEMBL:ENSG00000163735"
"ENSEMBL:ENSG00000110876"
"ENSEMBL:ENSG00000168878"
"ENSEMBL:ENSG00000168484"
"ENSEMBL:ENSG00000133661"
"ENSEMBL:ENSG00000064651"
"ENSEMBL:ENSG00000197208"
"ENSEMBL:ENSG00000166311"
"ENSEMBL:ENSG00000075618"
"ENSEMBL:ENSG00000125835"
"ENSEMBL:ENSG00000142168"
"ENSEMBL:ENSG00000112096"
"ENSEMBL:ENSG00000109610"
"ENSEMBL:ENSG00000125398"
"ENSEMBL:ENSG00000100883"
"ENSEMBL:ENSG00000168610"
"ENSEMBL:ENSG00000126561"
"ENSEMBL:ENSG00000173757"
"ENSEMBL:ENSG00000087586"
"ENSEMBL:ENSG00000067715"
"ENSEMBL:ENSG00000231925"
"ENSEMBL:ENSG00000006638"
"ENSEMBL:ENSG00000118526"
"ENSEMBL:ENSG00000120156"
"ENSEMBL:ENSG00000164362"
"ENSEMBL:ENSG00000003436"
"ENSEMBL:ENSG00000105329"
"ENSEMBL:ENSG00000198959"
"ENSEMBL:ENSG00000178726"
"ENSEMBL:ENSG00000116001"
"ENSEMBL:ENSG00000102265"
"ENSEMBL:ENSG00000136352"
"ENSEMBL:ENSG00000137462"
"ENSEMBL:ENSG00000164342"
"ENSEMBL:ENSG00000136869"
"ENSEMBL:ENSG00000127324"
"ENSEMBL:ENSG00000149809"
"ENSEMBL:ENSG00000232810"
"ENSEMBL:ENSG00000118503"
"ENSEMBL:ENSG00000067182"
"ENSEMBL:ENSG00000118194"
"ENSEMBL:ENSG00000131747"
"ENSEMBL:ENSG00000111669"
"ENSEMBL:ENSG00000128311"
"ENSEMBL:ENSG00000125482"
"ENSEMBL:ENSG00000155657"
"ENSEMBL:ENSG00000136810"
"ENSEMBL:ENSG00000198431"
"ENSEMBL:ENSG00000149021"
"ENSEMBL:ENSG00000174607"
"ENSEMBL:ENSG00000111424"
"ENSEMBL:ENSG00000112715"
"ENSEMBL:ENSG00000146469"
"ENSEMBL:ENSG00000110799"
"ENSEMBL:ENSG00000158125"
"ENSEMBL:ENSG00000164924"
"ENSEMBL:ENSG00000121966"
"ENSEMBL:ENSG00000146070"
"ENSEMBL:ENSG00000106305"
"ENSEMBL:ENSG00000050327"
"ENSEMBL:ENSG00000083168"
"ENSEMBL:ENSG00000118972"
"ENSEMBL:ENSG00000206561"
"ENSEMBL:ENSG00000184381"
"ENSEMBL:ENSG00000069764"
"ENSEMBL:ENSG00000108528"
"ENSEMBL:ENSG00000117461"
"ENSEMBL:ENSG00000134107"
"ENSEMBL:ENSG00000136908"
"ENSEMBL:ENSG00000171720"
"ENSEMBL:ENSG00000176170"
"ENSEMBL:ENSG00000111602"
"ENSEMBL:ENSG00000173805"
"ENSEMBL:ENSG00000131023"
"ENSEMBL:ENSG00000157456"
"ENSEMBL:ENSG00000162889"
"ENSEMBL:ENSG00000103671"
"ENSEMBL:ENSG00000133116"
"ENSEMBL:ENSG00000181092"
"ENSEMBL:ENSG00000100351"
"ENSEMBL:ENSG00000136156"
"ENSEMBL:ENSG00000102230"
"ENSEMBL:ENSG00000057663"
"ENSEMBL:ENSG00000134318"
"ENSEMBL:ENSG00000117592"
"ENSEMBL:ENSG00000187608"
"ENSEMBL:ENSG00000103335"
"ENSEMBL:ENSG00000165733"
"ENSEMBL:ENSG00000079999"
"ENSEMBL:ENSG00000044090"
"ENSEMBL:ENSG00000117020"
"ENSEMBL:ENSG00000105835"
"ENSEMBL:ENSG00000105246"
"ENSEMBL:ENSG00000131477"
"ENSEMBL:ENSG00000127528"
"ENSEMBL:ENSG00000167315"
"ENSEMBL:ENSG00000140092"
"ENSEMBL:ENSG00000101000"
"ENSEMBL:ENSG00000100591"
"ENSEMBL:ENSG00000160999"
"ENSEMBL:ENSG00000162493"
"ENSEMBL:ENSG00000048740"
"ENSEMBL:ENSG00000173083"
"ENSEMBL:ENSG00000196843"
"ENSEMBL:ENSG00000126264"
"ENSEMBL:ENSG00000137959"
"ENSEMBL:ENSG00000269821"
"ENSEMBL:ENSG00000083807"
"ENSEMBL:ENSG00000167114"
"ENSEMBL:ENSG00000129465"
"ENSEMBL:ENSG00000136110"
"ENSEMBL:ENSG00000256525"
"ENSEMBL:ENSG00000142082"
"ENSEMBL:ENSG00000096717"
"ENSEMBL:ENSG00000136859"
"ENSEMBL:ENSG00000172828"
"ENSEMBL:ENSG00000123415"
"ENSEMBL:ENSG00000025800"
"ENSEMBL:ENSG00000154589"
"ENSEMBL:ENSG00000177663"
"ENSEMBL:ENSG00000034677"
"ENSEMBL:ENSG00000196141"
"ENSEMBL:ENSG00000004142"
"ENSEMBL:ENSG00000113249"
"ENSEMBL:ENSG00000007952"
"ENSEMBL:ENSG00000086232"
"ENSEMBL:ENSG00000138744"
"ENSEMBL:ENSG00000163106"
"ENSEMBL:ENSG00000138375"
"ENSEMBL:ENSG00000086991"
"ENSEMBL:ENSG00000219430"
"ENSEMBL:ENSG00000138303"
"ENSEMBL:ENSG00000126524"
"ENSEMBL:ENSG00000167772"
"ENSEMBL:ENSG00000165682"
"ENSEMBL:ENSG00000101916"
"ENSEMBL:ENSG00000172458"
"ENSEMBL:ENSG00000124731"
"ENSEMBL:ENSG00000011426"
"ENSEMBL:ENSG00000135766"
"ENSEMBL:ENSG00000241635"
"ENSEMBL:ENSG00000104835"
"ENSEMBL:ENSG00000185480"
"ENSEMBL:ENSG00000110075"
"ENSEMBL:ENSG00000079691"
"ENSEMBL:ENSG00000171109"
"ENSEMBL:ENSG00000151849"
"ENSEMBL:ENSG00000126970"
"ENSEMBL:ENSG00000169241"
"ENSEMBL:ENSG00000074842"
"ENSEMBL:ENSG00000185115"
"ENSEMBL:ENSG00000136688"
"ENSEMBL:ENSG00000115350"
"ENSEMBL:ENSG00000111666"
"ENSEMBL:ENSG00000198074"
"ENSEMBL:ENSG00000283122"
"ENSEMBL:ENSG00000139946"
"ENSEMBL:ENSG00000175482"
"ENSEMBL:ENSG00000117569"
"ENSEMBL:ENSG00000130234"
"ENSEMBL:ENSG00000198026"
"ENSEMBL:ENSG00000132429"
"ENSEMBL:ENSG00000114745"
"ENSEMBL:ENSG00000060237"
"ENSEMBL:ENSG00000262246"
"ENSEMBL:ENSG00000104518"
"ENSEMBL:ENSG00000153395"
"ENSEMBL:ENSG00000146094"
"ENSEMBL:ENSG00000125779"
"ENSEMBL:ENSG00000197496"
"ENSEMBL:ENSG00000169612"
"ENSEMBL:ENSG00000138496"
"ENSEMBL:ENSG00000169962"
"ENSEMBL:ENSG00000130363"
"ENSEMBL:ENSG00000103510"
"ENSEMBL:ENSG00000106125"
"ENSEMBL:ENSG00000131653"
"ENSEMBL:ENSG00000145794"
"ENSEMBL:ENSG00000163702"
"ENSEMBL:ENSG00000100410"
"ENSEMBL:ENSG00000137691"
"ENSEMBL:ENSG00000160188"
"ENSEMBL:ENSG00000151148"
"ENSEMBL:ENSG00000137033"
"ENSEMBL:ENSG00000178473"
"ENSEMBL:ENSG00000162711"
"ENSEMBL:ENSG00000161544"
"ENSEMBL:ENSG00000153391"
"ENSEMBL:ENSG00000205359"
"ENSEMBL:ENSG00000168724"
"ENSEMBL:ENSG00000229140"
"ENSEMBL:ENSG00000165953"
"ENSEMBL:ENSG00000172967"
"ENSEMBL:ENSG00000163803"
"ENSEMBL:ENSG00000197272"
"ENSEMBL:ENSG00000175311"
"ENSEMBL:ENSG00000170782"
"ENSEMBL:ENSG00000189195"
"ENSEMBL:ENSG00000161911"
"ENSEMBL:ENSG00000197448"
"ENSEMBL:ENSG00000251562"
"ENSEMBL:ENSG00000187258"
"ENSEMBL:ENSG00000248131"
"ENSEMBL:ENSG00000284520"
"ENSEMBL:ENSG00000199133"
"ENSEMBL:ENSG00000284440"
"ENSEMBL:ENSG00000199161"
"ENSEMBL:ENSG00000207608"
"ENSEMBL:ENSG00000207625"
"ENSEMBL:ENSG00000207782"
"ENSEMBL:ENSG00000283904"
"ENSEMBL:ENSG00000283815"
"ENSEMBL:ENSG00000284204"
"ENSEMBL:ENSG00000207607"
"ENSEMBL:ENSG00000199038"
"ENSEMBL:ENSG00000207702"
"ENSEMBL:ENSG00000207590"
"ENSEMBL:ENSG00000207798"
"ENSEMBL:ENSG00000207870"
"ENSEMBL:ENSG00000284567"
"ENSEMBL:ENSG00000199075"
"ENSEMBL:ENSG00000199121"
"ENSEMBL:ENSG00000207808"
"ENSEMBL:ENSG00000207864"
"ENSEMBL:ENSG00000207827"
"ENSEMBL:ENSG00000207582"
"ENSEMBL:ENSG00000284357"
"ENSEMBL:ENSG00000207638"
"ENSEMBL:ENSG00000199059"
"ENSEMBL:ENSG00000199151"
"ENSEMBL:ENSG00000199104"
"ENSEMBL:ENSG00000198982"
"ENSEMBL:ENSG00000199020"
"ENSEMBL:ENSG00000208001"
"ENSEMBL:ENSG00000202569"
"ENSEMBL:ENSG00000194717"
"ENSEMBL:ENSG00000207731"
"ENSEMBL:ENSG00000122852"
"ENSEMBL:ENSG00000207571"
"ENSEMBL:ENSG00000185303"
"ENSEMBL:ENSG00000211590"
"ENSEMBL:ENSG00000285427"
"ENSEMBL:ENSG00000228750"
"ENSEMBL:ENSG00000280634"
"ENSEMBL:ENSG00000243438"
"ENSEMBL:ENSG00000201796"
"ENSEMBL:ENSG00000240160"))
(define NGLY1-overexpressed '("ENSEMBL:ENSG00000183044"
"ENSEMBL:ENSG00000179869"
"ENSEMBL:ENSG00000167972"
"ENSEMBL:ENSG00000198691"
"ENSEMBL:ENSG00000085563"
"ENSEMBL:ENSG00000005471"
"ENSEMBL:ENSG00000166016"
"ENSEMBL:ENSG00000120437"
"ENSEMBL:ENSG00000176244"
"ENSEMBL:ENSG00000114739"
"ENSEMBL:ENSG00000145808"
"ENSEMBL:ENSG00000155897"
"ENSEMBL:ENSG00000078549"
"ENSEMBL:ENSG00000075340"
"ENSEMBL:ENSG00000135298"
"ENSEMBL:ENSG00000173698"
"ENSEMBL:ENSG00000162618"
"ENSEMBL:ENSG00000164199"
"ENSEMBL:ENSG00000198221"
"ENSEMBL:ENSG00000135439"
"ENSEMBL:ENSG00000126878"
"ENSEMBL:ENSG00000230042"
"ENSEMBL:ENSG00000140057"
"ENSEMBL:ENSG00000171094"
"ENSEMBL:ENSG00000189292"
"ENSEMBL:ENSG00000165566"
"ENSEMBL:ENSG00000181754"
"ENSEMBL:ENSG00000185046"
"ENSEMBL:ENSG00000103723"
"ENSEMBL:ENSG00000154856"
"ENSEMBL:ENSG00000171388"
"ENSEMBL:ENSG00000134817"
"ENSEMBL:ENSG00000100336"
"ENSEMBL:ENSG00000178878"
"ENSEMBL:ENSG00000137727"
"ENSEMBL:ENSG00000179361"
"ENSEMBL:ENSG00000122644"
"ENSEMBL:ENSG00000169126"
"ENSEMBL:ENSG00000172379"
"ENSEMBL:ENSG00000099889"
"ENSEMBL:ENSG00000102048"
"ENSEMBL:ENSG00000139352"
"ENSEMBL:ENSG00000162174"
"ENSEMBL:ENSG00000141431"
"ENSEMBL:ENSG00000168874"
"ENSEMBL:ENSG00000158321"
"ENSEMBL:ENSG00000168646"
"ENSEMBL:ENSG00000109956"
"ENSEMBL:ENSG00000135454"
"ENSEMBL:ENSG00000164929"
"ENSEMBL:ENSG00000007516"
"ENSEMBL:ENSG00000171791"
"ENSEMBL:ENSG00000133169"
"ENSEMBL:ENSG00000133134"
"ENSEMBL:ENSG00000281406"
"ENSEMBL:ENSG00000101144"
"ENSEMBL:ENSG00000251079"
"ENSEMBL:ENSG00000169594"
"ENSEMBL:ENSG00000174672"
"ENSEMBL:ENSG00000151136"
"ENSEMBL:ENSG00000204347"
"ENSEMBL:ENSG00000162817"
"ENSEMBL:ENSG00000179902"
"ENSEMBL:ENSG00000239887"
"ENSEMBL:ENSG00000112539"
"ENSEMBL:ENSG00000137434"
"ENSEMBL:ENSG00000285312"
"ENSEMBL:ENSG00000112936"
"ENSEMBL:ENSG00000204711"
"ENSEMBL:ENSG00000225626"
"ENSEMBL:ENSG00000165118"
"ENSEMBL:ENSG00000118298"
"ENSEMBL:ENSG00000104267"
"ENSEMBL:ENSG00000178538"
"ENSEMBL:ENSG00000157782"
"ENSEMBL:ENSG00000006283"
"ENSEMBL:ENSG00000075461"
"ENSEMBL:ENSG00000105605"
"ENSEMBL:ENSG00000142408"
"ENSEMBL:ENSG00000104327"
"ENSEMBL:ENSG00000070808"
"ENSEMBL:ENSG00000164076"
"ENSEMBL:ENSG00000076826"
"ENSEMBL:ENSG00000237436"
"ENSEMBL:ENSG00000087589"
"ENSEMBL:ENSG00000130940"
"ENSEMBL:ENSG00000102924"
"ENSEMBL:ENSG00000183287"
"ENSEMBL:ENSG00000163081"
"ENSEMBL:ENSG00000198003"
"ENSEMBL:ENSG00000198865"
"ENSEMBL:ENSG00000203952"
"ENSEMBL:ENSG00000267909"
"ENSEMBL:ENSG00000117477"
"ENSEMBL:ENSG00000177875"
"ENSEMBL:ENSG00000015133"
"ENSEMBL:ENSG00000091972"
"ENSEMBL:ENSG00000272398"
"ENSEMBL:ENSG00000185275"
"ENSEMBL:ENSG00000174059"
"ENSEMBL:ENSG00000019582"
"ENSEMBL:ENSG00000112149"
"ENSEMBL:ENSG00000101542"
"ENSEMBL:ENSG00000179776"
"ENSEMBL:ENSG00000129596"
"ENSEMBL:ENSG00000064309"
"ENSEMBL:ENSG00000007129"
"ENSEMBL:ENSG00000278565"
"ENSEMBL:ENSG00000159409"
"ENSEMBL:ENSG00000143126"
"ENSEMBL:ENSG00000166582"
"ENSEMBL:ENSG00000147869"
"ENSEMBL:ENSG00000163075"
"ENSEMBL:ENSG00000188596"
"ENSEMBL:ENSG00000143375"
"ENSEMBL:ENSG00000070748"
"ENSEMBL:ENSG00000106153"
"ENSEMBL:ENSG00000016391"
"ENSEMBL:ENSG00000100604"
"ENSEMBL:ENSG00000276781"
"ENSEMBL:ENSG00000101938"
"ENSEMBL:ENSG00000175344"
"ENSEMBL:ENSG00000160716"
"ENSEMBL:ENSG00000125931"
"ENSEMBL:ENSG00000166165"
"ENSEMBL:ENSG00000150048"
"ENSEMBL:ENSG00000166509"
"ENSEMBL:ENSG00000153132"
"ENSEMBL:ENSG00000146352"
"ENSEMBL:ENSG00000118432"
"ENSEMBL:ENSG00000122756"
"ENSEMBL:ENSG00000184144"
"ENSEMBL:ENSG00000187955"
"ENSEMBL:ENSG00000139219"
"ENSEMBL:ENSG00000197565"
"ENSEMBL:ENSG00000112280"
"ENSEMBL:ENSG00000158270"
"ENSEMBL:ENSG00000047457"
"ENSEMBL:ENSG00000135678"
"ENSEMBL:ENSG00000196353"
"ENSEMBL:ENSG00000148204"
"ENSEMBL:ENSG00000178662"
"ENSEMBL:ENSG00000169862"
"ENSEMBL:ENSG00000163131"
"ENSEMBL:ENSG00000180891"
"ENSEMBL:ENSG00000111249"
"ENSEMBL:ENSG00000154639"
"ENSEMBL:ENSG00000145824"
"ENSEMBL:ENSG00000121966"
"ENSEMBL:ENSG00000019186"
"ENSEMBL:ENSG00000146233"
"ENSEMBL:ENSG00000276644"
"ENSEMBL:ENSG00000126733"
"ENSEMBL:ENSG00000187323"
"ENSEMBL:ENSG00000011465"
"ENSEMBL:ENSG00000232093"
"ENSEMBL:ENSG00000204580"
"ENSEMBL:ENSG00000229767"
"ENSEMBL:ENSG00000137332"
"ENSEMBL:ENSG00000230456"
"ENSEMBL:ENSG00000234078"
"ENSEMBL:ENSG00000223680"
"ENSEMBL:ENSG00000215522"
"ENSEMBL:ENSG00000109832"
"ENSEMBL:ENSG00000204624"
"ENSEMBL:ENSG00000262001"
"ENSEMBL:ENSG00000198719"
"ENSEMBL:ENSG00000275555"
"ENSEMBL:ENSG00000173253"
"ENSEMBL:ENSG00000158856"
"ENSEMBL:ENSG00000122735"
"ENSEMBL:ENSG00000225808"
"ENSEMBL:ENSG00000088538"
"ENSEMBL:ENSG00000101134"
"ENSEMBL:ENSG00000175497"
"ENSEMBL:ENSG00000121570"
"ENSEMBL:ENSG00000157851"
"ENSEMBL:ENSG00000162490"
"ENSEMBL:ENSG00000110042"
"ENSEMBL:ENSG00000133878"
"ENSEMBL:ENSG00000120875"
"ENSEMBL:ENSG00000264364"
"ENSEMBL:ENSG00000007968"
"ENSEMBL:ENSG00000282899"
"ENSEMBL:ENSG00000129173"
"ENSEMBL:ENSG00000136160"
"ENSEMBL:ENSG00000114654"
"ENSEMBL:ENSG00000108947"
"ENSEMBL:ENSG00000138798"
"ENSEMBL:ENSG00000206120"
"ENSEMBL:ENSG00000198759"
"ENSEMBL:ENSG00000164318"
"ENSEMBL:ENSG00000196361"
"ENSEMBL:ENSG00000186998"
"ENSEMBL:ENSG00000183798"
"ENSEMBL:ENSG00000163064"
"ENSEMBL:ENSG00000164778"
"ENSEMBL:ENSG00000168913"
"ENSEMBL:ENSG00000151023"
"ENSEMBL:ENSG00000136960"
"ENSEMBL:ENSG00000159023"
"ENSEMBL:ENSG00000129595"
"ENSEMBL:ENSG00000234690"
"ENSEMBL:ENSG00000229153"
"ENSEMBL:ENSG00000285468"
"ENSEMBL:ENSG00000154928"
"ENSEMBL:ENSG00000178568"
"ENSEMBL:ENSG00000149564"
"ENSEMBL:ENSG00000092820"
"ENSEMBL:ENSG00000158769"
"ENSEMBL:ENSG00000164434"
"ENSEMBL:ENSG00000184731"
"ENSEMBL:ENSG00000121104"
"ENSEMBL:ENSG00000150510"
"ENSEMBL:ENSG00000130054"
"ENSEMBL:ENSG00000154319"
"ENSEMBL:ENSG00000185442"
"ENSEMBL:ENSG00000140067"
"ENSEMBL:ENSG00000273533"
"ENSEMBL:ENSG00000258584"
"ENSEMBL:ENSG00000281032"
"ENSEMBL:ENSG00000111879"
"ENSEMBL:ENSG00000104059"
"ENSEMBL:ENSG00000273564"
"ENSEMBL:ENSG00000188732"
"ENSEMBL:ENSG00000084444"
"ENSEMBL:ENSG00000283329"
"ENSEMBL:ENSG00000166492"
"ENSEMBL:ENSG00000144152"
"ENSEMBL:ENSG00000130475"
"ENSEMBL:ENSG00000214814"
"ENSEMBL:ENSG00000149557"
"ENSEMBL:ENSG00000114279"
"ENSEMBL:ENSG00000102466"
"ENSEMBL:ENSG00000174721"
"ENSEMBL:ENSG00000261308"
"ENSEMBL:ENSG00000155816"
"ENSEMBL:ENSG00000122176"
"ENSEMBL:ENSG00000171956"
"ENSEMBL:ENSG00000129654"
"ENSEMBL:ENSG00000206262"
"ENSEMBL:ENSG00000164946"
"ENSEMBL:ENSG00000150893"
"ENSEMBL:ENSG00000172159"
"ENSEMBL:ENSG00000114541"
"ENSEMBL:ENSG00000147234"
"ENSEMBL:ENSG00000188738"
"ENSEMBL:ENSG00000134363"
"ENSEMBL:ENSG00000172461"
"ENSEMBL:ENSG00000104290"
"ENSEMBL:ENSG00000166206"
"ENSEMBL:ENSG00000268089"
"ENSEMBL:ENSG00000175229"
"ENSEMBL:ENSG00000119514"
"ENSEMBL:ENSG00000171766"
"ENSEMBL:ENSG00000168505"
"ENSEMBL:ENSG00000111846"
"ENSEMBL:ENSG00000285222"
"ENSEMBL:ENSG00000184344"
"ENSEMBL:ENSG00000130055"
"ENSEMBL:ENSG00000228175"
"ENSEMBL:ENSG00000165113"
"ENSEMBL:ENSG00000178445"
"ENSEMBL:ENSG00000242797"
"ENSEMBL:ENSG00000087258"
"ENSEMBL:ENSG00000128266"
"ENSEMBL:ENSG00000168243"
"ENSEMBL:ENSG00000282972"
"ENSEMBL:ENSG00000238105"
"ENSEMBL:ENSG00000150625"
"ENSEMBL:ENSG00000046653"
"ENSEMBL:ENSG00000183150"
"ENSEMBL:ENSG00000164604"
"ENSEMBL:ENSG00000211445"
"ENSEMBL:ENSG00000141449"
"ENSEMBL:ENSG00000158055"
"ENSEMBL:ENSG00000155511"
"ENSEMBL:ENSG00000152208"
"ENSEMBL:ENSG00000273079"
"ENSEMBL:ENSG00000198822"
"ENSEMBL:ENSG00000144366"
"ENSEMBL:ENSG00000145649"
"ENSEMBL:ENSG00000173805"
"ENSEMBL:ENSG00000170961"
"ENSEMBL:ENSG00000143630"
"ENSEMBL:ENSG00000263324"
"ENSEMBL:ENSG00000138622"
"ENSEMBL:ENSG00000138646"
"ENSEMBL:ENSG00000144485"
"ENSEMBL:ENSG00000112972"
"ENSEMBL:ENSG00000134709"
"ENSEMBL:ENSG00000120094"
"ENSEMBL:ENSG00000120068"
"ENSEMBL:ENSG00000170689"
"ENSEMBL:ENSG00000180806"
"ENSEMBL:ENSG00000116983"
"ENSEMBL:ENSG00000002587"
"ENSEMBL:ENSG00000182601"
"ENSEMBL:ENSG00000185352"
"ENSEMBL:ENSG00000176387"
"ENSEMBL:ENSG00000164070"
"ENSEMBL:ENSG00000168830"
"ENSEMBL:ENSG00000157423"
"ENSEMBL:ENSG00000283022"
"ENSEMBL:ENSG00000090339"
"ENSEMBL:ENSG00000174498"
"ENSEMBL:ENSG00000137142"
"ENSEMBL:ENSG00000085552"
"ENSEMBL:ENSG00000185811"
"ENSEMBL:ENSG00000123496"
"ENSEMBL:ENSG00000144730"
"ENSEMBL:ENSG00000160712"
"ENSEMBL:ENSG00000143195"
"ENSEMBL:ENSG00000148798"
"ENSEMBL:ENSG00000163362"
"ENSEMBL:ENSG00000161896"
"ENSEMBL:ENSG00000269837"
"ENSEMBL:ENSG00000177508"
"ENSEMBL:ENSG00000176842"
"ENSEMBL:ENSG00000101230"
"ENSEMBL:ENSG00000164171"
"ENSEMBL:ENSG00000135424"
"ENSEMBL:ENSG00000144668"
"ENSEMBL:ENSG00000105855"
"ENSEMBL:ENSG00000078596"
"ENSEMBL:ENSG00000180347"
"ENSEMBL:ENSG00000280780"
"ENSEMBL:ENSG00000154721"
"ENSEMBL:ENSG00000111262"
"ENSEMBL:ENSG00000129159"
"ENSEMBL:ENSG00000234233"
"ENSEMBL:ENSG00000082482"
"ENSEMBL:ENSG00000075043"
"ENSEMBL:ENSG00000281151"
"ENSEMBL:ENSG00000128052"
"ENSEMBL:ENSG00000165185"
"ENSEMBL:ENSG00000130294"
"ENSEMBL:ENSG00000139116"
"ENSEMBL:ENSG00000168280"
"ENSEMBL:ENSG00000276734"
"ENSEMBL:ENSG00000126259"
"ENSEMBL:ENSG00000163884"
"ENSEMBL:ENSG00000231160"
"ENSEMBL:ENSG00000162755"
"ENSEMBL:ENSG00000213160"
"ENSEMBL:ENSG00000122550"
"ENSEMBL:ENSG00000230658"
"ENSEMBL:ENSG00000154655"
"ENSEMBL:ENSG00000101680"
"ENSEMBL:ENSG00000078081"
"ENSEMBL:ENSG00000119862"
"ENSEMBL:ENSG00000153012"
"ENSEMBL:ENSG00000064042"
"ENSEMBL:ENSG00000131914"
"ENSEMBL:ENSG00000245526"
"ENSEMBL:ENSG00000233237"
"ENSEMBL:ENSG00000214381"
"ENSEMBL:ENSG00000277147"
"ENSEMBL:ENSG00000259134"
"ENSEMBL:ENSG00000261455"
"ENSEMBL:ENSG00000244041"
"ENSEMBL:ENSG00000260343"
"ENSEMBL:ENSG00000282706"
"ENSEMBL:ENSG00000229743"
"ENSEMBL:ENSG00000280744"
"ENSEMBL:ENSG00000248441"
"ENSEMBL:ENSG00000269416"
"ENSEMBL:ENSG00000229891"
"ENSEMBL:ENSG00000270164"
"ENSEMBL:ENSG00000280540"
"ENSEMBL:ENSG00000228459"
"ENSEMBL:ENSG00000180869"
"ENSEMBL:ENSG00000233684"
"ENSEMBL:ENSG00000264345"
"ENSEMBL:ENSG00000228271"
"ENSEMBL:ENSG00000257986"
"ENSEMBL:ENSG00000203688"
"ENSEMBL:ENSG00000248869"
"ENSEMBL:ENSG00000230269"
"ENSEMBL:ENSG00000272549"
"ENSEMBL:ENSG00000101670"
"ENSEMBL:ENSG00000175445"
"ENSEMBL:ENSG00000121207"
"ENSEMBL:ENSG00000081479"
"ENSEMBL:ENSG00000204950"
"ENSEMBL:ENSG00000179796"
"ENSEMBL:ENSG00000128594"
"ENSEMBL:ENSG00000183908"
"ENSEMBL:ENSG00000181350"
"ENSEMBL:ENSG00000131951"
"ENSEMBL:ENSG00000146006"
"ENSEMBL:ENSG00000198739"
"ENSEMBL:ENSG00000176204"
"ENSEMBL:ENSG00000105699"
"ENSEMBL:ENSG00000176956"
"ENSEMBL:ENSG00000274488"
"ENSEMBL:ENSG00000147676"
"ENSEMBL:ENSG00000197769"
"ENSEMBL:ENSG00000171533"
"ENSEMBL:ENSG00000109339"
"ENSEMBL:ENSG00000116141"
"ENSEMBL:ENSG00000132031"
"ENSEMBL:ENSG00000053524"
"ENSEMBL:ENSG00000198948"
"ENSEMBL:ENSG00000138111"
"ENSEMBL:ENSG00000071073"
"ENSEMBL:ENSG00000167889"
"ENSEMBL:ENSG00000225783"
"ENSEMBL:ENSG00000254377"
"ENSEMBL:ENSG00000199036"
"ENSEMBL:ENSG00000215386"
"ENSEMBL:ENSG00000141854"
"ENSEMBL:ENSG00000288191"
"ENSEMBL:ENSG00000100427"
"ENSEMBL:ENSG00000108960"
"ENSEMBL:ENSG00000100985"
"ENSEMBL:ENSG00000138722"
"ENSEMBL:ENSG00000120162"
"ENSEMBL:ENSG00000135097"
"ENSEMBL:ENSG00000170873"
"ENSEMBL:ENSG00000138823"
"ENSEMBL:ENSG00000129422"
"ENSEMBL:ENSG00000205277"
"ENSEMBL:ENSG00000116990"
"ENSEMBL:ENSG00000134323"
"ENSEMBL:ENSG00000233718"
"ENSEMBL:ENSG00000041515"
"ENSEMBL:ENSG00000095777"
"ENSEMBL:ENSG00000128833"
"ENSEMBL:ENSG00000145911"
"ENSEMBL:ENSG00000186462"
"ENSEMBL:ENSG00000185818"
"ENSEMBL:ENSG00000104490"
"ENSEMBL:ENSG00000130287"
"ENSEMBL:ENSG00000124479"
"ENSEMBL:ENSG00000078114"
"ENSEMBL:ENSG00000103154"
"ENSEMBL:ENSG00000277586"
"ENSEMBL:ENSG00000104722"
"ENSEMBL:ENSG00000184613"
"ENSEMBL:ENSG00000166342"
"ENSEMBL:ENSG00000107954"
"ENSEMBL:ENSG00000163531"
"ENSEMBL:ENSG00000066248"
"ENSEMBL:ENSG00000145506"
"ENSEMBL:ENSG00000276920"
"ENSEMBL:ENSG00000196338"
"ENSEMBL:ENSG00000157064"
"ENSEMBL:ENSG00000109255"
"ENSEMBL:ENSG00000101746"
"ENSEMBL:ENSG00000198929"
"ENSEMBL:ENSG00000007171"
"ENSEMBL:ENSG00000204301"
"ENSEMBL:ENSG00000238196"
"ENSEMBL:ENSG00000235396"
"ENSEMBL:ENSG00000232339"
"ENSEMBL:ENSG00000223355"
"ENSEMBL:ENSG00000206312"
"ENSEMBL:ENSG00000234876"
"ENSEMBL:ENSG00000139910"
"ENSEMBL:ENSG00000104967"
"ENSEMBL:ENSG00000151322"
"ENSEMBL:ENSG00000169418"
"ENSEMBL:ENSG00000106236"
"ENSEMBL:ENSG00000119508"
"ENSEMBL:ENSG00000091129"
"ENSEMBL:ENSG00000154146"
"ENSEMBL:ENSG00000021645"
"ENSEMBL:ENSG00000198400"
"ENSEMBL:ENSG00000148053"
"ENSEMBL:ENSG00000140876"
"ENSEMBL:ENSG00000132182"
"ENSEMBL:ENSG00000198088"
"ENSEMBL:ENSG00000174145"
"ENSEMBL:ENSG00000197822"
"ENSEMBL:ENSG00000273814"
"ENSEMBL:ENSG00000149635"
"ENSEMBL:ENSG00000115758"
"ENSEMBL:ENSG00000197444"
"ENSEMBL:ENSG00000177468"
"ENSEMBL:ENSG00000082556"
"ENSEMBL:ENSG00000085840"
"ENSEMBL:ENSG00000257950"
"ENSEMBL:ENSG00000233639"
"ENSEMBL:ENSG00000124171"
"ENSEMBL:ENSG00000135903"
"ENSEMBL:ENSG00000007372"
"ENSEMBL:ENSG00000125618"
"ENSEMBL:ENSG00000189223"
"ENSEMBL:ENSG00000238197"
"ENSEMBL:ENSG00000280623"
"ENSEMBL:ENSG00000251321"
"ENSEMBL:ENSG00000102290"
"ENSEMBL:ENSG00000099715"
"ENSEMBL:ENSG00000150275"
"ENSEMBL:ENSG00000136099"
"ENSEMBL:ENSG00000250120"
"ENSEMBL:ENSG00000255408"
"ENSEMBL:ENSG00000113248"
"ENSEMBL:ENSG00000113209"
"ENSEMBL:ENSG00000253873"
"ENSEMBL:ENSG00000253731"
"ENSEMBL:ENSG00000253953"
"ENSEMBL:ENSG00000169174"
"ENSEMBL:ENSG00000115252"
"ENSEMBL:ENSG00000123360"
"ENSEMBL:ENSG00000152270"
"ENSEMBL:ENSG00000184588"
"ENSEMBL:ENSG00000162493"
"ENSEMBL:ENSG00000242265"
"ENSEMBL:ENSG00000139946"
"ENSEMBL:ENSG00000181195"
"ENSEMBL:ENSG00000177614"
"ENSEMBL:ENSG00000130517"
"ENSEMBL:ENSG00000056487"
"ENSEMBL:ENSG00000168490"
"ENSEMBL:ENSG00000107242"
"ENSEMBL:ENSG00000179761"
"ENSEMBL:ENSG00000087842"
"ENSEMBL:ENSG00000166473"
"ENSEMBL:ENSG00000057294"
"ENSEMBL:ENSG00000100078"
"ENSEMBL:ENSG00000122861"
"ENSEMBL:ENSG00000114805"
"ENSEMBL:ENSG00000154822"
"ENSEMBL:ENSG00000284017"
"ENSEMBL:ENSG00000180287"
"ENSEMBL:ENSG00000166689"
"ENSEMBL:ENSG00000120278"
"ENSEMBL:ENSG00000008323"
"ENSEMBL:ENSG00000117598"
"ENSEMBL:ENSG00000136040"
"ENSEMBL:ENSG00000240694"
"ENSEMBL:ENSG00000277531"
"ENSEMBL:ENSG00000128567"
"ENSEMBL:ENSG00000184486"
"ENSEMBL:ENSG00000198914"
"ENSEMBL:ENSG00000196767"
"ENSEMBL:ENSG00000106536"
"ENSEMBL:ENSG00000175175"
"ENSEMBL:ENSG00000163590"
"ENSEMBL:ENSG00000198729"
"ENSEMBL:ENSG00000101445"
"ENSEMBL:ENSG00000135447"
"ENSEMBL:ENSG00000158528"
"ENSEMBL:ENSG00000156475"
"ENSEMBL:ENSG00000119698"
"ENSEMBL:ENSG00000278326"
"ENSEMBL:ENSG00000057657"
"ENSEMBL:ENSG00000112238"
"ENSEMBL:ENSG00000152784"
"ENSEMBL:ENSG00000188783"
"ENSEMBL:ENSG00000124126"
"ENSEMBL:ENSG00000046889"
"ENSEMBL:ENSG00000116690"
"ENSEMBL:ENSG00000162409"
"ENSEMBL:ENSG00000126583"
"ENSEMBL:ENSG00000007062"
"ENSEMBL:ENSG00000117707"
"ENSEMBL:ENSG00000183248"
"ENSEMBL:ENSG00000130032"
"ENSEMBL:ENSG00000112812"
"ENSEMBL:ENSG00000166450"
"ENSEMBL:ENSG00000225706"
"ENSEMBL:ENSG00000106278"
"ENSEMBL:ENSG00000250337"
"ENSEMBL:ENSG00000179331"
"ENSEMBL:ENSG00000152932"
"ENSEMBL:ENSG00000127328"
"ENSEMBL:ENSG00000218358"
"ENSEMBL:ENSG00000131831"
"ENSEMBL:ENSG00000091428"
"ENSEMBL:ENSG00000136237"
"ENSEMBL:ENSG00000106538"
"ENSEMBL:ENSG00000172575"
"ENSEMBL:ENSG00000101265"
"ENSEMBL:ENSG00000203867"
"ENSEMBL:ENSG00000167771"
"ENSEMBL:ENSG00000198771"
"ENSEMBL:ENSG00000121039"
"ENSEMBL:ENSG00000165731"
"ENSEMBL:ENSG00000178882"
"ENSEMBL:ENSG00000080298"
"ENSEMBL:ENSG00000111783"
"ENSEMBL:ENSG00000102760"
"ENSEMBL:ENSG00000147509"
"ENSEMBL:ENSG00000182732"
"ENSEMBL:ENSG00000141314"
"ENSEMBL:ENSG00000131941"
"ENSEMBL:ENSG00000166405"
"ENSEMBL:ENSG00000101098"
"ENSEMBL:ENSG00000255794"
"ENSEMBL:ENSG00000172602"
"ENSEMBL:ENSG00000108830"
"ENSEMBL:ENSG00000267128"
"ENSEMBL:ENSG00000141622"
"ENSEMBL:ENSG00000180537"
"ENSEMBL:ENSG00000108375"
"ENSEMBL:ENSG00000243742"
"ENSEMBL:ENSG00000241370"
"ENSEMBL:ENSG00000241779"
"ENSEMBL:ENSG00000241863"
"ENSEMBL:ENSG00000243009"
"ENSEMBL:ENSG00000239865"
"ENSEMBL:ENSG00000242726"
"ENSEMBL:ENSG00000239927"
"ENSEMBL:ENSG00000177519"
"ENSEMBL:ENSG00000072133"
"ENSEMBL:ENSG00000198208"
"ENSEMBL:ENSG00000025039"
"ENSEMBL:ENSG00000111834"
"ENSEMBL:ENSG00000182010"
"ENSEMBL:ENSG00000139970"
"ENSEMBL:ENSG00000103449"
"ENSEMBL:ENSG00000165821"
"ENSEMBL:ENSG00000177570"
"ENSEMBL:ENSG00000145284"
"ENSEMBL:ENSG00000226549"
"ENSEMBL:ENSG00000153253"
"ENSEMBL:ENSG00000166257"
"ENSEMBL:ENSG00000175356"
"ENSEMBL:ENSG00000007908"
"ENSEMBL:ENSG00000250722"
"ENSEMBL:ENSG00000153993"
"ENSEMBL:ENSG00000082684"
"ENSEMBL:ENSG00000188488"
"ENSEMBL:ENSG00000063015"
"ENSEMBL:ENSG00000163935"
"ENSEMBL:ENSG00000145423"
"ENSEMBL:ENSG00000189410"
"ENSEMBL:ENSG00000140600"
"ENSEMBL:ENSG00000162105"
"ENSEMBL:ENSG00000148082"
"ENSEMBL:ENSG00000187902"
"ENSEMBL:ENSG00000237515"
"ENSEMBL:ENSG00000138944"
"ENSEMBL:ENSG00000180592"
"ENSEMBL:ENSG00000139737"
"ENSEMBL:ENSG00000158296"
"ENSEMBL:ENSG00000163053"
"ENSEMBL:ENSG00000108932"
"ENSEMBL:ENSG00000036565"
"ENSEMBL:ENSG00000187714"
"ENSEMBL:ENSG00000110436"
"ENSEMBL:ENSG00000105143"
"ENSEMBL:ENSG00000137266"
"ENSEMBL:ENSG00000235064"
"ENSEMBL:ENSG00000173262"
"ENSEMBL:ENSG00000181856"
"ENSEMBL:ENSG00000288174"
"ENSEMBL:ENSG00000196376"
"ENSEMBL:ENSG00000050438"
"ENSEMBL:ENSG00000157103"
"ENSEMBL:ENSG00000165349"
"ENSEMBL:ENSG00000092068"
"ENSEMBL:ENSG00000100678"
"ENSEMBL:ENSG00000137491"
"ENSEMBL:ENSG00000154760"
"ENSEMBL:ENSG00000187122"
"ENSEMBL:ENSG00000086300"
"ENSEMBL:ENSG00000171243"
"ENSEMBL:ENSG00000182968"
"ENSEMBL:ENSG00000143842"
"ENSEMBL:ENSG00000181449"
"ENSEMBL:ENSG00000242808"
"ENSEMBL:ENSG00000125285"
"ENSEMBL:ENSG00000227640"
"ENSEMBL:ENSG00000134595"
"ENSEMBL:ENSG00000217236"
"ENSEMBL:ENSG00000104450"
"ENSEMBL:ENSG00000182957"
"ENSEMBL:ENSG00000171722"
"ENSEMBL:ENSG00000107742"
"ENSEMBL:ENSG00000262655"
"ENSEMBL:ENSG00000196220"
"ENSEMBL:ENSG00000125046"
"ENSEMBL:ENSG00000184005"
"ENSEMBL:ENSG00000140557"
"ENSEMBL:ENSG00000113532"
"ENSEMBL:ENSG00000130413"
"ENSEMBL:ENSG00000015592"
"ENSEMBL:ENSG00000068781"
"ENSEMBL:ENSG00000140022"
"ENSEMBL:ENSG00000165730"
"ENSEMBL:ENSG00000173320"
"ENSEMBL:ENSG00000145087"
"ENSEMBL:ENSG00000122012"
"ENSEMBL:ENSG00000110975"
"ENSEMBL:ENSG00000143858"
"ENSEMBL:ENSG00000134207"
"ENSEMBL:ENSG00000011347"
"ENSEMBL:ENSG00000144834"
"ENSEMBL:ENSG00000176907"
"ENSEMBL:ENSG00000092850"
"ENSEMBL:ENSG00000158246"
"ENSEMBL:ENSG00000087510"
"ENSEMBL:ENSG00000105825"
"ENSEMBL:ENSG00000129028"
"ENSEMBL:ENSG00000151090"
"ENSEMBL:ENSG00000144229"
"ENSEMBL:ENSG00000173825"
"ENSEMBL:ENSG00000169989"
"ENSEMBL:ENSG00000100234"
"ENSEMBL:ENSG00000007350"
"ENSEMBL:ENSG00000163762"
"ENSEMBL:ENSG00000149809"
"ENSEMBL:ENSG00000167619"
"ENSEMBL:ENSG00000249242"
"ENSEMBL:ENSG00000178233"
"ENSEMBL:ENSG00000205269"
"ENSEMBL:ENSG00000206432"
"ENSEMBL:ENSG00000125355"
"ENSEMBL:ENSG00000147027"
"ENSEMBL:ENSG00000125895"
"ENSEMBL:ENSG00000167874"
"ENSEMBL:ENSG00000176040"
"ENSEMBL:ENSG00000158164"
"ENSEMBL:ENSG00000123610"
"ENSEMBL:ENSG00000164761"
"ENSEMBL:ENSG00000049249"
"ENSEMBL:ENSG00000103460"
"ENSEMBL:ENSG00000146242"
"ENSEMBL:ENSG00000283085"
"ENSEMBL:ENSG00000134253"
"ENSEMBL:ENSG00000206557"
"ENSEMBL:ENSG00000083067"
"ENSEMBL:ENSG00000167723"
"ENSEMBL:ENSG00000106025"
"ENSEMBL:ENSG00000158457"
"ENSEMBL:ENSG00000223756"
"ENSEMBL:ENSG00000205838"
"ENSEMBL:ENSG00000170703"
"ENSEMBL:ENSG00000167614"
"ENSEMBL:ENSG00000276537"
"ENSEMBL:ENSG00000276887"
"ENSEMBL:ENSG00000275650"
"ENSEMBL:ENSG00000137285"
"ENSEMBL:ENSG00000250366"
"ENSEMBL:ENSG00000176912"
"ENSEMBL:ENSG00000168671"
"ENSEMBL:ENSG00000136014"
"ENSEMBL:ENSG00000162738"
"ENSEMBL:ENSG00000171724"
"ENSEMBL:ENSG00000134215"
"ENSEMBL:ENSG00000136451"
"ENSEMBL:ENSG00000128564"
"ENSEMBL:ENSG00000169085"
"ENSEMBL:ENSG00000166483"
"ENSEMBL:ENSG00000127578"
"ENSEMBL:ENSG00000165238"
"ENSEMBL:ENSG00000169884"
"ENSEMBL:ENSG00000002745"
"ENSEMBL:ENSG00000108379"
"ENSEMBL:ENSG00000277626"
"ENSEMBL:ENSG00000277641"
"ENSEMBL:ENSG00000154342"
"ENSEMBL:ENSG00000162552"
"ENSEMBL:ENSG00000179314"
"ENSEMBL:ENSG00000113645"
"ENSEMBL:ENSG00000206579"
"ENSEMBL:ENSG00000122121"
"ENSEMBL:ENSG00000166793"
"ENSEMBL:ENSG00000109906"
"ENSEMBL:ENSG00000119703"
"ENSEMBL:ENSG00000177108"
"ENSEMBL:ENSG00000136367"
"ENSEMBL:ENSG00000152977"
"ENSEMBL:ENSG00000043355"
"ENSEMBL:ENSG00000156925"
"ENSEMBL:ENSG00000174963"
"ENSEMBL:ENSG00000139800"
"ENSEMBL:ENSG00000171649"
"ENSEMBL:ENSG00000165061"
"ENSEMBL:ENSG00000131849"
"ENSEMBL:ENSG00000197279"
"ENSEMBL:ENSG00000187595"
"ENSEMBL:ENSG00000186496"
"ENSEMBL:ENSG00000180855"
"ENSEMBL:ENSG00000196653"
"ENSEMBL:ENSG00000281448"
"ENSEMBL:ENSG00000237149"
"ENSEMBL:ENSG00000198795"
"ENSEMBL:ENSG00000167555"
"ENSEMBL:ENSG00000269834"
"ENSEMBL:ENSG00000198597"
"ENSEMBL:ENSG00000198028"
"ENSEMBL:ENSG00000180626"
"ENSEMBL:ENSG00000177842"
"ENSEMBL:ENSG00000197472"
"ENSEMBL:ENSG00000196081"
"ENSEMBL:ENSG00000213967"
"ENSEMBL:ENSG00000197128"
"ENSEMBL:ENSG00000196466"
"ENSEMBL:ENSG00000180233"
"ENSEMBL:ENSG00000183579"
"ENSEMBL:ENSG00000162415"))
(define NGLY1-underexpressed '("ENSEMBL:ENSG00000128274"
"ENSEMBL:ENSG00000173210"
"ENSEMBL:ENSG00000157766"
"ENSEMBL:ENSG00000144476"
"ENSEMBL:ENSG00000102575"
"ENSEMBL:ENSG00000005187"
"ENSEMBL:ENSG00000107796"
"ENSEMBL:ENSG00000180139"
"ENSEMBL:ENSG00000169067"
"ENSEMBL:ENSG00000159251"
"ENSEMBL:ENSG00000145536"
"ENSEMBL:ENSG00000140873"
"ENSEMBL:ENSG00000154736"
"ENSEMBL:ENSG00000049192"
"ENSEMBL:ENSG00000121281"
"ENSEMBL:ENSG00000020181"
"ENSEMBL:ENSG00000272734"
"ENSEMBL:ENSG00000120907"
"ENSEMBL:ENSG00000171873"
"ENSEMBL:ENSG00000150594"
"ENSEMBL:ENSG00000135744"
"ENSEMBL:ENSG00000185567"
"ENSEMBL:ENSG00000106546"
"ENSEMBL:ENSG00000063438"
"ENSEMBL:ENSG00000006534"
"ENSEMBL:ENSG00000180318"
"ENSEMBL:ENSG00000139211"
"ENSEMBL:ENSG00000167772"
"ENSEMBL:ENSG00000154122"
"ENSEMBL:ENSG00000148677"
"ENSEMBL:ENSG00000011201"
"ENSEMBL:ENSG00000122359"
"ENSEMBL:ENSG00000163697"
"ENSEMBL:ENSG00000240583"
"ENSEMBL:ENSG00000128805"
"ENSEMBL:ENSG00000138639"
"ENSEMBL:ENSG00000150347"
"ENSEMBL:ENSG00000105643"
"ENSEMBL:ENSG00000140450"
"ENSEMBL:ENSG00000180801"
"ENSEMBL:ENSG00000108684"
"ENSEMBL:ENSG00000174939"
"ENSEMBL:ENSG00000206190"
"ENSEMBL:ENSG00000074370"
"ENSEMBL:ENSG00000277297"
"ENSEMBL:ENSG00000081923"
"ENSEMBL:ENSG00000104043"
"ENSEMBL:ENSG00000156273"
"ENSEMBL:ENSG00000168398"
"ENSEMBL:ENSG00000176697"
"ENSEMBL:ENSG00000183092"
"ENSEMBL:ENSG00000123095"
"ENSEMBL:ENSG00000168487"
"ENSEMBL:ENSG00000164619"
"ENSEMBL:ENSG00000101425"
"ENSEMBL:ENSG00000130303"
"ENSEMBL:ENSG00000222009"
"ENSEMBL:ENSG00000119280"
"ENSEMBL:ENSG00000173918"
"ENSEMBL:ENSG00000197927"
"ENSEMBL:ENSG00000171860"
"ENSEMBL:ENSG00000234511"
"ENSEMBL:ENSG00000197261"
"ENSEMBL:ENSG00000074410"
"ENSEMBL:ENSG00000100314"
"ENSEMBL:ENSG00000165995"
"ENSEMBL:ENSG00000138172"
"ENSEMBL:ENSG00000042493"
"ENSEMBL:ENSG00000159753"
"ENSEMBL:ENSG00000249669"
"ENSEMBL:ENSG00000105974"
"ENSEMBL:ENSG00000105971"
"ENSEMBL:ENSG00000177469"
"ENSEMBL:ENSG00000170955"
"ENSEMBL:ENSG00000141668"
"ENSEMBL:ENSG00000166510"
"ENSEMBL:ENSG00000149201"
"ENSEMBL:ENSG00000188549"
"ENSEMBL:ENSG00000185972"
"ENSEMBL:ENSG00000271503"
"ENSEMBL:ENSG00000274233"
"ENSEMBL:ENSG00000150637"
"ENSEMBL:ENSG00000026508"
"ENSEMBL:ENSG00000196352"
"ENSEMBL:ENSG00000013725"
"ENSEMBL:ENSG00000163814"
"ENSEMBL:ENSG00000071991"
"ENSEMBL:ENSG00000062038"
"ENSEMBL:ENSG00000138395"
"ENSEMBL:ENSG00000117266"
"ENSEMBL:ENSG00000147883"
"ENSEMBL:ENSG00000000971"
"ENSEMBL:ENSG00000205403"
"ENSEMBL:ENSG00000138135"
"ENSEMBL:ENSG00000123989"
"ENSEMBL:ENSG00000181072"
"ENSEMBL:ENSG00000174343"
"ENSEMBL:ENSG00000160161"
"ENSEMBL:ENSG00000163347"
"ENSEMBL:ENSG00000249035"
"ENSEMBL:ENSG00000158258"
"ENSEMBL:ENSG00000143786"
"ENSEMBL:ENSG00000130176"
"ENSEMBL:ENSG00000018236"
"ENSEMBL:ENSG00000154529"
"ENSEMBL:ENSG00000283378"
"ENSEMBL:ENSG00000182871"
"ENSEMBL:ENSG00000124749"
"ENSEMBL:ENSG00000172752"
"ENSEMBL:ENSG00000206384"
"ENSEMBL:ENSG00000144810"
"ENSEMBL:ENSG00000092758"
"ENSEMBL:ENSG00000198756"
"ENSEMBL:ENSG00000160471"
"ENSEMBL:ENSG00000128510"
"ENSEMBL:ENSG00000178773"
"ENSEMBL:ENSG00000139117"
"ENSEMBL:ENSG00000109846"
"ENSEMBL:ENSG00000112297"
"ENSEMBL:ENSG00000242193"
"ENSEMBL:ENSG00000147408"
"ENSEMBL:ENSG00000173546"
"ENSEMBL:ENSG00000260139"
"ENSEMBL:ENSG00000170373"
"ENSEMBL:ENSG00000101160"
"ENSEMBL:ENSG00000107562"
"ENSEMBL:ENSG00000169429"
"ENSEMBL:ENSG00000166394"
"ENSEMBL:ENSG00000051523"
"ENSEMBL:ENSG00000186684"
"ENSEMBL:ENSG00000134716"
"ENSEMBL:ENSG00000108669"
"ENSEMBL:ENSG00000146122"
"ENSEMBL:ENSG00000057019"
"ENSEMBL:ENSG00000197410"
"ENSEMBL:ENSG00000284227"
"ENSEMBL:ENSG00000165507"
"ENSEMBL:ENSG00000058866"
"ENSEMBL:ENSG00000211448"
"ENSEMBL:ENSG00000231672"
"ENSEMBL:ENSG00000107984"
"ENSEMBL:ENSG00000164741"
"ENSEMBL:ENSG00000185559"
"ENSEMBL:ENSG00000144355"
"ENSEMBL:ENSG00000115844"
"ENSEMBL:ENSG00000105880"
"ENSEMBL:ENSG00000197959"
"ENSEMBL:ENSG00000272636"
"ENSEMBL:ENSG00000272670"
"ENSEMBL:ENSG00000206052"
"ENSEMBL:ENSG00000176978"
"ENSEMBL:ENSG00000189212"
"ENSEMBL:ENSG00000184845"
"ENSEMBL:ENSG00000134762"
"ENSEMBL:ENSG00000171451"
"ENSEMBL:ENSG00000262102"
"ENSEMBL:ENSG00000143507"
"ENSEMBL:ENSG00000158560"
"ENSEMBL:ENSG00000135636"
"ENSEMBL:ENSG00000164176"
"ENSEMBL:ENSG00000078401"
"ENSEMBL:ENSG00000151617"
"ENSEMBL:ENSG00000115380"
"ENSEMBL:ENSG00000172638"
"ENSEMBL:ENSG00000166897"
"ENSEMBL:ENSG00000118985"
"ENSEMBL:ENSG00000049540"
"ENSEMBL:ENSG00000164035"
"ENSEMBL:ENSG00000138185"
"ENSEMBL:ENSG00000168032"
"ENSEMBL:ENSG00000261150"
"ENSEMBL:ENSG00000177106"
"ENSEMBL:ENSG00000065361"
"ENSEMBL:ENSG00000115363"
"ENSEMBL:ENSG00000283632"
"ENSEMBL:ENSG00000126218"
"ENSEMBL:ENSG00000181104"
"ENSEMBL:ENSG00000164251"
"ENSEMBL:ENSG00000148541"
"ENSEMBL:ENSG00000204442"
"ENSEMBL:ENSG00000248429"
"ENSEMBL:ENSG00000166147"
"ENSEMBL:ENSG00000116661"
"ENSEMBL:ENSG00000161243"
"ENSEMBL:ENSG00000156804"
"ENSEMBL:ENSG00000088340"
"ENSEMBL:ENSG00000138675"
"ENSEMBL:ENSG00000140285"
"ENSEMBL:ENSG00000176971"
"ENSEMBL:ENSG00000168386"
"ENSEMBL:ENSG00000176692"
"ENSEMBL:ENSG00000251493"
"ENSEMBL:ENSG00000176678"
"ENSEMBL:ENSG00000179772"
"ENSEMBL:ENSG00000070404"
"ENSEMBL:ENSG00000177283"
"ENSEMBL:ENSG00000163288"
"ENSEMBL:ENSG00000131386"
"ENSEMBL:ENSG00000136542"
"ENSEMBL:ENSG00000139629"
"ENSEMBL:ENSG00000180447"
"ENSEMBL:ENSG00000233695"
"ENSEMBL:ENSG00000141448"
"ENSEMBL:ENSG00000187210"
"ENSEMBL:ENSG00000156466"
"ENSEMBL:ENSG00000143869"
"ENSEMBL:ENSG00000164949"
"ENSEMBL:ENSG00000146013"
"ENSEMBL:ENSG00000099998"
"ENSEMBL:ENSG00000179855"
"ENSEMBL:ENSG00000109738"
"ENSEMBL:ENSG00000156049"
"ENSEMBL:ENSG00000138678"
"ENSEMBL:ENSG00000164850"
"ENSEMBL:ENSG00000166073"
"ENSEMBL:ENSG00000169508"
"ENSEMBL:ENSG00000170775"
"ENSEMBL:ENSG00000119714"
"ENSEMBL:ENSG00000125675"
"ENSEMBL:ENSG00000182771"
"ENSEMBL:ENSG00000164418"
"ENSEMBL:ENSG00000183454"
"ENSEMBL:ENSG00000198785"
"ENSEMBL:ENSG00000152822"
"ENSEMBL:ENSG00000179603"
"ENSEMBL:ENSG00000113070"
"ENSEMBL:ENSG00000099822"
"ENSEMBL:ENSG00000164683"
"ENSEMBL:ENSG00000019991"
"ENSEMBL:ENSG00000127124"
"ENSEMBL:ENSG00000136630"
"ENSEMBL:ENSG00000146151"
"ENSEMBL:ENSG00000275410"
"ENSEMBL:ENSG00000276194"
"ENSEMBL:ENSG00000171476"
"ENSEMBL:ENSG00000253293"
"ENSEMBL:ENSG00000106006"
"ENSEMBL:ENSG00000078399"
"ENSEMBL:ENSG00000173083"
"ENSEMBL:ENSG00000196639"
"ENSEMBL:ENSG00000106211"
"ENSEMBL:ENSG00000173641"
"ENSEMBL:ENSG00000135312"
"ENSEMBL:ENSG00000102468"
"ENSEMBL:ENSG00000148680"
"ENSEMBL:ENSG00000166033"
"ENSEMBL:ENSG00000170801"
"ENSEMBL:ENSG00000146674"
"ENSEMBL:ENSG00000163395"
"ENSEMBL:ENSG00000147255"
"ENSEMBL:ENSG00000152580"
"ENSEMBL:ENSG00000095752"
"ENSEMBL:ENSG00000163701"
"ENSEMBL:ENSG00000168685"
"ENSEMBL:ENSG00000122641"
"ENSEMBL:ENSG00000188487"
"ENSEMBL:ENSG00000120645"
"ENSEMBL:ENSG00000262607"
"ENSEMBL:ENSG00000005884"
"ENSEMBL:ENSG00000115221"
"ENSEMBL:ENSG00000149596"
"ENSEMBL:ENSG00000132854"
"ENSEMBL:ENSG00000182255"
"ENSEMBL:ENSG00000131398"
"ENSEMBL:ENSG00000152049"
"ENSEMBL:ENSG00000055118"
"ENSEMBL:ENSG00000184185"
"ENSEMBL:ENSG00000157551"
"ENSEMBL:ENSG00000104783"
"ENSEMBL:ENSG00000269821"
"ENSEMBL:ENSG00000250423"
"ENSEMBL:ENSG00000066735"
"ENSEMBL:ENSG00000162849"
"ENSEMBL:ENSG00000281216"
"ENSEMBL:ENSG00000127528"
"ENSEMBL:ENSG00000149243"
"ENSEMBL:ENSG00000128422"
"ENSEMBL:ENSG00000171345"
"ENSEMBL:ENSG00000135480"
"ENSEMBL:ENSG00000167767"
"ENSEMBL:ENSG00000240871"
"ENSEMBL:ENSG00000171435"
"ENSEMBL:ENSG00000115919"
"ENSEMBL:ENSG00000130702"
"ENSEMBL:ENSG00000196878"
"ENSEMBL:ENSG00000213626"
"ENSEMBL:ENSG00000122367"
"ENSEMBL:ENSG00000143768"
"ENSEMBL:ENSG00000108679"
"ENSEMBL:ENSG00000214269"
"ENSEMBL:ENSG00000143355"
"ENSEMBL:ENSG00000128342"
"ENSEMBL:ENSG00000072163"
"ENSEMBL:ENSG00000232931"
"ENSEMBL:ENSG00000186369"
"ENSEMBL:ENSG00000233117"
"ENSEMBL:ENSG00000185904"
"ENSEMBL:ENSG00000231711"
"ENSEMBL:ENSG00000246100"
"ENSEMBL:ENSG00000240476"
"ENSEMBL:ENSG00000228495"
"ENSEMBL:ENSG00000233621"
"ENSEMBL:ENSG00000234840"
"ENSEMBL:ENSG00000258754"
"ENSEMBL:ENSG00000259518"
"ENSEMBL:ENSG00000253161"
"ENSEMBL:ENSG00000268941"
"ENSEMBL:ENSG00000226476"
"ENSEMBL:ENSG00000204460"
"ENSEMBL:ENSG00000244649"
"ENSEMBL:ENSG00000259847"
"ENSEMBL:ENSG00000261175"
"ENSEMBL:ENSG00000258616"
"ENSEMBL:ENSG00000256268"
"ENSEMBL:ENSG00000234155"
"ENSEMBL:ENSG00000223764"
"ENSEMBL:ENSG00000241288"
"ENSEMBL:ENSG00000174482"
"ENSEMBL:ENSG00000136153"
"ENSEMBL:ENSG00000163431"
"ENSEMBL:ENSG00000129038"
"ENSEMBL:ENSG00000261801"
"ENSEMBL:ENSG00000184574"
"ENSEMBL:ENSG00000172061"
"ENSEMBL:ENSG00000128606"
"ENSEMBL:ENSG00000033122"
"ENSEMBL:ENSG00000049323"
"ENSEMBL:ENSG00000168056"
"ENSEMBL:ENSG00000153714"
"ENSEMBL:ENSG00000187398"
"ENSEMBL:ENSG00000150556"
"ENSEMBL:ENSG00000133800"
"ENSEMBL:ENSG00000181541"
"ENSEMBL:ENSG00000204103"
"ENSEMBL:ENSG00000189221"
"ENSEMBL:ENSG00000069535"
"ENSEMBL:ENSG00000101460"
"ENSEMBL:ENSG00000197442"
"ENSEMBL:ENSG00000156265"
"ENSEMBL:ENSG00000152601"
"ENSEMBL:ENSG00000076706"
"ENSEMBL:ENSG00000140563"
"ENSEMBL:ENSG00000151376"
"ENSEMBL:ENSG00000102802"
"ENSEMBL:ENSG00000134138"
"ENSEMBL:ENSG00000163975"
"ENSEMBL:ENSG00000105976"
"ENSEMBL:ENSG00000182050"
"ENSEMBL:ENSG00000283530"
"ENSEMBL:ENSG00000285137"
"ENSEMBL:ENSG00000111341"
"ENSEMBL:ENSG00000276365"
"ENSEMBL:ENSG00000247095"
"ENSEMBL:ENSG00000282810"
"ENSEMBL:ENSG00000196611"
"ENSEMBL:ENSG00000166670"
"ENSEMBL:ENSG00000099953"
"ENSEMBL:ENSG00000275365"
"ENSEMBL:ENSG00000137745"
"ENSEMBL:ENSG00000198598"
"ENSEMBL:ENSG00000125966"
"ENSEMBL:ENSG00000149968"
"ENSEMBL:ENSG00000079931"
"ENSEMBL:ENSG00000135324"
"ENSEMBL:ENSG00000179832"
"ENSEMBL:ENSG00000178860"
"ENSEMBL:ENSG00000235531"
"ENSEMBL:ENSG00000013364"
"ENSEMBL:ENSG00000162576"
"ENSEMBL:ENSG00000198336"
"ENSEMBL:ENSG00000065534"
"ENSEMBL:ENSG00000101605"
"ENSEMBL:ENSG00000229647"
"ENSEMBL:ENSG00000177791"
"ENSEMBL:ENSG00000138347"
"ENSEMBL:ENSG00000134369"
"ENSEMBL:ENSG00000166833"
"ENSEMBL:ENSG00000158747"
"ENSEMBL:ENSG00000164100"
"ENSEMBL:ENSG00000242242"
"ENSEMBL:ENSG00000163491"
"ENSEMBL:ENSG00000050030"
"ENSEMBL:ENSG00000162614"
"ENSEMBL:ENSG00000101096"
"ENSEMBL:ENSG00000162599"
"ENSEMBL:ENSG00000237928"
"ENSEMBL:ENSG00000163293"
"ENSEMBL:ENSG00000172548"
"ENSEMBL:ENSG00000188580"
"ENSEMBL:ENSG00000103024"
"ENSEMBL:ENSG00000166741"
"ENSEMBL:ENSG00000089250"
"ENSEMBL:ENSG00000086991"
"ENSEMBL:ENSG00000168743"
"ENSEMBL:ENSG00000113389"
"ENSEMBL:ENSG00000221890"
"ENSEMBL:ENSG00000164128"
"ENSEMBL:ENSG00000151623"
"ENSEMBL:ENSG00000123572"
"ENSEMBL:ENSG00000170091"
"ENSEMBL:ENSG00000185652"
"ENSEMBL:ENSG00000140538"
"ENSEMBL:ENSG00000133636"
"ENSEMBL:ENSG00000275074"
"ENSEMBL:ENSG00000104044"
"ENSEMBL:ENSG00000277361"
"ENSEMBL:ENSG00000145247"
"ENSEMBL:ENSG00000118733"
"ENSEMBL:ENSG00000162745"
"ENSEMBL:ENSG00000183715"
"ENSEMBL:ENSG00000116329"
"ENSEMBL:ENSG00000144645"
"ENSEMBL:ENSG00000180914"
"ENSEMBL:ENSG00000174944"
"ENSEMBL:ENSG00000099260"
"ENSEMBL:ENSG00000137819"
"ENSEMBL:ENSG00000152931"
"ENSEMBL:ENSG00000138650"
"ENSEMBL:ENSG00000184226"
"ENSEMBL:ENSG00000154678"
"ENSEMBL:ENSG00000172572"
"ENSEMBL:ENSG00000113448"
"ENSEMBL:ENSG00000197461"
"ENSEMBL:ENSG00000145431"
"ENSEMBL:ENSG00000154553"
"ENSEMBL:ENSG00000165966"
"ENSEMBL:ENSG00000112378"
"ENSEMBL:ENSG00000067057"
"ENSEMBL:ENSG00000119630"
"ENSEMBL:ENSG00000102174"
"ENSEMBL:ENSG00000181649"
"ENSEMBL:ENSG00000274538"
"ENSEMBL:ENSG00000109132"
"ENSEMBL:ENSG00000175287"
"ENSEMBL:ENSG00000153823"
"ENSEMBL:ENSG00000100100"
"ENSEMBL:ENSG00000158683"
"ENSEMBL:ENSG00000135549"
"ENSEMBL:ENSG00000189129"
"ENSEMBL:ENSG00000138193"
"ENSEMBL:ENSG00000149527"
"ENSEMBL:ENSG00000276429"
"ENSEMBL:ENSG00000115896"
"ENSEMBL:ENSG00000100558"
"ENSEMBL:ENSG00000169499"
"ENSEMBL:ENSG00000196155"
"ENSEMBL:ENSG00000102007"
"ENSEMBL:ENSG00000203805"
"ENSEMBL:ENSG00000130300"
"ENSEMBL:ENSG00000161381"
"ENSEMBL:ENSG00000120594"
"ENSEMBL:ENSG00000221866"
"ENSEMBL:ENSG00000132000"
"ENSEMBL:ENSG00000288195"
"ENSEMBL:ENSG00000132429"
"ENSEMBL:ENSG00000133110"
"ENSEMBL:ENSG00000224897"
"ENSEMBL:ENSG00000132170"
"ENSEMBL:ENSG00000086717"
"ENSEMBL:ENSG00000119938"
"ENSEMBL:ENSG00000061455"
"ENSEMBL:ENSG00000166501"
"ENSEMBL:ENSG00000027075"
"ENSEMBL:ENSG00000138669"
"ENSEMBL:ENSG00000171864"
"ENSEMBL:ENSG00000184838"
"ENSEMBL:ENSG00000150687"
"ENSEMBL:ENSG00000146250"
"ENSEMBL:ENSG00000165186"
"ENSEMBL:ENSG00000125384"
"ENSEMBL:ENSG00000073756"
"ENSEMBL:ENSG00000134242"
"ENSEMBL:ENSG00000054356"
"ENSEMBL:ENSG00000151490"
"ENSEMBL:ENSG00000115828"
"ENSEMBL:ENSG00000228492"
"ENSEMBL:ENSG00000041353"
"ENSEMBL:ENSG00000276600"
"ENSEMBL:ENSG00000128340"
"ENSEMBL:ENSG00000132359"
"ENSEMBL:ENSG00000100302"
"ENSEMBL:ENSG00000152689"
"ENSEMBL:ENSG00000198774"
"ENSEMBL:ENSG00000163694"
"ENSEMBL:ENSG00000159200"
"ENSEMBL:ENSG00000134533"
"ENSEMBL:ENSG00000256650"
"ENSEMBL:ENSG00000117152"
"ENSEMBL:ENSG00000186479"
"ENSEMBL:ENSG00000206712"
"ENSEMBL:ENSG00000198963"
"ENSEMBL:ENSG00000047936"
"ENSEMBL:ENSG00000181031"
"ENSEMBL:ENSG00000262334"
"ENSEMBL:ENSG00000282013"
"ENSEMBL:ENSG00000147655"
"ENSEMBL:ENSG00000188643"
"ENSEMBL:ENSG00000188015"
"ENSEMBL:ENSG00000197956"
"ENSEMBL:ENSG00000180739"
"ENSEMBL:ENSG00000187634"
"ENSEMBL:ENSG00000164483"
"ENSEMBL:ENSG00000205413"
"ENSEMBL:ENSG00000171951"
"ENSEMBL:ENSG00000149575"
"ENSEMBL:ENSG00000166396"
"ENSEMBL:ENSG00000135919"
"ENSEMBL:ENSG00000107819"
"ENSEMBL:ENSG00000108823"
"ENSEMBL:ENSG00000102683"
"ENSEMBL:ENSG00000118473"
"ENSEMBL:ENSG00000118515"
"ENSEMBL:ENSG00000104205"
"ENSEMBL:ENSG00000164023"
"ENSEMBL:ENSG00000104611"
"ENSEMBL:ENSG00000172985"
"ENSEMBL:ENSG00000259863"
"ENSEMBL:ENSG00000125089"
"ENSEMBL:ENSG00000129946"
"ENSEMBL:ENSG00000185634"
"ENSEMBL:ENSG00000178343"
"ENSEMBL:ENSG00000185187"
"ENSEMBL:ENSG00000170577"
"ENSEMBL:ENSG00000221955"
"ENSEMBL:ENSG00000141526"
"ENSEMBL:ENSG00000146477"
"ENSEMBL:ENSG00000185052"
"ENSEMBL:ENSG00000162241"
"ENSEMBL:ENSG00000139209"
"ENSEMBL:ENSG00000138449"
"ENSEMBL:ENSG00000148942"
"ENSEMBL:ENSG00000115665"
"ENSEMBL:ENSG00000131389"
"ENSEMBL:ENSG00000183023"
"ENSEMBL:ENSG00000065923"
"ENSEMBL:ENSG00000174640"
"ENSEMBL:ENSG00000184347"
"ENSEMBL:ENSG00000184564"
"ENSEMBL:ENSG00000120693"
"ENSEMBL:ENSG00000179256"
"ENSEMBL:ENSG00000271824"
"ENSEMBL:ENSG00000198732"
"ENSEMBL:ENSG00000112562"
"ENSEMBL:ENSG00000120833"
"ENSEMBL:ENSG00000246985"
"ENSEMBL:ENSG00000109610"
"ENSEMBL:ENSG00000061656"
"ENSEMBL:ENSG00000166145"
"ENSEMBL:ENSG00000167642"
"ENSEMBL:ENSG00000134668"
"ENSEMBL:ENSG00000196104"
"ENSEMBL:ENSG00000118785"
"ENSEMBL:ENSG00000116096"
"ENSEMBL:ENSG00000171621"
"ENSEMBL:ENSG00000070182"
"ENSEMBL:ENSG00000179954"
"ENSEMBL:ENSG00000172830"
"ENSEMBL:ENSG00000115525"
"ENSEMBL:ENSG00000148488"
"ENSEMBL:ENSG00000144681"
"ENSEMBL:ENSG00000115107"
"ENSEMBL:ENSG00000104435"
"ENSEMBL:ENSG00000148175"
"ENSEMBL:ENSG00000198829"
"ENSEMBL:ENSG00000137573"
"ENSEMBL:ENSG00000198203"
"ENSEMBL:ENSG00000109193"
"ENSEMBL:ENSG00000099994"
"ENSEMBL:ENSG00000173705"
"ENSEMBL:ENSG00000197321"
"ENSEMBL:ENSG00000234814"
"ENSEMBL:ENSG00000162520"
"ENSEMBL:ENSG00000078269"
"ENSEMBL:ENSG00000204176"
"ENSEMBL:ENSG00000139973"
"ENSEMBL:ENSG00000142765"
"ENSEMBL:ENSG00000147041"
"ENSEMBL:ENSG00000115353"
"ENSEMBL:ENSG00000158710"
"ENSEMBL:ENSG00000253676"
"ENSEMBL:ENSG00000135111"
"ENSEMBL:ENSG00000204219"
"ENSEMBL:ENSG00000282941"
"ENSEMBL:ENSG00000118526"
"ENSEMBL:ENSG00000110719"
"ENSEMBL:ENSG00000183508"
"ENSEMBL:ENSG00000226674"
"ENSEMBL:ENSG00000137203"
"ENSEMBL:ENSG00000105329"
"ENSEMBL:ENSG00000119699"
"ENSEMBL:ENSG00000120708"
"ENSEMBL:ENSG00000178726"
"ENSEMBL:ENSG00000136114"
"ENSEMBL:ENSG00000127666"
"ENSEMBL:ENSG00000142910"
"ENSEMBL:ENSG00000223573"
"ENSEMBL:ENSG00000038295"
"ENSEMBL:ENSG00000137462"
"ENSEMBL:ENSG00000183160"
"ENSEMBL:ENSG00000164484"
"ENSEMBL:ENSG00000196932"
"ENSEMBL:ENSG00000121900"
"ENSEMBL:ENSG00000105696"
"ENSEMBL:ENSG00000165548"
"ENSEMBL:ENSG00000187783"
"ENSEMBL:ENSG00000136842"
"ENSEMBL:ENSG00000120659"
"ENSEMBL:ENSG00000120337"
"ENSEMBL:ENSG00000116147"
"ENSEMBL:ENSG00000111907"
"ENSEMBL:ENSG00000259498"
"ENSEMBL:ENSG00000159713"
"ENSEMBL:ENSG00000102871"
"ENSEMBL:ENSG00000056558"
"ENSEMBL:ENSG00000211818"
"ENSEMBL:ENSG00000132481"
"ENSEMBL:ENSG00000121236"
"ENSEMBL:ENSG00000069018"
"ENSEMBL:ENSG00000144481"
"ENSEMBL:ENSG00000187688"
"ENSEMBL:ENSG00000134198"
"ENSEMBL:ENSG00000100300"
"ENSEMBL:ENSG00000180543"
"ENSEMBL:ENSG00000265972"
"ENSEMBL:ENSG00000215218"
"ENSEMBL:ENSG00000156687"
"ENSEMBL:ENSG00000145390"
"ENSEMBL:ENSG00000150630"
"ENSEMBL:ENSG00000206538"
"ENSEMBL:ENSG00000261373"
"ENSEMBL:ENSG00000146530"
"ENSEMBL:ENSG00000103175"
"ENSEMBL:ENSG00000156076"
"ENSEMBL:ENSG00000188064"
"ENSEMBL:ENSG00000255282"
"ENSEMBL:ENSG00000189420"
"ENSEMBL:ENSG00000251003"
"ENSEMBL:ENSG00000144331"
"ENSEMBL:ENSG00000225614"
"ENSEMBL:ENSG00000183779"
"ENSEMBL:ENSG00000170396"))
| false |
fd5a41632c68386705729d1d77d5889f4ef8732c | f9d7d9fa5c4129d7f5f9dde67b5a418f5c0371d3 | /x11/keysym-util.rkt | daac5401dc527100619c8a984177021b4c0bc5fc | []
| no_license | kazzmir/x11-racket | 20f96394df9997b9b681f405492b9d0ac41df845 | 97c4a75872cfd2882c8895bba88b87a4ad12be0e | refs/heads/master | 2021-07-16T04:13:17.708464 | 2021-03-10T15:22:41 | 2021-03-10T15:22:41 | 6,407,498 | 8 | 1 | null | 2013-08-14T03:43:00 | 2012-10-26T17:14:33 | Racket | UTF-8 | Racket | false | false | 1,175 | rkt | keysym-util.rkt | #lang racket
(require "keysymdef.rkt")
(provide (all-defined-out))
;;; From /usr/include/X11/Xutil.h
;;; Author: Laurent Orseau -- laurent orseau gmail com
;; key-sym: _ulong
(define (IsKeypadKey keysym)
(and (keysym . >= . XK-KP-Space) (keysym . <= . XK-KP-Equal)))
(define (IsPrivateKeypadKey keysym)
(and (keysym . >= . #x11000000) (keysym . <= . #x1100FFFF)))
(define (IsCursorKey keysym)
(and (keysym . >= . XK-Home) (keysym . < . XK-Select)))
(define (IsPFKey keysym)
(and (keysym . >= . XK-KP-F1) (keysym . <= . XK-KP-F4)))
(define (IsFunctionKey keysym)
(and (keysym . >= . XK-F1) (keysym . <= . XK-F35)))
(define (IsMiscFunctionKey keysym)
(and (keysym . >= . XK-Select) (keysym . <= . XK-Break)))
#|ifdef XK-XKB-KEYS
(define (IsModifierKey keysym)
(or
(and (keysym . >= . XK-Shift-L) (keysym . <= . XK-Hyper-R))
(and (keysym . >= . XK-ISO-Lock)
(keysym . <= . XK-ISO-Last-Group-Lock))
(keysym . = . XK-Mode-switch)
(keysym . = . XK-Num-Lock)))
|#;else
(define (IsModifierKey keysym)
(or (keysym . >= . XK-Shift-L) (keysym . <= . XK-Hyper-R)
(keysym . = . XK-Mode-switch)
(keysym . = . XK-Num-Lock)))
;#endif
| false |
1b2366860c2d31545f446dd0573631f500583afc | 00e9233f3c51474561c07a8fbb756f80068deb40 | /passes/flatten.rkt | 400cfbe7757f705bd7338f2832bc4147b6d595ef | [
"MIT"
]
| permissive | zachsully/rachet | efd1e3e9818f904e88836e3a5f942c61d0457bee | 9b5a56e3a777e7885a44d1b3d34cd85e3390bf74 | refs/heads/master | 2020-05-29T14:39:20.710808 | 2016-07-30T05:32:39 | 2016-07-30T05:32:39 | 61,372,031 | 2 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 6,096 | rkt | flatten.rkt | #lang racket
(require "../utilities.rkt")
(require "typecheck.rkt")
(require racket/pretty)
(provide flatten)
;;
;; Flatten
;;
;; flatten : R2 -> C2
;;
;; Takes a racket program in an AST and flattens it into a sequential one
;;
(define (flatten^ expr need-var)
(match expr
[`(has-type ,e ,t)
#:when (or (symbol? e)
(integer? e)
(boolean? e))
(values expr '())]
[`(has-type (eq? ,e1 ,e2) ,t)
(if
need-var
(let ([tmp (gensym "eq.")])
(let-values ([(e1_ex e1_stmts) (flatten^ e1 need-var)]
[(e2_ex e2_stmts) (flatten^ e2 need-var)])
(values `(has-type ,tmp ,t)
(append e1_stmts
e2_stmts
`((assign ,tmp (has-type (eq? ,e1_ex ,e2_ex)
Boolean)))))))
(let-values ([(e1_ex e1_stmts) (flatten^ e1 need-var)]
[(e2_ex e2_stmts) (flatten^ e2 need-var)])
(values `(has-type (eq? ,e1_ex ,e2_ex) ,t)
(append e1_stmts e2_stmts))))]
[`(has-type (let ([,x ,rhs]) ,body) ,t)
(let-values ([(rhs_ex rhs_stmts) (flatten^ rhs #f)]
[(body_ex body_stmts) (flatten^ body need-var)])
(values body_ex
(append rhs_stmts `((assign ,x ,rhs_ex)) body_stmts)))]
[`(has-type (read) ,t)
(let ([tmp (gensym "read.")])
(values `(has-type ,tmp ,t) `((assign ,tmp (has-type (read) ,t)))))]
[`(has-type (- ,es) ,t)
(if need-var
(let ([tmp (gensym "neg.")])
(let-values ([(ex stmts) (flatten^ es need-var)])
(values `(has-type ,tmp ,t)
(append stmts `((assign ,tmp (has-type (- ,ex) ,t)))))))
(let-values ([(ex stmts) (flatten^ es need-var)])
(values `(has-type (- ,ex) ,t) stmts)))]
[`(has-type (+ ,e1 ,e2) ,t)
(if need-var
(let ([tmp (gensym "plus.")])
(let-values ([(ex1 stmts1) (flatten^ e1 need-var)]
[(ex2 stmts2) (flatten^ e2 need-var)])
(values `(has-type ,tmp ,t)
(append stmts1 stmts2
`((assign ,tmp (has-type (+ ,ex1 ,ex2)
Integer)))))))
(let-values ([(ex1 stmts1) (flatten^ e1 #t)]
[(ex2 stmts2) (flatten^ e2 #t)])
(values `(has-type (+ ,ex1 ,ex2) ,t) (append stmts1 stmts2))))]
[`(has-type (if ,cnd ,thn ,els) ,t)
(let-values ([(cnd_ex cnd_stmts) (flatten^ cnd #t)]
[(thn_ex thn_stmts) (flatten^ thn #t)]
[(els_ex els_stmts) (flatten^ els #t)])
(let ([tmp (gensym "if.")])
(values `(has-type ,tmp ,t)
(append cnd_stmts
`((if (eq? (has-type #t Boolean) ,cnd_ex)
,(append thn_stmts `((assign ,tmp ,thn_ex)))
,(append els_stmts `((assign ,tmp ,els_ex))))
)))))]
[`(has-type (or ,e1 ,e2) ,t)
(flatten^ `(has-type (if ,e1 (has-type #t Boolean) e2) ,t)
need-var)]
[`(has-type (and ,e1 ,e2) ,t)
(flatten^ `(has-type (if ,e1 ,e2 (has-type #f Boolean)) ,t)
need-var)]
[`(has-type (not ,es) ,t)
(if need-var
(let ([tmp (gensym "not.")])
(let-values ([(es_ex es_stmts) (flatten^ es need-var)])
(values `(has-type ,tmp ,t)
(append es_stmts
`((assign ,tmp (has-type (not ,es_ex)
Boolean)))))))
(let-values ([(es_ex es_stmts) (flatten^ es need-var)])
(values `(has-type (not ,es_ex) ,t) es_stmts)))]
[`(has-type (vector ,args ...) ,t)
(let ([args^
(foldl (lambda (x acc)
(let-values ([(ex st) (flatten^ x need-var)])
(cons
(append (car acc) `(,ex))
(append st (cdr acc)))))
(cons '() '())
args)]
[tmp (gensym "vec.")])
(values `(has-type ,tmp ,t)
(append (cdr args^)
`((assign ,tmp (has-type (vector ,@(car args^)) ,t))))))]
[`(has-type (vector-ref ,arg ,i) ,t)
(let ([tmp (gensym "vref.")])
(let-values ([(ex stmts) (flatten^ arg need-var)])
(values `(has-type ,tmp ,t)
(append stmts
`((assign ,tmp
(has-type (vector-ref ,ex ,i) ,t)))))))]
[`(has-type (vector-set! ,arg ,i ,narg) ,t)
(if need-var
(let ([tmp (gensym "vset.")])
(let-values ([(exA stmtsA) (flatten^ arg #t)]
[(exN stmtsN) (flatten^ narg need-var)])
(values `(has-type ,tmp ,t)
(append stmtsA
stmtsN
`((assign ,tmp (has-type (vector-set! ,exA ,i ,exN)
_)))))))
(let-values ([(exA stmtsA) (flatten^ arg need-var)]
[(exN stmtsN) (flatten^ narg need-var)])
(values `(has-type (vector-set! ,exA ,i ,exN) ,t)
(append stmtsA stmtsN))))]
[`(has-type (function-ref ,f) ,t)
(let ([tmp (gensym "funk-ref.")])
(values `(has-type ,tmp ,t)
`((assign ,tmp (has-type (function-ref ,f) ,t)))))]
[`(has-type (app ,f ,args ...) ,t)
(let ([args^
(foldl (lambda (x acc)
(let-values ([(ex st) (flatten^ x need-var)])
(cons
(append (car acc) `(,ex))
(append st (cdr acc)))))
(cons '() '())
args)]
[tmp (gensym "app-funk.")])
(let-values ([(exF stmtsF) (flatten^ f need-var)])
(values `(has-type ,tmp ,t)
(append stmtsF
(cdr args^)
`((assign ,tmp (has-type (app ,exF ,@(car args^))
,t)))))))]
))
(define (flatten-define d)
(match d
[`(define (,name (clos : _) (,vars : ,ts) ...) : ,t ,e)
(let-values ([(ex stmts) (flatten^ e #t)])
`(define (,name [clos : _] ,@(map (lambda (v t)
`[,v : ,t]) vars ts))
: ,t
,(remove-duplicates (unique-vars stmts '()))
,@(append stmts `((return ,ex)))))]))
;; MAIN FLATTEN funk
(define (flatten p)
(match p
[`(program ,defs ... ,expr)
(let-values ([(ex rhs) (flatten^ expr #t)])
(let ([vars (remove-duplicates (unique-vars rhs '()))]
[defs^ (map flatten-define defs)])
`(program ,vars
(defines ,@defs^)
,@(append rhs `((return ,ex))))))]))
(define unique-vars-helper
(lambda (instr)
(match instr
[`(assign ,e1 ,e2) `(,e1)]
[`(if ,cnd ,thn ,els) (append (unique-vars thn '())
(unique-vars els '()))]
[else '()])))
(define unique-vars
(lambda (instrs ans)
(if (null? instrs)
ans
(unique-vars (cdr instrs)
(append ans
(unique-vars-helper (car instrs)))))
))
| false |
47ca08bdcb2591b1a720d28dc2533501068612d5 | a8338c4a3d746da01ef64ab427c53cc496bdb701 | /drbayes/private/set/types.rkt | 8638aff27bcb1e7415bed81f4e5084cef328a377 | []
| no_license | ntoronto/plt-stuff | 83c9c4c7405a127bb67b468e04c5773d800d8714 | 47713ab4c16199c261da6ddb88b005222ff6a6c7 | refs/heads/master | 2016-09-06T05:40:51.069410 | 2013-10-02T22:48:47 | 2013-10-02T22:48:47 | 1,282,564 | 4 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 595 | rkt | types.rkt | #lang typed/racket/base
(provide (all-defined-out))
(struct: Base-Value () #:transparent)
(struct: Base-Set () #:transparent)
(define set? Base-Set?)
(struct: Base-Bot-Set Base-Set () #:transparent)
(define bot-set? Base-Bot-Set?)
(struct: Base-Top-Set Base-Set () #:transparent)
(define top-set? Base-Top-Set?)
(struct: Base-Bot-Entry Base-Bot-Set () #:transparent)
(define bot-entry? Base-Bot-Entry?)
(struct: Base-Top-Entry Base-Top-Set () #:transparent)
(define top-entry? Base-Top-Entry?)
(struct: Base-Bot-Basic Base-Bot-Entry () #:transparent)
(define bot-basic? Base-Bot-Basic?)
| false |
d91e29ea35f82b4977ca2316e9d33c47d77d6c04 | a9726aae050211a6b6fd8d07792a71f7138e8341 | /conf-pane.rkt | eaedeecc955ed8e58e5423bca3dba496c11d528d | [
"MIT"
]
| permissive | souravdatta/rkts | 45f2633aa277fd0b84617b05263e4603c0b8d5e1 | cf07926d7cb4603ea6e1bf78553e3870befc863a | refs/heads/master | 2021-01-17T14:57:11.961644 | 2017-08-24T09:56:20 | 2017-08-24T09:56:20 | 52,510,749 | 0 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 2,086 | rkt | conf-pane.rkt | #lang typed/racket
(require typed/racket/gui)
(require "conf-button.rkt")
(define-type Conf-Pane% (Class
(init (conf-buttons (Listof (Instance Conf-Button%)))
(command (-> (Listof Nonnegative-Integer) Any)))
(field (command (-> (Listof Nonnegative-Integer) Any))
(conf-buttons (Listof (Instance Conf-Button%))))
(render (-> (Instance Pane%) (Instance Pane%)))))
(: conf-pane% Conf-Pane%)
(define conf-pane% (class object%
(init-field [conf-buttons : (Listof (Instance Conf-Button%))]
[command : (-> (Listof Nonnegative-Integer) Any)])
(: gen-config (-> (Listof Nonnegative-Integer)))
(define/private (gen-config)
(let ([ls (map (λ ([x : (Instance Conf-Button%)])
(send x render-list))
conf-buttons)])
(map (λ ([x : (Pairof
(List Nonnegative-Integer Nonnegative-Integer Nonnegative-Integer)
Nonnegative-Integer)])
(cdr x))
ls)))
(define/public (render parent)
(let* ([vpane (new vertical-pane% [parent parent])]
[genbtn (new button%
[parent vpane]
[label "Generate Configuration"]
[callback (λ ([b : (Instance Button%)]
[e : Any])
(command (gen-config)))])])
(for ([x conf-buttons])
(send x render vpane))
vpane))
(super-new)))
(provide Conf-Pane% conf-pane%)
| false |
b00739a35ff6a9be52a549d20bf552edae37f129 | 821e50b7be0fc55b51f48ea3a153ada94ba01680 | /exp5/slideshow/end.rkt | 3844227687448ad1bf7198d3dae5d1af1bcc03f5 | []
| no_license | LeifAndersen/experimental-methods-in-pl | 85ee95c81c2e712ed80789d416f96d3cfe964588 | cf2aef11b2590c4deffb321d10d31f212afd5f68 | refs/heads/master | 2016-09-06T05:22:43.353721 | 2015-01-12T18:19:18 | 2015-01-12T18:19:18 | 24,478,292 | 1 | 0 | null | 2014-12-06T20:53:40 | 2014-09-25T23:00:59 | Racket | UTF-8 | Racket | false | false | 1,403 | rkt | end.rkt | #lang slideshow
(require "analogy.rkt"
"castle.rkt"
"movie.rkt"
slideshow/play)
(provide end-slides
final-end-slide)
(define (white-out n p)
(refocus
(cc-superimpose p
(cellophane
(colorize (filled-rectangle (+ (pict-width p) (* 4 gap-size))
(pict-height p))
"white")
n))
p))
(define (transform n a b)
(define-values (n1 n2) (split-phase n))
(cc-superimpose (if (= n1 1.0)
(ghost a)
(white-out n1 a))
(if (= n2 0.0)
(ghost b)
(white-out (- 1 n2) b))))
(define urls
(scale
(vc-append
gap-size
(tt "www.plt-scheme.org")
(t "or")
(tt "pre.plt-scheme.org"))
0.8))
(define (make-end-slide book-n scribble-n url-n plt-n)
(vc-append
gap-size
(transform book-n (scale castle 0.5) book-icon)
(let ([p (transform scribble-n (scale million-well 0.5) drscheme-screen)])
(refocus (hc-append
gap-size
p
(cellophane urls url-n))
p))
(transform plt-n (scale kingdom 0.5) plt-langs)))
(define (end-slides)
(play-n
#:name "Conclusion"
make-end-slide))
(define final-end-slide
(make-end-slide 1.0 1.0 1.0 1.0))
| false |
b1cd050ff363cb80d3fa28aedc0f788a2b4dfd94 | c7b2e9798968b7b65626e30be8e53eced7fef55c | /TP/tp8/tp08_ca802636.rkt | 0b2b756ac8e37d90bc06fd1baa29773fc29ca463 | []
| no_license | MonsieurCo/ParadigmesL3 | bc61005ee8711a417db27ceea53699953cbf86db | 68af1bda1ce4da678e8131f39ac7d391cb3b463b | refs/heads/main | 2023-07-26T14:43:31.165775 | 2021-09-01T14:48:54 | 2021-09-01T14:48:54 | 336,847,745 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 15,516 | rkt | tp08_ca802636.rkt | ; Cours 08 : Continuations
#lang plait
;;;;;;;;;;;;;;;;;;;;;;;;
; Définition des types ;
;;;;;;;;;;;;;;;;;;;;;;;;
; Représentation des expressions
(define-type Exp
[numE (n : Number)]
[idE (s : Symbol)]
[appE (fun : Exp) (arg : Exp)]
[plusE (l : Exp) (r : Exp)]
[multE (l : Exp) (r : Exp)]
[lamE (par : Symbol) (body : Exp)]
[let/ccE (s : Symbol) (body : Exp)]
[setE (s : Symbol) (e : Exp)]
[beginE (f : Exp) (s : Exp)]
[ifE (cnd : Exp) (t : Exp) (f : Exp)]
[whileE (cnd : Exp) (body : Exp)]
[breakE]
)
; Représentation des valeurs
(define-type Value
[numV (n : Number)]
[closV (par : Symbol) (body : Exp) (env : Env)]
[contV (k : Cont)])
; Représentation des liaisons
(define-type Binding
[bind (name : Symbol) (location : Location)])
; Manipulation de l'environnement
(define-type-alias Env (Listof Binding))
(define mt-env empty)
(define extend-env cons)
; Représentation des continuations
(define-type Cont
[doneK]
[addSecondK (r : Exp) (env : Env) (k : Cont)]
[doAddK (val : Value) (k : Cont)]
[multSecondK (r : Exp) (env : Env) (k : Cont)]
[doMultK (val : Value) (k : Cont)]
[appArgK (arg : Exp) (env : Env) (k : Cont)]
[doAppK (val : Value) (k : Cont)]
[doSetk (s : Symbol) (env : Env) (k : Cont)]
[doBegin (ex : Exp) (env : Env) (k : Cont )]
[doIfk (t : Exp) ( f : Exp) (env : Env) (k : Cont)]
[doBodyK (cnd : Exp) (body : Exp) (env : Env) (k : Cont)]
[doCondK (cnd : Exp) (body : Exp) (env : Env) (k : Cont)]
)
; Représentation des adresses mémoire
(define-type-alias Location Number)
; Représentation d'un enregistrement
(define-type Storage
[cell (location : Location) (val : Value)])
; Manipulation de la mémoire
(define-type-alias Store (Listof Storage))
(define mt-store empty)
(define override-store cons)
;;;;;;;;;;;;;;;;;;;;;;
; Analyse syntaxique ;
;;;;;;;;;;;;;;;;;;;;;;
(define (parse [s : S-Exp]) : Exp
(cond
[(s-exp-match? `break s) (breakE)]
[(s-exp-match? `NUMBER s) (numE (s-exp->number s))]
[(s-exp-match? `SYMBOL s) (idE (s-exp->symbol s))]
[(s-exp-match? `{+ ANY ANY} s)
(let ([sl (s-exp->list s)])
(plusE (parse (second sl)) (parse (third sl))))]
[(s-exp-match? `{* ANY ANY} s)
(let ([sl (s-exp->list s)])
(multE (parse (second sl)) (parse (third sl))))]
[(s-exp-match? `{- ANY ANY} s)
(let ([sl (s-exp->list s)])
(plusE (parse (second sl)) (multE (numE -1) (parse (third sl)))))]
[(s-exp-match? `{let {[SYMBOL ANY]} ANY} s)
(let ([sl (s-exp->list s)])
(let ([subst (s-exp->list (first (s-exp->list (second sl))))])
(appE (lamE (s-exp->symbol (first subst)) (parse (third sl))) (parse (second subst)))))]
[(s-exp-match? `{lambda {SYMBOL} ANY} s)
(let ([sl (s-exp->list s)])
(lamE (s-exp->symbol (first (s-exp->list (second sl)))) (parse (third sl))))]
[(s-exp-match? `{let/cc SYMBOL ANY} s)
(let ([sl (s-exp->list s)])
(let/ccE (s-exp->symbol (second sl)) (parse (third sl))))]
[(s-exp-match? `{set! SYMBOL ANY} s)
(let ([sl (s-exp->list s)])
(setE (s-exp->symbol (second sl)) (parse (third sl))))]
[(s-exp-match? `{begin ANY ANY} s)
(let ([sl (s-exp->list s)])
(beginE (parse (second sl)) (parse (third sl))))]
[(s-exp-match? `{if ANY ANY ANY} s)
(let ([sl (s-exp->list s)])
(ifE (parse (second sl)) (parse (third sl)) (parse (fourth sl))))]
[(s-exp-match? `{while ANY ANY}s)
(let ([sl (s-exp->list s)])
(whileE (parse (second sl)) (parse (third sl))))]
[(s-exp-match? `{ANY ANY} s)
(let ([sl (s-exp->list s)])
(appE (parse (first sl)) (parse (second sl))))]
[else (error 'parse "invalid input")]))
;;;;;;;;;;;;;;;;;;
; Interprétation ;
;;;;;;;;;;;;;;;;;;
; Interpréteur
(define (interp [e : Exp] [env : Env] [sto : Store] [k : Cont]) : Value
(type-case Exp e
[(numE n) (continue k (numV n) sto)]
[(idE s) (continue k (fetch (lookup s env) sto) sto)]
[(plusE l r) (interp l env sto (addSecondK r env k))]
[(multE l r) (interp l env sto (multSecondK r env k))]
[(lamE par body) (continue k (closV par body env) sto)]
[(appE f arg) (interp f env sto (appArgK arg env k))]
[(beginE l r) (interp l env sto (doBegin r env k))]
[(let/ccE s body)
(let ([l (new-loc sto)])
(interp body
(extend-env (bind s l) env)
(override-store (cell l (contV k)) sto)
k))]
[(setE s ex) (interp ex env sto (doSetk s env k))]
[(ifE cnd t f ) ( interp cnd env sto ( doIfk t f env k))]
[(whileE cnd body) (interp cnd env sto (doBodyK cnd body env k))]
[(breakE) (escape k sto)]
))
;(define (escape-moi-ça k sto)
; (if (doCondK? k)
; (let ([kp (doCondK-k k)])
; (if (doBodyK? kp)
; (continue (doBodyK-k kp) (numV 0) sto)
; (continue k (numV 0) sto)))
;(error 'escape-moi-ça "break outside while")))
(define (escape [k : Cont] [sto : Store]) : Value
(type-case Cont k
[(doneK) (error 'escape "break outside while")]
[(addSecondK r env next-k) (escape next-k sto)]
[(doAddK v-l next-k) (escape next-k sto)]
[(multSecondK r env next-k) (escape next-k sto)]
[(doMultK v-l next-k) (escape next-k sto)]
[(appArgK arg env next-k) (escape next-k sto)]
[(doAppK v-f next-k) (escape next-k sto)]
[(doSetk s env next-k ) (escape next-k sto)]
[(doBegin ex env next-k ) (escape next-k sto)]
[(doIfk t f env next-k)(escape next-k sto) ]
[(doBodyK cnd body env next-k)(error 'escape "break outside while")]
[(doCondK cnd body env next-k) (continue next-k (numV 0) sto)]))
; Appel des continuations
(define (continue [k : Cont] [val : Value] [sto : Store]) : Value
(type-case Cont k
[(doneK) val]
[(addSecondK r env next-k) (interp r env sto(doAddK val next-k))]
[(doAddK v-l next-k) (continue next-k (num+ v-l val) sto)]
[(multSecondK r env next-k) (interp r env sto (doMultK val next-k))]
[(doMultK v-l next-k) (continue next-k (num* v-l val) sto)]
[(appArgK arg env next-k) (interp arg env sto (doAppK val next-k))]
[(doAppK v-f next-k)
(type-case Value v-f
[(closV par body c-env)
(let ([l (new-loc sto)])
(interp body
(extend-env (bind par l) c-env)
(override-store (cell l val) sto)
next-k))]
[(contV k-v) (continue k-v val sto)]
[else (error 'interp "not a function")])]
[(doBegin e2 env next-k) (interp e2 env sto next-k)]
[(doSetk s env next-k) (continue next-k val (override-store (cell (lookup s env) val)sto))]
[(doIfk t f env next-k ) (if (equal? val (numV 0)) (interp f env sto next-k) (interp t env sto next-k))]
[(doBodyK cnd body env next-k) (if (equal? val (numV 0)) (continue next-k (numV 0) sto) (interp body env sto (doCondK cnd body env next-k)))]
[(doCondK cnd body env next-k) (interp cnd env sto (doBodyK cnd body env next-k))]
))
; Fonctions utilitaires pour l'arithmétique
(define (num-op [op : (Number Number -> Number)]
[l : Value] [r : Value]) : Value
(if (and (numV? l) (numV? r))
(numV (op (numV-n l) (numV-n r)))
(error 'interp "not a number")))
(define (num+ [l : Value] [r : Value]) : Value
(num-op + l r))
(define (num* [l : Value] [r : Value]) : Value
(num-op * l r))
; Recherche d'un identificateur dans l'environnement
(define (lookup [n : Symbol] [env : Env]) : Location
(cond
[(empty? env) (error 'lookup "free identifier")]
[(equal? n (bind-name (first env))) (bind-location (first env))]
[else (lookup n (rest env))]))
; Renvoie une adresse mémoire libre
(define (new-loc [sto : Store]) : Location
(+ (max-address sto) 1))
; Le maximum des adresses mémoires utilisés
(define (max-address [sto : Store]) : Location
(if (empty? sto)
0
(max (cell-location (first sto)) (max-address (rest sto)))))
; Accès à un emplacement mémoire
(define (fetch [l : Location] [sto : Store]) : Value
(cond
[(empty? sto) (error 'interp "segmentation fault")]
[(equal? l (cell-location (first sto))) (cell-val (first sto))]
[else (fetch l (rest sto))]))
;;;;;;;;;
; Tests ;
;;;;;;;;;
(define (interp-expr [e : S-Exp]) : Value
(interp (parse e) mt-env mt-store (doneK)))
( test ( interp-expr `{ let {[x 0]}
{ begin { set! x 1}
x} })
( numV 1))
( test ( interp-expr `{ if 1 2 3}) ( numV 2))
( test ( interp-expr `{ if 0 2 3}) ( numV 3))
( test ( interp-expr `{ while 0 x}) ( numV 0))
( test ( interp-expr `{ let {[fac
{ lambda {n}
{ let {[res 1]}
{ begin
{ while n ; tant que n est non nul
{ begin
{ set! res {* n res } }
{ set! n {+ n -1} } } }
res } } }]}
{ fac 6} })
( numV 720))
(test (interp-expr `{let {[x 1]}
{begin
{while 0 {set! x 2}}
x}})
(numV 1))
(test (interp-expr `{let {[x 1]}
{begin
{while 0 0}
x}})
(numV 1))
( test ( interp-expr `{ while 1 break }) ( numV 0))
(test (interp-expr `{let {[n 10]}
{let {[x 50]}
{begin
{while n ; tant que n est non nul
(if (- n 1)
{while {- n 1}
{begin
{set! n {- n 1}}
{set! x {- x 1}}}}
break)}
x}}})
(numV 41))
(test (interp-expr `{let {[is-pos {lambda {n} ; n entier, renvoie n > 0
{let {[res 0]}
{begin
{let {[try-pos n]}
{let {[try-neg n]}
{while 1
{begin
{if try-neg
{set! try-neg {+ try-neg 1}}
break}
{if try-pos
{set! try-pos {- try-pos 1}}
{begin
{set! res 1}
break}}}}}}
res}}}]}
{is-pos 42}})
(numV 1))
(test (interp-expr `{let {[is-pos {lambda {n} ; n entier, renvoie n > 0
{let {[res 0]}
{begin
{let {[try-pos n]}
{let {[try-neg n]}
{while 1
{begin
{if try-neg
{set! try-neg {+ try-neg 1}}
break}
{if try-pos
{set! try-pos {- try-pos 1}}
{begin
{set! res 1}
break}}}}}}
res}}}]}
{is-pos -10}})
(numV 0))
(test (interp-expr `{let {[n 10]}
{begin
{while n ; tant que n est non nul
{if {- n 5}
{set! n {- n 1}} ; si n n' egale pas 5
break}} ; si n egale 5
n}})
(numV 5))
(test (interp-expr `{let {[n 10]}
{let {[x 50]}
{begin
{while n ; tant que n est non nul
{if {- n 1}
{while {- n 1}
{begin
{set! n {- n 1}}
{set! x {- x 1}}}}
break}}
x}}})
(numV 41))
(test (interp-expr `{while 1 {begin break 1}})
(numV 0))
(test (interp-expr `{let {[is-pos {lambda {n} ; n entier, renvoie n > 0
{let {[res 0]}
{begin
{let {[try-pos n]}
{let {[try-neg n]}
{while 1
{begin
{if try-neg
{set! try-neg {+ try-neg 1}}
break}
{if try-pos
{set! try-pos {- try-pos 1}}
{begin
{set! res 1}
break}}}}}}
res}}}]}
{is-pos 42}})
(numV 1))
(test (interp-expr `{let {[is-pos {lambda {n} ; n entier, renvoie n > 0
{let {[res 0]}
{begin
{let {[try-pos n]}
{let {[try-neg n]}
{while 1
{begin
{if try-neg
{set! try-neg {+ try-neg 1}}
break}
{if try-pos
{set! try-pos {- try-pos 1}}
{begin
{set! res 1}
break}}}}}}
res}}}]}
{is-pos -10}})
(numV 0))
(test/exn (interp-expr `{while break 1}) "break outside while")
(test (interp-expr `{let {[n 1]}
{while n {begin {set! n 0} 1}}})
(numV 0))
(test/exn (interp-expr `{let {[is-pos {lambda {n} ; n entier, renvoie n > 0
{let {[res 0]}
{begin
{let {[try-pos n]}
{let {[try-neg n]}
{while 1
{while break 0}}}}
res}}}]}
{is-pos -10}})
"break outside while")
| false |
4c843aacddfa423aec8c2c052b8dbdb24af8eee1 | d755de283154ca271ef6b3b130909c6463f3f553 | /htdp-test/tests/test-engine/check-expect.rkt | 5aceee3853a14167c68a91ebc98d36cf90f933e6 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
]
| permissive | racket/htdp | 2953ec7247b5797a4d4653130c26473525dd0d85 | 73ec2b90055f3ab66d30e54dc3463506b25e50b4 | refs/heads/master | 2023-08-19T08:11:32.889577 | 2023-08-12T15:28:33 | 2023-08-12T15:28:33 | 27,381,208 | 100 | 90 | NOASSERTION | 2023-07-08T02:13:49 | 2014-12-01T13:41:48 | Racket | UTF-8 | Racket | false | false | 887 | rkt | check-expect.rkt | #lang racket/base
(require (for-syntax racket/base)
rackunit)
(define-syntax (run stx)
(syntax-case stx ()
[(build name exp ...)
(let ([modname (string->symbol (format "mod~a" (syntax-line stx)))])
(datum->syntax
stx
`(begin
(module ,modname racket/base
(require test-engine/racket-tests)
(provide get-output)
,@(syntax->list #'(exp ...))
(define sp (open-output-string))
(parameterize ([current-output-port sp])
(test))
(define (get-output) (get-output-string sp)))
(require (submod "." ,modname))
(define ,#'name (get-output)))))]))
(run ch1 (check-expect "hello" "world"))
(check-regexp-match #rx"Actual value.*\"hello\"" ch1)
(check-regexp-match #rx"(\"world\".*expected value)|(Expected value.\"world\")" ch1)
| true |
3b2074742b49905cb28fa9e1bf2f2b7d683f8d09 | d2e71dfebb4a55f618989700bd58469ec6a3299e | /main.rkt | f48ce1d7d348864ba6b5865d7d7a2f4b4d242028 | []
| no_license | jackfirth/command-line-ext | d2dd108ee74d711f046be56b06a5e0aef1214a9b | e980b3b31d7a0cb6e0339335bde860f35a0fe471 | refs/heads/master | 2021-01-19T02:00:56.444437 | 2020-06-03T07:42:09 | 2020-06-03T07:42:09 | 32,500,058 | 4 | 2 | null | 2016-07-31T18:18:47 | 2015-03-19T04:05:57 | Racket | UTF-8 | Racket | false | false | 97 | rkt | main.rkt | #lang reprovide
"private/extensible-command-line-ext-syntax.rkt"
"private/library-expanders.rkt"
| false |
eefeb3915f4b8e3218671c48da7cf5253b138da6 | e553691752e4d43e92c0818e2043234e7a61c01b | /rosette/guide/scribble/reflection/symbolic-reflection.scrbl | 3d7fd3dd838d62d69927674e98bb8a0d6e93a2f6 | [
"BSD-2-Clause"
]
| permissive | emina/rosette | 2b8c1bcf0bf744ba01ac41049a00b21d1d5d929f | 5dd348906d8bafacef6354c2e5e75a67be0bec66 | refs/heads/master | 2023-08-30T20:16:51.221490 | 2023-08-11T01:38:48 | 2023-08-11T01:38:48 | 22,478,354 | 656 | 89 | NOASSERTION | 2023-09-14T02:27:51 | 2014-07-31T17:29:18 | Racket | UTF-8 | Racket | false | false | 825 | scrbl | symbolic-reflection.scrbl | #lang scribble/manual
@(require (for-label racket))
@title[#:tag "ch:symbolic-reflection" #:style 'toc]{Symbolic Reflection}
This chapter describes @deftech{symbolic reflection}, a
mechanism for manipulating the representation of symbolic values
(Section @seclink["sec:value-reflection"]{7.1}) and
the state of the symbolic evaluation from within a Rosette program
(Section @seclink["sec:state-reflection"]{7.2}).
Symbolic reflection has three main applications: (1) @tech[#:key "lifted constructs"]{lifting}
additional Racket constructs to work with symbolic values;
(2) guiding Rosette's symbolic virtual machine to achieve
better performance; and (3) implementing advanced solver-aided functionality.
@[table-of-contents]
@include-section["value-reflection.scrbl"]
@include-section["state-reflection.scrbl"] | false |
6b37f97ce56e41291280f46b76dcc9440595ea6b | ba5171ca08db9e0490db63df59ee02c85a581c70 | /exam/2020-11-07/3.rkt | f03c4a3646a78befcae336cd1b676d10a79bf9cb | []
| no_license | semerdzhiev/fp-2020-21 | 030071ed14688751d615b1d1d39fa406c131a285 | 64fa00c4f940f75a28cc5980275b124ca21244bc | refs/heads/master | 2023-03-07T10:17:49.583008 | 2021-02-17T11:46:08 | 2021-02-17T11:46:08 | 302,139,037 | 31 | 16 | null | 2021-01-17T15:22:17 | 2020-10-07T19:24:33 | Racket | UTF-8 | Racket | false | false | 1,535 | rkt | 3.rkt | (define (number-valid? n)
(cond ((< n 10) #t)
((= (remainder n 100) 0) #f) ;two consecutive zeros
(else (number-valid? (quotient n 10)))
)
)
(define (set-add s elem)
(let* ((mask (expt 2 elem))
(rest (quotient s mask)))
(if (= 1 (remainder rest 2)) ; elem is already in the set
s
(+ s mask))
)
)
(define (valid->nset n)
(define (find-where-next-number-begins n)
(if (= (remainder n 10) 0)
0
(+ 1 (find-where-next-number-begins (quotient n 10)))
)
)
(define (loop k result)
(cond ((= k 0) ; no more digits in the number
result)
((= 0 (remainder k 10)) ; curent digit is zero
(loop (quotient k 10) result))
(else ; current digit is non-zero
(let* (
(i (find-where-next-number-begins k))
(mask (expt 10 i))
(next-number (remainder k mask))
(rest-of-k (quotient k (* 10 mask)))
)
(loop rest-of-k (set-add result next-number))
)
)
)
)
(if (number-valid? n) (loop n 0) #f)
)
(define (accumulate op term init a next b)
(define (loop i)
(if (<= i b)
(op (term i) (loop (next i)) )
init
))
(loop a)
)
(define (make-nset a b pred?)
(define (1+ n) (+ 1 n))
(define (id i) i)
(define (op i result)
(if (pred? i)
(+ (expt 2 i) result)
result
)
)
(accumulate op id 0 a 1+ b)
) | false |
29b2f7f6e127b71ead56b316c98e3a8cb49cc789 | e4d80c9d469c9ca9ea464a4ad213585a578d42bc | /build.rkt | d6d42cb7fc4f912b43ee7c001412065384d03188 | []
| no_license | garciazz/curr | 0244b95086b0a34d78f720e9cae1cb0fdb686ec5 | 589a93c4a43967b06d7a6ab9d476b470366f9323 | refs/heads/master | 2021-01-17T19:14:21.756115 | 2016-02-24T22:16:26 | 2016-02-24T22:16:26 | 53,657,555 | 1 | 0 | null | 2016-03-11T09:58:01 | 2016-03-11T09:58:01 | null | UTF-8 | Racket | false | false | 13,644 | rkt | build.rkt | #!/usr/bin/env racket
#lang racket/base
(require racket/runtime-path
racket/system
racket/string
racket/cmdline
racket/path
racket/file
(lib "curr/lib/system-parameters.rkt")
"lib/translate-pdfs.rkt"
"lib/paths.rkt"
scribble/render
file/zip)
;; This is a toplevel build script which generates scribble files for
;; the lessons and courses. These scribble files will be translated
;; to HTML files, written under the deployment directory for simple
;; distribution.
;; The default deployment directory is "distribution"
(current-deployment-dir (simple-form-path "distribution"))
;; The following is a bit of namespace magic to avoid funkiness that
;; several of our team members observed when running this build script
;; under DrRacket with debugging enabled. We must make sure to use
;; a fairly clean namespace, but one that shares some critical modules
;; with this build script.
(define-namespace-anchor this-anchor)
(define shared-modules (list 'scribble/render
'(lib "curr/lib/system-parameters.rkt")))
(define (make-fresh-document-namespace)
(define ns (make-base-namespace))
(for ([mod shared-modules])
(namespace-attach-module (namespace-anchor->namespace this-anchor) mod ns))
ns)
(define document-namespace (make-fresh-document-namespace))
;; run-scribble: path -> void
;; Runs scribble on the given file.
(define (run-scribble scribble-file #:never-generate-pdf? [never-generate-pdf? #f]
#:include-base-path? [include-base-path? #t])
(define output-dir (cond [(current-deployment-dir)
;; Rendering to a particular deployment directory.
(if include-base-path?
(let-values ([(base name dir?)
(split-path
(find-relative-path (simple-form-path root-path)
(simple-form-path scribble-file)))])
(simple-form-path (build-path (current-deployment-dir) base)))
(current-deployment-dir))]
[else
(error 'run-scribble "No deployment directory?")
;; In-place rendering
#;(let-values ([(base name dir?)
(split-path (simple-form-path scribble-file))])
base)]))
(define-values (base name dir?) (split-path scribble-file))
(define output-path (build-path output-dir (string->path (regexp-replace #px"\\.scrbl$" (path->string name) ".html"))))
(parameterize ([current-directory base]
[current-namespace document-namespace]
[current-document-output-path output-path])
(render (list (dynamic-require `(file ,(path->string name)) 'doc))
(list name)
#:dest-dir output-dir)
(when (and (not never-generate-pdf?) (current-generate-pdf?))
(translate-html-to-pdf
(build-path output-dir
(regexp-replace #px".scrbl$"
(path->string name)
".html")))))
(void))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Command line parsing. We initialize the SCRIBBLE_TAGS environmental
;; variable
(putenv "AUDIENCE" "volunteer")
(putenv "CURRENT-SOLUTIONS-MODE" "off")
(putenv "TARGET-LANG" "racket")
(define current-contextual-tags
(command-line
#:program "build"
#:once-each
;; Going to remove this option: it's obsolete, as we always
;; build bs1 and bs2.
#;[("--course") -course "Choose course (default bs1)"
(current-course -course)]
;; removed option for now, since not scribbling workbook
;; option is set in main entry point at end of file
#;[("--worksheet-links-to-pdf") "Direct worksheet links to StudentWorkbook.pdf"
(putenv "WORKSHEET-LINKS-TO-PDF" "true")]
[("--audience") -audience "Indicate student (default), teacher, volunteer, or self-guided"
(putenv "AUDIENCE" -audience)]
[("--deploy") -deploy-dir "Deploy into the given directory, and create a .zip. Default: deploy"
(current-deployment-dir (simple-form-path -deploy-dir))]
[("--lang") -lang "Indicate which language (Racket or Pyret) to generate"
(putenv "TARGETLANG" -lang)]
[("--pdf") "Generate PDF documentation"
(current-generate-pdf? #t)]
#:args tags
tags))
;; Note: this should be called first, because it can potentially wipe
;; out other subdirectories in the current deployment directory
;; otherwise. The intent is for generated files to overwrite static
;; resources.
(define (make-fresh-deployment-and-copy-static-pages)
(when (directory-exists? (current-deployment-dir))
(delete-directory/files (current-deployment-dir)))
(make-directory (current-deployment-dir))
(for ([base (directory-list static-pages-path)])
(define source-full-path (build-path static-pages-path base))
(define target-full-path (build-path (current-deployment-dir) base))
(when (or (file-exists? target-full-path)
(directory-exists? target-full-path))
(delete-directory/files target-full-path))
(copy-directory/files source-full-path target-full-path)))
(define (initialize-tagging-environment)
(void (putenv "SCRIBBLE_TAGS" (string-join current-contextual-tags " ")))
(printf "build.rkt: tagging context is: ~s\n" current-contextual-tags)
(printf "deployment path: ~s\n" (current-deployment-dir))
(printf "-------\n"))
;; Building the units of the course.
;; We must do this twice to resolve cross references for lessons.
(define (build-course-units)
(printf "build.rkt: building ~a\n" (current-course))
(for ([phase (in-range 2)])
(printf "Phase ~a\n" phase)
(for ([subdir (directory-list (get-units-dir))]
#:when (directory-exists? (build-path (get-units-dir) subdir)))
(define scribble-file (simple-form-path (build-path (get-units-dir) subdir "the-unit.scrbl")))
(cond [(file-exists? scribble-file)
(printf "build.rkt: Building ~a\n" scribble-file)
(copy-file (build-path "lib" "box.gif")
(build-path (get-units-dir) subdir "box.gif")
#t)
(run-scribble scribble-file #:never-generate-pdf? (= phase 0))]
[else
(printf "Could not find a \"the-unit.scrbl\" in directory ~a\n"
(build-path (get-units-dir) subdir))])))
(printf "build.rkt: building ~a main\n" (current-course))
(run-scribble (get-course-main)))
;; Building the lessons
(define (build-lessons)
(printf "build.rkt: building lessons\n")
(for ([subdir (directory-list lessons-dir)]
#:when (directory-exists? (build-path lessons-dir subdir)))
(define scribble-file (simple-form-path (build-path lessons-dir subdir "lesson" "lesson.scrbl")))
(cond [(file-exists? scribble-file)
(printf "build.rkt: Building ~a\n" scribble-file)
(run-scribble scribble-file #:never-generate-pdf? #t)]
[else
(printf "Could not find a \"lesson.scrbl\" in directory ~a\n"
(build-path lessons-dir subdir))]))
)
; ;; and the long-lessons
; (printf "build.rkt: building long lessons\n")
; (for ([subdir (directory-list lessons-dir)]
; #:when (directory-exists? (build-path lessons-dir subdir)))
; (define scribble-file (simple-form-path (build-path lessons-dir subdir "lesson" "lesson-long.scrbl")))
; (cond [(file-exists? scribble-file)
; (printf "build.rkt: Building ~a\n" scribble-file)
; (run-scribble scribble-file #:never-generate-pdf? #t)])))
;; Building exercise handouts
(define (build-exercise-handouts)
(for ([subdir (directory-list lessons-dir)]
#:when (directory-exists? (build-path lessons-dir subdir)))
(when (directory-exists? (build-path lessons-dir subdir "exercises"))
(for ([worksheet (directory-list (build-path lessons-dir subdir "exercises"))]
#:when (regexp-match #px".scrbl$" worksheet))
(printf "build.rkt: building exercise handout ~a: ~a\n" subdir worksheet)
(run-scribble (build-path lessons-dir subdir "exercises" worksheet))))))
;; Building exercise handout solutions
;; need putenv rather than parameter to communicate with form-elements.rkt -- not sure why
(define (build-exercise-handout-solutions)
(putenv "CURRENT-SOLUTIONS-MODE" "on")
(parameterize ([current-deployment-dir (build-path (current-deployment-dir) "courses" (current-course) "resources" "teachers" "solutions")])
(unless (directory-exists? (current-deployment-dir))
(make-directory (current-deployment-dir)))
(for ([subdir (directory-list lessons-dir)]
#:when (directory-exists? (build-path lessons-dir subdir)))
(let ([exercises-path (build-path lessons-dir subdir "exercises")])
(when (directory-exists? exercises-path)
(for ([worksheet (directory-list exercises-path)]
#:when (regexp-match #px".scrbl$" worksheet))
(printf "build.rkt: building exercise handout solution ~a: ~a\n" subdir worksheet)
(run-scribble #:include-base-path? #f (build-path exercises-path worksheet)))))))
(putenv "CURRENT-SOLUTIONS-MODE" "off")
)
(define (build-worksheets)
;; and the worksheets
(for ([subdir (directory-list lessons-dir)]
#:when (directory-exists? (build-path lessons-dir subdir)))
(when (directory-exists? (build-path lessons-dir subdir "worksheets"))
(for ([worksheet (directory-list (build-path lessons-dir subdir "worksheets"))]
#:when (regexp-match #px".scrbl$" worksheet))
(printf "build.rkt: building worksheet ~a: ~a\n" subdir worksheet)
(run-scribble (build-path lessons-dir subdir "worksheets" worksheet))))))
(define (build-drills)
;; and the drills
(for ([subdir (directory-list lessons-dir)]
#:when (directory-exists? (build-path lessons-dir subdir)))
(when (directory-exists? (build-path lessons-dir subdir "drills"))
(for ([drill (directory-list (build-path lessons-dir subdir "drills"))]
#:when (regexp-match #px".scrbl$" drill))
(printf "build.rkt: building drill ~a: ~a\n" subdir drill)
(run-scribble (build-path lessons-dir subdir "drills" drill))))))
(define (build-resources)
;; Under deployment mode, include the resources.
(when (current-deployment-dir)
(when (directory-exists? (get-resources))
(let ([input-resources-dir (get-resources)]
[output-resources-dir
(build-path (current-deployment-dir) "courses" (current-course)
"resources")])
(when (directory-exists? output-resources-dir)
(delete-directory/files output-resources-dir))
(copy-directory/files input-resources-dir
(simple-form-path
(build-path output-resources-dir)))
(let ([sourcefiles (build-path output-resources-dir "source-files")]
[sourcezip (build-path output-resources-dir "source-files.zip")])
(when (file-exists? sourcezip)
(delete-file sourcezip))
(zip sourcezip sourcefiles))
)))
;; copy auxiliary files into units within distribution
(when (current-deployment-dir)
(for ([subdir (directory-list (get-units-dir))])
(copy-file (build-path "lib" "box.gif")
(build-path (current-deployment-dir) "courses"
(current-course) "units" subdir "box.gif")
#t)))
;; Subtle: this must come after we potentially touch the output
;; resources subdirectory.
(cond [(file-exists? (get-teachers-guide))
(printf "build.rkt: building teacher's guide\n")
(run-scribble (get-teachers-guide))]
[else
(printf "build.rkt: no teacher's guide found; skipping\n")]))
(define (archive-as-zip)
;; Finally, zip up the deployment directory
(when (current-deployment-dir)
(let-values ([(base file dir?) (split-path (current-deployment-dir))])
(parameterize ([current-directory base])
(define output-file (build-path base (format "~a.zip" (path->string file))))
(when (file-exists? output-file)
(delete-file output-file))
(zip output-file file)))))
(define (create-distribution-lib)
(let ([distrib-lib-dir (build-path (current-deployment-dir) "lib")])
(if (directory-exists? distrib-lib-dir)
(delete-directory/files distrib-lib-dir)
(make-directory distrib-lib-dir))
(copy-file (build-path "lib" "mathjaxlocal.js")
(build-path distrib-lib-dir "mathjaxlocal.js")
#t)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main entry point:
(make-fresh-deployment-and-copy-static-pages)
(define bootstrap-courses '("bs1" "bs2"))
;; remove next line if ever want to generate links to web docs instead of PDF
(putenv "WORKSHEET-LINKS-TO-PDF" "true")
(putenv "CURRENT-SOLUTIONS-MODE" "off")
(initialize-tagging-environment)
(for ([course (in-list bootstrap-courses)])
(parameterize ([current-course course])
(build-course-units)
(build-resources))) ;; should resources get built once, or once per course?
(build-exercise-handouts)
(create-distribution-lib)
;(build-exercise-handout-solutions)
;(build-lessons)
;(build-worksheets)
;(build-drills)
;(archive-as-zip)
| false |
053e134d41b14e0140cd3c78a5b677776f3f9cb7 | d755de283154ca271ef6b3b130909c6463f3f553 | /htdp-lib/htdp/error.rkt | 71219f7922079de76eecfdc3fc3e6f220716478e | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | racket/htdp | 2953ec7247b5797a4d4653130c26473525dd0d85 | 73ec2b90055f3ab66d30e54dc3463506b25e50b4 | refs/heads/master | 2023-08-19T08:11:32.889577 | 2023-08-12T15:28:33 | 2023-08-12T15:28:33 | 27,381,208 | 100 | 90 | NOASSERTION | 2023-07-08T02:13:49 | 2014-12-01T13:41:48 | Racket | UTF-8 | Racket | false | false | 5,433 | rkt | error.rkt | #lang racket/base
(require lang/private/rewrite-error-message
(only-in racket/math natural?))
;; -----------------------------------------------------------------------------
;; this module provides one-point functionality to report errors in teachpacks
;; -----------------------------------------------------------------------------
(provide check-arg
check-list-list
check-arity
check-proc
check-result
check-fun-res
check-color
check-dependencies
natural?
number->ord
find-non
tp-exn?
tp-error)
;; check-arg : sym bool str (or/c str non-negative-integer) TST -> void
(define (check-arg pname condition expected arg-posn given)
(unless condition
(tp-error pname "expects ~a as ~a argument, given ~e"
(add-article expected)
(spell-out arg-posn)
given)))
;; Symbol (union true String) String X -> void
(define (check-list-list pname condition pred given)
(when (string? condition)
(tp-error pname (string-append condition (format "\nin ~e" given)))))
;; check-arity : sym num (list-of TST) -> void
(define (check-arity name arg# args)
(unless (= (length args) arg#)
(tp-error name (argcount-error-message #f arg# (length args)))))
;; check-proc : sym (... *->* ...) num (union sym str) (union sym str) -> void
(define (check-proc name f exp-arity arg# arg-err)
(define arg#-text (if (number? arg#) (number->ord arg#) arg#))
(unless (procedure? f)
(tp-error name "expected a function as ~a argument; given ~e" arg#-text f))
(define arity-of-f (procedure-arity f))
(unless (procedure-arity-includes? f exp-arity)
(tp-error name "expected function of ~a as ~a argument; given function of ~a "
arg-err arg#-text
(cond
[(number? arity-of-f)
(if (= arity-of-f 1)
(format "1 argument")
(format "~s arguments" arity-of-f))]
[(arity-at-least? arity-of-f) "variable number of arguments"]
[else (format "multiple arities (~s)" arity-of-f)]))))
;; Symbol (_ -> Boolean) String X X *-> X
(define (check-result pname pred? expected given . other-given)
(if (pred? given)
given
(tp-error pname "is expected to return ~a, but it returned ~v"
(add-article expected)
(if (pair? other-given)
(car other-given)
given))))
;; check-color : symbol (or/c str non-negative-integer) TST -> void
(define (check-color pname arg-pos given)
(check-arg pname
(or (string? given)
(symbol? given))
'color
arg-pos given)
;; this would be good to check, but it isn't possible, since this
;; file is not allowed to rely on mred.
;; also nice would be to allow color% objects here, but that's
;; not possible for the same reason (but that is why
;; the '[else color]' case is below in the cond.
#;
(let ([color
(cond
[(symbol? given)
(send the-color-database find-color (symbol->string given))]
[(string? given)
(send the-color-database find-color given)]
[else given])])
(unless color
(tp-error pname
"expected the name ~e to be a color, but did not recognize it"
given))))
;; (: check-fun-res (∀ (γ) (∀ (β α ...) (α ...α -> β)) (_ -γ-> boolean) _ -> γ))
(define (check-fun-res f pred? type)
(lambda x
(check-result (object-name f) pred? type (apply f x))))
;; check-dependencies : Symbol x Boolean x FormatString x Any* -> Void
(define (check-dependencies pname condition fmt . args)
(unless condition
(tp-error pname (apply format fmt args))))
(define-struct (tp-exn exn) ())
(define (tp-error name fmt . args)
(raise
(make-exn:fail:contract
(string-append (format "~a: " name) (apply format fmt args))
(current-continuation-marks))))
(define (number->ord i)
(if (= i 0)
"zeroth"
(case (modulo i 10)
[(0 4 5 6 7 8 9) (format "~ath" i)]
[(1) (format "~ast" i)]
[(2) (format "~and" i)]
[(3) (format "~ard" i)])))
;; (_ -> Boolean) (listof X) -> (union X false)
;; (not (find-non list? '((1 2 3) (a b c))))
;; (symbol? (find-non number? '(1 2 3 a)))
;; (symbol? (find-non list? '((1 2 3) a (b c))))
(define (find-non pred? l)
(let ([r (filter (compose not pred?) l)])
(if (null? r) #f (car r))))
;; add-article : anything -> string
;; (add-article 'color) should be "a color"
;; (add-article 'acronym) should be "an acronym"
(define (add-article thing)
(let ((s (format "~a" thing)))
(string-append
(if (starts-with-vowel? s)
"an "
"a ")
s)))
;; starts-with-vowel? : string -> boolean
(define (starts-with-vowel? s)
(and
(not (string=? s ""))
(member (string-ref s 0) (list #\a #\e #\i #\o #\u))))
;; spell-out : number-or-string -> string
(define (spell-out arg-posn)
(cond
[(string? arg-posn) arg-posn]
[(number? arg-posn)
(case arg-posn
[(1) "first"]
[(2) "second"]
[(3) "third"]
[(4) "fourth"]
[(5) "fifth"]
[(6) "sixth"]
[(7) "seventh"]
[(8) "eighth"]
[(9) "ninth"]
[(10) "tenth"]
[else (number->ord arg-posn)])]))
| false |
7329264d70b5e6699b31abfdf43d4996ba509d21 | 5162661b8ec358d1ac289956c3a23acfe9796c65 | /value.rkt | 824763a04eb1c52256a277b3a29a5f1ded7c4f78 | [
"ISC"
]
| permissive | aymanosman/riposte | 5e7457f48bbfe594f3b25d8af2a7eef77597f231 | 84e5975e9364703bff0b330438de59a30f8b5382 | refs/heads/master | 2020-05-07T08:43:34.057133 | 2019-04-09T10:33:30 | 2019-04-09T10:33:30 | 180,343,436 | 0 | 0 | null | 2019-04-09T10:32:48 | 2019-04-09T10:32:48 | null | UTF-8 | Racket | false | false | 124 | rkt | value.rkt | #lang racket/base
(provide value?)
(require (only-in ejs
ejsexpr?))
(define (value? x)
(ejsexpr? x))
| false |
c61f7e701c780ac3d910275995b3a7147b60a697 | 1da0749eadcf5a39e1890195f96903d1ceb7f0ec | /a-d6/a-d/tests-and-unittests/graph-algorithms-directed-weighted-tests.rkt | d4a966da659e2d28e0168a43cfc9f8db24b0771a | []
| no_license | sebobrien/ALGO1 | 8ce02fb88b6db9e001d936356205a629b49b884d | 50df6423fe45b99db9794ef13920cf03d532d69f | refs/heads/master | 2020-04-08T20:08:16.986517 | 2018-12-03T06:48:07 | 2018-12-03T06:48:07 | 159,685,194 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,642 | rkt | graph-algorithms-directed-weighted-tests.rkt | #lang r6rs
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;-*-* *-*-
;-*-* Shortest Path Algorithms Tests *-*-
;-*-* *-*-
;-*-* Wolfgang De Meuter *-*-
;-*-* 2009 Software Languages Lab *-*-
;-*-* Vrije Universiteit Brussel *-*-
;-*-* *-*-
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
(import
(rnrs base)
(rnrs io simple)
(a-d graph-algorithms directed single-source-shortest-path)
(a-d graph-algorithms directed traclo-weighted)
(a-d graph examples directed-weighted))
(display "Cormen589")(newline)
(display (list "Bellman-Ford" (bellman-ford cormen589 0)))(newline)
(display (list "Dijkstra " (dijkstra cormen589 0)))(newline)
(display "Cormen")(newline)
(display (list "Dijkstra " (dijkstra cormen 0))) (newline)
(display (list "Bellman-Ford" (bellman-ford cormen 0)))(newline)
(display "weighted-dag")(newline)
(display (list "Lawler " (lawler weighted-dag 1)))(newline)
(display "cormen")(newline)
(display (list "pre-Floyd-Warshall " (traclo-weighted-exp cormen)))(newline)
(display (list "Floyd-Warshall " (floyd-warshall cormen)))(newline)
| false |
a99a0b3e68fba2268602bc4312556ff77e44e35c | 8935203857f7aec86e067c77d84b64aa06c2d99a | /lang/rep.rkt | 37629564f5030f35264876e591944b516b3a8eb9 | []
| no_license | julian-becker/rince | 83004c0fc4003eca3080b8cba2dacc9ed2224cb6 | 9367f6613ae306d1761ef05764ee7418962f9869 | refs/heads/master | 2020-05-24T03:23:56.965471 | 2019-03-28T10:46:12 | 2019-03-28T10:46:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 10,360 | rkt | rep.rkt | #lang turnstile/base
;; Representation of C values in racket
(require (for-meta 2 racket/base)
racket/generic
racket/math
"parameterized-type.rkt")
(provide
(for-syntax Constrained-Integer?
Constrained-Integer-id
Constrained-Integer-bits+signed?
Constrained-Integer⊂?
sizeof/type)
(type-out Integer
Single-Float
Double-Float
Array
Struct
Pointer)
define-integer-type
define-integer-types
object-ref
set-lvalue!
lvalue
unwrap-lvalue
make-variable
define-struct-type
struct-ref
make-pointer
pointer-dereference
pointer-inc
pointer-diff
cast
initializer
static-initializer
unspecified-initializer
(rename-out
[#%datum+ #%datum]))
(define-base-type Integer)
(define-base-type Single-Float)
(define-base-type Double-Float)
(define-typed-syntax #%datum+
[(_ . n:integer) ≫
--------
[⊢ (quote n) ⇒ Integer]]
[(_ . r) ≫
#:when (single-flonum? (syntax-e #'r))
--------
[⊢ (quote r) ⇒ Single-Float]]
[(_ . r) ≫
#:when (flonum? (syntax-e #'r))
--------
[⊢ (quote r) ⇒ Double-Float]]
[(_ . s:string) ≫
#:do ((define data
(list->vector
(append
(bytes->list
(string->bytes/utf-8 (syntax-e #'s)))
'(0)))))
--------
[⊢ (array #,data 1) ⇒ (Array '(#,(vector-length data)))]]
[(_ . x) ≫
--------
[#:error (type-error #:src #'x #:msg "Unsupported literal: ~v" #'x)]])
; TODO: use parameterized type for constrained-integer
(define (Constrained-Integer . args)
(error "invalid use of constrained integer type"))
(begin-for-syntax
(struct constrained-integer-type (id bits signed?)
#:property prop:procedure
(λ (this stx)
(syntax-case stx ()
[_ (identifier? stx)
(with-syntax ([id (constrained-integer-type-id this)]
[bits (constrained-integer-type-bits this)]
[signed? (constrained-integer-type-signed? this)])
(mk-type
(syntax/loc stx
(#%plain-app Constrained-Integer 'id bits signed?))))])))
(define-syntax ~Constrained-Integer
(pattern-expander
(λ (stx)
(syntax-case stx ()
[(_ bits-pat signed?-pat)
#'(~describe
#:opaque
"constrained integer type"
((~literal #%plain-app)
(~literal Constrained-Integer)
((~literal quote) _:id)
((~literal quote) bits-pat)
((~literal quote) signed?-pat)))])))))
(define-for-syntax (Constrained-Integer? stx)
(syntax-parse stx [(~Constrained-Integer _ _) #t] [_ #f]))
(define-for-syntax (Constrained-Integer-id τ)
(syntax-parse ((current-type-eval) τ)
[((~literal #%plain-app)
(~literal Constrained-Integer)
((~literal quote) id:id)
_
_)
(syntax-e #'id)]))
(define-for-syntax (Constrained-Integer-bits+signed? τ)
(syntax-parse ((current-type-eval )τ)
[(~Constrained-Integer bits signed?)
(values (syntax-e #'bits) (syntax-e #'signed?))]))
(define-for-syntax (Constrained-Integer⊂? τ1 τ2)
(let ([τ1 ((current-type-eval) τ1)]
[τ2 ((current-type-eval) τ2)])
(let-values ([(bits1 signed?1) (Constrained-Integer-bits+signed? τ1)]
[(bits2 signed?2) (Constrained-Integer-bits+signed? τ2)])
(cond
[(eq? signed?1 signed?2) (<= bits1 bits2)]
[signed?2 (< bits1 bits2)]
[else #f]))))
(define-syntax define-integer-type
(syntax-parser
[(_ τ:id bits:exact-positive-integer (~and (~or #t #f) signed))
(with-syntax ([τ? (format-id #'τ "~a?" #'τ)])
#'(begin
(define-for-syntax (τ? stx) (type=? #'τ stx))
; TODO: expander
(define-syntax τ (constrained-integer-type #'τ bits signed))))]))
(define-syntax-rule
(define-integer-types [id bits signed?] ...)
(begin (define-integer-type id bits signed?) ...))
(define (constrain-int/bool v)
(if (eqv? 0 v) 0 1))
(define (constrain-int/unsigned v bits)
(let ([mask (sub1 (arithmetic-shift 1 bits))])
(bitwise-and v mask)))
(define (constrain-int/signed v bits)
; signed truncation is implementation-defined
; For now, we'll truncate and sign-extend.
(let ([mask (sub1 (arithmetic-shift 1 bits))])
(let ([a (bitwise-and v mask)])
(if (bitwise-bit-set? a (sub1 bits))
(bitwise-ior a (bitwise-not mask))
a))))
(define-for-syntax (make-integer-constraint τ v)
(let-values ([(bits signed?) (Constrained-Integer-bits+signed? τ)])
(cond
[(eqv? 1 bits) #`(constrain-int/bool #,v)]
[signed? #`(constrain-int/signed #,v #,bits)]
[else #`(constrain-int/unsigned #,v #,bits)])))
; TODO: should we have an "implicit cast" mode? (eg, for integer overflow)
(define-typed-syntax (cast τ:type v:expr) ≫
[⊢ v ≫ v- ⇒ τ_orig]
--------
[⊢ #,(make-cast-expression this-syntax #'τ.norm #'τ_orig #'v-) ⇒ τ])
(define-for-syntax (make-cast-expression stx τ_to τ_from v)
(define (fail)
(raise-syntax-error #f "invalid cast" stx))
; TODO: more checks here
(define cast-stx
(cond
[(type=? τ_to τ_from) v]
[(Constrained-Integer? τ_to)
; TODO: don't need to constrain subtypes
(make-integer-constraint
τ_to
(cond
[(or (Integer? τ_from) (Constrained-Integer? τ_from)) v]
[(or (Single-Float? τ_from) (Double-Float? τ_from)) #`(exact-truncate #,v)]
[else (fail)]))]
[(Single-Float? τ_to) #`(real->single-flonum #,v)]
[(Double-Float? τ_to) #`(real->double-flonum #,v)]
[(and (Pointer? τ_to) (Array? τ_from))
; XXX: cast element type
#`(array->pointer #,v)]
[else (fail)]))
(syntax-track-origin cast-stx stx (stx-car stx)))
(define-for-syntax (sizeof/type τ)
(syntax-parse τ
[(~Constrained-Integer bits _) (max 1 (quotient (syntax-e #'bits) 8))]
[~Single-Float 4]
[~Double-Float 8]
[else (raise-syntax-error 'sizeof/type "invalid type" #f τ)]))
; Objects
; base type for objects: ref, to-integer, size
; TODO: use type/syntax info to handle defaults at expansion time
(define-generics object
(object-ref object)
#:fast-defaults
([box?
(define object-ref unbox)]
[number?
(define object-ref values)]))
; Lvalues
(define-generics lvalue
(set-lvalue! lvalue v)
#:fast-defaults
([box?
(define set-lvalue! set-box!)]))
(begin-for-syntax
(struct lvalue-wrapper (target)
#:property prop:procedure
(λ (this stx)
(syntax/loc stx target))))
(define (lvalue v) (object-ref v))
; Hack: lvalue expressions need to evaluate to the unboxed value, but we
; still need to be able to get at the box for mutation and referencing.
(define-syntax unwrap-lvalue
(syntax-parser
[(_ v)
(syntax-parse (local-expand #'v 'expression '())
[((~literal #%plain-app-) (~literal lvalue) lv) #'lv]
[_ (println this-syntax) (raise-syntax-error #f "not an lvalue" #f #'v)])]))
(define make-variable box)
; Arrays
(define-parameterized-type (Array dimensions))
(struct array (data element-size))
(define (array->pointer arr)
(pointer
arr
0
(λ (p) (vector-ref (array-data (pointer-target p)) (pointer-index p)))
(λ (p v) (vector-set! (array-data (pointer-target p)) (pointer-index p) v))))
; Structs
; This needs a bit of extra logic elsewhere to handle
; anonymous struct types and tag declarations.
(define-for-syntax introduce-struct-info (make-syntax-introducer))
(define-parameterized-type (Struct tag))
(define-syntax define-struct-type
(syntax-parser
[(_ name:id ([τ:type field:id] ...))
; TODO: make- helper
(with-syntax ([info (introduce-struct-info #'name)])
#'(begin
(define-syntax info #'((field . τ) ...))))]))
(define-for-syntax (struct-tag->info tag)
(stx-map
syntax-e
(syntax-local-value
(introduce-struct-info tag)
(λ () (error "not a struct type:" tag)))))
; FIXME: s.x is only an lvalue if s is also.
(define-typed-syntax (struct-ref s field) ≫
[⊢ s ≫ s- ⇒ (~Struct tag)]
#:with (i τ)
(let ([info (struct-tag->info #'tag)]
[id (syntax-e #'field)])
(let loop ([fields info]
[i 0])
(cond
[(null? fields) (raise-syntax-error #f "invalid member specifier" this-syntax #'field)]
[(eq? id (syntax-e (caar fields))) (list i (cdar fields))]
[else (loop (cdr fields) (add1 i))])))
--------
[⊢ (lvalue (struct-reference s- (quote i))) ⇒ τ])
(struct struct-reference
(s i)
#:methods gen:object
((define (object-ref ref)
(vector-ref (struct-reference-s ref) (struct-reference-i ref))))
#:methods gen:lvalue
((define (set-lvalue! ref v)
(vector-set! (struct-reference-s ref) (struct-reference-i ref) v))))
; Unions
; Pointers
(define-type-constructor Pointer #:arity = 1)
; should this be a generic, with array-pointer, cast-pointer etc?
(struct pointer
(target index get set!))
(struct reference
(pointer)
#:methods gen:object
((define (object-ref ref)
(let ([ptr (reference-pointer ref)])
((pointer-get ptr) ptr))))
#:methods gen:lvalue
((define (set-lvalue! ref v)
(let ([ptr (reference-pointer ref)])
((pointer-set! ptr) ptr v)))))
(define (make-pointer lv)
(cond
[(box? lv)
(pointer
lv
0
(λ (p) (object-ref (pointer-target p)))
(λ (p v) (set-lvalue! (pointer-target p) v)))]
[(reference? lv) (reference-pointer lv)]
[else (error 'make-pointer "invalid argument")]))
(define pointer-dereference reference)
(define (pointer-inc p n)
(struct-copy pointer p [index (+ (pointer-index p) n)]))
(define (pointer-diff p q)
(- (pointer-index p) (pointer-index q)))
; Initializers
(define-syntax initializer
(syntax-parser
[(_ τ v)
#'(cast τ v)]))
(define-syntax unspecified-initializer
(syntax-parser
[(_ (~Array dims)) (error 'TODO)]
[(_ (~Struct tag))
(with-syntax ([(τ_e ...) (map cdr (struct-tag->info #'tag))])
#'(vector (unspecified-initializer τ_e) ...))]
[(_ τ) #''unspecified]))
(define-syntax static-initializer
(syntax-parser
[(_ τ) #'(cast τ (#%datum+ . 0))]))
| true |
82119a308e3641dcadd31ee8dfc635a8fe9cfdee | 84a9d89ad3627d65f361304c689486518e54ba1c | /src/hash-utils.rkt | 85031dc76639b62971cc30e3e047e14f85d92671 | [
"MIT"
]
| permissive | martinklepsch/glitter | b8757b512e4ec99d1b67d92c11945bcd0e7e9070 | 915d3880a62ca13f2bb3f822c7fc96b8655eadcd | refs/heads/master | 2021-01-10T07:19:12.378353 | 2015-10-03T16:03:26 | 2015-10-03T16:03:26 | 43,575,358 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 4,251 | rkt | hash-utils.rkt | #lang racket
;; https://github.com/DarrenN/racketutils
;; The MIT License (MIT)
;; Copyright (c) 2015 Darren_N
;; Permission is hereby granted, free of charge, to any person obtaining a copy
;; of this software and associated documentation files (the "Software"), to deal
;; in the Software without restriction, including without limitation the rights
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;; copies of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;; The above copyright notice and this permission notice shall be included in all
;; copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.
;; Hash Utilities
;; ==============
;; hash-ref*
;; =========
;; recursively call hash-ref from a list of keys
;; example: (hash-ref* (hash 'a (hash 'b (hash 'c 2))) '(a b c)) -> 2
;;
(define (hash-ref* h keys #:failure-result [failure #f])
(foldl (λ (k h)
(if (hash? h)
(if (hash-has-key? h k)
(hash-ref h k)
(if failure
failure
(raise-arguments-error 'hash-ref*
"no value found for key"
"key" k)))
h))
h keys))
;; hash-ref* tests
;; ===============
#; (module+ test
(require rackunit
quickcheck)
(define foo (hash 'a 1
'b (hash 'bb 1
'cc (hash 'ccc 12))
'c "foo"))
;; Returns the first non-hash value
(check-equal?
(hash-ref* foo '(b bb ccc) #:failure-result 120) 1)
;; Fails and returns failure-result
(check-equal?
(hash-ref* foo '(b dd) #:failure-result "nope") "nope")
;; Gets value
(check-equal?
(hash-ref* foo '(b cc ccc)) 12)
;; Invalid keys raises exception
(check-exn exn:fail? (λ () (hash-ref* foo '(b dd))))
;; Non-list raises exception
(check-exn exn:fail? (λ () (hash-ref* foo "foo")))
;; Generate a hash from a list (must be non-empty) with a value of y
(define (not-empty-hash xs y)
(foldr (λ (l r)
(hash-set r (first xs)
(hash l (hash-ref r (first xs)))))
(hash (first xs) y)
(rest xs)))
;; It will find a value in a validly-nested hash
(define hash-ref-has-nest
(property ([xs (arbitrary-list
arbitrary-ascii-char)]
[y arbitrary-integer])
(let* ([xss (if (empty? xs) '(1 2) xs)]
[hsh (not-empty-hash xss y)])
(equal? (hash-ref* hsh xss) y))))
(quickcheck hash-ref-has-nest)
;; It will not find a value in a validly-nested hash
(define hash-ref-not-has-nest
(property ([xs (arbitrary-list
arbitrary-ascii-char)]
[z arbitrary-integer])
(let* ([xss (if (empty? xs) (list (random 100) (random 100)) xs)]
[hsh (not-empty-hash xss z)])
(not (equal? (hash-ref* hsh (cdr xss) #:failure-result "f") z)))))
(quickcheck hash-ref-not-has-nest)
;; Passing en empty list will return the hash
(define hash-ref-empty-list
(property ([xs (arbitrary-list
arbitrary-ascii-char)]
[y arbitrary-integer])
(let* ([xss (if (empty? xs) '(1 2) xs)]
[hsh (not-empty-hash xss y)])
(equal? (hash-ref* hsh '()) hsh))))
(quickcheck hash-ref-empty-list))
;; Contracts
(provide (contract-out
[hash-ref* (->* ((and/c hash? immutable?)
list?)
(#:failure-result any/c)
any/c)]))
| false |
ae8ae5a1e31680a7347b755fada309f035246451 | 384aa07e410ae62d9625bea05b9385c99ddcfe50 | /steward-raspberry.rkt | 35eb419154cb9ed4983625af39a122560c7a0ba1 | []
| no_license | aropop/programeerproject2 | b2c18d8faeafd1ee8e551253a733f7a52fdde1d9 | 309f5e0a26a6fee0feebf80a52b609e7a105452b | refs/heads/master | 2016-09-05T14:10:36.679958 | 2014-06-02T15:34:26 | 2014-06-02T15:34:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 14,442 | rkt | steward-raspberry.rkt | #lang r5rs
;---------------------------------------------------------------------
;|
;| Steward.rkt
;| Arno De Witte - Programmeerproject 2
;| Code that runs on the raspberry (this is a simulated version
;| that wil run on any racket device)
;|
;---------------------------------------------------------------------
(#%require racket/tcp)
(#%require (only racket/base let-values))
(#%require "device-r5rs.rkt" "xbee-simulation.rkt")
(#%provide steward%)
(define SUPPORTED-DEVICES
(list
(vector 'plug "ZBS-110" "Plug" (list (cons "GET" 'not)
(cons "SET POW=ON" "ack: set pow=on")
(cons "SET POW=OFF" "ack: set pow=off")))
(vector 'multiSensor "ZBS-121" "MultiSensor" '())))
(define package-recieved-code 144)
(define package-recieved-data-offset 12)
(define package-recieved-end-length 2)
(define package-transmit-info-code 139)
(define package-transmit-succes 0)
(define package-transmit-offset 4)
(define (steward% id port)
(let
;public
((devices~ '())
(steward-id~ id)
(place~ "none")
;private
(xbee (xbee-init "/dev/ttyUSB0" 9600)))
;SIMULATED ONLY
(define con (tcp-listen port))
;Help procedure to facilitate debuging
(define (displayln mes)
(display mes)
(newline))
;Displays an error (slips defines error but it's just a display of the first argument
(define (error . mes)
(map
display
mes)
(newline))
;Sleeps for seconds
(define (sleep t)
(define time (+ t (clock)))
(define (lp)
(if (not (>= (clock) time))
(lp)))
(lp))
;Sleeps till there is a message
(define (sleep2)
(sleep 5e+2)
(if (not (xbee-ready? xbee))
(sleep2)))
;returns the device for the given id
(define (get-device device-id)
(define (filter lam list)
(define (lp r rest)
(cond
((null? rest) r)
((lam (car rest))
(lp (cons (car rest) r) (cdr rest)))
(else
(lp r (cdr rest)))))
(lp '() list))
(let ((filtered
(filter (lambda (device)
(equal? device-id (device 'get-id)))
devices~)))
(if (null? filtered)
(error "No such device in this steward, device id:" device-id " steward id:" steward-id~)
(car filtered))))
;returns #t if the device is in the list
(define (has-device device-id)
(define has-device-bool #f)
(map (lambda (device)
(if (equal? device-id (device 'get-id))
(set! has-device-bool #t)))
devices~)
has-device-bool)
;defines if this steward is already in the database
(define (is-already-stored?)
(> steward-id~ 0))
;this way its able to edit id when converting from local to stored steward
(define (set-id! id)
(if (> steward-id~ 0)
(error "This object already has an id")
(set! steward-id~ id)))
;Raspberry does not know wherer it is
(define (set-place! new-place)
(set! place~ new-place)
place~)
;Converts a byte vector to a vector with hexadecimal strings
(define (byte-vector->hex-vector byte-vector)
(define l (bytevector-length byte-vector))
(define ret (make-vector (bytevector-length byte-vector)))
(define (lp idx)
(define (to-hex d) ;http://en.wikipedia.org/wiki/Hexadecimal#Binary_conversion
(define r (modulo d 16))
(if (= 0 (- d r))
(to-char r)
(string-append (to-hex (/ (- d r) 16)) (to-char r))))
(define (to-char n)
(define chars (vector "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"))
(vector-ref chars n))
(if (>= idx l)
ret
(begin
(vector-set! ret idx (to-hex (bytevector-ref byte-vector idx)))
(lp (+ idx 1)))))
(lp 0))
;Converts to a string
(define (bytevector->string byte-vector . fromTo)
(define (lp idx str-idx str l)
(if (or
(>= str-idx l)
(and
(= (length fromTo) 2)
(>= idx (cadr fromTo))))
str
(begin
;(display str-idx)(display " ") (display idx) (display " ") (displayln str)
(if (= (bytevector-ref byte-vector idx) 10)
(string-set! str str-idx #\,)
(string-set! str str-idx (integer->char (bytevector-ref byte-vector idx))))
(lp (+ idx 1) (+ str-idx 1) str l))))
(if (= (length fromTo) 3) ;unreproducable bug sometimes gives the 3 arguments in fromTo
(set! fromTo (cdr fromTo)))
(let
((l (-
(bytevector-length byte-vector)
(cond ;String might be too big
((null? fromTo) 0)
((null? (cdr fromTo)) (car fromTo))
(else (+ (car fromTo) (- (bytevector-length byte-vector) (cadr fromTo))))))))
(if (>= (length fromTo) 1)
(lp (car fromTo) 0 (make-string l #\a) l)
(lp 0 0 (make-string l #\a) l))))
;Slip has not yet implemented this procedure so we define it here
(define (list->bytevector list)
(define v (make-bytevector (+ (length list) 1)))
(define i 0)
(define (lp lst)
(if (null? lst)
v
(begin
(bytevector-set! v i (car lst))
(set! i (+ i 1))
(lp (cdr lst)))))
(bytevector-set! v (length list) 10)
(lp list))
;Slip has not yet implemented this procedure so we define it here
(define (bytevector-equal? bv1 bv2)
(define (eq-lp idx)
(if (>= idx (bytevector-length bv1))
#t
(and (= (bytevector-ref bv1 idx) (bytevector-ref bv2 idx))
(eq-lp (+ idx 1)))))
(and
(= (bytevector-length bv1) (bytevector-length bv2))
(eq-lp 0)))
;Slip has not yet implemented this procedure so we define it here
(define (string->list str)
(define l (string-length str))
(define (lp i lst)
(if (< i 0)
lst
(lp (- i 1) (cons (string-ref str i) lst))))
(lp (- l 1) '()))
;Converts a message into a bytevector to send
(define (string->bytevector string)
(list->bytevector (map char->integer (string->list string))))
;Sends the actual data
(define (send-bytes-to-device bytes adr content-expectation)
(define last-good-frame 'null)
(define (content-satisfies? message-string)
(or
(symbol? content-expectation)
(and
(>= (string-length message-string) (string-length content-expectation))
(equal? (substring message-string 0 (string-length content-expectation))
content-expectation))))
(define (frame-type frame)
(bytevector-ref frame 0))
(define (frame-address frame)
(define frame-adr (make-bytevector 8))
(define (lp idx)
(if (> idx 8)
frame-adr
(begin
(bytevector-set! frame-adr (- idx 1) (bytevector-ref frame idx))
(lp (+ idx 1)))))
(lp 1))
(define (read-loop)
;(sleep2)
(let ((current-frame (if (or
(not (= (xbee-tick xbee) 0))
(xbee-ready? xbee))
(xbee-read xbee)
'no-more)))
(cond
((eq? current-frame 'no-more)
(if (eq? 'null last-good-frame)
(begin
(displayln "Could not find anything retrying")
(sleep 1e+2)
(xbee-tick xbee)
(read-loop))
last-good-frame))
;Frame is a recieved package
((and
(= (frame-type current-frame) package-recieved-code)
(bytevector-equal? (frame-address current-frame) adr))
(display "Got frame, message: ")
(displayln (bytevector->string current-frame
package-recieved-data-offset
(- (bytevector-length current-frame)
package-recieved-end-length)))
(if (content-satisfies? (bytevector->string current-frame
package-recieved-data-offset
(- (bytevector-length current-frame)
package-recieved-end-length)))
(set! last-good-frame current-frame))
(read-loop))
;Transmit info package
((= (frame-type current-frame) package-transmit-info-code)
(if (= (bytevector-ref current-frame package-transmit-offset) package-transmit-succes)
(begin
(displayln "Transmitting succesfull, waiting for response packet")
(read-loop))
(begin
(displayln "Not correctly sent, retrying")
(xbee-write xbee adr bytes)
(read-loop))))
(else ;Unknown message type
(read-loop)))))
(xbee-write xbee adr bytes)
(xbee-tick xbee)
(sleep 5e+3)
(read-loop))
;Sends a single message to a device
(define (send-message-to-device device-id mes)
(define dev (get-device device-id))
(define message-bytes (string->bytevector mes))
(define (get-expectated-mes me)
(define type (dev 'get-type))
(define (search-mes lst)
(cond ((null? lst) 'nothing)
((equal? (caar lst) me) (cdar lst))
(else (search-mes (cdr lst)))))
(define (get-vect-loop lst)
(cond ((null? lst) 'nothing)
((equal? (vector-ref (car lst) 1) type) (search-mes (vector-ref (car lst) 3)))
(else (get-vect-loop (cdr lst)))))
(get-vect-loop SUPPORTED-DEVICES))
(display "Sending message: ")
(displayln mes)
(displayln (get-expectated-mes mes))
;* only in r5rs
(let* ((frame (send-bytes-to-device message-bytes
(dev 'get-address)
(get-expectated-mes mes)))
(end (- (bytevector-length frame) package-recieved-end-length)))
(displayln end)
(display "t:") (displayln frame)
(bytevector->string frame package-recieved-data-offset end)))
(define (send-message-to-all-devices mes)
(map
(lambda (dev)
(send-message-to-device (dev 'get-address) mes))
devices~))
;Creates a device object from an xbee-node
(define (create-device xbee-node)
(define (supported? type lst)
(cond ((null? lst) #f)
((equal? type (vector-ref (car lst) 1)) #t)
(else (supported? type (cdr lst)))))
(define (get-device-type idstring)
(if (>= (string-length idstring) 7)
(substring idstring 0 7)
idstring))
(if (supported? (get-device-type (car xbee-node)) SUPPORTED-DEVICES)
(device-slip
(car xbee-node)
(cadr xbee-node)
place~
(get-device-type (car xbee-node)))
'()))
(define (build-device-list)
(define (loop lst res)
(if (null? lst)
(set! devices~ res)
(loop
(cdr lst)
(let ((dev-obj (create-device (car lst))))
(if (null? dev-obj)
res
(cons dev-obj res))))))
(loop (xbee-list) '()))
;returns the list of device objects
(define (get-device-list)
(build-device-list)
(map (lambda (dev)
(dev 'serialize))
devices~))
;Reconnects when master goes down
(define (reconnect)
;(let ((io (tcp-accept (tcp-listen port)))
; (in (car io))
; (out (cdr io)))
(let-values (((in out) (tcp-accept con)))
(displayln "Connected over TCP/IP")
(loop in out xbee)))
(define (dispatch mes . args)
(set! args (car args))
(cond
((eq? mes 'has-device) (apply has-device args))
((eq? mes 'is-already-stored?) (is-already-stored?))
((eq? mes 'send-message-to-device) (apply send-message-to-device args))
((eq? mes 'send-message-to-all-devices) (apply send-message-to-all-devices args))
((eq? mes 'get-device-list) (get-device-list))
((eq? mes 'set-id!) (apply set-id! (car args)))
((eq? mes 'set-place) (apply set-place! args))
(else (display "Unknown Message :")(displayln mes)
'(Unknown Message))))
(define (loop in out xbee)
(let
((mes (read in))
(devices (xbee-list)))
(xbee-tick xbee)
(sleep 5e+3)
(display "Device-list: ") (displayln devices)
(build-device-list)
(display "Got: ")(displayln mes)
(if (eof-object? mes)
(begin
(displayln "Master went down, waiting for new")
(reconnect))
;2 lets because we need to have the devices updated
(let ((response (dispatch (car mes) (cdr mes))))
(display "Response: ")(displayln response)
(write response out)
(newline out)
(flush-output out)
(loop in out xbee)))))
;listens to the steward wrapper for the messages
;(let ((io (tcp-accept port))
; (in (car io))
; (out (cdr io)))
(let-values (((in out) (tcp-accept con)))
(displayln "Connected over TCP/IP")
(xbee-discover xbee)
(sleep 5e+3)
(xbee-tick xbee)
(sleep 5e+3)
(build-device-list)
(loop in out xbee)))) | false |
70d4cf34921eba9be9a70037253e34c2a3562629 | b08b7e3160ae9947b6046123acad8f59152375c3 | /Programming Language Detection/Experiment-2/Dataset/Train/Racket/permutations-derangements.rkt | c5ab4c57b9434d07a49adf3fe9ac32d4f202931a | []
| no_license | dlaststark/machine-learning-projects | efb0a28c664419275e87eb612c89054164fe1eb0 | eaa0c96d4d1c15934d63035b837636a6d11736e3 | refs/heads/master | 2022-12-06T08:36:09.867677 | 2022-11-20T13:17:25 | 2022-11-20T13:17:25 | 246,379,103 | 9 | 5 | null | null | null | null | UTF-8 | Racket | false | false | 1,328 | rkt | permutations-derangements.rkt | #lang racket
(define (all-misplaced? l)
(for/and ([x (in-list l)] [n (in-naturals 1)]) (not (= x n))))
;; 1. Create a named function to generate derangements of the integers 0..n-1.
(define (derangements n)
(define (all-misplaced? l1 l2)
(or (null? l1)
(and (not (eq? (car l1) (car l2)))
(all-misplaced? (cdr l1) (cdr l2)))))
(define l (range n))
(for/list ([p (permutations l)] #:when (all-misplaced? p l))
p))
;; 2. Generate and show all the derangements of 4 integers using the above
;; routine.
(derangements 4)
;; -> '((1 0 3 2) (3 0 1 2) (1 3 0 2) (2 0 3 1) (2 3 0 1)
;; (3 2 0 1) (1 2 3 0) (2 3 1 0) (3 2 1 0))
;; 3. Create a function that calculates the subfactorial of n, !n.
(define (sub-fact n)
(if (< n 2) (- 1 n)
(* (+ (sub-fact (- n 1)) (sub-fact (- n 2))) (sub1 n))))
;; 4. Print and show a table of the counted number of derangements of n vs. the
;; calculated !n for n from 0..9 inclusive.
(for ([i 10])
(printf "~a ~a ~a\n" i
(~a #:width 7 #:align 'right (length (derangements i)))
(sub-fact i)))
;; Output:
;; 0 1 1
;; 1 0 0
;; 2 1 1
;; 3 2 2
;; 4 9 9
;; 5 44 44
;; 6 265 265
;; 7 1854 1854
;; 8 14833 14833
;; 9 133496 133496
;; Extra: !20
(sub-fact 20)
;; -> 895014631192902121
| false |
09ba482feb09532d1314faa87fae640e5d90ae39 | 083798c01064f1a28165dcee7359398e066cbecf | /mess.rkt | 85a47542ebe87f1c21f8689fdfe5b0269f7b6074 | []
| no_license | gbaz/mess | 9cc209bc335da9810bc55412f0984fd9ae064b85 | 502e4524f3c11c4ccf13aa9a65aa31d4b0af5241 | refs/heads/master | 2016-08-04T06:39:58.779752 | 2015-07-01T14:19:55 | 2015-07-01T14:19:55 | 35,452,843 | 23 | 5 | null | null | null | null | UTF-8 | Racket | false | false | 29,759 | rkt | mess.rkt | #lang racket
; MESS
; Martin-Löf Extensible Specification and Simulator
; (c) Gershom Bazerman, 2015
; BSD(3) Licensed
(require racket/match)
; value formers
(struct lam-pi (var vt body) #:transparent)
(struct app (fun arg) #:transparent)
; primitives
(struct closure (typ body) #:transparent)
(struct trustme (typ body) #:transparent)
; type formers
(struct type-fun (dom codom) #:transparent)
; one basic type
(define type-unit 'type-unit)
; dependency
(struct type-pi (var dom codom) #:transparent)
(define type-type 'type) ; inconsistent!
; contexts
(define (find-cxt nm cxt)
(match (assoc nm cxt) [(cons a b) b] [_ #f]))
(define (fresh-var nm cxt)
(if (assoc nm cxt) (fresh-var (string->symbol (string-append (symbol->string nm) "'")) cxt) nm))
(define-syntax-rule (extend-cxt var vt cxt (newvar newcxt) body)
(let* ([newvar (fresh-var var cxt)]
[newcxt (cons (cons newvar vt) cxt)])
body))
(struct stuck-app (fun arg) #:transparent)
; a reduction of a value in a context creates a term where "app" is not in the head position.
; this is "weak head normal form" call-by-name reduction
; we call a term in such a form "reduced" or simply a "value"
(define/match (reduce cxt body)
; To reduce an application of a function to an argument
; we confirm that the argument is compatible with the function
; and we produce the application of the function to the argument
; (if we omit the type check, we get nuprl semantics)
[(_ (app (lam-pi var vt b) arg))
(if (hasType? cxt arg vt) (reduce cxt (b arg))
(raise-arguments-error 'bad-type "bad type"
"cxt" cxt "arg" arg "vt" vt "app" (lam-pi var vt b)))]
; To reduce an application of a closure to an argument, we produce a closure
; whose type is the application of the closure type to the argument type
; and whose body is the application of the closure body to the argument
[(_ (app (closure ty b) arg))
(closure (app-type cxt (red-eval cxt ty) arg) (lambda (cxt) (app (b cxt) arg)))]
; To reduce an application of anything else to an argument, we first reduce the thing itself
; and then attempt to again reduce the application of the result
[(_ (app fun arg)) (if (or (not fun) (symbol? fun))
(stuck-app fun arg)
(reduce cxt (app (reduce cxt fun) arg)))]
[(_ _) body])
; A red-eval of a term in a context creates a term where neither "app" nor "closure" are in the head position
; we call a term in such a form "evaluated" (or also, where evident, a "value").
(define (red-eval cxt x)
(match (reduce cxt x)
; To red-eval a closure, we red-eval the application of the body of the closure to the context
[(closure typ b) (red-eval cxt (b cxt))]
[v v]))
; An application of a type to a term confirms the term is compatible with the type
; and if so, removes provides the new type that is the result of applying a term
; with the type to a term with the type of the argument
(define/match (app-type cxt fun arg)
[(_ (type-fun a b) _)
(if (hasType? cxt arg a) b
(raise-arguments-error 'bad-type "bad type applying in closure" "cxt" cxt "fun" fun "arg" arg))]
[(_ (type-pi a at b) _)
(if (hasType? cxt arg a) (b arg)
(raise-arguments-error 'bad-type "bad pi type applying in closure" "cxt" cxt "fun" fun "arg" arg))]
[(_ _ _) (raise-arguments-error 'bad-type "can't apply non-function type in closure" "cxt" cxt "fun" fun "arg" arg)])
(define/match (head-type t)
[((type-fun a b)) a]
[((type-pi av a b)) a]
[(_) (raise-arguments-error 'bad-type "can't take head of non-function-type")]) ; TODO what if it is a symbol?
; In all the following, judgment may be read as "verification"
; and "to judge" may be read as "to verify," "to know" or "to confirm"
; We may judge that an evaluated term is a type by the following rules
(define (type? cxt t)
(match (red-eval cxt t)
; We know a value is a type if we know that it is tagged type-fun
; and furthermore we know that its domain is a type and its codomain is a type
[(type-fun a b) (and (type? cxt a) (type? cxt b))]
; We know a value is a type if it has the symbol 'type-unit
['type-unit #t]
; We know a value is a type in a context if it is a symbol and that context assigns it a type of type
[(? symbol? vname) #:when (eq? type-type (find-cxt vname cxt)) #t]
; We know a value is a type if we know that it is tagged type-pi
; and furthermore we know that its domain is a type and in a context where
; its domain is assigned the proper type, its body can send the domain to a type.
[(type-pi var a b)
(and (type? cxt a) (extend-cxt var a cxt (newvar newcxt) (type? newcxt (b newvar))))]
; We know a value is a type if it has the symbol 'type
['type #t]
; Or, we know a value is a type if any other rules let us make such a judgment
[t1 (type?-additional cxt t1)]
))
; We may judge that a reduced value has an evaluated type by the following rules
(define (hasType? cxt x1 t1)
(match* ((reduce cxt x1) (red-eval cxt t1))
; To know a closure is of a type is to know that the type of the closure is equal to the desired type
[((closure typ b) t) (eqType? cxt typ t)]
; To know a primitive is of a type is to know the type claimed by the primitive is equal to the desired type
[((trustme typ b) t) (eqType? cxt typ t)]
; To know that a symbol has a type in a context is to know that the context assigns the symbol a type equal to the desired type
[((? symbol? x) t) #:when (eqType? cxt t (find-cxt x cxt)) #t]
; To know that a lambda has type function is to know that
; the domain of the function type is equal to the input type of the body and to know that
; in a context where the argument is assigned the proper domain type
; the body in turn has a type of the codomain of the function type
[((lam-pi vn vt body) (type-fun a b))
(and (eqType? cxt vt a)
(extend-cxt vn vt cxt (newvar newcxt) (hasType? newcxt (body newvar) b)))]
; To know that a term has type unit is to know that it is the unit value
[(x 'type-unit) (null? x)]
; To know that a lambda has type pi is to know that
; the domain of the function type is equal to the input type of the body and to know that
; in a context where the argument is assigned the proper domain type
; the body in turn has a type of the codomain of the function type, as viewed in the same context
[((lam-pi vn vt body) (type-pi _ a b))
(and (eqType? cxt vt a)
(extend-cxt vn vt cxt (newvar newcxt)
(hasType? newcxt (body newvar) (reduce newcxt (b newvar)))))]
; To know that a term has type type is to know that the term may be judged a type
[(x 'type) (type? cxt x)]
; Or, to know that a term has any other type is to follow any additional rules
; on how we may judge the types of terms
[(x t) (hasType?-additional cxt x t)]))
; We may judge that two evaluated values are equal as types by the following rules
(define (eqType? cxt t1 t2)
(match* ((red-eval cxt t1) (red-eval cxt t2))
; To know two types tagged type-fun are equal is to know that
; they have terms equal as types in their domains and
; they have terms equal as types in their codomains
[((type-fun a b) (type-fun a1 b1))
(and (eqType? cxt a a1) (eqType? cxt b b1))]
; To know two types tagged type-pi are equal is to know that
; they have terms equal as types in their domains and
; in a context where their arguments are assigned the proper domain type
; then their codomains also equal as types
[((type-pi v a b) (type-pi v1 a1 b1))
(and (eqType? cxt a a1)
(extend-cxt v a cxt (newvar newcxt)
(eqType? newcxt (b newvar) (b1 newvar))))]
; To know two symbols are equal as types is to know that they are the same symbol
[((? symbol? vname) (? symbol? vname1)) (eq? vname vname1)]
; To know two stuck applications are equal as types is to know that their functions have equal types, and are equal as values.
; And additionally, to know that their arguments have equal values at the type of the function argument.
[((stuck-app fun arg) (stuck-app fun1 arg1))
(and
(eqType? cxt (find-cxt fun cxt) (find-cxt fun1 cxt))
(eqVal? cxt (find-cxt fun cxt) fun fun1)
(eqVal? cxt (head-type (find-cxt fun cxt)) arg arg1))]
; Or to know any other two values are equal as types is to follow any
; additional rules on how we may judge the equality of terms as types
[(a b) (and a b (or (eqType?-additional cxt a b)
(begin (printf "not equal\n ~a\n ~a\n cxt: ~a\n" a b cxt) #f)))]))
; We may judge that two evaluated values are equal at an evaluated type types by the following rules
(define (eqVal? cxt typ v1 v2)
(match* ((red-eval cxt typ) (red-eval cxt v1) (red-eval cxt v2))
; To know two lambda terms are equal at a function type is to know that
; their domains are equal as types to the domain of the function type and
; in a context where their domains are assigned the proper input type
; then their bodies are equal at the type of the codomain
[((type-fun a b) (lam-pi x xt body) (lam-pi y yt body2))
(and (eqType? cxt a xt) (eqType? cxt a yt)
(extend-cxt x xt cxt (newv newcxt)
(eqVal? newcxt b (body newv) (body2 newv))))]
; To know two lambda terms are equal at a pi type is to know that
; their domains are equal as types to the domain of the function type and
; in a context where their domains are assigned the proper input type
; then their bodies are equal at the type of the codomain, as viewed in the same context
[((type-pi v a b) (lam-pi x xt body) (lam-pi y yt body2))
(and (eqType? cxt a xt) (eqType? cxt a yt)
(extend-cxt x xt cxt (newv newcxt)
(eqVal? newcxt (b newv) (body newv) (body2 newv))))]
; To know two values are equal at unit type
; requires knowing nothing else -- it is always known
[('type-unit _ _) #t]
; To know two values are equal at type type is to know that they are equal as types
[('type a b) (eqType? cxt a b)]
; To know two symbols are equal at any type is to know that they are equal as symbols
[(_ (? symbol? x) (? symbol? y)) #:when (eq? x y) #t]
; To know two primitives are equal at any type is to know their types are equal and know that
; their bodies are equal by primitive recursive comparison
[(_ (trustme t v) (trustme t1 v1)) (and (eqType? cxt t t1) (equal? v v1))] ;if all else fails use primitive equality
; Or to know any other two values are equal at any other type is to follow any
; additional rules on how we may judge the equality of terms at types
; [(rtyp x y) (eqVal?-additional cxt rtyp x y)]))
[(rtyp x y) (and rtyp (or (eqVal?-additional cxt rtyp x y)
(begin (printf "not equal\n typ: ~a\n ~a\n ~a\n cxt: ~a\n" rtyp x y cxt) #f)))]))
; TODO try to add just syntactic equality for stuck terms at a type
(define type-judgments '())
(define (type?-additional cxt t)
(for/or ([p type-judgments]) (p cxt t)))
(define hasType-judgments '())
(define (hasType?-additional cxt x t)
(for/or ([p hasType-judgments]) (p cxt x t)))
(define eqType-judgments '())
(define (eqType?-additional cxt t1 t2)
(for/or ([p eqType-judgments]) (p cxt t1 t2)))
(define eqVal-judgments '())
(define (eqVal?-additional cxt typ v1 v2)
(for/or ([p eqVal-judgments]) (p cxt typ v1 v2)))
(define apps
(lambda (fun . args)
(foldl (lambda (arg acc) (app acc arg)) fun args)))
(define-syntax-rule (lam (x t) body) (lam-pi (quote x) t (lambda (x) body)))
(define-syntax-rule (pi (x t) body) (lam-pi (quote x) t (lambda (x) body)))
(define-syntax-rule (pi-ty (x t) body) (type-pi (quote x) t (lambda (x) body)))
(define-syntax-rule (close t body) (closure t body))
(displayln "id-unit: is type, has type")
(define id-unit (lam (x type-unit) x))
(define id-unit-type (type-fun type-unit type-unit))
(type? '() id-unit-type)
(hasType? '() id-unit id-unit-type)
(displayln "id-forall: is type, has type")
(define id-forall (pi (t type-type) (lam (x t) x)))
(define id-forall-type (pi-ty (tau type-type) (type-fun tau tau)))
(type? '() id-forall-type)
(hasType? '() id-forall id-forall-type)
(displayln "id-forall: application typechecks")
(hasType? '() (app id-forall type-unit) id-unit-type)
(hasType? '() (apps id-forall type-unit '()) type-unit)
(displayln "k-comb: is type, has type")
(define k-comb
(pi (a type-type) (lam (x a) (pi (b type-type) (lam (y b) x)))))
(define k-comb-type
(pi-ty (a type-type) (type-fun a (pi-ty (b type-type) (type-fun b a)))))
(type? '() k-comb-type)
(hasType? '() k-comb k-comb-type)
(displayln "checking rejection of bad signatures")
(hasType? '() k-comb id-forall-type)
(hasType? '() id-forall id-unit-type)
; To introduce a new type is to
; extend the ways to know a value is a type
; give a way to know a value has that type
; extend the ways to know two values are equal as types
; give a way to know two values are equal at that type
(define (new-form type-judgment hasType-judgment eqType-judgment eqVal-judgment)
(cond [type-judgment (set! type-judgments (cons type-judgment type-judgments))])
(cond [hasType-judgment (set! hasType-judgments (cons hasType-judgment hasType-judgments))])
(cond [eqType-judgment (set! eqType-judgments (cons eqType-judgment eqType-judgments))])
(cond [eqVal-judgment (set! eqVal-judgments (cons eqVal-judgment eqVal-judgments))])
)
; adding bool
(define type-bool 'type-bool)
(new-form
; To know a value is a type may be to know that it is the symbol 'type-bool
(lambda (cxt t) (eq? t 'type-bool))
; To know a value is of type bool is to know that it is #t or #f
(lambda (cxt x t) (and (eq? t 'type-bool) (boolean? x)))
; to know a two values are equal as types when the symbol 'type-bool corresponds to a type
; is to compare the symbols, which is already known
#f
; To know two values are equal at type bool is to know that they are equal as scheme values
(lambda (cxt t x y) (and (eq? t 'type-bool) (eq? x y))))
; If we are given two terms at a type,
; then we may produce a term that sends bools to either the first or second of those given terms.
(define bool-elim
(pi (a type-type) (lam (x a) (lam (y a) (lam (b type-bool) (close a (lambda (cxt) (if (red-eval cxt b) x y))))))))
; If we know a mapping from bools to types
; and we know a term of the type that is the image of that function on true
; and we know a term of the type that is the image of that function on false
; then we may produce a term that sends bools to either the first or second of those terms
; at either the first or second of those types
(define bool-induct
(pi (p (type-fun type-bool type-type))
(lam (x (app p #t))
(lam (y (app p #f))
(pi (bl type-bool)
(close (app p bl) (lambda (cxt) (if (red-eval cxt bl) x y))))))))
(displayln "functions on bool")
(define not-bool (apps bool-elim type-bool #f #t))
(red-eval '() (app not-bool #t))
(red-eval '() (app not-bool #f))
; adding equality types
(struct type-eq (type v1 v2) #:transparent)
(struct val-eq (v1 v2))
(new-form
; To know a value is a type may be to know that
; it is tagged with type-eq and a given type
; to know that its first term is of the appropriate type and
; to know that its second term is of the appropriate type
(match-lambda**
[(cxt (type-eq type v1 v2))
(and (hasType? cxt v1 type)
(hasType? cxt v2 type))]
[(_ _) #f])
; To know a value has an equality type is to know that
; the values of equality type can be known equal at the appropriate type
(match-lambda**
[(cxt 'refl (type-eq type v1 v2)) ;note we ignore the refl
(eqVal? cxt type v1 v2)]
[(_ _ _) #f])
; To know a two types are equal may be to know that
; they are of type-eq and
; they are equalities at the same type and
; their first values are equal at that type
; their second values are equal at that type
(match-lambda**
[(cxt (type-eq t1t t1a t1b) (type-eq t2t t2a t2b))
(and (eqType? cxt t1t t2t) (eqVal? cxt t1t t1a t2a) (eqVal? cxt t1t t1b t2b))]
[(_ _ _) #f])
; To know if two values are equal at any given equality type
; requires knowing nothing else -- it is always known
(match-lambda**
[(cxt (type-eq t a b) _ _) #t]
[(_ _ _ _) #f])
)
; equality intro
; if we know a term at a type, we know that the term, at that type, is equal to itself
(define refl (pi (a type-type) (pi (x a) (close (type-eq a x x) (lambda (cxt) 'refl)))))
; equality elim
; if we know a type
; and we know a family C which can send two terms at that type and an equality between them to types
; and know how to produce from a term at a type a value of C as decided by the identity path on our term
; then we may produce a term that
; sends two values at a type and an equality between them to the value of C as decided by that path between them
(define equal-induct
(pi (a type-type)
(pi (c (pi-ty (x a) (pi-ty (y a) (type-fun (type-eq a x y) type-type))))
(lam (f (pi-ty (z a) (apps c z z 'refl)))
(pi (m a)
(pi (n a)
(pi (p (type-eq a m n))
(close (apps c m n p) (lambda (cxt) (app f m))))))))))
;todo prove transitivity
(displayln "proving that for all bool, not (not x) = x")
(define not-not-bool (lam (x type-bool) (app not-bool (app not-bool x))))
(define id-bool (lam (x type-bool) x))
; not-not-is-id
(define nnii-fam (lam (x type-bool) (type-eq type-bool (app id-bool x) (app not-not-bool x))))
(hasType? '() nnii-fam (type-fun type-bool type-type))
(hasType? '() 'refl (app nnii-fam #t))
(define nnii-type (pi-ty (x type-bool) (app nnii-fam x)))
(define nnii (pi (x type-bool) (apps bool-induct nnii-fam (apps refl type-bool #t) (apps refl type-bool #f) x)))
(type? '() nnii-type)
(hasType? '() nnii nnii-type)
(displayln "but we don't have extensional function equality")
(define nnii-extensional (type-eq (type-fun type-bool type-bool) id-bool not-not-bool))
(type? '() nnii-extensional)
(hasType? '() (apps refl (type-fun type-bool type-bool) id-bool) nnii-extensional)
(displayln "although we do have intensional equality")
(hasType? '() (apps refl (type-fun type-bool type-bool) not-not-bool) (type-eq (type-fun type-bool type-bool) not-not-bool not-not-bool))
(displayln "and we can add eta as an axiom")
(define eta-axiom
(pi (a type-type)
(pi (b type-type)
(pi (f (type-fun a b))
(pi (g (type-fun a b))
(pi (prf (pi-ty (x a) (type-eq a (app f x) (app g x))))
(trustme (type-eq (type-fun a b) f g) 'eta-axiom)))))))
(define nnii-extensional-term (apps eta-axiom type-bool type-bool id-bool not-not-bool nnii))
(hasType? '() nnii-extensional-term nnii-extensional)
(hasType? '() (red-eval '() nnii-extensional-term) nnii-extensional)
(red-eval '() nnii-extensional-term)
(displayln "naturals are easy")
(define type-nat 'type-nat)
(new-form
(lambda (cxt t) (eq? t 'type-nat))
(lambda (cxt x t) (and (eq? t 'type-nat) (exact-integer? x) (>= x 0)))
#f
(lambda (cxt t x y) (and (eq? t 'type-nat) (eq? x y))))
(define z 0)
(define succ (lam (x type-nat)
(close type-nat (lambda (cxt)
(let ([x1 (red-eval cxt x)])
(if (number? x1)
(+ x1 1)
(trustme type-nat (cons 'succ x1))))))))
(define nat-induct
(pi (c (type-fun type-nat type-type))
(lam (base (app c z))
(lam (induct (pi-ty (n2 type-nat)
(type-fun (app c n2) (app c (app succ n2)))))
(pi (n1 type-nat)
(close (app c n1) (lambda (cxt) (for/fold ([acc base])
([x (in-range (red-eval cxt n1))])
(apps induct x acc)))))))))
(define double (apps nat-induct (lam (x type-nat) type-nat) z (pi (x type-nat) (lam (n type-nat) (app succ (app succ n))))))
(red-eval '() (app double (app double (app succ z))))
(define plus (lam (a type-nat)
(apps nat-induct (lam (x type-nat) type-nat) a (pi (n type-nat) (lam (n type-nat) (app succ n))))))
(red-eval '() (apps plus 5 5))
(displayln "we can use sigma types, for existential proofs")
(struct type-sig (a b) #:transparent)
(define-syntax-rule (sig-ty (x t) body) (type-sig t (lambda (x) body)))
(new-form
; To know a value is a type may be to know that it is tagged type-sig
; and to know that its first element is a type
; and to know that the second element can send terms of the first element to types.
(match-lambda**
[(cxt (type-sig a b))
(and (type? cxt a)
(extend-cxt 'fst a cxt (newv newcxt)
(type? newcxt (b newv))))]
[(_ _) #f])
; To know a value is of type sigma is to know that it is a pair
; and to know that its first element has the type of the first element of the type
; and to know that its second element has the type that the second element of the type
; sends the first element of the value to.
(match-lambda**
[(cxt (cons x y) (type-sig a b))
(and (hasType? cxt x a)
(hasType? cxt y (b x)))]
[(_ _ _) #f])
; To know two values are equal as types may be to know that they are both tagged type-sig
; and that their first elements are equal as types
; and that their second elements send values of the first element to terms that are equal as types
(match-lambda**
[(cxt (type-sig a b) (type-sig a1 b1))
(and (eqType? cxt a a1)
(extend-cxt 'fst a cxt (newv newcxt)
(eqType? newcxt (b newv) (b1 newv))))]
[(_ _ _) #f])
; To know two values are equal at a sigma type is to know that
; their first elements are equal at the first component of the sigma type
; and their second elements are equal at the type produced by the application of the
; second component of the sigma type to either of their first elements.
(match-lambda**
[(cxt (type-sig a b) (cons x y) (cons x1 y1))
(and (eqVal? cxt a x x1)
(eqVal? cxt (b x) y y1))]
[(_ _ _ _) #f]))
(define sig-induct-type
(pi-ty (a type-type)
(pi-ty (b (type-fun a type-type))
(pi-ty (c (type-fun (sig-ty (x a) (app b x)) type-type))
(type-fun
(pi-ty (x a)
(pi-ty (y (app b x))
(app c (cons x y))))
(pi-ty (p (sig-ty (x a) (app b x)))
(app c p)))))))
(define sig-induct
(pi (a type-type)
(pi (b (type-fun a type-type))
(pi (c (type-fun (sig-ty (x a) (app b x)) type-type))
(lam (g (pi-ty (x a)
(pi-ty (y (app b x))
(app c (cons x y)))))
(pi (p (sig-ty (x a) (app b x)))
(close (app c p) (lambda (env) (apps g (car (red-eval env p)) (cdr (red-eval env p)))))))))))
(displayln "Sigma induction can be defined.")
(hasType? '() sig-induct sig-induct-type)
;; Forall A, B over A, app fst Sig(a A,B a) : A
(define fst-sig-type
(pi-ty (a type-type)
(pi-ty (b (type-fun a type-type))
(type-fun (sig-ty (x a) (app b x)) a)
)))
(define fst-sig
(pi (a type-type)
(pi (b (type-fun a type-type))
(lam (sg (sig-ty (x a) (app b x)))
(apps sig-induct a b
(lam (s (sig-ty (x a) (app b x))) a)
(pi (x a) (pi (y (app b x)) x))
sg)))))
(displayln "We can use sigma induction to properly eliminate out of sigma, with the type we would expect")
(red-eval '() (apps fst-sig type-nat (lam (x type-nat) type-bool) (cons 25 #t)))
; every number has a successor
(define has-succ (pi (n type-nat) (cons (app succ n) (apps refl type-nat (app succ n)))))
(define has-succ-type (pi-ty (n type-nat) (sig-ty (x type-nat) (type-eq type-nat x (app succ n)))))
(hasType? '() has-succ has-succ-type)
; every inhabitant of unit is equal to '()
(define unit-induct
(pi (c (type-fun type-unit type-type))
(lam (v (app c '()))
(pi (u type-unit)
(close (app c u) (lambda (env) v))))))
(define is-unit (pi (u type-unit) (cons u (apps unit-induct
(lam (x type-unit) (type-eq type-unit x '()))
(apps refl type-unit '())
u))))
(define is-unit-type (pi-ty (u type-unit) (sig-ty (x type-unit) (type-eq type-unit x '()))))
(hasType? '() is-unit is-unit-type)
(displayln "we have partial type inference")
(define (inferType cxt x1)
(match (reduce cxt x1)
[(closure typ b) typ]
[(trustme typ b) typ]
[(? symbol? x) #:when (find-cxt x cxt) (find-cxt x cxt)]
[(lam-pi vn vt body)
(extend-cxt vn vt cxt (newvar newcxt)
(type-pi newvar vt (lambda (y) (subst y newvar (reduce newcxt (inferType newcxt (body newvar)))))))]
['() type-unit]
[(? number? x) type-nat]
[(? boolean? x) type-bool]
[(cons a b) (type-sig (inferType cxt a) (lambda (arg) (inferType cxt b)))] ; can't infer sigmas in general
; ['refl ...] -- given a plain refl what is its type?
; in both cases, more data in terms can help clean this up...
[(? (lambda (x) (type? cxt x))) type-type]
))
(define/match (subst y v x)
[(_ _ (? symbol? x)) #:when (eq? x y) y]
[(_ _ (closure typ b)) (closure (abs y v typ) (lambda (cxt) (subst y v (b cxt))))]
[(_ _ (trustme typ b)) (closure (subst y v typ) (subst y v b))]
[(_ _ (lam-pi vn vt body)) (lam-pi vn (subst y v vt) (lambda (arg) (subst y v (body arg))))]
[(_ _ (cons a b)) (cons (subst y v a) (subst y v b))]
[(_ _ (type-fun a b)) (type-fun (subst y v a) (subst y v b))]
[(_ _ (type-eq t a b)) (type-eq (subst y v t) (subst y v a) (subst y v b))]
[(_ _ (type-pi av a b)) (type-pi av (subst y v a) (lambda (arg) (subst y v (b arg))))]
[(_ _ (type-sig a b)) (type-sig (subst y v a) (lambda (arg) (subst y v (b arg))))]
[(_ _ _) x]
)
(define (saturate cxt x)
(match (reduce cxt x)
[(closure typ b) (closure (saturate cxt typ) (saturate cxt (red-eval cxt (b cxt))))]
[(trustme typ b) (trustme (saturate cxt typ) b)]
[(lam-pi vn vt body)
(extend-cxt vn vt cxt (newvar newcxt)
(lam-pi vn vt (saturate newcxt (body newvar))))]
[(cons a b) (cons (saturate cxt a) (saturate cxt b))]
[(type-fun a b) (type-fun (saturate cxt a) (saturate cxt b))]
[(type-eq t a b) (type-eq (saturate cxt t) (saturate cxt a) (saturate cxt b))]
[(type-pi av a b)
(extend-cxt av a cxt (newvar newcxt)
(type-pi newvar (saturate newcxt a) (saturate newcxt (b newvar))))]
[(type-sig a b)
(extend-cxt 'fst a cxt (newvar newcxt)
(type-sig (saturate newcxt a) (saturate newcxt (b newvar))))]
[v v]
))
(saturate '() (inferType '() id-bool))
(saturate '() (inferType '() not-not-bool))
(saturate '() (inferType '() nnii))
(saturate '() (inferType '() (cons #t '())))
(displayln "we can build either from sigma")
(define (either-type a b) (sig-ty (bl type-bool)
(apps bool-elim type-type a b bl)))
(define left (pi (t type-type) (lam (a t) (cons #t a))))
(define right (pi (t type-type) (lam (a t) (cons #f a))))
(hasType? '() (apps left type-nat 5) (either-type type-nat type-nat))
(define maybe-zero (pi (n type-nat) (either-type (type-eq type-nat n z) type-bool)))
(define zero-or-not (apps nat-induct
(lam (x type-nat) (app maybe-zero x))
(apps left (type-eq type-nat z z) (apps refl type-nat z))
(pi (x type-nat) (lam (y (app maybe-zero x)) (apps right type-bool #f)))))
(hasType? '() (pi (x type-nat) (app zero-or-not x)) (pi-ty (x type-nat) (app maybe-zero x)))
(displayln "we can introduce a type for falsehood, and use it to show contradiction.")
(define type-false 'false)
(new-form
(lambda (cxt t) (eq? t 'false))
#f
#f
(lambda (cxt t x y) (eq? t 'false)))
(define transport
(pi (a type-type)
(pi (p (type-fun a type-type))
(apps equal-induct
a
(pi (x a) (pi (y a) (lam (q (type-eq a x y)) (type-fun (app p x) (app p y)))))
(pi (z a) (lam (v (app p z)) v))))))
(define trivial-transport (apps transport type-bool (lam (x type-bool) type-nat) #t #t (apps refl type-bool #t)))
(red-eval '() (app trivial-transport 4))
(define true-is-false (type-eq type-bool #t #f))
(define bool-to-type (apps bool-elim type-type type-unit type-false))
(define contradiction-implies-false
(lam (absurd true-is-false)
(apps transport type-bool bool-to-type #t #f absurd '())))
(hasType? '() contradiction-implies-false (type-fun true-is-false type-false))
(hasType? '() (app contradiction-implies-false (trustme true-is-false 'haha)) type-false)
(displayln "although if we posit a falsehood we still can't generate an actual inhabitant of type false.")
(red-eval '() (app contradiction-implies-false (trustme true-is-false 'haha)))
; And finally we can give an axiom for univalence.
(struct pair-ty (fst snd) #:transparent)
(define (fun-compose a f g)
(lam (x a) (app f (app g a))))
(define (type-homotopy a p f g)
(pi (x a) (type-eq (app p x) (app f x) (app g x))))
(define (type-isequiv a b f)
(pair-ty
(sig-ty (g (type-fun b a)) (type-homotopy b (lam (x a) b) (fun-compose b f g) (lam (x b) x)))
(sig-ty (h (type-fun b a)) (type-homotopy a (lam (x b) a) (fun-compose a h f) (lam (x a) x)))))
(define (type-equiv a b)
(sig-ty (f (type-fun a b)) (type-isequiv a b f)))
(define univalence-axiom (pi (a type-type) (pi (b type-type)
(trustme (type-equiv (type-equiv a b) (type-eq type-type a b)) 'ua))))
; references
; Simply Easy: http://strictlypositive.org/Easy.pdf
; Simpler, Easier: http://augustss.blogspot.com/2007/10/simpler-easier-in-recent-paper-simply.html
; PTS: http://hub.darcs.net/dolio/pts
; Pi-Forall: https://github.com/sweirich/pi-forall
| true |
3c7bac7f018b23bcdd930fdf7c7c8f279d17efc0 | bd528140fc0a7ada47a4cb848f34eae529620c1e | /2-13.rkt | caf263af0a5d212537bb9cf18583df0adfa8650a | []
| no_license | michaldarda/sicp | c09c197b35014d66f516f4a0a8d49f33e3c09a37 | 8ea78f8f0780f786057dfdaae24e44f16abf063b | refs/heads/master | 2020-07-15T01:23:51.573237 | 2020-05-24T19:54:59 | 2020-05-24T19:54:59 | 205,447,221 | 4 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,156 | rkt | 2-13.rkt | #lang racket
(define (mul-interval x y)
(let ([p1 (* (lower-bound x) (lower-bound y))]
[p2 (* (lower-bound x) (upper-bound y))]
[p3 (* (upper-bound x) (lower-bound y))]
[p4 (* (upper-bound x) (upper-bound y))])
(make-interval (min p1 p2 p3 p4)
(max p1 p2 p3 p4))))
(define (make-interval a b) (cons a b))
(define (lower-bound interval) (car interval))
(define (upper-bound interval) (cdr interval))
(define (make-center-width c w)
(make-interval (- c w) (+ c w)))
(define (center int)
(/ (+ (lower-bound int) (upper-bound int)) 2))
(define (width int)
(/ (- (upper-bound int) (lower-bound int)) 2))
(define (make-center-percent c p)
(make-interval (- c (* c p))
(+ c (* c p))))
(define (percentage-tolerance-interval int)
(let ([center (center int)]
[lower (lower-bound int)])
(/ (- center lower) center)))
(define tolerance 0.5)
(define int1 (make-center-percent 50 tolerance))
(define int2 (make-center-percent 50 0.4))
(percentage-tolerance-interval (mul-interval int1 int2))
(+ (percentage-tolerance-interval int1) (percentage-tolerance-interval int2))
| false |
bf6513bd109a0bfcc4ce82c65893e9ec2d4edbda | b0c07ea2a04ceaa1e988d4a0a61323cda5c43e31 | /langs/test-programs/hoax/str.rkt | 1deacc49d07f157f80be45944e08c60fb3ece373 | [
"AFL-3.0"
]
| permissive | cmsc430/www | effa48f2e69fb1fd78910227778a1eb0078e0161 | 82864f846a7f8f6645821e237de42fac94dff157 | refs/heads/main | 2023-09-03T17:40:58.733672 | 2023-08-28T15:26:33 | 2023-08-28T15:26:33 | 183,064,322 | 39 | 30 | null | 2023-08-28T15:49:59 | 2019-04-23T17:30:12 | Racket | UTF-8 | Racket | false | false | 21 | rkt | str.rkt | #lang racket
"hoax"
| false |
1a9c2236f6b3a04e299cfa0c21e0474ed230447d | 6071e11de198415ad1e562e0bf9e3685d078074e | /parser-helpers.rkt | 53c79814577e15ff5c52c05d7ef182b2a7a256f9 | []
| no_license | jpverkamp/abc | cb6f6d9b10773ec98ea3cfbb199bd0aa020f9b32 | 7e9936e3cee6dccaf85518de5a9a20c4d32e55c4 | refs/heads/master | 2021-01-23T00:15:53.528088 | 2013-11-12T08:05:31 | 2013-11-12T08:05:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 2,417 | rkt | parser-helpers.rkt | #lang racket
(provide (all-defined-out))
; Meter / time signature
(struct meter
(beats ; How many notes are in a measure
1-beat ; Which note is a beat (4 = quarter, so 1/n)
) #:transparent #:mutable)
; Key signature
(struct key
(base ; Base note for the key (C-B, ex: G)
type ; Type of key (major, minor, etc)
sharps ; List of notes that are sharp (C-B)
flats ; List of flats
) #:transparent #:mutable)
; Parse tempo information
(define (parse-tempo text)
(string->number text))
; Parse length header information
(define (parse-length text)
(string->number text))
; Parse a meter definition
(define (parse-meter text)
(cond
[(equal? text "none") (meter #f #f)]
[(equal? text "C") (meter 4 4)]
[(equal? text "C|") (meter "C|")]
[else
(apply meter (map string->number (string-split text "/")))]))
; Parse a key signature
(define (parse-key text)
(match-define (list _ note type)
(map
string->symbol
(regexp-match #px"([A-G][#b]?)(|Maj|m|Min|Mix|Dor|Phr|Lyd|Loc)" text)))
(when (eq? type '||) (set! type 'Maj))
(when (eq? type 'm) (set! type 'Min))
(define-values (num-sharps num-flats)
(case (string->symbol (format "~a~a" note type))
[(C#Maj, AMin, G#Mix, D#Dor, E#Phr, F#Lyd, B#Loc) (values 7 0)]
[(F#Maj, DMin, C#Mix, G#Dor, A#Phr, BLyd, E#Loc) (values 6 0)]
[(BMaj, GMin, F#Mix, C#Dor, D#Phr, ELyd, A#Loc) (values 5 0)]
[(EMaj, CMin, BMix, F#Dor, G#Phr, ALyd, D#Loc) (values 4 0)]
[(AMaj, FMin, EMix, BDor, C#Phr, DLyd, G#Loc) (values 3 0)]
[(DMaj, Min, AMix, EDor, F#Phr, GLyd, C#Loc) (values 2 0)]
[(GMaj, Min, DMix, ADor, BPhr, CLyd, F#Loc) (values 1 0)]
[(CMaj, Min, GMix, DDor, EPhr, FLyd, BLoc) (values 0 0)]
[(FMaj, Min, CMix, GDor, APhr, BbLyd, ELoc) (values 0 1)]
[(BbMaj, Min, FMix, CDor, DPhr, EbLyd, ALoc) (values 0 2)]
[(EbMaj, Min, BbMix, FDor, GPhr, AbLyd, DLoc) (values 0 3)]
[(AbMaj, Min, EbMix, BbDor, CPhr, DbLyd, GLoc) (values 0 4)]
[(DbMaj, BMin, AbMix, EbDor, FPhr, GbLyd, CLoc) (values 0 5)]
[(GbMaj, EMin, DbMix, AbDor, BbPhr, CbLyd, FLoc) (values 0 6)]
[(CbMaj, AMin, GbMix, DbDor, EbPhr, FbLyd, BbLoc) (values 0 7)]))
(key note
type
(take '(F C G D A E B) num-sharps)
(take '(B E A D G C F) num-flats))) | false |
299203beb458745c767cafa150c9ca0fdee6d60d | 925fa95cc25d1d4d9afbe036c2e7b01791f080da | /autopack/model/executor.rkt | 1e332da8cbb05a41eb1492a6c53d74008cdcc199 | []
| no_license | fujingjunben/autopack-racket | 947a7f306f63624320320f7e08df3f89dbf70b8b | d274432f4649792d126c57149468a97f8592d744 | refs/heads/master | 2021-01-10T11:09:18.408427 | 2016-04-08T11:16:24 | 2016-04-08T11:16:24 | 55,772,328 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 49 | rkt | executor.rkt | #lang racket
;; executor model
(define executor) | false |
c29bb1558890cf3b9812454789bf0a32572ef0c3 | 40698932cff82e2a0f12299f179114040f2435a7 | /old-gui/trussGuilherme.rkt | 0ebc3a14cd7d6bfbf488cee8ca4d02aa24549d24 | []
| no_license | PastelBelem8/2019-CAADRIA-conflicting-goals-a-multi-objective-optimization-study | e02ac0c007f624c2424f17bdd87aea1f95622c91 | 38549fe6e4a6e295891ef003eac5a23536753304 | refs/heads/master | 2020-12-27T22:04:56.184615 | 2020-02-03T22:31:04 | 2020-02-03T22:31:04 | 238,073,679 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 10,844 | rkt | trussGuilherme.rkt | #lang racket
;(require rosetta/autocad) (define I_MT_STEEL 1) (define analysis-nodes-height (make-parameter 1)) (define-syntax-rule (with-simulation . args) #t) (define add-radiance-polygon! list) (define-syntax-rule (add-radiance-shape! x) #t)
(require rosetta/robot/backend)(define load-beam-family list) (define create-layer list) (define-syntax-rule (with-current-layer l body ...) (begin body ...)) (define analysis-nodes-height (make-parameter 1)) (define-syntax-rule (with-simulation . args) #t) (define add-radiance-polygon! list) (define-syntax-rule (add-radiance-shape! x) #t) (define panel list) (define loft list) (define polygon list)
(delete-all-shapes)
(define cmd-vector (current-command-line-arguments))
(define angle-0 (string->number (vector-ref cmd-vector 0)))
(define angle-1 (string->number (vector-ref cmd-vector 1)))
(define angle-2 (string->number (vector-ref cmd-vector 2)))
(define pos-0 (string->number (vector-ref cmd-vector 3)))
(define pos-1 (string->number (vector-ref cmd-vector 4)))
(define pos-2 (string->number (vector-ref cmd-vector 5)))
;PROPRIEDADES E FAMÍLIAS
(define fixed-xyz-truss-node-family (truss-node-family-element (default-truss-node-family)
;#:radius 0.1
#:support (create-node-support "SupportA" #:ux #t #:uy #t #:uz #t)))
(define fixed-z-truss-node-family (truss-node-family-element (default-truss-node-family)
;#:radius 0.1
#:support (create-node-support "SupportB" #:ux #f #:uy #f #:uz #t)))
(default-truss-bar-family (truss-bar-family-element (default-truss-bar-family)
;#:radius 0.05
#:material (list "ElasticIsotropic"
I_MT_STEEL
"Steel"
"I'm really steel"
210000000000.0
0.3
81000000000.0
77010.0
1.2E-05
0.04
235000000.0
360000000.0)
#:section (list "Tube"
"ElasticIsotropic"
#f
(list (list #t ;;solid?
0.1
0.01)))))
(define truss-node-family (truss-node-family-element (default-truss-node-family)
#:radius 0.1
))
(define (no-trelica p)
(truss-node p))
;(truss-node p truss-node-family))
(define (fixed-xyz-no-trelica p)
(truss-node p fixed-xyz-truss-node-family))
(define (fixed-z-no-trelica p)
(truss-node p fixed-z-truss-node-family))
(define (barra-trelica p0 p1)
(truss-bar p0 p1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;LAYERS
(define node-layer (create-layer "Nodes"))
(define fixed-node-layer (create-layer "Fixed Nodes"))
(define bar-layer (create-layer "Bars"))
(define radiation-layer (create-layer "Radiation"))
;TRELIÇA
(define (nos-trelica ps)
(if (null? ps)
#t
(begin
(no-trelica (car ps))
(nos-trelica (cdr ps)))))
(define (fixed-nos-trelica ps)
(fixed-xyz-no-trelica (car ps))
(nos-trelica (drop-right (cdr ps) 1))
(fixed-xyz-no-trelica (last ps)))
(define (barras-trelica ps qs)
(if (or (null? ps) (null? qs))
#t
(begin
(barra-trelica (car ps) (car qs))
(barras-trelica (cdr ps) (cdr qs)))))
(define intermediate-loc intermediate-point)
(define (trelica-espacial curvas f (first? #t))
(let ((as (car curvas))
(bs (cadr curvas))
(cs (caddr curvas)))
(if first?
(fixed-nos-trelica as)
(nos-trelica as))
(nos-trelica bs)
(if (null? (cdddr curvas))
(begin
(fixed-nos-trelica cs)
(barras-trelica (cdr cs) cs))
(begin
(trelica-espacial (cddr curvas) f #f)
(barras-trelica bs (cadddr curvas))))
(barras-trelica as cs)
(barras-trelica bs as)
(barras-trelica bs cs)
(barras-trelica bs (cdr as))
(barras-trelica bs (cdr cs))
(barras-trelica (cdr as) as)
(barras-trelica (cdr bs) bs)))
;TRELIÇA
(define attractors (make-parameter (list (xyz 5 5 5))))
(define (affect-radius r p)
(* r (+ 1 (* +0.5 (expt 1.4
(- (apply min (map (lambda (attractor) (distance p attractor))
(attractors)))))))))
(define (pontos-arco p r fi psi0 psi1 dpsi)
(if (> psi0 psi1)
(list)
(cons (+sph p (affect-radius r (+sph p r fi psi0)) fi psi0)
(pontos-arco p r fi (+ psi0 dpsi) psi1 dpsi))))
(define (coordenadas-trelica-ondulada p rac rb l fi psi0 psi1 dpsi
alfa0 alfa1 d-alfa d-r)
(if (>= alfa0 alfa1)
(list (pontos-arco
(+pol p (/ l 2.0) (- fi pi/2))
(+ rac (* d-r (sin alfa0)))
fi psi0 psi1 dpsi))
(cons
(pontos-arco
(+pol p (/ l 2.0) (- fi pi/2))
(+ rac (* d-r (sin alfa0)))
fi psi0 psi1 dpsi)
(cons
(pontos-arco
p
(+ rb (* d-r (sin alfa0)))
fi (+ psi0 (/ dpsi 2)) (- psi1 (/ dpsi 2)) dpsi)
(coordenadas-trelica-ondulada
(+pol p l (+ fi pi/2))
rac rb l fi psi0 psi1 dpsi
(+ alfa0 d-alfa) alfa1 d-alfa d-r)))))
(define (trelica-ondulada p rac rb l n fi psi0 psi1
alfa0 alfa1 d-alfa d-r)
(trelica-espacial
(coordenadas-trelica-ondulada
p rac rb l fi psi0 psi1 (/ (- psi1 psi0) n)
alfa0 alfa1 d-alfa d-r)
panel))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#;(parameterize ((attractors (list (+y (sph 10 0 angle-0) pos-0)
(+y (sph 10 0 angle-1) pos-1)
(+y (sph 10 0 angle-2) pos-2))))
(trelica-ondulada (xyz 0 0 0) 10 9 1.0 10 0 -pi/2 pi/2 0 4pi (/ pi 8) 0.1))
;ANÁLISE ROBOT
(require (prefix-in % rosetta/robot/robot-com))
#;#;#;#;
(require (prefix-in ac: rosetta/autocad))
(ac:delete-all-shapes)
(define red (rgb 255 0 0))
(with-robot-analysis (results)
(trelica-ondulada (xyz 0 0 0) 10 9 1.0 10 0 -pi/2 pi/2 0 4pi (/ pi 8) 1)
(vz -50000)
(let* ((node-radius 0.04)
(bar-radius 0.02)
(factor 100)
(node-displacement (lambda (node)
(let ((node-id (%truss-node-data-id node)))
(let ((d (%node-displacement (%Displacements (%nodes results)) node-id 1)))
(v*r (vxyz (%UX d) (%UY d) (%UZ d)) factor))))))
(for ((node (in-hash-values (%added-nodes))))
(let ((node-id (%truss-node-data-id node)))
(let ((d (node-displacement node)))
(let ((p (%truss-node-data-loc node)))
(ac:sphere p node-radius)
(ac:shape-color (ac:sphere (p+v p d) node-radius) red)))))
(for ((bar (in-hash-values (%added-bars))))
(let ((node0 (%truss-bar-data-node0 bar))
(node1 (%truss-bar-data-node1 bar)))
(let ((p0 (%truss-node-data-loc node0))
(p1 (%truss-node-data-loc node1)))
(ac:cylinder p0 bar-radius p1)
(let ((d0 (node-displacement node0))
(d1 (node-displacement node1)))
(ac:shape-color (ac:cylinder (p+v p0 d0) bar-radius (p+v p1 d1)) red)))))))
#;
(with-robot-analysis (results)
(trelica-ondulada (xyz 0 0 0) 10 9 1.0 #;20 10 0 -pi/2 pi/2 0 4pi (/ pi 4) #;(/ pi 8) 1)
(vz -50000)
(let* ((node-radius 0.08)
(bar-radius 0.04)
(factor 100))
(for ((node (in-hash-values (%added-nodes))))
(let ((node-id (%truss-node-data-id node)))
(let ((p (%truss-node-data-loc node)))
(ac:sphere p node-radius))))
(let* ((bars (hash-values (%added-bars)))
(bars-id (map %truss-bar-data-id bars))
(bars-stress (map (lambda (bar-id)
(abs (%bar-max-stress results bar-id 1)))
bars-id)))
(let ((max-stress (argmax identity bars-stress))
(min-stress (argmin identity bars-stress)))
(for ((bar (in-list bars))
(bar-in (in-list bars-id))
(bar-stress (in-list bars-stress)))
(let ((node0 (%truss-bar-data-node0 bar))
(node1 (%truss-bar-data-node1 bar)))
(let ((p0 (%truss-node-data-loc node0))
(p1 (%truss-node-data-loc node1)))
(ac:shape-color (ac:cylinder p0 bar-radius p1)
(color-in-range bar-stress min-stress max-stress)))))))))
(display
(with-robot-analysis (results)
(parameterize ((attractors (list (+y (sph 10 0 angle-0) pos-0)
(+y (sph 10 0 angle-1) pos-1)
(+y (sph 10 0 angle-2) pos-2))))
(trelica-ondulada (xyz 0 0 0) 10 9 1.0 10 0 -pi/2 pi/2 0 4pi (/ pi 8) 0.1))
(vz -50000)
(let* ((node-radius 0.04)
(bar-radius 0.02)
(factor 100))
(apply min
(for/list ((node (in-hash-values (%added-nodes))))
(cz (v*r (%node-displacement-vector
results
(%truss-node-data-id node)
1)
factor))))))
)
;(trelica-ondulada p rac rb l n fi psi0 psi1 alfa0 alfa1 d-alfa d-r)
#;(parameterize ((attractors (list (+y (sph 10 0 angle-0) pos-0)
(+y (sph 10 0 angle-1) pos-1)
(+y (sph 10 0 angle-2) pos-2))))
(map (lambda (p) (sphere p 0.5)) (attractors))
(trelica-ondulada (xyz 0 0 0) 10 9 1.0 10 0 -pi/2 pi/2 0 4pi (/ pi 8) 0.1)) | true |
91f54bd2523cb412630d8244fb3f50a233651185 | 478865cd191e2d9598664b191c7d5fcc203f094f | /racket/semantic-type-metafunctions.rkt | 66bee8e6ade6ad69a1ec1ece7bb468f99c1d11f3 | [
"Apache-2.0"
]
| permissive | vollmerm/semantic-numeric-tower | fd8c5fffd9f6bce8b088b4d80c84f11dd87a22c6 | 6f9b8a78ebdb33afca42f8e2cffa75694e1ba716 | refs/heads/master | 2020-03-27T05:57:19.954091 | 2018-08-24T18:21:23 | 2018-08-24T18:21:23 | 146,066,075 | 0 | 0 | Apache-2.0 | 2018-08-25T04:54:32 | 2018-08-25T04:54:32 | null | UTF-8 | Racket | false | false | 2,923 | rkt | semantic-type-metafunctions.rkt | #lang typed/racket/base
(require racket/match
"semantic-type-rep.rkt"
"semantic-type-ops.rkt")
(provide project
domain
funapp)
(: project (-> (U 1 2) TYPE (U TYPE False)))
(define (project i t)
(cond
[(not (subtype? t Any-Prod-TYPE)) #false]
[else
(let loop : TYPE
([bdd : BDD (TYPE-prods t)]
[s1 : TYPE Any-TYPE]
[s2 : TYPE Any-TYPE]
[N : (Listof ATOM) '()])
(match bdd
[(== bot eq?) Empty-TYPE]
[(== top eq?) (prod-phi i s1 s2 N)]
[(NODE: (and a (cons t1 t2)) l m r)
(define s1* (type-and s1 t1))
(define s2* (type-and s2 t2))
(define tl (if (or (empty? s1*) (empty? s2*))
Empty-TYPE
(loop l s1* s2* N)))
(define tm (loop m s1 s2 N))
(define tr (loop r s1 s2 (cons a N)))
(type-or tl (type-or tm tr))]))]))
(: prod-phi (-> (U 1 2) TYPE TYPE (Listof ATOM) TYPE))
(define (prod-phi i s1 s2 N)
(match N
[(list) (if (eqv? i 1) s1 s2)]
[(cons (cons t1 t2) N)
(define s1* (type-diff s1 t1))
(define s2* (type-diff s2 t2))
(type-or (if (empty? s1*) Empty-TYPE (prod-phi i s1* s2 N))
(if (empty? s2*) Empty-TYPE (prod-phi i s1 s2* N)))]))
(: domain (-> TYPE (U TYPE False)))
(define (domain t)
(cond
[(not (subtype? t Any-Arrow-TYPE)) #false]
[else
(let loop : TYPE
([bdd : BDD (TYPE-arrows t)]
[t : TYPE Empty-TYPE])
(match bdd
[(== top eq?) t]
[(== bot eq?) Any-TYPE]
[(NODE: (cons s1 _) l m r)
(type-and (loop l (type-or t s1))
(type-and (loop m t)
(loop r t)))]))]))
(: funapp (-> TYPE TYPE (U TYPE False)))
(define (funapp fun arg)
(define dom (domain fun))
(cond
[(or (not dom) (not (subtype? arg dom))) #false]
[else
(let loop : TYPE
([bdd (TYPE-arrows fun)]
[P : (Listof ATOM) '()])
(match bdd
[(== bot eq?) Empty-TYPE]
[(== top eq?) (funapp-helper arg Any-TYPE P)]
[(NODE: (and a (cons s1 _)) l m r)
(define tl
(cond
[(overlap? s1 arg) (loop l (cons a P))]
[else (loop l P)]))
(define tm (loop m P))
(define tr (loop r P))
(type-or tl (type-or tm tr))]))]))
(: funapp-helper (-> TYPE TYPE (Listof ATOM) TYPE))
(define (funapp-helper arg res P)
(match P
[(cons (cons s1 s2) P)
(define res1 (let ([res* (type-and res s2)])
(if (empty? res*)
Empty-TYPE
(funapp-helper arg res* P))))
(define res2 (let ([arg* (type-diff arg s1)])
(if (empty? arg*)
Empty-TYPE
(funapp-helper arg* res P))))
(type-or res1 res2)]
[_ res]))
| false |
96f045c72f28a2adfb689a51a6937bbc987c8e10 | 8ad263e7b4368801cda4d28abb38c4f622e7019a | /compile-context.rkt | fadc1cc4b0a0be830a219987c91685d58ae005df | []
| no_license | LeifAndersen/expander | d563f93a983523dfa11bf4d7521ad4b5ab5cc7a6 | eec8a6d973624adc7390272fa3c29a082e45e0f8 | refs/heads/master | 2020-02-26T17:28:17.399606 | 2016-06-09T15:20:27 | 2016-06-09T15:20:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,537 | rkt | compile-context.rkt | #lang racket/base
(require "namespace.rkt")
(provide (struct-out compile-context)
make-compile-context)
(struct compile-context (namespace ; compile-time namespace
phase ; phase (top level) or phase level (within a module)
self ; if non-#f module path index, compiling the body of a module
module-self ; if non-#f, same as `self` and compiling the body of a module
root-module-name ; set to a symbol if `self` is non-#f
lazy-syntax-literals? ; #t (for modules) => deserialize and shift syntax on demand
header)) ; accumulates initialization and other parts shared among expressions
(define (make-compile-context #:namespace [namespace (current-namespace)]
#:phase [phase (namespace-phase namespace)]
#:self [self (namespace-mpi namespace)]
#:module-self [module-self #f]
#:root-module-name [root-module-name #f]
#:lazy-syntax-literals? [lazy-syntax-literals? (and module-self #t)])
(when (and module-self (not root-module-name))
(error "internal error: module-self provided without root"))
(compile-context namespace
phase
self
module-self
root-module-name
lazy-syntax-literals?
#f))
| false |
2097f603b6bc3d2bc7cd8e1c12991c54b32a1c3c | cfdfa191f40601547140a63c31e933b16323cf84 | /racket/monadic-eval/units/ev-symbolic-unit.rkt | 458e5753e40ed5f53cfa688eef354e9b47b86a08 | []
| no_license | philnguyen/monadic-eval | 6e3415512195d680551ce9203133281790feb7ef | ca1142fd932b17fee7d8e791519eaa8f11d9a9ef | refs/heads/master | 2020-05-29T11:43:21.777045 | 2016-03-02T22:35:01 | 2016-03-02T22:35:01 | 53,002,423 | 0 | 0 | null | 2016-03-02T22:49:33 | 2016-03-02T22:49:32 | null | UTF-8 | Racket | false | false | 1,483 | rkt | ev-symbolic-unit.rkt | #lang racket/unit
(require racket/match
"../signatures.rkt"
"../syntax.rkt")
(import monad^ δ^ symbolic^ sto^ env^ err^ ref^)
(export ev^)
(define ((ev e r) rec)
(match e
['err (err)]
[(vbl x) (get r x)]
[(sym s) (return s)]
[(num n) (return n)]
[(ifz e0 e1 e2)
(do v ← (rec e0 r)
#;
(do b ← (is-zero? v)
(if b
(rec e1 r)
(rec e2 r)))
(match v
[0 (rec e1 r)]
[(? number?) (rec e2 r)]
[(? symbolic?)
(both (rec e1 r)
(rec e2 r))]))]
[(op1 o e0)
(do v ← (rec e0 r)
(δ o v))]
[(op2 o e0 e1)
(do v0 ← (rec e0 r)
v1 ← (rec e1 r)
(δ o v0 v1))]
[(ref e)
(do v ← (rec e r)
(new v))]
[(drf e)
(do a ← (rec e r)
(ubox a))]
[(srf e0 e1)
(do a ← (rec e0 r)
v ← (rec e1 r)
(sbox a v))]
[(lam x e)
(return (cons (lam x e) r))]
[(lrc f (lam x e0) e)
(do a ← (ralloc f (lam x e0) r)
(rec e (ext r f a)))]
[(app e0 e1)
(do v0 ← (rec e0 r)
v1 ← (rec e1 r)
(match v0
[(cons (lam x e) r0)
(do a ← (alloc (cons (lam x e) r0) v1)
(rec e (ext r0 x a)))]
[(? symbolic?)
(symbolic-apply v0 v1)]))]))
(define-syntax do
(syntax-rules (←)
[(do b) b]
[(do x ← e . r)
(bind e (λ (x) (do . r)))]))
| true |
2e766af34d6e29c87d28b15b16300d6f717ce6e8 | a6a93e4a4485f1730a8080a71046d14728d07cd2 | /helper.rkt | ffe23e96b89d2b9ae090ac2ec063c9de2d01c0c6 | []
| no_license | KasoLu/KScheme | 47406e0fc3c8671882002965b73f6cd047a67dd2 | 2b17caeee710a5ad2c3da32be65489a758afe1a8 | refs/heads/master | 2020-06-03T13:34:21.246795 | 2019-07-24T13:12:55 | 2019-07-24T13:12:55 | 191,588,144 | 1 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 7,837 | rkt | helper.rkt | #lang racket
(provide (all-defined-out))
; ----- syntax pred ----- ;
(define int?
(lambda (i)
(or (int32? i) (int64? i))))
(define int32?
(lambda (x)
(and (and (integer? x) (exact? x))
(<= (- (expt 2 31)) x (- (expt 2 31) 1)))))
(define int64?
(lambda (x)
(and (and (integer? x) (exact? x))
(<= (- (expt 2 63)) x (- (expt 2 63) 1)))))
(define int32~64?
(lambda (x)
(and (int? x) (not (int32? x)))))
(define reg?
(lambda (x)
(set-member? (reg-set) x)))
(define loc?
(lambda (x)
(or (reg? x) (fvar? x))))
(define var?
(lambda (x)
(or (uvar? x) (loc? x))))
(define triv?
(lambda (x)
(or (var? x) (int? x) (label? x))))
(define binop?
(lambda (op)
(memq op '(+ - * logand logor sra))))
(define relop?
(lambda (op)
(memq op '(= > < >= <=))))
(define label?
(lambda (x)
(any->bool (label-match x))))
(define fvar?
(lambda (x)
(or (any->bool (fvar-match x)) (disp-opnd? x))))
(define uvar?
(lambda (x)
(any->bool (uvar-match x))))
(struct disp-opnd (reg offset) #:prefab)
(define reg-set
(let ([reg-set '(rax rbx rcx rdx rbp rsi rdi r8 r9 r10 r11 r12 r13 r14 r15)])
(lambda () reg-set)))
; ----- helper ----- ;
(define label-match
(lambda (x)
(rx-match #rx"^.+?\\$(0|[1-9][0-9]*)$" x)))
(define fvar-match
(lambda (x)
(rx-match #rx"^fv(0|[1-9][0-9]*)$" x)))
(define uvar-match
(lambda (x)
(rx-match #rx"^.+?\\.(0|[1-9][0-9]*)$" x)))
(define label->index
(lambda (x)
(x->index label-match x)))
(define fvar->index
(lambda (x)
(x->index fvar-match x)))
(define uvar->index
(lambda (x)
(x->index uvar-match x)))
; ----- func ----- ;
(define test
(lambda (pass #:trace [trace #f] . cases)
(for-each
(lambda (c)
(printf "~a~n" (pretty-format c))
(if trace
(printf "~a~n" (pretty-format (pass c)))
(with-handlers ([exn:fail? (lambda (exn) (displayln (exn-message exn)))])
(printf "~a~n" (pretty-format (pass c)))))
(printf "~n"))
(begin cases))))
(define driver
(let ([build-file "build.s"])
(lambda (debug-passes build-passes #:trace [trace #f] inputs)
(define (run input)
(printf "~a~n" (evalify ((apply pipe debug-passes) input)))
(with-output-to-file build-file #:exists 'replace
(lambda () ((apply pipe build-passes) input)))
(system (format "cc runtime.c ~a && ./a.out" build-file)))
(for-each
(lambda (input)
(printf "~a~n" input)
(if trace
(run input)
(with-handlers ([exn:fail? (lambda (exn) (displayln (exn-message exn)))])
(run input)))
(printf "~n"))
(begin inputs)))))
(define evalify
(lambda (program)
(let ([ns (module->namespace 'racket)])
(for-each
(lambda (expr) (eval expr ns))
`((define rax (box 0)) (define rbx (box 0)) (define rcx (box 0)) (define rdx (box 0))
(define rsi (box 0)) (define rdi (box 0)) (define rbp (box 0)) (define rsp (box 0))
(define r8 (box 0)) (define r9 (box 0)) (define r10 (box 0)) (define r11 (box 0))
(define r12 (box 0)) (define r13 (box 0)) (define r14 (box 0))
(define r15 (box (lambda () (unbox rax))))
(define stack (list->vector (map (lambda (x) (box 0)) (range 25))))
(define-syntax locate (syntax-rules () [(_ bind* body ...) (let bind* body ...)]))
(define (nop) (void)) (define (true) #t) (define (false) #t)
(define (sra x n) (arithmetic-shift x (- n)))
(define (logand x y) (bitwise-and x y))
(define (logor x y) (bitwise-ior x y))
(define (int64-truncate x)
(if (= 1 (bitwise-bit-field x 63 64))
(- (bitwise-bit-field (bitwise-not (sub1 x)) 0 64))
(bitwise-bit-field x 0 64)))))
(eval program ns))))
; ----- struct ----- ;
(define hash-env:make
(lambda ()
(cons (make-hash) '())))
(define hash-env:search
(lambda (env var)
(let loop ([env env])
(match env
[(? null?)
(begin #f)]
[(cons table prev)
(hash-ref table var (lambda () (loop prev)))]))))
(define hash-env:extend
(lambda (env [pairs '()])
(cons (make-hash pairs) env)))
(define hash-env:modify!
(lambda (env var val)
(match env
[(? null?)
(begin #f)]
[(cons table prev)
(hash-set! table var val)])))
(define list-env:make
(lambda () '()))
(define list-env:search
(lambda (env var)
(let loop ([env env])
(match env
[(? null?)
(begin #f)]
[(cons (cons e-var (box b-val)) prev)
(if (equal? var e-var)
(begin b-val)
(loop prev))]))))
(define list-env:extend
(lambda (env [pairs '()])
(let loop ([pairs pairs])
(match pairs
[(? null?)
(begin env)]
[(cons (cons var val) prev)
(cons (cons var (box val)) (loop prev))]))))
(define list-env:modify!
(lambda (env var val)
(let loop ([env env])
(match env
[(? null?)
(begin #f)]
[(cons (cons e-var e-val) prev)
(if (equal? var e-var)
(set-box! e-val val)
(loop prev))]))))
(define list-env:map
(lambda (env #:reverse [rev #f] func)
(let loop ([env env] [res* '()])
(match env
[(? null?)
(if (not rev)
(reverse res*)
(begin res*))]
[(cons (cons e-var (box e-val)) prev)
(loop prev (cons (func e-var e-val) res*))]))))
(define list-env:fold
(lambda (env func)
(let loop ([env env] [res* '()])
(match env
[(? null?)
(begin res*)]
[(cons (cons e-var (box e-val)) prev)
(loop prev (func e-var e-val res*))]))))
; ----- utils ----- ;
(define pipe
(lambda fs
(lambda (arg)
(foldl (lambda (f a) (f a)) arg fs))))
(define any->bool
(lambda (x)
(if (not x) #f #t)))
(define rx-match
(lambda (rx x)
(cond
[(symbol? x)
(regexp-match rx (symbol->string x))]
[else
(begin #f)])))
(define x->index
(lambda (x-m x)
(match (x-m x)
[`(,_ ,idx)
(string->number idx)]
[else
(begin #f)])))
(define sra
(lambda (x n) (arithmetic-shift x (- n))))
(define all?
(lambda ps
(lambda (x)
(if (null? ps)
(begin #t)
(and ((car ps) x) ((apply all? (cdr ps)) x))))))
(define any?
(lambda ps
(lambda (x)
(if (null? ps)
(begin #f)
(or ((car ps) x) ((apply any? (cdr ps)) x))))))
(define symbol-format
(lambda (fmt . vals)
(string->symbol (apply format fmt vals))))
(define-syntax-rule
(hook ([prev prev-lmd] [post post-lmd]) expr ...)
(begin
(prev-lmd)
(let ([res (begin expr ...)])
(post-lmd)
(begin res))))
(define-syntax (bundle stx)
(define concat
(lambda (tag name*)
(map
(lambda (name)
(datum->syntax
(begin tag)
(string->symbol
(string-append
(symbol->string (syntax-e tag)) ":" (symbol->string (syntax-e name))))
(begin tag)))
(syntax-e name*))))
(define make-define
(lambda (name* args* expr*)
(map
(lambda (name args expr) #`(define #,name (lambda #,args #,@expr)))
(begin name*)
(syntax-e args*)
(syntax-e expr*))))
(syntax-case stx ()
[(_ name bind* ([func* args* expr* ...] ...))
(identifier? #'name)
(let*
([bind-val* #'bind*]
[name-func* (concat #'name #'(func* ...))]
[func-def* (make-define name-func* #'(args* ...) #'((expr* ...) ...))])
#`(define-values
(#,@name-func*)
(let #,bind-val*
#,@func-def*
(values #,@name-func*))))]))
| true |
6e6d4befbd6753c7cfc86bafbad6843a84beeda7 | 1da0749eadcf5a39e1890195f96903d1ceb7f0ec | /a-d6/a-d/examples/memoization.rkt | caddc8ab64c75645159dfec26b8b030558d697bc | []
| no_license | sebobrien/ALGO1 | 8ce02fb88b6db9e001d936356205a629b49b884d | 50df6423fe45b99db9794ef13920cf03d532d69f | refs/heads/master | 2020-04-08T20:08:16.986517 | 2018-12-03T06:48:07 | 2018-12-03T06:48:07 | 159,685,194 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,180 | rkt | memoization.rkt | #lang r6rs
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;-*-* *-*-
;-*-* Memoization *-*-
;-*-* *-*-
;-*-* Wolfgang De Meuter *-*-
;-*-* 2009 Programming Technology Lab *-*-
;-*-* Vrije Universiteit Brussel *-*-
;-*-* *-*-
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
(import (rnrs base))
(define (fib n)
(define fib-tab (make-vector (+ n 1) #f))
(define (fib-rec n)
(if (not (vector-ref fib-tab n))
(vector-set! fib-tab n (+ (fib-rec (- n 1))
(fib-rec (- n 2)))))
(vector-ref fib-tab n))
(vector-set! fib-tab 0 1)
(vector-set! fib-tab 1 1)
(fib-rec n)) | false |
61bb9056fe51decab579085a372f3e26de5bd421 | aac00fa20ca35abc9557b5ec16b021c8c333992a | /expressive/tcpheader-text.rkt | 5f649e067a9d4491af166d926598f7e210d300fc | []
| no_license | spdegabrielle/artifact2020 | c80ddced4c6be4bbe159c5ac42539b20f79e82c6 | 1863e9b58a09232bc85ba9fb6b1832c974559ad9 | refs/heads/master | 2022-12-03T12:48:55.930122 | 2020-08-09T05:21:25 | 2020-08-19T03:06:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,019 | rkt | tcpheader-text.rkt | #lang racket/base
(require bitsyntax)
(define (parse-header bs)
(bit-string-case
bs
([(source-port :: binary bits 16)
(destination-port :: binary bits 16)
(sequence-number :: binary bits 32)
(acknowledgement-number :: binary bits 32)
(data-offset :: binary bits 4)
(reserved :: binary bits 6)
(urg :: binary bits 1)
(ack :: binary bits 1)
(psh :: binary bits 1)
(rst :: binary bits 1)
(syn :: binary bits 1)
(fin :: binary bits 1)
(window :: binary bits 16)
(checksum :: binary bits 16)
(urgent-pointer :: binary bits 16)
(rest :: binary)]
checksum)))
(define pattern
(bytes-append
#"\x00\x00\x03\x04\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00"
#"\x45\x00\x00\x37\x21\x2d\x40\x00\x40\x06\x1b\x92\x7f\x00\x00\x01"
#"\x7f\x00\x00\x01\xbf\x3e\x23\x82\xc6\xfe\xe6\xeb\xbe\xb9\x01\x07"
#"\x80\x18\x02\x00\xfe\x2b\x00\x00\x01\x01\x08\x0a\x10\xde\xd5\xe7"
#"\x10\xde\xd5\xe7\x48\x69\x0a"))
(parse-header pattern)
| false |
bf228c107452013ecbe4f4df2c9ce0b24fc02404 | 8ad263e7b4368801cda4d28abb38c4f622e7019a | /eval.rkt | 7e75fde7cb2d5622de6cf8f0cbb90f03433850c6 | []
| no_license | LeifAndersen/expander | d563f93a983523dfa11bf4d7521ad4b5ab5cc7a6 | eec8a6d973624adc7390272fa3c29a082e45e0f8 | refs/heads/master | 2020-02-26T17:28:17.399606 | 2016-06-09T15:20:27 | 2016-06-09T15:20:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 11,543 | rkt | eval.rkt | #lang racket/base
(require "module-binding.rkt"
"checked-syntax.rkt"
"namespace.rkt"
"core.rkt"
"phase.rkt"
"match.rkt"
"expand-context.rkt"
(rename-in "expand.rkt" [expand expand-in-context])
"compile.rkt"
"compiled-in-memory.rkt"
"eval-compiled-top.rkt"
"eval-compiled-module.rkt"
"module-path.rkt"
"linklet.rkt"
"bulk-binding.rkt"
"contract.rkt"
"namespace-eval.rkt"
"lift-context.rkt")
(provide eval
compile
expand
compiled-module-expression?
dynamic-require)
;; This `eval` is suitable as an eval handler that will be called by
;; the `eval` and `eval-syntax` of '#%kernel
(define (eval s [ns (current-namespace)] [compile compile])
(parameterize ([current-bulk-binding-fallback-registry
(namespace-bulk-binding-registry ns)])
(cond
[(or (compiled-in-memory? s)
(linklet-directory? s))
(eval-compiled s ns)]
[(and (syntax? s)
(or (compiled-in-memory? (syntax-e s))
(linklet-directory? (syntax-e s))))
(eval-compiled (syntax->datum s) ns)]
[else
(per-top-level s ns
#:single (lambda (s ns)
(eval-compiled (compile s ns) ns)))])))
(define (eval-compiled c ns)
(cond
[(compiled-module-expression? c)
(eval-module c #:namespace ns)]
[else
(eval-top c ns eval-compiled)]))
(define (compiled-module-expression? c)
(define ld (if (compiled-in-memory? c)
(compiled-in-memory-linklet-directory c)
c))
(and (linklet-directory? ld)
(hash-ref (linklet-directory->hash ld) #".decl" #f)))
;; This `compile` is suitable as a compile handler that will be called
;; by the `compile` and `compile-syntax` of '#%kernel
(define (compile s [ns (current-namespace)] [expand expand]
#:serializable? [serializable? #f])
(define cs
(parameterize ([current-bulk-binding-fallback-registry
(namespace-bulk-binding-registry ns)])
(per-top-level s ns
#:single (lambda (s ns) (list (compile-single s ns expand
serializable?)))
#:combine append)))
(if (= 1 (length cs))
(car cs)
(compiled-tops->compiled-top cs)))
(define (compile-single s ns expand serializable?)
(define exp-s (expand s ns))
(case (core-form-sym exp-s (namespace-phase ns))
[(module)
(compile-module exp-s (make-compile-context #:namespace ns))]
[(begin)
;; expansion must have captured lifts
(define m (match-syntax exp-s '(begin e ...)))
(compiled-tops->compiled-top
(for/list ([e (in-list (m 'e))])
(compile-top e (make-compile-context #:namespace ns)
#:serializable? serializable?)))]
[else
(compile-top exp-s (make-compile-context #:namespace ns)
#:serializable? serializable?)]))
;; This `expand` is suitable as an expand handler (if such a thing
;; existed) to be called by `expand` and `expand-syntax`.
(define (expand s [ns (current-namespace)])
(parameterize ([current-bulk-binding-fallback-registry
(namespace-bulk-binding-registry ns)])
(per-top-level s ns
#:single expand-single
#:combine cons
#:wrap (lambda (form-id s r)
(datum->syntax s
(cons form-id r)
s
s)))))
(define (expand-single s ns)
;; Ideally, this would be just
;; (expand-in-context s (make-expand-context ns))
;; but we have to handle lifted definitions
(define ctx (make-expand-context ns))
(define lift-ctx (make-lift-context (make-toplevel-lift ctx)))
(define exp-s
(expand-in-context s (struct-copy expand-context ctx
[lifts lift-ctx])))
(define lifts (get-and-clear-lifts! lift-ctx))
(cond
[(null? lifts) exp-s]
[else
(wrap-lifts-as-begin lifts exp-s s (namespace-phase ns)
#:adjust-defn
(lambda (defn)
(expand-single defn ns)))]))
;; Add scopes to `s` if it's not syntax:
(define (maybe-intro s ns)
(if (syntax? s)
s
(namespace-syntax-introduce (datum->syntax #f s) ns)))
;; Top-level compilation and evaluation, which involves partial
;; expansion to detect `begin` and `begin-for-syntax` to interleave
;; expansions
(define (per-top-level given-s ns
#:single single
#:combine [combine #f]
#:wrap [wrap #f])
(define s (maybe-intro given-s ns))
(define ctx (make-expand-context ns))
(define phase (namespace-phase ns))
(let loop ([s s] [phase phase] [ns ns])
(define tl-ctx (struct-copy expand-context ctx
[phase phase]
[namespace ns]))
(define lift-ctx (make-lift-context (make-toplevel-lift tl-ctx)))
(define exp-s
(expand-in-context s (struct-copy expand-context tl-ctx
[only-immediate? #t]
[phase phase]
[namespace ns]
[lifts lift-ctx])))
(define lifts (get-and-clear-lifts! lift-ctx))
(cond
[(null? lifts)
(case (core-form-sym exp-s phase)
[(begin)
(define m (match-syntax exp-s '(begin e ...)))
;; Map `loop` over the `e`s, but in the case of `eval`,
;; tail-call for last one:
(define (begin-loop es)
(cond
[(null? es) (if combine null (void))]
[(and (not combine) (null? (cdr es)))
(loop (car es) phase ns)]
[else
(define a (loop (car es) phase ns))
(if combine
(combine a (begin-loop (cdr es)))
(begin-loop (cdr es)))]))
(if wrap
(wrap (m 'begin) exp-s (begin-loop (m 'e)))
(begin-loop (m 'e)))]
[(begin-for-syntax)
(define m (match-syntax exp-s '(begin-for-syntax e ...)))
(define next-phase (add1 phase))
(define next-ns (namespace->namespace-at-phase ns next-phase))
(define l
(for/list ([s (in-list (m 'e))])
(loop s next-phase next-ns)))
(cond
[wrap (wrap (m 'begin-for-syntax) exp-s l)]
[combine l]
[else (void)])]
[else
(single exp-s ns)])]
[else
;; Fold in lifted definitions and try again
(define new-s (wrap-lifts-as-begin lifts exp-s s phase))
(loop new-s phase ns)])))
;; ----------------------------------------
(define (dynamic-require mod-path sym [fail-k default-fail-thunk])
(unless (or (module-path? mod-path)
(module-path-index? mod-path)
(resolved-module-path? mod-path))
(raise-argument-error 'dynamic-require
"(or/c module-path? module-path-index? resolved-module-path?)"
mod-path))
(unless (or (symbol? sym)
(not sym)
(equal? sym 0)
(void? sym))
(raise-argument-error 'dynamic-require "(or/c symbol? #f 0 void?)" sym))
(unless (and (procedure? fail-k) (procedure-arity-includes? fail-k 0))
(raise-argument-error 'dynamic-require "(-> any)" fail-k))
(define ns (current-namespace))
(define mpi
(cond
[(module-path? mod-path) (module-path-index-join mod-path #f)]
[(module-path-index? mod-path) mod-path]
[else
(define name (resolved-module-path-name mod-path))
(define root-name (if (pair? name) (car name) name))
(define root-mod-path (if (path? root-name)
root-name
`(quote ,root-name)))
(define new-mod-path (if (pair? name)
root-mod-path
`(submod ,root-mod-path ,@(cdr name))))
(module-path-index-join new-mod-path #f)]))
(define mod-name (module-path-index-resolve mpi #t))
(define phase (namespace-phase ns))
(cond
[(or (not sym)
(equal? sym 0)) ;; FIXME: 0 is different when we distinguish availability
(namespace-module-instantiate! ns mpi phase)]
[(void? sym)
(namespace-module-visit! ns mpi phase)]
[else
(namespace-module-instantiate! ns mpi phase)
(define m (namespace->module ns mod-name))
(define binding (hash-ref (hash-ref (module-provides m) 0 #hasheq())
sym
#f))
(cond
[(not binding) (if (eq? fail-k default-fail-thunk)
(raise-arguments-error 'dynamic-require
"name is not provided"
"name" sym
"module" mod-name)
(fail-k))]
[else
(define ex-sym (module-binding-sym binding))
(define ex-phase (module-binding-phase binding))
(define m-ns (namespace->module-namespace ns
(module-path-index-resolve
(module-path-index-shift
(module-binding-module binding)
(module-self m)
mpi))
(phase- phase ex-phase)
#:complain-on-failure? #t))
(namespace-get-variable m-ns ex-phase ex-sym
(lambda ()
;; Maybe syntax?
(define missing (gensym 'missing))
(define t (namespace-get-transformer m-ns ex-phase ex-sym missing))
(cond
[(eq? t missing)
(if (eq? fail-k default-fail-thunk)
(raise-arguments-error 'dynamic-require
"name is not provided"
"name" sym
"module" mod-name)
(fail-k))]
[else
;; expand in a fresh namespace
(define tmp-ns (make-empty-namespace ns))
(define name (resolved-module-path-name mod-name))
(define mod-path (if (path? name)
name
`(quote ,name)))
(namespace-require mod-path tmp-ns)
(eval sym tmp-ns)])))])]))
;; The `dynamic-require` function checks by recognizing this failure
;; thunk and substituting a more specific error:
(define (default-fail-thunk)
(error "failed"))
| false |
0378205a05c156358dc00fc484929d5ed370b45a | f2e65ac33a71e4e1315107f3bdc9eb2389c84871 | /exp/idx.rkt | cc6a1b8a7dbf0df6c8f938e471f2718dc64e8a0b | []
| no_license | daviesaz/get-bonus | ac217ade9879dbcd9aca1adc5fcfa7f102864dbe | ea77c5b2914316343eabd86265aee0433d0e7b03 | refs/heads/master | 2020-05-20T19:27:59.194962 | 2014-09-25T01:51:29 | 2014-09-25T01:51:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 478 | rkt | idx.rkt | #lang racket/base
(require racket/file
gb/lib/gzip)
(module+ main
(define bs (gunzip-bytes (file->bytes "../r.idx.bin.gz")))
(define k 4)
(printf "~a\n" (/ (bytes-length bs) k))
(for ([i (in-range (/ (bytes-length bs) k))])
(define s (* k i))
(when (zero? (modulo i 4))
(newline)
(printf "~a: " (/ i 4)))
(printf "~a " (floating-point-bytes->real bs (system-big-endian?)
s (+ s k)))
))
| false |
5dfc362560bb24c046c3bdda946e081040a340d5 | 6c5f684b2e0f0b01cfb1f457331e0fe91c653254 | /lisp/train/lister.rkt | a911666a3b30f54aa784dc893b8cdbe38dde4b71 | []
| no_license | ldcc/learn | dbb485c7e9e9d49fd0d7ab1e8465bbd954eade0a | b321e3b348a574f4a9f5fd44c0433656f70c68ba | refs/heads/master | 2022-08-11T03:10:28.821663 | 2022-07-19T08:32:55 | 2022-07-19T08:32:55 | 121,287,472 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 1,046 | rkt | lister.rkt | #lang racket
;; ----- base operate -----
(define atom?
(lambda (v)
(and (not (null? v))
(not (pair? v)))))
(define map
(lambda (f l)
(cond
[(null? l) l]
[else
(cons (f (car l))
(map f (cdr l)))])))
(define pattern
(lambda (exp)
(match exp
['+ +]
['- -]
['* *]
['/ /]
['simplify simplify]
[(? pair?) (simplify exp)]
[else exp])))
;; ----- simplify -----
(define simplify
(lambda (exp)
(caling (car exp) (cdr exp))))
(define caling
(lambda (op exp)
(match exp
[`(,e1 ,e2)
(let ([v1 (fs op e1)]
[v2 (fs op e2)])
((pattern op) v1 v2))]
[`(,e1 . ,e2)
(let ([v1 (fs op e1)]
[v2 (fs op e2)])
((pattern op) v1 v2))])))
(define fs
(lambda (op e)
(cond
[(null? e) 0]
[(atom? e) e]
[(symbol? (car e))
(simplify e)]
[else
(caling op e)])))
;; ----- make list -----
(define clist
(lambda (exp)
(map simplify exp)))
| false |
eed28d0b337221683e9370c5a176cda2e8df8363 | e7cbef1aa2dd9ab4cb6f46233a21a29917110a34 | /compiler.rkt | bb1d32dbc4e8cb2e59aa4324485e9f3f3a1ef200 | []
| no_license | pbpf/expr | c965eee8db3baf9f73ae8409e1698ab1e6b4089a | fa8266d311df18010da4e56648e06a9fe53c6b0b | refs/heads/master | 2020-03-20T16:57:31.639985 | 2018-02-09T01:28:56 | 2018-02-09T01:28:56 | 137,549,485 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 2,998 | rkt | compiler.rkt | #lang racket/base
(require "grammar/ast.rkt"
"grammar/yacc.rkt"
math/array
racket/match
)
(define compile-statement
(match-lambda
[(definition name value)
#`(define #,name #, (compile-expr value))]
[(func-definition name lst value)
#`(define(#,name #,@lst)#,@(compile-expr-for-define-func value))]
[(box-definition name value)
#`(define #,(compile-expr name) (box #,(compile-expr value)))]
[(assign id value)
#`(set! #,id #,(compile-expr value))]
[(box-assign id value)
#`(set-box! #,id #,(compile-expr value))]
[(when-statement test block)
#`(when #,(compile-expr test)
#,@(map compile-statement block))]
;optcall do not support
; [(func-definition name formlist value)
; #`(define (#,name #,@formlist ) #,(compile-statement value))]
; [(pair-expr car cdr)
; #`(#,(compile-statement cdr) #,(compile-statement car))]
; [(pair-exprlist lst else1)
; #`(cond
; #,@(map compile-statement lst)
; [else #,(compile-statement else1)])]
[else #f];do not soport
))
(define (compile-expr-for-define-func x)
(match x
[(block-expr block value)
#`(#,@(map compile-statement block) #,(compile-expr value))]
[else (compile-expr x)]))
(define compile-expr
(match-lambda
[(constant value)
value]
[(variable sym)
(define srcstx (datum->syntax #f 'this-scope))
(datum->syntax #f sym srcstx)]
[(operation sym lst)
#`(#,sym #,@(map compile-expr lst))]
[(call expr lst)
#`(#,(compile-expr expr) #,@(map compile-expr lst))]
[(sub-extract expr lst)
#`(list-ref #,expr #,(car lst))]
[(seq f s e)
#`(let([fr #,(compile-expr f)])
(:: fr #,(compile-expr e) (- #,(compile-expr s) fr)))]
[(array-expr lst)
#`(list->array #,(map compile-expr lst))]
[(unbox-expr value)
#`(unbox #,(compile-expr value))]
[(block-expr block value)
#`(begin #,@(map compile-statement block) #,(compile-expr value))]
[(binding-block-expr bindings block value)
;(displayln bindings)
(define(compiler-binding binding)
; (displayln binding)
#`(#,(car binding)#,(compile-expr (cdr binding))))
#`(let #,(map compiler-binding bindings)
#,@(map compile-statement block)
#,(compile-expr value))]
[(if-expr test avalue bvalue)
#`(if #,(compile-expr test) #,(compile-expr avalue) #,(compile-expr bvalue))]
[(hash-expr name index else)
#`(hash-ref #,(compile-expr name) #,(compile-expr index) (lambda()#,(compile-expr else)))]
[else #f]))
(define(compile-program lst)
(map compile-statement lst))
(define(expr-expander x)
(compile-expr(parse-expr (open-input-string x))))
(provide expr-expander)
(module+ test
(expr-expander "(x->1,y->2)=>x+y"))
;(syntax-debug-info #'expr-expander)
;(compile-expr(parse-expr (open-input-string "{a=a+1;cond x>0:{&z=2;} x>1: {z=2;} else {z=1;}}=>x+a+z"))) | false |
93c93820b48e3e75c1b0bd6db404b808628de2af | 592ccef7c8ad9503717b2a6dff714ca233bc7317 | /docs-src/guide-abstract.scrbl | 3a4ff620c4f751f2f549c972c128b487e9172545 | [
"Apache-2.0"
]
| permissive | Thegaram/reach-lang | 8d68183b02bfdc4af3026139dee25c0a3e856662 | 4fdc83d9b9cfce4002fa47d58d2bcf497783f0ee | refs/heads/master | 2023-02-25T00:10:31.744099 | 2021-01-26T22:41:38 | 2021-01-26T22:41:38 | 333,350,309 | 1 | 0 | Apache-2.0 | 2021-01-27T08:17:28 | 2021-01-27T08:17:27 | null | UTF-8 | Racket | false | false | 1,190 | scrbl | guide-abstract.scrbl | #lang scribble/manual
@(require "lib.rkt")
@title[#:version reach-vers #:tag "guide-abstract"]{Building decentralized abstractions}
Many decentralized applications have the same structure, similar to how there are many games that can be categorized as @link["https://en.wikipedia.org/wiki/Combinatorial_game_theory"]{combinatorial games} or @link["https://en.wikipedia.org/wiki/Simultaneous_game"]{simultaneous games}.
These applications can either be programmed individually, or you can build an abstraction that captures the common structure of a game.
Reach supports typical programming language abstractions, like first-class functions (via @tech{arrow expressions}) and objects, that can be used to build these abstractions.
When building such abstractions, the most difficult part is correctly capturing @seclink["guide-loop-invs"]{loop invariants} of the user of the abstraction on the inside of the abstraction.
Often, this means the abstraction must set up a protocol to communicate with its user, such as by receiving an invariant captured by an @tech{arrow expression}.
@margin-note{See @secref["workshop-abstract-simul"] for a walthrough of building such an abstraction.}
| false |
64444f0b1bbd44f24d9a0f34d92d9e8ec1d52caa | 099418d7d7ca2211dfbecd0b879d84c703d1b964 | /whalesong/lang/private/with-handlers.rkt | 105f314ec30c0705fde90bff70bd6f1b1034d247 | []
| no_license | vishesh/whalesong | f6edd848fc666993d68983618f9941dd298c1edd | 507dad908d1f15bf8fe25dd98c2b47445df9cac5 | refs/heads/master | 2021-01-12T21:36:54.312489 | 2015-08-19T19:28:25 | 2015-08-19T20:34:55 | 34,933,778 | 3 | 0 | null | 2015-05-02T03:04:54 | 2015-05-02T03:04:54 | null | UTF-8 | Racket | false | false | 2,368 | rkt | with-handlers.rkt | #lang s-exp "../kernel.rkt"
(require (for-syntax racket/base
syntax/parse))
(provide with-handlers)
;; We adapt much of this from Racket's standard implementation of
;; with-handlers in racket/private/more-scheme.
(define (check-with-handlers-in-context handler-prompt-key)
(unless (continuation-prompt-available? handler-prompt-key)
(error 'with-handlers
"exception handler used out of context")))
(define handler-prompt-key (make-continuation-prompt-tag))
(define (call-handled-body handle-proc body-thunk)
(call-with-continuation-prompt
(lambda (body-thunk)
;; Restore the captured break parameterization for
;; evaluating the `with-handlers' body. In this
;; special case, no check for breaks is needed,
;; because bpz is quickly restored past call/ec.
;; Thus, `with-handlers' can evaluate its body in
;; tail position.
(with-continuation-mark
exception-handler-key
(lambda (e)
;; Deliver the exception to the escape handler:
(abort-current-continuation
handler-prompt-key
e))
(body-thunk)))
handler-prompt-key
handle-proc
body-thunk))
(define (select-handler e l)
(let loop ([l l])
(cond
[(null? l)
(raise e)]
[((caar l) e)
((cdar l) e)]
[else
(loop (cdr l))])))
(define-syntax with-handlers
(lambda (stx)
(syntax-case stx ()
[(_ () expr1 expr ...) (syntax/loc stx (let () expr1 expr ...))]
[(_ ([pred handler] ...) expr1 expr ...)
(with-syntax ([(pred-name ...) (generate-temporaries (map (lambda (x) 'with-handlers-predicate)
(syntax->list #'(pred ...))))]
[(handler-name ...) (generate-temporaries (map (lambda (x) 'with-handlers-handler)
(syntax->list #'(handler ...))))])
(syntax-protect
(quasisyntax/loc stx
(let-values ([(pred-name) pred] ...
[(handler-name) handler] ...)
(call-handled-body
(lambda (e)
(select-handler e (list (cons pred-name handler-name) ...)))
(lambda ()
expr1 expr ...))))))])))
| true |
ebf68bceabe9fabaf22b379ea59fc0f969d125de | 954c700f0a37fdb80de0d414f2b367f67582c62d | /examples/lam_env3.rkt | 7ea42ab0d3e9a8fce62ac54f6ba6204684ce1ead | [
"MIT"
]
| permissive | GrantMatejka/rasm | 637cc14e08b884a2d10b6ba0d0b7d51cfe7b1429 | 301190d41165dd1c6726ebc73c4bfada1b6caaba | refs/heads/main | 2023-05-23T16:37:46.630710 | 2022-11-11T14:59:39 | 2022-11-11T14:59:39 | 446,220,939 | 20 | 3 | null | 2022-11-11T14:59:40 | 2022-01-09T22:49:17 | Racket | UTF-8 | Racket | false | false | 121 | rkt | lam_env3.rkt | (module add racket
(provide x)
(define f
(let ((y 5))
(lambda (x) (+ x y))))
(define x (f 2)))
| false |
2d6716fb0e7858699c520cc949fad90ff4dc2419 | 76df16d6c3760cb415f1294caee997cc4736e09b | /rosette-benchmarks-3/jitterbug/jitterbug/racket/stacklang/jit.rkt | 38245224337058bf09341d3270fb3a1211ec77c0 | [
"MIT"
]
| permissive | uw-unsat/leanette-popl22-artifact | 70409d9cbd8921d794d27b7992bf1d9a4087e9fe | 80fea2519e61b45a283fbf7903acdf6d5528dbe7 | refs/heads/master | 2023-04-15T21:00:49.670873 | 2021-11-16T04:37:11 | 2021-11-16T04:37:11 | 414,331,908 | 6 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 3,615 | rkt | jit.rkt | #lang rosette
; The JIT implementation largely follows the code in Section 4 ("Verified JIT
; compiler – version 1") of the paper "Verified Just-In-Time Compiler on x86"
; in POPL 2010:
;
; xenc t (pop) = [8B, 07, 83, C7, 04]
; xenc t (sub) = [2B, 07]
; xenc t (swap) = [87, 07]
; xenc t (stop) = [FF, E2]
; xenc t (push i) = [83, EF, 04, 89, 07, B8, w2w i, 00, 00, 00]
; xenc t (jump i) = [E9] ++ ximm (t(w2n i) − 5)
; xenc t (jeq i) = [3B, 07, 0F, 84] ++ ximm (t (w2n i) − 5)
; xenc t (jlt i) = [3B, 07, 0F, 82] ++ ximm (t (w2n i) − 5)
;
; However, there are two bugs in the above code from the paper: the offsets in
; last two lines (for jeq and jlt) should be 8, rather than 5.
;
; The corresponding Isabelle code is correct:
; https://www.cl.cam.ac.uk/~mom22/jit/
(require (prefix-in stacklang: "sema.rkt")
"../lib/extraction/c.rkt"
(prefix-in core: serval/lib/core))
(provide emit_insn
current-context
(struct-out context))
(define immof stacklang:@immof)
(define opcodeof stacklang:opcodeof)
(define inject_bugs stacklang:inject-bugs)
(define current-context (make-parameter #f))
(struct context (insns base-addr addrs) #:mutable #:transparent)
(define (emit_code ctx lst)
(define vec (list->vector lst))
(define size (bv (vector-length vec) 32))
(for/all ([i (context-insns ctx) #:exhaustive])
(set-context-insns! ctx (vector-append i vec))))
(define (EMIT v n)
(define lst
(cond
[(list? v) (map (lambda (x) (if (bv? x) (extract 7 0 x) (bv x 8))) v)]
[(bv? v) (core:bitvector->list/le v)]
[(integer? v) (core:bitvector->list/le (bv v (* n 8)))]
[else (core:bug (format "emit: ~a" v))]))
(emit_code (current-context) (take lst n)))
(define (EMIT1 b0)
(EMIT (list b0) 1))
(define (EMIT2 b0 b1)
(EMIT (list b0 b1) 2))
(define (EMIT3 b0 b1 b2)
(EMIT (list b0 b1 b2) 3))
(func (emit_insn idx insn addrs ctx)
(var [base (@ addrs idx)]
[opcode (opcodeof insn)])
(switch opcode
[(POP)
(comment "/* mov eax,[edi] */")
(EMIT2 (0x 8B) (0x 07))
(comment "/* add edi,4 */")
(EMIT3 (0x 83) (0x C7) (0x 04))]
[(SUB)
(comment "/* sub eax,[edi] */")
(EMIT2 (0x 2B) (0x 07))]
[(SWAP)
(comment "/* xchg [edi],eax */")
(EMIT2 (0x 87) (0x 07))]
[(PUSH)
(comment "/* sub edi,4 */")
(EMIT3 (0x 83) (0x EF) (0x 04))
(comment "/* mov [edi],eax */")
(EMIT2 (0x 89) (0x 07))
(comment "/* mov eax,imm32 */")
(EMIT1 (0x B8))
(EMIT (immof insn) 4)]
[(JUMP)
(comment "/* jmp off32 */")
(EMIT1 (0x E9))
(EMIT (bvsub (bvsub (@ addrs (immof insn)) base) (bv 5 32)) 4)]
[(JEQ)
(comment "/* cmp eax,[edi] */")
(EMIT2 (0x 3B) (0x 07))
(comment "/* je off32 */")
(EMIT2 (0x 0F) (0x 84))
(if (inject_bugs)
(EMIT (bvsub (bvsub (@ addrs (immof insn)) base) (bv 5 32)) 4)
(EMIT (bvsub (bvsub (@ addrs (immof insn)) base) (bv 8 32)) 4))]
[(JLT)
(comment "/* cmp eax,[edi] */")
(EMIT2 (0x 3B) (0x 07))
(comment "/* jb off32 */")
(EMIT2 (0x 0F) (0x 82))
(EMIT (bvsub (bvsub (@ addrs (immof insn)) base) (bv 8 32)) 4)]
[(STOP)
(comment "/* jmp edx */")
(EMIT2 (0x FF) (0x E2))]))
; types for C code
(begin-for-syntax
(emit-infer-type
(lambda (stx)
(define e (syntax-e stx))
(define op (syntax-e (car e)))
(cond
[(member op '(opcodeof))
"int"]
[(and (equal? op '@) (equal? (syntax-e (second e)) 'addrs))
"int"]))))
| false |
e9cf642505db8ff25b53f194aac496a558fd75da | 00d4882c98aadb8010fcee2688e32d795fcc514e | /marketing/research/data/stephens-database-util.rkt | 4349059a4347c286b626eb46938b7b3b80669476 | []
| no_license | thoughtstem/morugamu | dae77f19b9eecf156ffe501a6bfeef12f0c1749d | a9095ddebe364adffb036c3faed95c873a4d9f3c | refs/heads/master | 2020-03-22T04:09:18.238849 | 2018-08-20T18:55:55 | 2018-08-20T18:55:55 | 139,476,760 | 13 | 5 | null | 2018-08-02T22:29:48 | 2018-07-02T17:56:26 | Racket | UTF-8 | Racket | false | false | 95,666 | rkt | stephens-database-util.rkt | #reader(lib"read.ss""wxme")WXME0108 ##
#|
This file uses the GRacket editor format.
Open this file in DrRacket version 6.10.1 or later to read it.
Most likely, it was created by saving a program in DrRacket,
and it probably contains a program with non-text elements
(such as images or comment boxes).
http://racket-lang.org/
|#
33 7 #"wxtext\0"
3 1 6 #"wxtab\0"
1 1 8 #"wximage\0"
2 0 8 #"wxmedia\0"
4 1 34 #"(lib \"syntax-browser.ss\" \"mrlib\")\0"
1 0 36 #"(lib \"cache-image-snip.ss\" \"mrlib\")\0"
1 0 68
(
#"((lib \"image-core.ss\" \"mrlib\") (lib \"image-core-wxme.rkt\" \"mr"
#"lib\"))\0"
) 1 0 16 #"drscheme:number\0"
3 0 44 #"(lib \"number-snip.ss\" \"drscheme\" \"private\")\0"
1 0 36 #"(lib \"comment-snip.ss\" \"framework\")\0"
1 0 93
(
#"((lib \"collapsed-snipclass.ss\" \"framework\") (lib \"collapsed-sni"
#"pclass-wxme.ss\" \"framework\"))\0"
) 0 0 43 #"(lib \"collapsed-snipclass.ss\" \"framework\")\0"
0 0 19 #"drscheme:sexp-snip\0"
0 0 29 #"drscheme:bindings-snipclass%\0"
1 0 101
(
#"((lib \"ellipsis-snip.rkt\" \"drracket\" \"private\") (lib \"ellipsi"
#"s-snip-wxme.rkt\" \"drracket\" \"private\"))\0"
) 2 0 88
(
#"((lib \"pict-snip.rkt\" \"drracket\" \"private\") (lib \"pict-snip.r"
#"kt\" \"drracket\" \"private\"))\0"
) 0 0 55
#"((lib \"snip.rkt\" \"pict\") (lib \"snip-wxme.rkt\" \"pict\"))\0"
1 0 34 #"(lib \"bullet-snip.rkt\" \"browser\")\0"
0 0 25 #"(lib \"matrix.ss\" \"htdp\")\0"
1 0 22 #"drscheme:lambda-snip%\0"
1 0 29 #"drclickable-string-snipclass\0"
0 0 26 #"drracket:spacer-snipclass\0"
0 0 57
#"(lib \"hrule-snip.rkt\" \"macro-debugger\" \"syntax-browser\")\0"
1 0 26 #"drscheme:pict-value-snip%\0"
0 0 45 #"(lib \"image-snipr.ss\" \"slideshow\" \"private\")\0"
1 0 38 #"(lib \"pict-snipclass.ss\" \"slideshow\")\0"
2 0 55 #"(lib \"vertical-separator-snip.ss\" \"stepper\" \"private\")\0"
1 0 18 #"drscheme:xml-snip\0"
1 0 31 #"(lib \"xml-snipclass.ss\" \"xml\")\0"
1 0 21 #"drscheme:scheme-snip\0"
2 0 34 #"(lib \"scheme-snipclass.ss\" \"xml\")\0"
1 0 10 #"text-box%\0"
1 0 32 #"(lib \"text-snipclass.ss\" \"xml\")\0"
1 0 1 6 #"wxloc\0"
0 0 138 0 1 #"\0"
0 75 1 #"\0"
0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 9
#"Standard\0"
0 75 10 #"Monospace\0"
0 9 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 2 24
#"framework:default-color\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 150 0 150 0 0 0 -1 -1 2 15
#"text:ports out\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 150 0 150 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 255 0 0 0 0 0 -1
-1 2 15 #"text:ports err\0"
0 -1 1 #"\0"
1 0 -1 -1 93 -1 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 175 0 0 0 -1 -1 2 17
#"text:ports value\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 175 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1
-1 2 27 #"Matching Parenthesis Style\0"
0 -1 1 #"\0"
1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1
-1 2 1 #"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 38 38 128 0 0 0 -1 -1 2 37
#"framework:syntax-color:scheme:symbol\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 38 38 128 0 0 0 -1 -1 2 38
#"framework:syntax-color:scheme:keyword\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 38 38 128 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 194 116 31 0 0 0 -1 -1 2
38 #"framework:syntax-color:scheme:comment\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 194 116 31 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 37
#"framework:syntax-color:scheme:string\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 35
#"framework:syntax-color:scheme:text\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 39
#"framework:syntax-color:scheme:constant\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 49
#"framework:syntax-color:scheme:hash-colon-keyword\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 42
#"framework:syntax-color:scheme:parenthesis\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 36
#"framework:syntax-color:scheme:error\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 36
#"framework:syntax-color:scheme:other\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 16
#"Misspelled Text\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 81 112 203 0 0 0 -1 -1 2
38 #"drracket:check-syntax:lexically-bound\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 81 112 203 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 28
#"drracket:check-syntax:set!d\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 37
#"drracket:check-syntax:unused-require\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 36
#"drracket:check-syntax:free-variable\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 68 0 203 0 0 0 -1 -1 2 31
#"drracket:check-syntax:imported\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 68 0 203 0 0 0 -1 -1 2 47
#"drracket:check-syntax:my-obligation-style-pref\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 116 0 0 0 0 -1 -1 2 50
#"drracket:check-syntax:their-obligation-style-pref\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 116 0 0 0 0 -1 -1 2 48
#"drracket:check-syntax:unk-obligation-style-pref\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 139 142 28 0 0 0 -1 -1 2
49 #"drracket:check-syntax:both-obligation-style-pref\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 139 142 28 0 0 0 -1 -1 2
26 #"plt:htdp:test-coverage-on\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 1
#"\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 2 27
#"plt:htdp:test-coverage-off\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 4 1
#"\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 4 4 #"XML\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 2 37 #"plt:module-language:test-coverage-on\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 38
#"plt:module-language:test-coverage-off\0"
0 -1 1 #"\0"
1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 0 1
#"\0"
0 75 10 #"Monospace\0"
0.0 9 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255 255
255 1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 150 0 150 0
0 0 -1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 93 -1 -1 -1 0 1 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0
0 -1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 175 0 0
0 -1 -1 0 1 #"\0"
0 75 1 #"\0"
0.0 10 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 0 1 #"\0"
0 75 12 #"Courier New\0"
0.0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 0 1 #"\0"
0 75 12 #"Courier New\0"
0.0 11 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 194 116 31 0
0 0 -1 -1 2 41 #"profj:syntax-colors:scheme:block-comment\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 194 116 31 0
0 0 -1 -1 2 35 #"profj:syntax-colors:scheme:keyword\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 139 0 139 0
0 0 -1 -1 2 37 #"profj:syntax-colors:scheme:prim-type\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 139 0 139 0
0 0 -1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 38 38 128 0
0 0 -1 -1 2 38 #"profj:syntax-colors:scheme:identifier\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 38 38 128 0
0 0 -1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 34 139 34 0
0 0 -1 -1 2 34 #"profj:syntax-colors:scheme:string\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 34 139 34 0
0 0 -1 -1 2 35 #"profj:syntax-colors:scheme:literal\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 34 139 34 0
0 0 -1 -1 2 35 #"profj:syntax-colors:scheme:comment\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 194 116 31 0
0 0 -1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0
0 -1 -1 2 33 #"profj:syntax-colors:scheme:error\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0
0 -1 -1 2 35 #"profj:syntax-colors:scheme:default\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 2 37 #"profj:syntax-colors:scheme:uncovered\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 2 35 #"profj:syntax-colors:scheme:covered\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 139 0 139 0
0 0 -1 -1 0 1 #"\0"
0 75 6 #"Menlo\0"
0.0 22 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 4 1 #"\0"
0 71 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 255 0 0
0 -1 -1 4 1 #"\0"
0 71 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 255 0 0
0 -1 -1 4 1 #"\0"
0 71 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 100 0 0 0
0 -1 -1 2 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 200 0 0 0 0
0 -1 -1 0 1 #"\0"
0 75 12 #"Courier New\0"
0.0 13 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 0 1 #"\0"
0 75 12 #"Courier New\0"
0.0 16 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 0 1 #"\0"
0 75 12 #"Courier New\0"
0.0 10 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 4 1 #"\0"
0 71 1 #"\0"
1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0
0 -1 -1 2 1 #"\0"
0 70 1 #"\0"
1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 148 0 211 0
0 0 -1 -1 2 1 #"\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 255 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 0 -1 -1 0 1 #"\0"
0 75 10 #"Monospace\0"
0.0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 4 32 #"widget.rkt::browser-text% basic\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 4 59
#"macro-debugger/syntax-browser/properties color-text% basic\0"
0 70 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 90 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 190 190 190
0 0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 255 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 107 142 35 0
0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 100 0 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 139 0 0 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 100 149 237
0 0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 65 105 225 0
0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 70 130 180 0
0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 47 79 79 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 139 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 75 0 130 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 160 32 240 0
0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 165 0 0
0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 250 128 114
0 0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 184 134 11 0
0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 128 128 0 0
0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 169 169 169
0 0 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 0 0 0 0
-1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
228 225 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 224
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 255 0 0 224
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 255 224
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 107 142 35
224 255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 100 0 224
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 139 0 0 224
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 100 149 237
224 255 255 -1 -1 89 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 255 0 0 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 169 169 169
224 255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 255 0 0 255
228 225 -1 -1 90 1 #"\0"
0 -1 1 #"\0"
1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 255 0 0
0 -1 -1 90 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0.0 0.0 0.0 1.0 1.0 1.0 0 0 255 0 0
0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 90 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 255 0 0 255
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 90 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 90 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 255 0 0 224
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 90 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 224
255 255 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 92 -1 -1 -1 -1 -1 1 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 0 -1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 90 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
228 225 -1 -1 0 1 #"\0"
0 75 6 #"Menlo\0"
0.0 14 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 4 1 #"\0"
0 -1 1 #"\0"
1.0 0 90 -1 -1 -1 -1 -1 0 0 0 0 0 1 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255 0
0 0 0 0 1 #"\0"
0 70 1 #"\0"
0.0 0 90 90 90 90 0 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 0 0 0 0
0 0 1 #"\0"
0 75 6 #"Menlo\0"
0.0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255 0
0 0 0 0 1 #"\0"
0 75 6 #"Menlo\0"
0.0 12 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 0 1 #"\0"
0 75 6 #"Menlo\0"
0.0 13 90 -1 90 -1 3 -1 0 1 0 1 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 255
255 255 1 -1 0 2245 0 28 3 12 #"#lang racket"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 20 #";(provide get-index)"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"require"
0 0 24 3 2 #" ("
0 0 14 3 9 #"prefix-in"
0 0 24 3 1 #" "
0 0 14 3 5 #"game:"
0 0 24 3 1 #" "
0 0 19 3 18 #"\"./games/database."
0 0 29 3 3 #"rkt"
0 0 19 3 1 #"\""
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"require"
0 0 24 3 2 #" ("
0 0 14 3 9 #"prefix-in"
0 0 24 3 1 #" "
0 0 14 3 8 #"company:"
0 0 24 3 1 #" "
0 0 19 3 22 #"\"./companies/database."
0 0 29 3 3 #"rkt"
0 0 19 3 1 #"\""
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"require"
0 0 24 3 2 #" ("
0 0 14 3 9 #"prefix-in"
0 0 24 3 1 #" "
0 0 14 3 18 #"companies<->games:"
0 0 24 3 1 #" "
0 0 19 3 33 #"\"./join-games-companies/database."
0 0 29 3 3 #"rkt"
0 0 19 3 1 #"\""
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 7 #"require"
0 0 24 3 1 #" "
0 0 14 3 8 #"rackunit"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 40 #";Better names for our various data types"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 5 #"list?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 2 #" ("
0 0 14 3 6 #"listof"
0 0 24 3 1 #" "
0 0 14 3 5 #"list?"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 10 #"procedure?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 3 #"id?"
0 0 24 3 1 #" "
0 0 14 3 7 #"symbol?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 22 #";provide all functions"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 14 3 7 #"provide"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 8 #"find-all"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 12 #"keep-columns"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 19 #"keep-columns-in-row"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 17 #"column-has-value?"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 10 #"find-games"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 8 #"compare?"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 8 #"success?"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 19 #"asked-for-less-than"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 19 #"asked-for-more-than"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 3 #"S&U"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 10 #"2xcompare?"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 15 #"receive-double?"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 36 #"filter-companies-with-multiple-games"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 13 #"more-than-one"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" "
0 0 14 3 24 #"more-than-one-successful"
0 0 24 29 1 #"\n"
0 0 24 3 10 #" )"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 10 #";Test data"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 4 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"12.3"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Era of Kingdoms\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.85"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 8 #"Reign-Ed"
0 0 24 3 1 #" "
0 0 19 3 10 #"\"Reign Ed\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 3 #"2.1"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 18 #"The-Game-of-Crimps"
0 0 24 3 1 #" "
0 0 19 3 20 #"\"The Game of Crimps\""
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 11 #"Gokuls-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 6 #" Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 18 #"Gokuls-Better-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 13 #" Better Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 17 3 82
(
#";Note: this is NOT valid data. We made up these numbers for testing "
#"purposes only."
) 0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 13 #"company:table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 4 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Load-Board-Game"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Load Board Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"3"
0 0 24 3 2 #") "
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 15 #"Mage-Hand-Press"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 4 #"Mage"
0 0 19 3 12 #" Hand Press\""
0 0 24 3 1 #" "
0 0 21 3 2 #"42"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 9 #"HeartBeat"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 9 #"HeartBeat"
0 0 19 3 1 #"\""
0 0 24 3 1 #" "
0 0 21 3 3 #"100"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 14 #"Mystical-Games"
0 0 24 3 1 #" "
0 0 19 3 16 #"\"Mystical Games\""
0 0 24 3 1 #" "
0 0 21 3 2 #"42"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 17 #"Jon-Stynes-Design"
0 0 24 3 1 #" "
0 0 19 3 5 #"\"Jon "
0 0 29 3 6 #"Stynes"
0 0 19 3 8 #" Design\""
0 0 24 3 1 #" "
0 0 21 3 3 #"400"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 14 3 17 #"Thomassie-Mangiok"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 9 #"Thomassie"
0 0 19 3 1 #" "
0 0 29 3 7 #"Mangiok"
0 0 19 3 1 #"\""
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 4 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 14 3 15 #"Load-Board-Game"
0 0 24 3 1 #" "
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 14 3 8 #"KC-Games"
0 0 24 3 1 #" "
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 21 3 1 #"3"
0 0 24 3 1 #" "
0 0 14 3 15 #"Third-Eye-Games"
0 0 24 3 1 #" "
0 0 14 3 8 #"Reign-Ed"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 21 3 1 #"4"
0 0 24 3 1 #" "
0 0 14 3 14 #"Crimps-Company"
0 0 24 3 1 #" "
0 0 14 3 25 #"Adella-The-Game-of-Crimps"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 21 3 1 #"5"
0 0 24 3 1 #" "
0 0 14 3 17 #"Chip-Theory-Games"
0 0 24 3 1 #" "
0 0 14 3 19 #"Game-to-Pick-a-Game"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 21 3 1 #"6"
0 0 24 3 1 #" "
0 0 14 3 12 #"Joggle-Games"
0 0 24 3 1 #" "
0 0 14 3 15 #"Crown-of-Aragon"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 21 3 2 #"36"
0 0 24 3 1 #" "
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 19 #"Guilds-of-Cadwallon"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 21 3 2 #"38"
0 0 24 3 1 #" "
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 11 #"4-the-Birds"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 7 #" ("
0 0 21 3 2 #"42"
0 0 24 3 1 #" "
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 23 #"Zombicide:-Black-Plague"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 24 29 1 #"\n"
0 0 24 3 3 #" )"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 33 #";FUNCTIONS THAT OPERATE ON TABLES"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 415 21 0 0 0 68 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 3 1 #" "
0 0 14 3 5 #"Finds"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 1 #" "
0 0 14 3 5 #"whose"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 3 #"has"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 10 #"particular"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 5 #"any/c"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" ("
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"RETURNS:"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"12.3"
0 0 24 3 2 #"))"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 5 #"any/c"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 2 #") "
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 5 #"first"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"12.3"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 17 3 77
(
#";TODO: Add more tests for other tables and other columns - done, Ayd"
#"a & Julia"
) 0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 25 #"companies<->games:game-id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 14 3 15 #"Load-Board-Game"
0 0 24 3 1 #" "
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 10 #"company:id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 15 #"Load-Board-Game"
0 0 24 3 2 #" ("
0 0 14 3 13 #"company:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 15 #"Load-Board-Game"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Load Board Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"3"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" )"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 643 21 0 0 0 106 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 8 #"find-all"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 3 1 #" "
0 0 14 3 5 #"Finds"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 8 #"subtable"
0 0 24 3 1 #" "
0 0 14 3 5 #"whose"
0 0 24 3 1 #" "
0 0 14 3 4 #"rows"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 4 #"have"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 4 #"with"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 10 #"particular"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 5 #"any/c"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 15 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"12.3"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 18 #" ("
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Era of Kingdoms\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.85"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 18 #" ("
0 0 14 3 8 #"Reign-Ed"
0 0 24 3 1 #" "
0 0 19 3 10 #"\"Reign Ed\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 3 #"2.1"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 18 #" ("
0 0 14 3 11 #"Gokuls-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 6 #" Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 2 #"))"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 5 #"any/c"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 2 #") "
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 7 #"matches"
0 0 24 29 1 #"\n"
0 0 24 3 5 #" ("
0 0 14 3 6 #"filter"
0 0 24 3 2 #" ("
0 0 14 3 17 #"column-has-value?"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 2 #") "
0 0 14 3 5 #"table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 14 3 7 #"matches"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"12.3"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Era of Kingdoms\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.85"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 8 #"Reign-Ed"
0 0 24 3 1 #" "
0 0 19 3 10 #"\"Reign Ed\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 3 #"2.1"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 11 #"Gokuls-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 6 #" Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 18 #"The-Game-of-Crimps"
0 0 24 3 1 #" "
0 0 19 3 20 #"\"The Game of Crimps\""
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 18 #"Gokuls-Better-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 13 #" Better Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 18 #"The-Game-of-Crimps"
0 0 24 3 1 #" "
0 0 19 3 20 #"\"The Game of Crimps\""
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 11 #"Gokuls-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 6 #" Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 18 #"Gokuls-Better-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 13 #" Better Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 28 #"companies<->games:company-id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 4 #"CMON"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 21 3 2 #"36"
0 0 24 3 1 #" "
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 19 #"Guilds-of-Cadwallon"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 21 3 2 #"38"
0 0 24 3 1 #" "
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 11 #"4-the-Birds"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 21 3 2 #"42"
0 0 24 3 1 #" "
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 23 #"Zombicide:-Black-Plague"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" )"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 541 21 0 0 0 89 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 12 #"keep-columns"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 3 1 #" "
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 8 #"subtable"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 8 #"dropping"
0 0 24 3 1 #" "
0 0 14 3 7 #"columns"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 4 #"aren"
0 0 21 3 1 #"'"
0 0 14 3 1 #"t"
0 0 24 3 1 #" "
0 0 14 3 2 #"in"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"list"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 2 #" ("
0 0 14 3 7 #"list-of"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 2 #") "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 14 3 12 #"keep-columns"
0 0 24 3 2 #" ("
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 14 3 10 #"game:title"
0 0 24 3 3 #") ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"Returns:"
0 0 24 29 1 #"\n"
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Era of Kingdoms\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 8 #"Reign-Ed"
0 0 24 3 1 #" "
0 0 19 3 10 #"\"Reign Ed\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 18 #"The-Game-of-Crimps"
0 0 24 3 1 #" "
0 0 19 3 20 #"\"The Game of Crimps\""
0 0 24 3 2 #"))"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 12 #"keep-columns"
0 0 24 3 1 #" "
0 0 14 3 11 #"column-list"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 2 #" ("
0 0 14 3 6 #"listof"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 2 #") "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 3 #"map"
0 0 24 3 2 #" ("
0 0 14 3 5 #"curry"
0 0 24 3 1 #" "
0 0 14 3 19 #"keep-columns-in-row"
0 0 24 3 1 #" "
0 0 14 3 11 #"column-list"
0 0 24 3 2 #") "
0 0 14 3 5 #"table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 12 #"keep-columns"
0 0 24 3 2 #" ("
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 14 3 10 #"game:title"
0 0 24 3 3 #") ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Era of Kingdoms\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 8 #"Reign-Ed"
0 0 24 3 1 #" "
0 0 19 3 10 #"\"Reign Ed\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 18 #"The-Game-of-Crimps"
0 0 24 3 1 #" "
0 0 19 3 20 #"\"The Game of Crimps\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 11 #"Gokuls-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 6 #" Game\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 18 #"Gokuls-Better-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 13 #" Better Game\""
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 17 3 77
(
#";TODO: Add more tests for other tables and other columns - done, Ayd"
#"a & Julia"
) 0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 12 #"keep-columns"
0 0 24 3 2 #" ("
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 10 #"company:id"
0 0 24 3 1 #" "
0 0 14 3 12 #"company:name"
0 0 24 3 3 #") ("
0 0 14 3 13 #"company:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Load-Board-Game"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Load Board Game\""
0 0 24 3 2 #") "
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 15 #"Mage-Hand-Press"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 4 #"Mage"
0 0 19 3 12 #" Hand Press\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 9 #"HeartBeat"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 9 #"HeartBeat"
0 0 19 3 1 #"\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 14 #"Mystical-Games"
0 0 24 3 1 #" "
0 0 19 3 16 #"\"Mystical Games\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 17 #"Jon-Stynes-Design"
0 0 24 3 1 #" "
0 0 19 3 5 #"\"Jon "
0 0 29 3 6 #"Stynes"
0 0 19 3 8 #" Design\""
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 17 #"Thomassie-Mangiok"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 9 #"Thomassie"
0 0 19 3 1 #" "
0 0 29 3 7 #"Mangiok"
0 0 19 3 1 #"\""
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 12 #"keep-columns"
0 0 24 3 2 #" ("
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 28 #"companies<->games:company-id"
0 0 24 3 1 #" "
0 0 14 3 25 #"companies<->games:game-id"
0 0 24 3 3 #") ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Load-Board-Game"
0 0 24 3 1 #" "
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 8 #"KC-Games"
0 0 24 3 1 #" "
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 15 #"Third-Eye-Games"
0 0 24 3 1 #" "
0 0 14 3 8 #"Reign-Ed"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 14 #"Crimps-Company"
0 0 24 3 1 #" "
0 0 14 3 25 #"Adella-The-Game-of-Crimps"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 17 #"Chip-Theory-Games"
0 0 24 3 1 #" "
0 0 14 3 19 #"Game-to-Pick-a-Game"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 12 #"Joggle-Games"
0 0 24 3 1 #" "
0 0 14 3 15 #"Crown-of-Aragon"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 19 #"Guilds-of-Cadwallon"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 11 #"4-the-Birds"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 4 #"CMON"
0 0 24 3 1 #" "
0 0 14 3 23 #"Zombicide:-Black-Plague"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" )"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 37 #";END FUNCTIONS THAT OPERATE ON TABLES"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 31 #";FUNCTIONS THAT OPERATE ON ROWS"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 457 21 0 0 0 75 0 24 3 1 #" "
0 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 19 #"keep-columns-in-row"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 3 1 #" "
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 6 #"subrow"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 8 #"dropping"
0 0 24 3 1 #" "
0 0 14 3 7 #"columns"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 4 #"aren"
0 0 21 3 1 #"'"
0 0 14 3 1 #"t"
0 0 24 3 1 #" "
0 0 14 3 2 #"in"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"list"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 2 #" ("
0 0 14 3 7 #"list-of"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 2 #") "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 14 3 19 #"keep-columns-in-row"
0 0 24 3 2 #" ("
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 14 3 10 #"game:title"
0 0 24 3 3 #") ("
0 0 14 3 5 #"first"
0 0 24 3 1 #" "
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"Returns:"
0 0 24 29 1 #"\n"
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #")"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 19 #"keep-columns-in-row"
0 0 24 3 1 #" "
0 0 14 3 11 #"column-list"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 2 #" ("
0 0 14 3 6 #"listof"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 2 #") "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 3 #"map"
0 0 24 3 2 #" ("
0 0 15 3 6 #"lambda"
0 0 24 3 2 #" ("
0 0 14 3 1 #"f"
0 0 24 3 3 #") ("
0 0 14 3 1 #"f"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 3 #")) "
0 0 14 3 11 #"column-list"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 3 #" ("
0 0 14 3 19 #"keep-columns-in-row"
0 0 24 3 2 #" ("
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 14 3 10 #"game:title"
0 0 24 3 3 #") ("
0 0 14 3 5 #"first"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 17 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 3 #" ("
0 0 14 3 19 #"keep-columns-in-row"
0 0 24 3 2 #" ("
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 10 #"company:id"
0 0 24 3 1 #" "
0 0 14 3 12 #"company:name"
0 0 24 3 3 #") ("
0 0 14 3 6 #"second"
0 0 24 3 2 #" ("
0 0 14 3 13 #"company:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 17 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 15 #"Mage-Hand-Press"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 4 #"Mage"
0 0 19 3 12 #" Hand Press\""
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 3 #" ("
0 0 14 3 19 #"keep-columns-in-row"
0 0 24 3 2 #" ("
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 20 #"companies<->games:id"
0 0 24 3 1 #" "
0 0 14 3 28 #"companies<->games:company-id"
0 0 24 3 3 #") ("
0 0 14 3 5 #"third"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 17 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 21 3 1 #"3"
0 0 24 3 1 #" "
0 0 14 3 15 #"Third-Eye-Games"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 451 21 0 0 0 74 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 17 #"column-has-value?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 29 1 #"\n"
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 8 #"function"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 6 #"checks"
0 0 24 3 1 #" "
0 0 14 3 2 #"if"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 1 #" "
0 0 14 3 3 #"has"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 4 #"with"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 6 #"value."
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 14 3 17 #"column-has-value?"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 5 #"any/c"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 2 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 8 #"boolean?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 24 3 2 #"(("
0 0 14 3 17 #"column-has-value?"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 3 #") ("
0 0 14 3 5 #"first"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"Returns:"
0 0 24 3 1 #" "
0 0 21 3 2 #"#t"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 17 #"column-has-value?"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 5 #"any/c"
0 0 24 3 2 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 8 #"boolean?"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 2 #"\316\273"
0 0 24 3 1 #"("
0 0 14 3 3 #"row"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 5 #" ("
0 0 14 3 6 #"equal?"
0 0 24 3 2 #" ("
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 12 #" "
0 0 14 3 5 #"value"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 3 #" (("
0 0 14 3 17 #"column-has-value?"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 3 #") ("
0 0 14 3 5 #"first"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 4 #"))) "
0 0 21 3 2 #"#t"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 3 #" (("
0 0 14 3 17 #"column-has-value?"
0 0 24 3 1 #" "
0 0 14 3 20 #"companies<->games:id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 3 #") ("
0 0 14 3 6 #"second"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 4 #"))) "
0 0 21 3 2 #"#f"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 3 #" (("
0 0 14 3 17 #"column-has-value?"
0 0 24 3 1 #" "
0 0 14 3 10 #"company:id"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 3 #") ("
0 0 14 3 4 #"last"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 4 #"))) "
0 0 21 3 2 #"#f"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 35 #";END FUNCTIONS THAT OPERATE ON ROWS"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 13 #";COMMON TASKS"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 475 21 0 0 0 78 0 24 3 1 #" "
0 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 10 #"find-games"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 4 #"made"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 8 #"provided"
0 0 24 3 1 #" "
0 0 14 3 8 #"company."
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 10 #"find-games"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 6 #"value?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 2 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 8 #"EXAMPLE:"
0 0 24 3 2 #" ("
0 0 14 3 10 #"find-games"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 8 #"KC-Games"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 8 #"Returns:"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Era of Kingdoms\""
0 0 24 3 1 #" "
0 0 21 3 3 #"0.8"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.85"
0 0 24 3 2 #"))"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 10 #"find-games"
0 0 24 3 1 #" "
0 0 14 3 10 #"company-id"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 3 #"id?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 9 #"game-list"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 5 #" ("
0 0 14 3 3 #"map"
0 0 24 3 1 #" "
0 0 14 3 25 #"companies<->games:game-id"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 6 #"second"
0 0 24 3 1 #" "
0 0 14 3 10 #"company-id"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 5 #"apply"
0 0 24 3 1 #" "
0 0 14 3 6 #"append"
0 0 24 29 1 #"\n"
0 0 24 3 10 #" ("
0 0 14 3 3 #"map"
0 0 24 3 2 #" ("
0 0 15 3 2 #"\316\273"
0 0 24 3 1 #"("
0 0 14 3 2 #"id"
0 0 24 3 3 #") ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 7 #"game:id"
0 0 24 3 1 #" "
0 0 14 3 2 #"id"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 5 #"))) ("
0 0 14 3 9 #"game-list"
0 0 24 3 4 #"))))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 10 #"find-games"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 8 #"KC-Games"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 15 #"Era-of-Kingdoms"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Era of Kingdoms\""
0 0 24 3 1 #" "
0 0 21 3 3 #"0.8"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.85"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 10 #"find-games"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 14 3 4 #"CMON"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"(("
0 0 14 3 19 #"Guilds-of-Cadwallon"
0 0 24 3 1 #" "
0 0 19 3 11 #"\"Guilds of "
0 0 29 3 9 #"Cadwallon"
0 0 19 3 1 #"\""
0 0 24 3 1 #" "
0 0 21 3 3 #"0.5"
0 0 24 3 1 #" "
0 0 21 3 4 #"11.7"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 11 #"4-the-Birds"
0 0 24 3 1 #" "
0 0 19 3 13 #"\"4 the Birds\""
0 0 24 3 1 #" "
0 0 21 3 3 #"1.9"
0 0 24 3 1 #" "
0 0 21 3 3 #"1.2"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ("
0 0 14 3 23 #"Zombicide:-Black-Plague"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 9 #"Zombicide"
0 0 19 3 15 #": Black Plague\""
0 0 24 3 1 #" "
0 0 21 3 4 #"12.5"
0 0 24 3 1 #" "
0 0 21 3 5 #"407.9"
0 0 24 3 4 #"))))"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 667 21 0 0 0 110 0 24 3 1 #" "
0 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 8 #"Success?"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 4 #"rows"
0 0 24 3 1 #" "
0 0 14 3 2 #"in"
0 0 24 3 1 #" "
0 0 14 3 5 #"which"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 5 #"money"
0 0 24 3 1 #" "
0 0 14 3 8 #"received"
0 0 24 3 1 #" "
0 0 14 3 2 #"is"
0 0 24 3 1 #" "
0 0 14 3 7 #"greater"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 5 #"money"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 6 #"within"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 10 #"Unsuccess?"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 2 #"To"
0 0 24 3 1 #" "
0 0 14 3 5 #"check"
0 0 24 3 1 #" "
0 0 14 3 10 #"successful"
0 0 24 3 1 #" "
0 0 14 3 10 #"companies:"
0 0 24 3 2 #" ("
0 0 14 3 8 #"Success?"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 2 #"To"
0 0 24 3 1 #" "
0 0 14 3 5 #"check"
0 0 24 3 1 #" "
0 0 14 3 12 #"unsuccessful"
0 0 24 3 1 #" "
0 0 14 3 10 #"companies:"
0 0 24 3 2 #" ("
0 0 14 3 8 #"Success?"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 1051 21 0 0 0 174 0 24 3 1 #" "
0 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 8 #"compare?"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 8 #"function"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 4 #"will"
0 0 24 3 1 #" "
0 0 14 3 7 #"compare"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 3 #"two"
0 0 24 3 1 #" "
0 0 14 3 8 #"inputted"
0 0 24 3 1 #" "
0 0 14 3 7 #"columns"
0 0 24 3 1 #" "
0 0 14 3 4 #"with"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 12 #"greater-than"
0 0 24 3 1 #" "
0 0 14 3 5 #"sign."
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 4 #"This"
0 0 24 3 1 #" "
0 0 14 3 8 #"returned"
0 0 24 3 1 #" "
0 0 14 3 8 #"function"
0 0 24 3 1 #" "
0 0 14 3 5 #"needs"
0 0 24 3 1 #" "
0 0 14 3 2 #"to"
0 0 24 3 1 #" "
0 0 14 3 2 #"be"
0 0 24 3 1 #" "
0 0 14 3 6 #"called"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 7 #"another"
0 0 24 3 1 #" "
0 0 14 3 8 #"function"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 4 #"will"
0 0 24 3 1 #" "
0 0 14 3 6 #"supply"
0 0 24 3 1 #" "
0 0 14 3 2 #"it"
0 0 24 3 1 #" "
0 0 14 3 4 #"with"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 5 #"whose"
0 0 24 3 1 #" "
0 0 14 3 7 #"columns"
0 0 24 3 1 #" "
0 0 14 3 2 #"it"
0 0 24 3 1 #" "
0 0 14 3 4 #"will"
0 0 24 3 1 #" "
0 0 14 3 5 #"test."
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 8 #"compare?"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 10 #"procedure?"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 2 #" ("
0 0 14 3 3 #"row"
0 0 24 3 1 #")"
0 0 14 3 1 #"?"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 5 #"Since"
0 0 24 3 1 #" "
0 0 14 3 4 #"this"
0 0 24 3 1 #" "
0 0 14 3 8 #"function"
0 0 24 3 1 #" "
0 0 14 3 11 #"effectively"
0 0 24 3 1 #" "
0 0 14 3 7 #"returns"
0 0 24 3 1 #" "
0 0 14 3 7 #"another"
0 0 24 3 1 #" "
0 0 14 3 8 #"function"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 2 #"it"
0 0 24 3 1 #" "
0 0 14 3 5 #"needs"
0 0 24 3 1 #" "
0 0 14 3 2 #"to"
0 0 24 3 1 #" "
0 0 14 3 2 #"be"
0 0 24 3 1 #" "
0 0 14 3 6 #"called"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 14 3 6 #"second"
0 0 24 3 1 #" "
0 0 14 3 8 #"function"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 4 #"will"
0 0 24 3 1 #" "
0 0 14 3 6 #"supply"
0 0 24 3 1 #" "
0 0 14 3 2 #"it"
0 0 24 3 1 #" "
0 0 14 3 4 #"with"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 9 #"specified"
0 0 24 3 1 #" "
0 0 14 3 4 #"row."
0 0 24 3 1 #" "
0 0 14 3 4 #"*See"
0 0 24 3 1 #" "
0 0 14 3 7 #"EXAMPLE"
0 0 24 3 1 #" "
0 0 14 3 4 #"from"
0 0 24 3 1 #" "
0 0 14 3 6 #"recipe"
0 0 24 3 1 #" "
0 0 14 3 6 #"above*"
0 0 24 29 1 #"\n"
0 0 24 3 1 #" "
0 0 0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 8 #"compare?"
0 0 24 3 1 #" "
0 0 14 3 7 #"column1"
0 0 24 3 1 #" "
0 0 14 3 1 #"f"
0 0 24 3 1 #" "
0 0 14 3 7 #"column2"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 10 #"procedure?"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 2 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 8 #"boolean?"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 2 #"\316\273"
0 0 24 3 1 #"("
0 0 14 3 3 #"row"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 5 #" ("
0 0 14 3 1 #"f"
0 0 24 3 2 #" ("
0 0 14 3 7 #"column1"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 8 #" ("
0 0 14 3 7 #"column2"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 4 #"))))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 8 #"success?"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 6 #"filter"
0 0 24 3 2 #" ("
0 0 14 3 8 #"compare?"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 14 3 2 #"<="
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 2 #") "
0 0 14 3 5 #"table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 5 #"first"
0 0 24 3 2 #" ("
0 0 14 3 8 #"success?"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"12.3"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 6 #"second"
0 0 24 3 2 #" ("
0 0 14 3 8 #"success?"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 8 #"Reign-Ed"
0 0 24 3 1 #" "
0 0 19 3 10 #"\"Reign Ed\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 3 #"2.1"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 499 21 0 0 0 82 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 14 #"asked-for-less"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 29 1 #"\n"
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"less"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 5 #"$1000"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 14 3 14 #"asked-for-less"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 14 3 2 #"To"
0 0 24 3 1 #" "
0 0 14 3 3 #"see"
0 0 24 3 1 #" "
0 0 14 3 2 #"if"
0 0 24 3 1 #" "
0 0 14 3 5 #"there"
0 0 24 3 1 #" "
0 0 14 3 3 #"are"
0 0 24 3 1 #" "
0 0 14 3 3 #"any"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"less"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 6 #"$1000:"
0 0 24 3 2 #" ("
0 0 14 3 14 #"asked-for-less"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 22 #"column-less-than-value"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 2 #" ("
0 0 14 3 5 #"value"
0 0 24 3 1 #" "
0 0 21 3 2 #".1"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 3 #"->*"
0 0 24 3 2 #" ("
0 0 14 3 7 #"column?"
0 0 24 3 3 #") ("
0 0 14 3 7 #"number?"
0 0 24 3 3 #") ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 8 #"boolean?"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 8 #"compare?"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 1 #"<"
0 0 24 3 2 #" ("
0 0 15 3 2 #"\316\273"
0 0 24 3 1 #"("
0 0 14 3 1 #"x"
0 0 24 3 2 #") "
0 0 14 3 5 #"value"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 19 #"asked-for-less-than"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"number?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 6 #"filter"
0 0 24 3 2 #" ("
0 0 14 3 22 #"column-less-than-value"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 2 #") "
0 0 14 3 5 #"table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 19 #"asked-for-less-than"
0 0 24 3 1 #" "
0 0 21 3 3 #"0.1"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 4 #"()))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 499 21 0 0 0 82 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 14 #"asked-for-more"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 29 1 #"\n"
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 4 #"list"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"more"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 5 #"$1000"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 14 3 14 #"asked-for-less"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 14 3 2 #"To"
0 0 24 3 1 #" "
0 0 14 3 3 #"see"
0 0 24 3 1 #" "
0 0 14 3 2 #"if"
0 0 24 3 1 #" "
0 0 14 3 5 #"there"
0 0 24 3 1 #" "
0 0 14 3 3 #"are"
0 0 24 3 1 #" "
0 0 14 3 3 #"any"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"more"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 6 #"$1000:"
0 0 24 3 2 #" ("
0 0 14 3 14 #"asked-for-more"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 22 #"column-more-than-value"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 7 #"number?"
0 0 24 3 2 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 8 #"boolean?"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 8 #"compare?"
0 0 24 3 1 #" "
0 0 14 3 6 #"column"
0 0 24 3 1 #" "
0 0 14 3 1 #">"
0 0 24 3 2 #" ("
0 0 15 3 2 #"\316\273"
0 0 24 3 1 #"("
0 0 14 3 1 #"x"
0 0 24 3 2 #") "
0 0 14 3 5 #"value"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 19 #"asked-for-more-than"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"number?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 6 #"filter"
0 0 24 3 2 #" ("
0 0 14 3 22 #"column-more-than-value"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 2 #") "
0 0 14 3 5 #"table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 19 #"asked-for-more-than"
0 0 24 3 1 #" "
0 0 21 3 3 #"0.1"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 17 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 331 21 0 0 0 54 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 3 #"S&U"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCIRPTION:"
0 0 24 29 1 #"\n"
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 3 #"had"
0 0 24 3 1 #" "
0 0 14 3 4 #"both"
0 0 24 3 1 #" "
0 0 14 3 2 #"an"
0 0 24 3 1 #" "
0 0 14 3 12 #"unsuccessful"
0 0 24 3 1 #" "
0 0 14 3 3 #"and"
0 0 24 3 1 #" "
0 0 14 3 10 #"successful"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"kickstarters"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 3 1 #" "
0 0 14 3 3 #"S&U"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 9 #"EXAMPLES:"
0 0 24 3 1 #" "
0 0 14 3 3 #"S&U"
0 0 24 3 1 #" "
0 0 17 3 21 #";just directly run it"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 3 #"S&U"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 13 #"set-intersect"
0 0 24 29 1 #"\n"
0 0 24 3 4 #" ("
0 0 14 3 3 #"map"
0 0 24 3 1 #" "
0 0 14 3 10 #"company:id"
0 0 24 3 2 #" ("
0 0 14 3 5 #"succe"
0 0 14 3 3 #"ss?"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 4 #" ("
0 0 14 3 3 #"map"
0 0 24 3 1 #" "
0 0 14 3 10 #"company:id"
0 0 24 3 2 #" ("
0 0 14 3 8 #"success?"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 5 #")))))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 313 21 0 0 0 51 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 10 #"2xcompare?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 29 1 #"\n"
0 0 14 3 7 #"Returns"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 8 #"received"
0 0 24 3 1 #" "
0 0 14 3 2 #"at"
0 0 24 3 1 #" "
0 0 14 3 5 #"least"
0 0 24 3 1 #" "
0 0 14 3 6 #"double"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 6 #"amount"
0 0 24 3 1 #" "
0 0 14 3 4 #"they"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 29 1 #"\n"
0 0 14 3 22 #"receive-double::->row?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 9 #"EXAMPLES:"
0 0 24 3 2 #" ("
0 0 14 3 15 #"receive-double?"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 10 #"2xcompare?"
0 0 24 3 1 #" "
0 0 14 3 7 #"column1"
0 0 24 3 1 #" "
0 0 14 3 7 #"column2"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 2 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #" "
0 0 14 3 8 #"boolean?"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 2 #"\316\273"
0 0 24 3 1 #"("
0 0 14 3 3 #"row"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 5 #" ("
0 0 14 3 1 #">"
0 0 24 3 2 #" ("
0 0 14 3 7 #"column1"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 8 #" ("
0 0 14 3 1 #"*"
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 2 #" ("
0 0 14 3 7 #"column2"
0 0 24 3 1 #" "
0 0 14 3 3 #"row"
0 0 24 3 5 #")))))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 15 #"receive-double?"
0 0 24 3 1 #" "
0 0 14 3 7 #"column1"
0 0 24 3 1 #" "
0 0 14 3 7 #"column2"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 7 #"column?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 6 #"filter"
0 0 24 3 2 #" ("
0 0 14 3 10 #"2xcompare?"
0 0 24 3 1 #" "
0 0 14 3 7 #"column1"
0 0 24 3 1 #" "
0 0 14 3 7 #"column2"
0 0 24 3 2 #") "
0 0 14 3 5 #"table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 63
#";2xcompare does not need module+ tests if receieve-double works"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 5 #"first"
0 0 24 3 2 #" ("
0 0 14 3 15 #"receive-double?"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 15 #"Vanguard-of-War"
0 0 24 3 1 #" "
0 0 19 3 17 #"\"Vanguard of War\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"12.3"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 12 #"check-equal?"
0 0 24 3 2 #" ("
0 0 14 3 5 #"third"
0 0 24 3 2 #" ("
0 0 14 3 15 #"receive-double?"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 16 #" "
0 0 21 3 1 #"'"
0 0 24 3 1 #"("
0 0 14 3 11 #"Gokuls-Game"
0 0 24 3 1 #" "
0 0 19 3 1 #"\""
0 0 29 3 6 #"Gokuls"
0 0 19 3 6 #" Game\""
0 0 24 3 1 #" "
0 0 21 3 1 #"2"
0 0 24 3 1 #" "
0 0 21 3 4 #"0.28"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" )"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 211 21 0 0 0 34 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 13 #"more-than-one"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 17 #"DESCRIPTION:finds"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 3 #"who"
0 0 24 3 1 #" "
0 0 14 3 4 #"make"
0 0 24 3 1 #" "
0 0 14 3 4 #"more"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 3 #"one"
0 0 24 3 1 #" "
0 0 14 3 4 #"game"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 14 3 13 #"more-than-one"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 2 #"))"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 13 #"more-than-one"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #" "
0 0 14 3 4 #"row?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 4 #"cond"
0 0 24 3 3 #" [("
0 0 14 3 5 #"null?"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 2 #") "
0 0 21 3 1 #"'"
0 0 24 3 3 #"()]"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" ["
0 0 14 3 4 #"else"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 10 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 4 #"row1"
0 0 24 3 2 #" ("
0 0 14 3 5 #"first"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 10 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 8 #"subtable"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 28 #"companies<->games:company-id"
0 0 24 3 2 #" ("
0 0 14 3 10 #"company:id"
0 0 24 3 1 #" "
0 0 14 3 4 #"row1"
0 0 24 3 3 #") ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 10 #" ("
0 0 14 3 2 #"if"
0 0 24 3 2 #" ("
0 0 14 3 1 #">"
0 0 24 3 2 #" ("
0 0 14 3 6 #"length"
0 0 24 3 1 #" "
0 0 14 3 8 #"subtable"
0 0 24 3 2 #") "
0 0 21 3 1 #"1"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 14 #" ("
0 0 14 3 4 #"cons"
0 0 24 3 2 #" ("
0 0 14 3 10 #"company:id"
0 0 24 3 1 #" "
0 0 14 3 4 #"row1"
0 0 24 3 3 #") ("
0 0 14 3 13 #"more-than-one"
0 0 24 3 2 #" ("
0 0 14 3 4 #"rest"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 14 #" ("
0 0 14 3 13 #"more-than-one"
0 0 24 3 2 #" ("
0 0 14 3 4 #"rest"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 5 #")))])"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" )"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 535 21 0 0 0 88 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 22 #"thomas-the-tank-engine"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 19 #"DESCRIPTION:creates"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 4 #"made"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"with"
0 0 24 3 1 #" "
0 0 14 3 8 #"multiple"
0 0 24 3 1 #" "
0 0 14 3 6 #"games."
0 0 24 3 1 #" "
0 0 14 3 4 #"Then"
0 0 28 3 1 #","
0 0 24 3 1 #" "
0 0 14 3 5 #"sorts"
0 0 24 3 1 #" "
0 0 14 3 7 #"through"
0 0 24 3 1 #" "
0 0 14 3 7 #"looking"
0 0 24 29 1 #"\n"
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"less"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 21 3 5 #"1000."
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 3 1 #" "
0 0 14 3 4 #"void"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 29 1 #"\n"
0 0 14 3 4 #"Find"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 3 #"who"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"less"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 21 3 4 #"1000"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 10 #"developers"
0 0 24 3 1 #" "
0 0 14 3 4 #"with"
0 0 24 3 1 #" "
0 0 14 3 8 #"multiple"
0 0 24 3 1 #" "
0 0 14 3 6 #"games."
0 0 24 3 2 #" ("
0 0 14 3 22 #"thomas-the-tank-engine"
0 0 24 3 1 #")"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 15 #"define/contract"
0 0 24 3 2 #" ("
0 0 14 3 36 #"filter-companies-with-multiple-games"
0 0 24 3 1 #" "
0 0 14 3 8 #"criteria"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 10 #"procedure?"
0 0 24 3 1 #" "
0 0 14 3 7 #"number?"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" ("
0 0 14 3 8 #"criteria"
0 0 24 3 1 #" "
0 0 14 3 5 #"value"
0 0 24 3 2 #" ("
0 0 14 3 5 #"apply"
0 0 24 3 1 #" "
0 0 14 3 6 #"append"
0 0 24 3 2 #" ("
0 0 14 3 3 #"map"
0 0 24 29 1 #"\n"
0 0 24 3 4 #" ("
0 0 14 3 6 #"curryr"
0 0 24 3 1 #" "
0 0 14 3 10 #"find-games"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 4 #" ("
0 0 14 3 13 #"more-than-one"
0 0 24 3 2 #" ("
0 0 14 3 13 #"company:table"
0 0 24 3 6 #"))))))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 7 #"module+"
0 0 24 3 1 #" "
0 0 14 3 4 #"test"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 5 #"check"
0 0 24 3 1 #" "
0 0 14 3 6 #"equal?"
0 0 24 3 3 #" ("
0 0 14 3 36 #"filter-companies-with-multiple-games"
0 0 24 3 1 #" "
0 0 14 3 19 #"asked-for-less-than"
0 0 24 3 1 #" "
0 0 21 3 3 #"0.1"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 17 #" "
0 0 21 3 1 #"'"
0 0 24 3 2 #"()"
0 0 24 29 1 #"\n"
0 0 24 3 19 #" ))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 241 21 0 0 0 39 0 14 3 5 #"NAME:"
0 0 24 3 1 #" "
0 0 14 3 24 #"more-than-one-successful"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"DESCRIPTION:"
0 0 24 3 1 #" "
0 0 14 3 5 #"Finds"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"with"
0 0 24 3 1 #" "
0 0 14 3 4 #"more"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 3 #"one"
0 0 24 3 1 #" "
0 0 14 3 10 #"successful"
0 0 24 3 1 #" "
0 0 14 3 4 #"game"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TYPE:"
0 0 24 3 1 #" "
0 0 14 3 24 #"more-than-one-successful"
0 0 24 3 1 #" "
0 0 14 3 2 #"::"
0 0 24 3 1 #" "
0 0 14 3 2 #"->"
0 0 24 3 1 #" "
0 0 14 3 6 #"table?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 8 #"EXAMPLE:"
0 0 24 3 2 #" ("
0 0 14 3 24 #"more-than-one-successful"
0 0 24 3 1 #")"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 24 #"more-than-one-successful"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 11 #"multi-table"
0 0 24 3 2 #" ("
0 0 14 3 13 #"more-than-one"
0 0 24 3 2 #" ("
0 0 14 3 13 #"company:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 10 #"games-list"
0 0 24 3 2 #" ("
0 0 14 3 3 #"map"
0 0 24 3 2 #" ("
0 0 14 3 6 #"curryr"
0 0 24 3 1 #" "
0 0 14 3 10 #"find-games"
0 0 24 3 2 #" ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 3 #")) "
0 0 14 3 11 #"multi-table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 12 #"success-list"
0 0 24 3 2 #" ("
0 0 14 3 8 #"success?"
0 0 24 3 1 #" "
0 0 14 3 14 #"game:$received"
0 0 24 3 1 #" "
0 0 14 3 15 #"game:$asked-for"
0 0 24 3 2 #" ("
0 0 14 3 10 #"game:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 14 #"intersect-list"
0 0 24 3 2 #" ("
0 0 14 3 3 #"map"
0 0 24 3 2 #" ("
0 0 14 3 6 #"curryr"
0 0 24 3 1 #" "
0 0 14 3 13 #"set-intersect"
0 0 24 3 1 #" "
0 0 14 3 12 #"success-list"
0 0 24 3 2 #") "
0 0 14 3 10 #"games-list"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 3 #"ret"
0 0 24 3 1 #" "
0 0 21 3 1 #"'"
0 0 24 3 3 #"())"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 6 #"check?"
0 0 24 3 1 #" "
0 0 14 3 5 #"list1"
0 0 24 3 1 #" "
0 0 14 3 5 #"list2"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 5 #" ("
0 0 15 3 4 #"cond"
0 0 24 29 1 #"\n"
0 0 24 3 8 #" [("
0 0 14 3 3 #"not"
0 0 24 3 2 #" ("
0 0 14 3 6 #"empty?"
0 0 24 3 1 #" "
0 0 14 3 5 #"list1"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 13 #" ("
0 0 15 3 5 #"begin"
0 0 24 29 1 #"\n"
0 0 24 3 15 #" ("
0 0 15 3 4 #"cond"
0 0 24 29 1 #"\n"
0 0 24 3 18 #" [("
0 0 14 3 1 #">"
0 0 24 3 2 #" ("
0 0 14 3 6 #"length"
0 0 24 3 2 #" ("
0 0 14 3 5 #"first"
0 0 24 3 1 #" "
0 0 14 3 5 #"list2"
0 0 24 3 3 #")) "
0 0 21 3 1 #"1"
0 0 24 3 3 #") ("
0 0 14 3 4 #"set!"
0 0 24 3 1 #" "
0 0 14 3 3 #"ret"
0 0 24 3 2 #" ("
0 0 14 3 4 #"cons"
0 0 24 3 2 #" ("
0 0 14 3 5 #"first"
0 0 24 3 1 #" "
0 0 14 3 5 #"list1"
0 0 24 3 2 #") "
0 0 14 3 3 #"ret"
0 0 24 3 4 #"))])"
0 0 24 29 1 #"\n"
0 0 24 3 15 #" ("
0 0 14 3 6 #"check?"
0 0 24 3 2 #" ("
0 0 14 3 4 #"rest"
0 0 24 3 1 #" "
0 0 14 3 5 #"list1"
0 0 24 3 3 #") ("
0 0 14 3 4 #"rest"
0 0 24 3 1 #" "
0 0 14 3 5 #"list2"
0 0 24 3 6 #")))]))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 14 3 6 #"check?"
0 0 24 3 1 #" "
0 0 14 3 11 #"multi-table"
0 0 24 3 1 #" "
0 0 14 3 14 #"intersect-list"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 2 #" "
0 0 14 3 3 #"ret"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 9 3007 21 0 0 0 500 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 4 #"were"
0 0 24 3 1 #" "
0 0 14 3 4 #"made"
0 0 24 3 1 #" "
0 0 14 3 2 #"by"
0 0 24 3 1 #" "
0 0 14 3 4 #"some"
0 0 24 3 1 #" "
0 0 14 3 8 #"company?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"less"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 5 #"1000?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"more"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 5 #"1000?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 4 #"made"
0 0 24 3 1 #" "
0 0 14 3 4 #"more"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 21 3 1 #"1"
0 0 24 3 1 #" "
0 0 14 3 5 #"game?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 15 #"; Julie & Astha"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 15 3 6 #"define"
0 0 24 3 2 #" ("
0 0 14 3 13 #"more-than-one"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" ("
0 0 15 3 4 #"cond"
0 0 24 3 3 #" [("
0 0 14 3 5 #"null?"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 2 #") "
0 0 21 3 1 #"'"
0 0 24 3 3 #"()]"
0 0 24 29 1 #"\n"
0 0 24 3 9 #" ["
0 0 14 3 4 #"else"
0 0 24 3 1 #" "
0 0 24 29 1 #"\n"
0 0 24 3 10 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 4 #"row1"
0 0 24 3 2 #" ("
0 0 14 3 5 #"first"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 3 10 #" ("
0 0 15 3 6 #"define"
0 0 24 3 1 #" "
0 0 14 3 8 #"subtable"
0 0 24 3 2 #" ("
0 0 14 3 8 #"find-all"
0 0 24 3 1 #" "
0 0 14 3 28 #"companies<->games:company-id"
0 0 24 3 2 #" ("
0 0 14 3 10 #"company:id"
0 0 24 3 1 #" "
0 0 14 3 4 #"row1"
0 0 24 3 3 #") ("
0 0 14 3 23 #"companies<->games:table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 3 10 #" ("
0 0 14 3 2 #"if"
0 0 24 3 2 #" ("
0 0 14 3 1 #">"
0 0 24 3 2 #" ("
0 0 14 3 6 #"length"
0 0 24 3 1 #" "
0 0 14 3 8 #"subtable"
0 0 24 3 2 #") "
0 0 21 3 1 #"1"
0 0 24 3 1 #")"
0 0 24 29 1 #"\n"
0 0 24 3 14 #" ("
0 0 14 3 4 #"cons"
0 0 24 3 2 #" ("
0 0 14 3 10 #"company:id"
0 0 24 3 1 #" "
0 0 14 3 4 #"row1"
0 0 24 3 3 #") ("
0 0 14 3 13 #"more-than-one"
0 0 24 3 2 #" ("
0 0 14 3 4 #"rest"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 3 #")))"
0 0 24 29 1 #"\n"
0 0 24 3 14 #" ("
0 0 14 3 13 #"more-than-one"
0 0 24 3 2 #" ("
0 0 14 3 4 #"rest"
0 0 24 3 1 #" "
0 0 14 3 5 #"table"
0 0 24 3 5 #")))])"
0 0 24 29 1 #"\n"
0 0 24 3 3 #" )"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 17 3 37 #"; pass company database into function"
0 0 24 29 1 #"\n"
0 0 24 3 1 #"("
0 0 14 3 13 #"more-than-one"
0 0 24 3 2 #" ("
0 0 14 3 13 #"company:table"
0 0 24 3 2 #"))"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 3 #"who"
0 0 24 3 1 #" "
0 0 14 3 4 #"made"
0 0 24 3 1 #" "
0 0 14 3 2 #"at"
0 0 24 3 1 #" "
0 0 14 3 5 #"least"
0 0 24 3 1 #" "
0 0 14 3 3 #"one"
0 0 24 3 1 #" "
0 0 14 3 4 #"game"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 15 3 3 #"for"
0 0 24 3 1 #" "
0 0 14 3 4 #"less"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 5 #"1000?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 3 #"had"
0 0 24 3 1 #" "
0 0 14 3 2 #"an"
0 0 24 3 1 #" "
0 0 14 3 12 #"unsuccessful"
0 0 24 3 1 #" "
0 0 14 3 12 #"kickstarter?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 17 3 17 #"; Katherine & Mit"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 3 #"had"
0 0 24 3 1 #" "
0 0 14 3 1 #"a"
0 0 24 3 1 #" "
0 0 14 3 10 #"successful"
0 0 24 3 1 #" "
0 0 14 3 12 #"kickstarter?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 17 3 17 #"; Katherine & Mit"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 3 #"had"
0 0 24 3 1 #" "
0 0 14 3 4 #"both"
0 0 24 3 1 #" "
0 0 14 3 2 #"an"
0 0 24 3 1 #" "
0 0 14 3 12 #"unsuccessful"
0 0 24 3 1 #" "
0 0 14 3 3 #"and"
0 0 24 3 1 #" "
0 0 14 3 10 #"successful"
0 0 24 29 1 #"\n"
0 0 14 3 12 #"kickstarter?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"companies"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 3 #"had"
0 0 24 3 1 #" "
0 0 14 3 4 #"more"
0 0 24 3 1 #" "
0 0 14 3 4 #"than"
0 0 24 3 1 #" "
0 0 14 3 3 #"one"
0 0 24 3 1 #" "
0 0 14 3 10 #"successful"
0 0 24 3 1 #" "
0 0 14 3 12 #"kickstarter?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 3 #"How"
0 0 24 3 1 #" "
0 0 15 3 2 #"do"
0 0 24 3 1 #" "
0 0 14 3 2 #"we"
0 0 24 3 1 #" "
0 0 14 3 4 #"find"
0 0 24 3 1 #" "
0 0 14 3 3 #"all"
0 0 24 3 1 #" "
0 0 14 3 5 #"games"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 8 #"received"
0 0 24 3 1 #" "
0 0 14 3 2 #"at"
0 0 24 3 1 #" "
0 0 14 3 5 #"least"
0 0 24 3 1 #" "
0 0 14 3 2 #"2x"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 7 #"ammount"
0 0 24 3 1 #" "
0 0 14 3 5 #"asked"
0 0 24 3 1 #" "
0 0 14 3 4 #"for?"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Add"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 4 #"code"
0 0 24 29 1 #"\n"
0 0 17 3 16 #";Jacob and Simon"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 14 3 5 #"TODO:"
0 0 24 3 1 #" "
0 0 14 3 3 #"Use"
0 0 24 3 1 #" "
0 0 14 3 3 #"the"
0 0 24 3 1 #" "
0 0 14 3 9 #"questions"
0 0 24 3 1 #" "
0 0 14 3 5 #"above"
0 0 24 3 1 #" "
0 0 14 3 3 #"and"
0 0 24 3 1 #" "
0 0 14 3 3 #"add"
0 0 24 3 1 #" "
0 0 14 3 4 #"more"
0 0 24 3 1 #" "
0 0 14 3 9 #"questions"
0 0 24 3 1 #" "
0 0 14 3 4 #"that"
0 0 24 3 1 #" "
0 0 14 3 3 #"are"
0 0 24 3 1 #" "
0 0 14 3 4 #"sort"
0 0 24 3 1 #" "
0 0 14 3 2 #"of"
0 0 24 3 1 #" "
0 0 14 3 7 #"similar"
0 0 0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0 24 29 1 #"\n"
0 0
| false |
caf5c02a13f47d003e172910e419d5e991b88e39 | d9276fbd73cdec7a5a4920e46af2914f8ec3feb1 | /data/scheme/toplevel-trampoline.rkt | 4ffc96592314447d0cd031478cf16031554c707d | []
| no_license | CameronBoudreau/programming-language-classifier | 5c7ab7d709b270f75269aed1fa187e389151c4f7 | 8f64f02258cbab9e83ced445cef8c1ef7e5c0982 | refs/heads/master | 2022-10-20T23:36:47.918534 | 2016-05-02T01:08:13 | 2016-05-02T01:08:13 | 57,309,188 | 1 | 1 | null | 2022-10-15T03:50:41 | 2016-04-28T14:42:50 | C | UTF-8 | Racket | false | false | 8,256 | rkt | toplevel-trampoline.rkt | #lang racket/base
;; This module implements Typed Racket's trampolining top-level
;; typechecking. The entrypoint is the function provided below, which
;; sets up the trampoline.
;;
;; Subsequently, the macros forms defined in the submodule at the bottom
;; take over and keep head local-expanding until `begin` forms are exhausted,
;; at which point the syntax can be fully-expanded and checked normally.
(require "../utils/utils.rkt"
syntax/parse
(private syntax-properties)
(for-template racket/base))
(provide tc-toplevel-start)
;; entrypoint for typechecking a top-level interaction
;; this is defined in this module (instead of tc-top-level.rkt) in
;; order to avoid cyclic dependency issues
;; syntax syntax -> syntax
(define (tc-toplevel-start orig-stx stx)
(syntax-parse stx
#:literal-sets (kernel-literals)
;; Don't open up `begin`s that are supposed to be ignored
[(~and (begin e ... e-last)
(~not (~or _:ignore^ _:ignore-some^)))
;; the original syntax is threaded through for error message reporting
;; later in `trampoline-core`
#`(begin (tc-toplevel-trampoline (quote-syntax #,orig-stx) e) ...
(tc-toplevel-trampoline/report
(quote-syntax #,orig-stx) e-last))]))
(module trampolines racket/base
(require "../utils/utils.rkt"
(for-syntax racket/base
racket/match
syntax/kerncase
syntax/parse
syntax/stx
(rep type-rep)
(optimizer optimizer)
(types utils abbrev printer generalize)
(typecheck tc-toplevel possible-domains)
(private type-contract syntax-properties)
(env mvar-env)
(utils disarm lift utils timing tc-utils arm mutated-vars)))
(provide tc-toplevel-trampoline
tc-toplevel-trampoline/report)
(define-for-syntax (maybe-optimize body)
;; do we optimize?
(if (optimize?)
(begin
(do-time "Starting optimizer")
(begin0 (stx-map optimize-top body)
(do-time "Optimized")))
body))
(define-for-syntax (trampoline-core stx report? kont)
(syntax-parse stx
[(_ orig-stx e)
(define head-expanded
(disarm*
(local-expand/capture* #'e 'top-level (kernel-form-identifier-list))))
(syntax-parse head-expanded
#:literal-sets (kernel-literals)
;; keep trampolining on begins, transfer syntax properties so that ignore
;; properties are retained in the begin subforms
[(begin (define-values (n) e-rhs) ...
(~and the-begin (begin e ... e-last)))
(define e*s
(for/list ([e (in-list (syntax->list #'(e ...)))])
(syntax-track-origin e #'the-begin #'begin)))
(define e-last*
(syntax-track-origin #'e-last #'the-begin #'begin))
(with-syntax ([(e ...) e*s]
[e-last e-last*])
#`(begin (tc-toplevel-trampoline orig-stx (define-values (n) e-rhs))
...
(tc-toplevel-trampoline orig-stx e) ...
#,(if report?
#'(tc-toplevel-trampoline/report orig-stx e-last)
#'(tc-toplevel-trampoline orig-stx e-last))))]
[_
(define fully-expanded
;; a non-begin form can still cause lifts, so still have to catch them
(disarm* (local-expand/capture* #'e 'top-level (list #'module*))))
(find-mutated-vars fully-expanded mvar-env)
;; Unlike the `begin` cases, we probably don't need to trampoline back
;; to the top-level because we're not catching lifts from macros at the
;; top-level context but instead from expression context.
(parameterize ([orig-module-stx #'orig-stx]
[expanded-module-stx fully-expanded])
(syntax-parse fully-expanded
#:literal-sets (kernel-literals)
[(begin form ...)
(define forms (syntax->list #'(form ...)))
(define result
(for/last ([form (in-list forms)])
(tc-toplevel-form form)))
;; Transform after optimization for top-level because the flattening
;; will change syntax object identity (via syntax-track-origin) which
;; doesn't work for looking up types in the optimizer.
(define new-stx
(apply append
(for/list ([form (in-list forms)])
(change-contract-fixups (maybe-optimize (list form))))))
(kont new-stx result)]))])]))
;; Trampoline that continues the typechecking process.
(define-syntax (tc-toplevel-trampoline stx)
(trampoline-core
stx #f
(λ (new-stx result)
(arm
(if (unbox include-extra-requires?)
#`(begin #,extra-requires #,@new-stx)
#`(begin #,@new-stx))))))
(begin-for-syntax
(define did-I-suggest-:print-type-already? #f)
(define :print-type-message " ... [Use (:print-type <expr>) to see more.]"))
;; Trampoline that continues the typechecking process and reports the type
;; information to the user.
(define-syntax (tc-toplevel-trampoline/report stx)
(trampoline-core
stx #t
(λ (new-stx result)
(define ty-str
(match result
;; 'no-type means the form is not an expression and
;; has no meaningful type to print
['no-type #f]
;; don't print results of type void
[(tc-result1: (== -Void type-equal?)) #f]
;; don't print results of unknown type
[(tc-any-results: f) #f]
[(tc-result1: t f o)
;; Don't display the whole types at the REPL. Some case-lambda types
;; are just too large to print.
;; Also, to avoid showing too precise types, we generalize types
;; before printing them.
(define tc (cleanup-type t))
(define tg (generalize tc))
(format "- : ~a~a~a\n"
(pretty-format-type tg #:indent 4)
(cond [(equal? tc tg) ""]
[else (format " [more precisely: ~a]" tc)])
(cond [(equal? tc t) ""]
[did-I-suggest-:print-type-already? " ..."]
[else (set! did-I-suggest-:print-type-already? #t)
:print-type-message]))]
[(tc-results: t)
(define tcs (map cleanup-type t))
(define tgs (map generalize tcs))
(define tgs-val (make-Values (map -result tgs)))
(define formatted (pretty-format-type tgs-val #:indent 4))
(define indented? (regexp-match? #rx"\n" formatted))
(format "- : ~a~a~a\n"
formatted
(cond [(andmap equal? tgs tcs) ""]
[indented?
(format "\n[more precisely: ~a]"
(pretty-format-type (make-Values (map -result tcs))
#:indent 17))]
[else (format " [more precisely: ~a]" (cons 'Values tcs))])
;; did any get pruned?
(cond [(andmap equal? t tcs) ""]
[did-I-suggest-:print-type-already? " ..."]
[else (set! did-I-suggest-:print-type-already? #t)
:print-type-message]))]
[x (int-err "bad type result: ~a" x)]))
(define with-printing
(with-syntax ([(e ... e-last) new-stx])
(if ty-str
#`(begin e ...
(begin0 e-last (display '#,ty-str)))
#'(begin e ... e-last))))
(arm
(if (unbox include-extra-requires?)
#`(begin #,extra-requires #,with-printing)
with-printing))))))
(require (for-template (submod "." trampolines)))
| true |
4c53ff7518633151955125caef70e434f4c46357 | 49bef55e6e2ce9d3e64e55e71496be8f4fc7f4f3 | /rb/sections/preamble.scrbl | a01e70f783791b38f82c5c80f25810307fed31dd | []
| no_license | brittAnderson/compNeuroIntro420 | 13dad04726c1bf3b75a494bc221c0c56f52a060f | ad4211f433c22f647b1bf2e30561106178b777ab | refs/heads/racket-book | 2023-08-10T18:34:48.611363 | 2023-07-28T15:59:50 | 2023-07-28T15:59:50 | 78,282,622 | 26 | 97 | null | 2023-07-22T19:50:59 | 2017-01-07T14:10:01 | JavaScript | UTF-8 | Racket | false | false | 9,172 | scrbl | preamble.scrbl | #lang scribble/book
@(require plot/pict
scribble/manual
scribble/base
scribble-math/dollar
scribble/example
racket/math
scriblib/autobib
"./../code/refs.rkt")
@(define plot-eval
(let ([eval (make-base-eval)])
(eval '(begin
(require racket/math
racket/match
racket/list
racket/draw
racket/class
plot/pict
plot/utils)))
eval))
@(define-cite ~cite citet-id generate-bibliography #:style author+date-style)
@title{Preface}
Experimental psychology was invented as a counterweight to the physical sciences. It is the difference between a science of mass and of weight, luminance and brightness. A pound of feathers has the same mass as a pound of pennies, but clearly the latter weighs more. Just try it.
To make a science of such subjective experience as to whether one thing is heavier or brighter than another there needed to be methods for human experimentation that were scientific. That is, they combined a subject matter of subjective experience with the standard procedures of empirical sciences: repeat measurements, control conditions, and systematic variation. By convention Wilhelm Wundt is taken as Empirical Psychology's founder and 1879, the year he established his independent experimental laboratory, as the date for the founding. It is only in the 1800s that we see the emergence of scientific experiments that look like modern psychology: Weber's weights, Helmholtz's mercury lamp flash experiments on attention, and Wundt's own experiments on attention.
@(require scribble-embedding)
@(youtube "https://www.youtube.com/embed/Zr7O41r8uEI")
While Wundt was merging the experimental methods of physics and physiology with the content of human awareness, it was a generation before Wundt that Weber collected the data that led Gustav Fechner, a physicist, to express mathematically a procedure for measuring psychological magnitudes as functions of physical intensities: @emph{psychophysics}@~cite[fechner-psychophysics].
Despite this early and potent demonstration of the power of using math for achieving insight into human subjective experience, quantitative models were not frequent in psychology for the next hundred years, and even now, despite notable and influential exceptions (the Rescorla-Wagner model, developed in the context of conditioning and the source of modern reinforcement learning, Rosenblatt's perceptrons: the font from which neural networks flowed), mathematical models form only a small portion of published psychological research. While the contemporary content of scientific psychology has greatly expanded, the predominant use of quantitative methods in psychology is still @italic{statistical inference}. That reliance on statistics may be both cause and consequence for why mathematics, such as calculus and linear algebra, are not curricular requirements for many psychology undergraduate programs though statistics courses are. We are much quicker to deploy complicated statistical methodologies than to use math as the language for expressing concretely, concisely, and unambiguously our psychological theories. Nor do we use computer programs based on psychological theories to explore model implications via simulations as much as we should.
@bold{This course is intended as a corrective. It endeavors to give undergraduates who may not have had any post-secondary math courses to speak of an exposure to some of the terminology and notation for the areas of mathematics most used in psychological and neuroscience models. The course combines this exposure with a heavy dose of programming exercises to practice concrete use. The goal is to build familiarity with terms and to desensitize some of the math and computing anxiety that formula and code excerpts can induce. In addition, and perhaps most importantly, the course wants to give students practice in seeing how formal mathematical ideas can be a potent source for focusing our discussion of what key psychological concepts @italic{are}}.
Of course, one cannot explore computational and mathematical ideas without having some familiarity with computing basics: writing code, markup syntax for reports and documentation, and ancillary tools such as @emph{git} for sharing. In years past I combined all these content areas into this single course. The heterogeneity of student backgrounds made that tough, but as there were no alternatives it was necessary. Now, however, I have split off the computing tools part from this content part. Students can and should come to this course with some basic familiarity with using their computer as a research tool. If they do not have that knowledge they can gain it from a variety of on-line sources. I outline my approach @hyperlink["https://brittanderson.github.io/Intro2Computing4Psychology/book/index.html"]{here}.
@(youtube "https://player.vimeo.com/video/448900968?h=eff8e7355a&badge=0&autopause=0&player_id=0&app_id=58479" )
Freeing this course from the constraints of teaching computing basics provides the space for including new content and teaching the older material differently. I would like both novice programmers and those with more experience programming to be able to get something from the exercises. I have explicitly decided not to use more common programming languages, such as python, so that everyone can focus on what it is we are trying to do, and not just what library can we import or what code we can find online to cut and paste? With the freedom to select any computing language I had the chance to hearken back to the early days of artificial intelligence (AI); an era when AI was about thinking and reasoning and not about how to import a model pretrained on billions of examples. By choosing a LISP I can also engage in a discussion of how programming languages differ, and how the design choices and features of a programming language may influence the expression of our theoretical ideas. Can a particular programming language lead us to new ways of thinking and conceiving of the problem space we wish to explore theoretically and via simulation?
All that is grand, but the course is still intended for undergraduates, many of whom may only possess programming rudiments. How to get them all, the Mac Users (both Intel and M1/2), as well as Windows and *Nix users, to have a common environment so that I can teach the same thing to all and so that they can get the tools installed on their computers in less than a month? Common-Lisp (CL) would be ideal, and I wrote some of the code for an @hyperlink["https://github.com/brittAnderson/compNeuroIntro420/tree/lisp"]{earlier offering} in CL, but installing CL and getting a sane working environment can be challenging. Thus, I decided to try @hyperlink["https://racket-lang.org/"]{Racket}. It is a language designed to support teaching, and has the DrRacket IDE. This works pretty much out of the box on Linux, Windows, and OSX systems. It even has a documentation system, @hyperlink["https://docs.racket-lang.org/scribble/index.html"]{scribble}, built-in, and which I am using to write this document.
The remaining question is what new content to include? So far, I plan to expand the section on neuron modeling with an additional example, the Morris-Lecar model, that gives us a chance to explore how the differential equation formulation gives us additional information about our model via visualizing the phase space.
I also can now include something more traditional in the history of computational models of mind. We can code a simple Turing machine solving the busy beaver problem. We gain familiarity with this oft cited entity, and some concrete experience with the idea of computability and halting. How much more space is left for additional models? I hope to get to the Kohonen neural network for a week too. We will see from this fresh offering if there is time.
In summary, the goals for this course and this document are to give
students a familiarity with the mathematical terminology and domains
that form the backdrop to modeling in psychology. I still feel some
basic understanding of what certain mathematical gadgets are is
important, e.g. what a differential equation is is something
psychologists modeling memory should know about, but that most of them
do not. They do not, most of them, need to know how to analytically
solve the equations, but they should be able to use their own
programmed implementation to explore the implications of their ideas.
The basic constructs of linear algebra, matrices and vectors, are also
critical. It is essential for implementing many common neural
networks, but vector spaces also comprise a theoretical account of
representation. How much I can move beyond these fundamentals now that
I am not also trying to combine it with an introduction to programming
is a continuing experiment as we prepare to launch the Spring 2023 offering.
@generate-bibliography[#:sec-title "Preamble Bibliography"
#:tag "ref:preamble"]
| false |
be80846d52e15128336ec9c02a1a030e4146ef51 | b98c135aff9096de1311926c2f4f401be7722ca1 | /sgml/digitama/xexpr/sax/handler/writer.rkt | cda0c16073b32b026b20d0dbfc1ea7fa984f7b45 | []
| no_license | wargrey/w3s | 944d34201c16222abf51a7cf759dfed11b7acc50 | e5622ad2ca6ec675fa324d22dd61b7242767fb53 | refs/heads/master | 2023-08-17T10:26:19.335195 | 2023-08-09T14:17:45 | 2023-08-09T14:17:45 | 75,537,036 | 3 | 1 | null | 2022-02-12T10:59:27 | 2016-12-04T12:49:33 | Racket | UTF-8 | Racket | false | false | 3,038 | rkt | writer.rkt | #lang typed/racket/base
(provide (all-defined-out))
(require "../../sax.rkt")
(require "../../prompt.rkt")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define #:forall (T) sax-display-prolog : (XML-Prolog-Handler T)
(lambda [pname version encoding standalone? etype? datum]
(if (or etype?)
(printf "<?xml version=\"~a\" encoding=\"~a\" standalone=\"~a\" ?>~n"
version (if (not encoding) "UTF-8" encoding) (if standalone? 'yes 'no))
(printf "<!-- END OF ~a -->~n" pname))
datum))
(define #:forall (T) sax-display-doctype : (XML-Doctype-Handler T)
(lambda [?name public system datum]
(cond [(not ?name) (sax-stop-with datum)]
[(and public system) (printf "<!DOCTYPE ~a PUBLIC \"~a\" \"~a\">~n" ?name public system)]
[(and system) (printf "<!DOCTYPE ~a SYSTEM \"~a\">~n" ?name system)]
[else (printf "<!DOCTYPE ~a>~n" ?name)])
datum))
(define #:forall (T) sax-display-pi : (XML-PI-Handler T)
(lambda [xpath target body datum]
(cond [(not body) (printf "<?~a?>~n" target)]
[else (printf "<!~a ~a>~n" target body)])
datum))
(define #:forall (T) sax-display-comment : (XML-Comment-Handler T)
(lambda [xpath comment preserve? datum]
(printf "<!--~a-->" comment)
(when (not preserve?)
(newline))
datum))
(define #:forall (T) sax-display-element : (XML-Element-Handler T)
(lambda [name xpath attrs empty? preserve? datum]
(define indent (make-string (* (length xpath) 4) #\space))
(cond [(not attrs) (printf "~a</~a>~n" (if preserve? "" indent) name)]
[else (printf "~a<~a" indent name)
(for ([attr (in-list attrs)])
(printf " ~a=\"~a\"" (car attr) (cdr attr)))
(if (not empty?) (printf ">") (printf "/>"))
(when (not preserve?) (newline))])
datum))
(define #:forall (T) sax-display-pcdata : (XML-PCData-Handler T)
(lambda [element xpath pcdata preserve? cdata? datum]
(define indention
(cond [(or preserve?) ""]
[else (make-string (* (+ (length xpath) 1) 4) #\space)]))
(cond [(and cdata?) (printf "<![CDATA[~a[[>" pcdata)]
[else (printf "~a~a" indention pcdata)
(when (not preserve?)
(newline))])
datum))
(define #:forall (T) sax-display-entity : (XML-GEReference-Handler T)
(lambda [entity ?default-char datum]
(when (char? ?default-char)
(display ?default-char))
datum))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define #:forall (T) sax-xml-writer : (-> (XML-Event-Handlerof T))
(lambda []
((inst make-xml-event-handler T)
#:prolog sax-display-prolog #:doctype sax-display-doctype #:pi sax-display-pi
#:element sax-display-element #:pcdata sax-display-pcdata
#:gereference sax-display-entity #:comment sax-display-comment)))
(define sax-handler/xml-writer ((inst sax-xml-writer Void)))
| false |
8e2f8c7d65a1b7db8c9873bfb37503aa34de49fc | bde1fd2511c16bc4dfb3f26337eb4a8941fcb7af | /ch1/1.6.rkt | bec13ab85da7e11272d6536ce7ae4a3460091164 | []
| no_license | sjhuangx/EOPL | dcb6d8c4e23f6a55de18a99c17366cdeb1ffab6e | a6475e10a955128600f964340c590b80955e0f83 | refs/heads/master | 2021-06-28T03:24:18.388747 | 2018-03-12T15:06:16 | 2018-03-12T15:06:16 | 96,590,962 | 1 | 0 | null | 2017-08-05T14:15:19 | 2017-07-08T02:34:20 | Racket | UTF-8 | Racket | false | false | 164 | rkt | 1.6.rkt | #lang eopl
;; Exercise
;
; with a reversed order, nth-element would try to take the car
; of the empty list when called with a list which is 1 element
; too short. | false |
fe29efdcbd3515e01251d3863e6bb04fccc914e2 | 6b4aa8f5d12bdc673f545d1582c1cf0a92c46368 | /meta-engine/demos/physics-bullet.rkt | f4deb03fcdb2736b0301cb02a3d8ec682828a50f | []
| no_license | thoughtstem/meta-engine | b360f77c15c242ef817c2cc9aea29c8e3bf93778 | ffa8eb6a02ce3cd31816ee47ca7bd1d3143d6c5f | refs/heads/master | 2020-06-23T05:44:14.712756 | 2020-06-22T22:18:50 | 2020-06-22T22:18:50 | 198,533,313 | 4 | 1 | null | 2020-03-06T22:55:58 | 2019-07-24T01:16:36 | Racket | UTF-8 | Racket | false | false | 1,147 | rkt | physics-bullet.rkt | #lang racket
(provide g)
(require meta-engine
2htdp/image)
(define (my-thing x y color)
(entity
(physics-system #:mass 1
20 20)
(position (posn x y) (get-physics-position))
(rotation 0 (get-physics-rotation))
(sprite (register-sprite
(square 20 'solid color)))))
(define (random-thing)
(my-thing
(+ 200 (random -20 20))
(+ 200 (random -20 20))
(make-color (random 0 255) (random 0 255) 0)))
(define (bullet)
(entity
(physics-system #:mass 10
#:forces (thunk* (posn 1000 0))
20 20)
(position (posn 10 200)
(get-physics-position))
(rotation 0 (get-physics-rotation))
(sprite (register-sprite
(circle 10 'solid 'blue))
)))
(define (wall x y)
(entity
(physics-system #:static #t
400 10)
(position (posn x y))
(sprite (register-sprite
(rectangle 400 10 'solid 'white)))))
(define g
(game
(delta-time-entity)
(physics-manager)
(bullet)
(wall 200 10)
(wall 200 390)
(map (thunk* (random-thing))
(range 0 70))))
(module+ main
(play! g))
| false |
b179e155adafc6e2e9704b95dda6b5e2272d1925 | 3c2a208910579b8fa92e1b03133ed88de5fe73eb | /generic-bind/nested-binds-helper.rkt | 560d0631bcb4c0803156621657b1737f9887a817 | []
| no_license | stchang/generic-bind | cbc639b5e29f9d426a51581d46fe65a7fe6de65b | d8bd9b76b792c6ebdc32d05db9545274f2ab5053 | refs/heads/master | 2022-09-13T20:06:26.404413 | 2022-08-08T03:06:05 | 2022-08-08T03:06:05 | 11,781,825 | 4 | 2 | null | 2023-08-21T16:34:03 | 2013-07-31T03:47:06 | Racket | UTF-8 | Racket | false | false | 2,664 | rkt | nested-binds-helper.rkt | #lang racket/base
(provide with-new-match-pat-def-set
splicing-with-new-match-pat-def-set
define-current-match-pat-def-set
(for-syntax make-gen-bind-match-expander-proc-maker
))
(require racket/stxparam
racket/splicing
"syntax-parse-utils.rkt"
(for-syntax racket/base
syntax/parse
racket/set
"stx-utils.rkt"
))
(define-syntax-parameter current-match-pat-def-set #f)
(begin-for-syntax
(define (get-current-match-pat-def-set)
(syntax-parameter-value #'current-match-pat-def-set))
(define (nested-gen-bind-not-supported-error stx)
(raise-syntax-error
#f
(string-append
"nested generic-binding instances not supported for Racket version "(version)"\n"
" because syntax-local-match-introduce is needed")
stx))
(define ((make-gen-bind-match-expander-proc-maker ~define-id))
;; hash : (Hash-Table Any Symbol)
(define hash (make-hash))
(lambda (stx)
(define def-set (get-current-match-pat-def-set))
(cond [(set-mutable? def-set)
(unless syntax-local-match-introduce-available?
(nested-gen-bind-not-supported-error stx))
(define/syntax-parse name
(datum->stx stx (hash-ref! hash (syntax->datum+srcloc+props stx)
gensym)))
(define/syntax-parse -define ~define-id)
(define/syntax-parse stx* stx)
(define def
(syntax-local-match-introduce-2
(syntax/loc stx (-define stx* name))))
(set-add! def-set def)
#'name]
[else
(raise-syntax-error #f "not within a generic binding context" stx)]))))
(define-syntax/parse with-new-match-pat-def-set #:stx stx
[(wnmpds expr:expr ...+)
(syntax/loc stx
(syntax-parameterize ([current-match-pat-def-set (mutable-set)])
expr ...))])
(define-syntax/parse splicing-with-new-match-pat-def-set #:stx stx
[(swnmpds expr:expr ...+)
(syntax/loc stx
(splicing-syntax-parameterize ([current-match-pat-def-set (mutable-set)])
expr ...))])
(define-syntax define-current-match-pat-def-set
(lambda (stx)
(define def-set (syntax-parameter-value #'current-match-pat-def-set))
(cond [(set-mutable? def-set)
(define/syntax-parse (def ...) (map syntax-local-introduce (set->list def-set)))
(begin0 #'(begin def ...)
(set-clear! def-set))]
[else
(raise-syntax-error #f "no current-match-pat-def-set" stx)])))
| true |
94d4e9b7eaf1572df193e71e441f636a3d2344e6 | c01a4c8a6cee08088b26e2a2545cc0e32aba897b | /contrib/medikanren2/Thi/example-one-hop-ORPHANET-ICD-9-10.rkt | 20c99cc9a6d49ecd22f421502caaec5d94a110e7 | [
"MIT"
]
| permissive | webyrd/mediKanren | c8d25238db8afbaf8c3c06733dd29eb2d7dbf7e7 | b3615c7ed09d176e31ee42595986cc49ab36e54f | refs/heads/master | 2023-08-18T00:37:17.512011 | 2023-08-16T00:53:29 | 2023-08-16T00:53:29 | 111,135,120 | 311 | 48 | MIT | 2023-08-04T14:25:49 | 2017-11-17T18:03:59 | Racket | UTF-8 | Racket | false | false | 908 | rkt | example-one-hop-ORPHANET-ICD-9-10.rkt | #lang racket/base
(require
"query-low-level.rkt"
racket/pretty)
(define close-match-preds '("biolink:close_match"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Find ORPHANET curies that are close matches to ICD9 or ICD10 curies ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define prefix.ORPHANET "ORPHANET:")
(define prefix.ICD9 "ICD9:")
(define prefix.ICD10 "ICD10:")
(newline)
(define ORPHANET-ICD9-matches (query:Prefix->Prefix prefix.ORPHANET close-match-preds prefix.ICD9))
(pretty-write `(ORPHANET-ICD9-matches count: ,(length ORPHANET-ICD9-matches)))
(pretty-write ORPHANET-ICD9-matches)
(newline)
(define ORPHANET-ICD10-matches (query:Prefix->Prefix prefix.ORPHANET close-match-preds prefix.ICD10))
(pretty-write `(ORPHANET-ICD10-matches count: ,(length ORPHANET-ICD10-matches)))
(pretty-write ORPHANET-ICD10-matches)
| false |
05329137e1a7fc89f13a60bb7fc060ba0670ef69 | 7ff9a9fd919280015c420ecc491c88d987fee235 | /typed-nanopass-model.rkt | dcc99281f57a102b10fc98d6a0150c351cba949f | []
| no_license | LeifAndersen/typed-nanopass-model | 09eb9c25d23974d569a3b8120915b28a8ad14016 | 6d09351d53d86c488ff84bc2b511e73fffd58057 | refs/heads/master | 2020-05-18T07:12:50.462211 | 2015-08-03T00:16:38 | 2015-08-03T00:16:38 | 40,097,148 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 9,848 | rkt | typed-nanopass-model.rkt | #lang racket
(require redex)
(define-syntax quasiquote (make-rename-transformer #'term))
(define-syntax-rule (test-true arg)
(test-equal arg #t))
;; ---------------------------------------------------------------------------------------------------
; Language describing typed nanopass
(define-language typed-nanopass
(p (program e ...))
(he (λ (x ...) he)
(he he ...)
(begin he ...)
(if he he he)
base
x)
(e (define-type pt he)
(define-language l
(lt lp ...) ...)
(define-extended-language l l
(lt (+ lp ...) (- lp ...)) ...)
(define-pass (x (x : t) ...) (ret ...)
(pr ((x : t) ...) (ret ...)
[pp e ...] ...) ...
b)
(define-terms (x ...) e)
(e e ...)
(begin e ...)
(term t pat)
(new t he)
x
base)
(b e #f)
(ret [e : t] t)
(t (→ (t ...) (t ...)) l (l lt) pt unit str num bool)
(base string number boolean)
((x lt pt n l pr) variable-not-otherwise-mentioned)
;; Term patterns
(pat (unterm e)
(n pv ...))
(pv (unterm e)
x
base
()
(pv pve ...))
(pve pv \\...)
;; Language Pattern
(lp t (n lpv ...))
(lpv t
(lpv lpve ...))
(lpve lpv \\...)
;; Pass pattern
(pp (unterm e)
(n ppv ...))
(ppv x
(unterm e)
base
()
(ppv ppve ...))
(ppve ppv \\...))
(module+ test
(test-true
(redex-match? typed-nanopass p
`(program (define-type Integer integer?)
(define-language l
(Expr Integer)))))
(test-true
(redex-match? typed-nanopass p
`(program (define-type Integer integer?)
(define-language Lsrc
(Expr Integer
(when0 Integer Integer)
(if0 Integer Integer Integer)))
(define-extended-language Ltarget Lsrc
(Expr (+)
(- (when0 Integer Integer))))
(define-pass (remove-when0 [e : Lsrc]) (Ltarget)
(mkExpr ([e : Expr]) (Expr)
[(when0 (unterm cond) (unterm body))
(term (Ltarget Expr) (if0 (unterm cond)
(unterm body)
0))])
#f))))
(test-true
(redex-match? typed-nanopass lp
`(let ([Variable Expr] \\...) Expr)))
(test-true
(redex-match? typed-nanopass e
`(term (Ltarget Expr)
(let ([(unterm x) (unterm expr)])
(unterm
(mkExpr
(term (Ltarget Expr)
(let* ([(unterm x*) (unterm expr*)] \\...)
(unterm (mkExpr body))))))))))
(test-true
(redex-match? typed-nanopass p
`(program (define-type Variable (λ (x) (or (symbol? x) (identifier? x))))
(define-language Lsrc
(Expr (let ([Variable Expr] \\...) Expr)
(let* ([Variable Expr] \\...) Expr)))
(define-extended-language Ltarget Lsrc
(Expr (+)
(- (let* ([Variable Expr] \\...) Expr))))
(define-pass (remove-let* [e : Lsrc]) (Ltarget)
(mkExpr ([e : Expr]) (Expr)
[(let* () (unterm body))
(term (Ltarget Expr) (let* () (unterm body)))]
#;[(let* ([(unterm x) (unterm expr)]
[(unterm x*) (unterm expr*)] \\...)
body)
(term (Ltarget Expr)
(let ([(unterm x) (unterm expr)])
(unterm
(mkExpr
(term (Ltarget Expr)
(let* ([(unterm x*) (unterm expr*)] \\...)
(unterm (mkExpr body))))))))])
#f)))))
;; ---------------------------------------------------------------------------------------------------
; Type environments for typed nanopass
(define-extended-language typed-nanopass+Γ typed-nanopass
(Γ ((x : t) ...))
(Σ (t ...))
(Δ ((l : lt ...) ...)))
; Typing rules for typed nanopass
(define-judgment-form typed-nanopass+Γ
#:mode (types I I I I O O O O)
#:contract (types Γ Σ Δ e Γ Σ Δ (t ...))
[(side-condition (valid-types Γ (pt t ...)))
------------------------------------------------------------- "define-type"
(types Γ (t ...) Δ (define-type pt he) Γ (pt t ...) Δ (unit))]
[(where ((n ...) ...) ((pattern-tags lp ...) ...))
(where ((n_3 : t_3) ...) (splice-names ((n ...) ...) ((l lt) ...)))
(side-condition (valid-types ((n_3 : t_3) ... (x : t_1) ...) (l (l lt) ... t_2 ...)))
--------------------------------------------------------------------------------- "define-language"
(types ((x : t_1) ...)
(t_2 ...)
((l_3 : lt_3 ...) ...)
(define-language l (lt lp ...) ...)
((n_3 : t_3) ... (x : t_1) ...)
(l (l lt) ... t_2 ...)
((l : lt ...) (l_3 : lt_3 ...) ...)
(unit))]
[(where ((n ...) ...) ((pattern-tags lp ...) ...))
(where ((n_3 : t_3) ...) (splice-names ((n ...) ...) ((l lt) ...)))
(side-condition (valid-types ((x : t_1) ...) (t_2 ...)))
--------------------------------------------------------------- "define-extended-language"
(types ((x : t_1) ...)
(t_2 ...)
((l_1 : lt_1 ...) ... (l_src : lt_src ...) (l_2 : lt_2) ...)
(define-extended-langauge l l_src (lt lp ...) ...)
((n_3 : t_3) ... (x : t_1) ...)
(l (l lt) ... (l lt_src) ... t_2 ...)
((l_1 : lt_1 ...) ... (l_src : lt ...) (l_2 : lt_2) ...)
(unit))]
[--------------------------------------------------- "define-pass"
(types Γ
Σ
Δ
(define-pass (p [x : t_in] ...) (ret ...) b)
Γ
Σ
Δ
(unit))]
[(types ((x_1 : t_1) ...) Σ Δ e Γ_1 Σ_1 Δ_1 (t ...))
(side-condition (valid-types ((x : t) ... (x_1 : t_1) ...) Σ))
------------------------------------------------------------------------------------- "define-term"
(types ((x_1 : t_1) ...) Σ Δ (define-term (x ...) e) ((x : t) ... (x_1 : t_1) ...) Σ Δ (t ...))]
[(side-condition (valid-types Γ Σ))
---------------------------- "new"
(types Γ Σ Δ (new t he) Γ Σ Δ (t))]
[(side-condition (valid-types Γ Σ))
------------------------------------ "term"
(types Γ Σ Δ (term t pat) Γ Σ Δ (t))]
[(side-condition (valid-types Γ Σ))
---------------------------------- "begin-0"
(types Γ Σ Δ (begin) Γ Σ Δ (unit))]
[(types Γ Σ Δ e Γ_1 Σ_1 Δ_1 (t ...))
(side-condition (valid-types Γ Σ))
------------------------------------------- "begin-1"
(types Γ Σ Δ (begin e) Γ_1 Σ_1 Δ_1 (t ...))]
[(types Γ Σ Δ e_1 Γ_1 Σ_1 Δ_1 (t_1 ...))
(types Γ_1 Σ_1 Δ_1 (begin e_2 e ...) Γ_2 Σ_2 Δ_2 (t ...))
(side-condition (valid-types Γ Σ))
--------------------------------------------------------- "begin-*"
(types Γ Σ Δ (begin e_1 e_2 e ...) Γ_2 Σ_2 Δ_2 (t ...))]
[(types Γ Σ Δ e Γ_1 Σ_1 Δ_1 (→ (t_1 ...) (t ...)))
(types Γ Σ Δ e_1 Γ_2 Σ_2 Δ_2 (t_1)) ...
(side-condition (valid-types Γ Σ))
------------------------------------------------- "application"
(types Γ Σ Δ (e e_1 ...) Γ Σ Δ (t ...))]
[(side-condition (valid-types ((x_1 : t_1) ... (x : t) (x_2 : t_2) ...) Σ))
-------------------------------------------------------------------------- "reference"
(types ((x_1 : t_1) ... (x : t) (x_2 : t_2) ...) Σ Δ x
((x_1 : t_1) ... (x : t) (x_2 : t_2) ...) Σ Δ (t))]
[(side-condition (valid-types Γ Σ))
---------------------------------- "numbers"
(types Γ Σ Δ number Γ Σ Δ num)]
[(side-condition (valid-types Γ Σ))
---------------------------------- "boolean"
(types Γ Σ Δ boolean Γ Σ Δ bool)]
[(side-condition (valid-types Γ Σ))
---------------------------------- "strings"
(types Γ Σ Δ string Γ Σ Δ str)])
; Retrieve language types from language patterns
(define-metafunction typed-nanopass
pattern-tags : lp ... -> (n ...)
[(pattern-tags) ()]
[(pattern-tags (n pv ...) pat ...) (n (pattern-tags pat ...))]
[(pattern-tags t pat ...) (pattern-tags pat ...)])
; Splice a list of names and types into a form acceptable for Γ
(define-metafunction typed-nanopass
splice-names : ((n ...) ...) (t ...) -> ((n : t) ...)
[(splice-names () ()) ()]
[(splice-names ((n_1 ...) (n_2 ...) ...) (t_1 t_2 ...))
((n_1 : t_1) ... ,@(term (splice-names ((n_2 ...) ...) (t_2 ...))))])
; Ensure all types in Γ are valid types (in Σ)
(define-metafunction typed-nanopass+Γ
valid-types : Γ Σ -> boolean
[(valid-types () Σ) #t]
[(valid-types ((x : t) (x_rest : t_rest) ...) (t_1 ... t t_2 ...))
(valid-types ((x_rest : t_rest) ...) (t_1 ... t t_2 ...))]
[(valid-types Γ Σ) #f])
;; ---------------------------------------------------------------------------------------------------
(module+ test (test-results)) | true |
0bfbb5b248934990aafc58578a61adb97a5a5268 | 657061c0feb2dcbff98ca7a41b4ac09fe575f8de | /Racket/Exercises/Week2/primes.rkt | 9ec8ff285afb9d0af9acba707efdfc3ef887da36 | []
| no_license | vasil-pashov/FunctionalProgramming | 77ee7d9355329439cc8dd89b814395ffa0811975 | bb998a5df7b715555d3272c3e39b0a7481acf80a | refs/heads/master | 2021-09-07T19:31:05.031600 | 2018-02-27T20:50:44 | 2018-02-27T20:50:44 | 108,046,015 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 461 | rkt | primes.rkt | #lang racket
;Generate first cnt prime numbers
(define (is_prime? n)
(define (has_divisor? end)
(cond
[(= end 1) #f]
[(= (remainder n end) 0) #t]
[else (has_divisor? (- end 1))]
))
(not (has_divisor? (round (sqrt n)))))
(define (primes cnt)
(define (primes* n l)
(if [= (length l) cnt]
l
{if (is_prime? n)
(primes* (+ n 1) (append l (cons n '())))
(primes* (+ n 1) l)}))
(primes* 3 '(2))) | false |
ae11f2dce6635ec3e00d4ee33939dd9a94317bfe | 5e5dcfa1ac8b5ebadec5525bd57cc36c90a68d47 | /shared/fructerm/fructerm.rkt | f18fa0f54cdef641050a5fd9ca675d29b8613d1b | [
"Apache-2.0"
]
| permissive | standardgalactic/fructure | c6aa2c2fc66314425c80ac9954a0fea2767af217 | d434086052eab3c450f631b7b14dcbf9358f45b7 | refs/heads/master | 2023-07-08T13:07:42.565079 | 2020-09-24T02:06:10 | 2020-09-24T02:06:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 34,008 | rkt | fructerm.rkt | #lang racket
(require racket/hash
"fructerm-common.rkt"
memoize)
(module+ test
(require rackunit))
#|
fructerm
a syntax-rewriting-oriented pattern-matching system
in the style of racket/match, but where patterns can
be written at run-time.
currently implemented:
- pattern variables/data
- fixed-length list pattern
- ellipses-patterns
- quote (needs more tests)
- quasiquote/unquote (NON-NESTED)
- simple containment patterns
to-come:
- quasiquote/unquote NESTED
- unquote/splicing?
not necessary, but for the hell of it?
- non-binding wildcard
- complex containment patterns
- sets & hashes
|#
; rewriting internals
(provide runtime-match ; literals → pattern-templates → stx → stx
desugar
destructure ; stx → env
restructure) ; env → stx → stx
; temporary forms for annotation patterns
(provide anno-runtime-match
desugar-annotation)
; ratch is a match-like syntactic form
(provide ratch)
#| desugar-pattern : stx → stx
desugar-pattern makes pattern combinators
more explicit; in particular, it rewrites
bare sexprs into pconses, and, if they contain
ellipses literals, into pconses & p...es.
i'll also take the opportunity to introduce
some of the combinators.|#
(define (desugar stx)
(define D desugar)
(match stx
; don't parse quoted content
[`(quote ,_) stx]
; annotation patterns
#;[`(▹ / ,stx)
`(p/ ▹ ,(D stx))]
#;[`(_ / ,stx)
`(p/ _ ,(D stx))]
[`(,anns ... / ,stx)
`(p/ ,(D `(phash ,@anns)) ,(D stx))]
[`(,ann / ,stx)
`(p/ ,ann ,(D stx))]
[(list 'phash anns ... and-pat '...)
`(phash ,@(for/list ([ann anns])
(if (symbol? ann)
`(,ann ,ann)
ann))
,and-pat '...)]
[`(phash ,anns ...)
`(phash ,@(for/list ([ann anns])
(if (symbol? ann)
`(,ann ,ann)
ann)))]
; containment patterns
[`(⋱ ,pat)
(D `(p⋱ _ ,pat))]
[`(⋱ (until ,?-pat) ,pat)
(D `(p⋱until _ ,?-pat ,pat))]
[`(,id ⋱ ,pat)
(D `(p⋱ ,id ,pat))]
[`(,id ⋱+ ,pat)
(D `(p⋱+ ,id ,pat))]
[`(,id ⋱ (until ,?-pat) ,pat)
(D `(p⋱until ,id ,?-pat ,pat))]
#| lists and ellipses patterns:
these forms can be most readily understood
by examining their reconstructions; into cons
and append respectively. explictly, (p... a b)
greedily matches pattern a to the initial
segments of a list|#
[`(,(and (not 'phash)
(not 'quote)
(not 'p/)
(not 'p⋱)
(not 'p⋱+)
(not 'p⋱until)
(not 'p...)
(not 'pcons)) . ,_)
(D (foldr
(λ (x acc)
(match acc
[`(,_ ,(== '...) ,y ,ys ...)
`(p... ,x ,y)]
[_ `(pcons ,x ,acc)]))
'() stx))]
; budget recursion scheme
[(? list?) (map D stx)]
[_ stx]))
; quasiquotation desugaring (this is WIP)
(define (desugar-qq stx [quote-level 0])
(define D (curryr desugar-qq quote-level))
(match stx
[`(quote ,_) stx]
[`(quasiquote ,(and x (not (? list?))))
`(quote ,x)]
[`(quasiquote ,(? list? xs))
#:when (equal? 0 quote-level)
(D (map (curryr desugar-qq (add1 quote-level)) xs))]
[(and (? symbol?)
#;(not 'quote)
#;(not 'quasiquote)
#;(note 'unquote)
(not 'p/)
(not 'p⋱)
(not 'p⋱+)
(not 'p⋱until)
(not 'p...)
(not 'pcons)
(not 'phash))
(match quote-level
[0 stx]
[_ `(quote ,stx)])]
[(list 'unquote x)
; #:when (quote-level . = . 1)
(when (zero? quote-level) (error "bad unquote"))
(desugar-qq x (sub1 quote-level))]
; budget recursion scheme
[(? list?) (map D stx)]
[_ stx]))
(define (desugar-annotation stx)
(define D desugar-annotation)
(match stx
; annotation patterns
[`(,ann / ,stx)
`(p/ ,ann ,(D stx))]
[`(▹ ,stx)
`(p/ ▹ ,(D stx))]
[(or (? symbol?) (? empty?) (? number?))
stx]
[`(,(and spec
(or 'quote
'p/
'p⋱
'p⋱+
'p⋱until
'p...
'pcons
'phash))
,stx ...)
`(,spec ,@(map D stx))]
[(? list?)
#; (println stx)
`(p/ () ,(map D stx))]
))
; wip
(define (apply-expr f stx)
(match stx
#;[`(quasiquote ,x) 0]
#;[(list 'unquote x) 0]
[`(quote ,p)
`(quote ,(f p))]
[`(pcons ,p ,ps)
`(pcons ,(f p) ,(f ps))]
[`(p... ,p ,ps)
`(p... ,(f p) ,(f ps))]
[`(p⋱ ,(? symbol? id) ,arg)
`(p⋱ ,id ,(f arg))]
[(? symbol?) stx]
[(or (? number?) (? empty?)) stx]
[(? list?) (map f stx)])
)
; wip
(define ((quote-literals literals) stx)
(define literal?
(curry hash-has-key? literals))
(match stx
[(? literal?) `(quote ,stx)]
[`(quote ,p) stx]
[_ (apply-expr (quote-literals literals) stx)]))
; wip
#;(define ((process-qq quote-level) stx)
(println "process-qq")
(println quote-level)
(println stx)
(when (quote-level . < . 0) (error "bad unquote"))
(match stx
[(? number?) stx]
[`(quote ,x) `(quote ,x)]
[`(quasiquote ,x)
((process-qq (add1 quote-level)) x)]
[(and (? symbol?))
#:when (not (zero? quote-level))
`(quote ,stx)]
[(list 'unquote x)
#:when (equal? 1 quote-level)
x]
[(list 'unquote x)
#:when (quote-level . > . 1)
(match ((process-qq (sub1 quote-level)) x)
[`(quote ,w) (list 'unquote ((process-qq (sub1 quote-level)) w))]
[_ ((process-qq (sub1 quote-level)) x)])
]
[(? list?)
#:when (not (zero? quote-level))
(println "lsit case")
(println stx)
(println (second stx))
(map (process-qq quote-level) stx)]))
#;(define (explicit⋱ stx)
(match stx
[`(,id ⋱ ,pat)
`(p⋱ ,id ,pat)]))
(module+ test
(check-equal? ((quote-literals #hash((a . _))) 'a)
'(quote a))
(check-equal? ((quote-literals #hash((a . _))) '(1 a))
'(1 (quote a)))
(check-equal? ((quote-literals #hash((b . _))) '(1 a))
'(1 a))
(check-equal? ((quote-literals #hash((b . _))) '(1 (pcons a b)))
'(1 (pcons a (quote b)))))
; desugar examples
(module+ test
(check-equal? (desugar `(a ⋱ 1))
'(p⋱ a 1))
(check-equal? (desugar `(a ⋱+ 1))
'(p⋱+ a 1))
(check-equal? (desugar `(a ⋱ (until 2) 1))
'(p⋱until a 2 1))
(check-equal? (desugar `(a ⋱ (1 b ...)))
'(p⋱ a (pcons 1 (p... b ()))))
(check-equal? (desugar '(1 2 3 d ... 5 f ... 7 8))
'(pcons 1 (pcons 2 (pcons 3 (p... d (pcons 5 (p... f (pcons 7 (pcons 8 ())))))))))
)
(module+ test
(check-equal? (desugar '(ann1 (ann2 val2) / 0))
`(p/ (phash (ann1 ann1) (ann2 val2)) 0))
(check-equal? (destructure #hash() #hash()
'(p/ #hash((ann1 . 1) (ann2 . 2)) 0)
'(p/ (phash (ann1 ann1) (ann2 val2)) 0))
#hash((ann1 . 1) (val2 . 2)))
(check-equal? (destructure #hash() #hash()
'(p/ #hash((ann1 . 1) (ann2 . 2)) 0)
'(p/ (phash (ann1 ann1)) 0))
#hash((ann1 . 1)))
(check-equal? (destructure #hash() #hash()
'(p/ #hash((ann2 . 2)) 0)
'(p/ (phash (ann1 ann1) (ann2 val2)) 0))
'no-match)
(check-equal? (runtime-match #hash()
`(((p/ (phash (ann1 ann1) (ann2 val2)) 0)
(p/ (phash (ann2 val2)) 0)))
'(p/ #hash((ann1 . 1) (ann2 . 2)) 0))
`(p/ #hash((ann2 . 2)) 0))
(check-equal? (runtime-match #hash()
`((((ann1 ann1) (ann2 val2) / 0)
((ann2 val2) ann1 / 0)))
'(p/ #hash((ann1 . 1) (ann2 . 2)) 0))
`(p/ #hash((ann1 . 1) (ann2 . 2)) 0))
; note below handling of the non-variable ann2
#| need a better way of handling this generally
basically if a pair is specified, the first thing
should always be interpreted as a literal, and
the second thing should be a pattern/template.
if a single thing is specified, we want it to
expand into (literal pat-var) in patterns,
but (literal whatever) in templates. since
i dont care about the values for now, i'm
going to come back to this later. |#
(check-equal? (runtime-match #hash((ann2 . _))
`((((ann1 ann1) (ann2 val2) / 0)
(ann2 ann1 / 0)))
'(p/ #hash((ann1 . 1) (ann2 . 2)) 0))
`(p/ #hash((ann1 . 1) (ann2 . ann2)) 0))
; capture rest of hash subpattern:
(check-equal? (destructure #hash() #hash()
#hash((ann1 . 2)(ann2 . 2))
'(phash others ...))
#hash((others . #hash((ann1 . 2) (ann2 . 2)))))
(check-equal? (destructure #hash() #hash()
#hash((ann1 . 2)(ann2 . 2))
'(phash (ann1 a) others ...))
#hash((a . 2)(others . #hash((ann2 . 2)))))
(check-equal? (destructure #hash() #hash()
#hash((ann1 . 1) (ann2 . 2))
'(phash (ann2 val) others ...))
#hash((val . 2)(others . #hash((ann1 . 1)))))
(check-equal? (runtime-match #hash()
'(((phash others ...)
(phash others ...)))
#hash((ann1 . 1) (ann2 . 2)))
#hash((ann1 . 1) (ann2 . 2)))
(check-equal? (runtime-match #hash()
'(((phash (ann1 val) others ...)
(phash others ...)))
#hash((ann1 . 1) (ann2 . 2)))
#hash((ann2 . 2)))
(check-equal? (runtime-match #hash()
'(((phash (ann2 val) others ...)
(phash (ann1 val) others ...)))
#hash((ann1 . 1) (ann2 . 2)))
#hash((ann1 . 2)))
(check-equal? (runtime-match #hash()
'(((phash (ann2 val) others ...)
(phash (ann4 val) others ...)))
#hash((ann1 . 1) (ann2 . 2) (ann3 . 3)))
#hash((ann1 . 1) (ann3 . 3) (ann4 . 2)))
)
; helpers for destructuring
#| bind : maybe-env → (env → maybe-env) → maybe-env
passthrough match failures |#
(define (bind x f)
(if (equal? 'no-match x)
'no-match
(f x)))
#| append-hashes : hash → hash → hash
for incrementally binding lists along folds|#
(define (append-hashes h1 h2)
(hash-union
h1
; must be a better way to do this
; which doesnt involve rebuilding the hash
(make-hash (hash-map h2 (λ (k v) (cons k (list v)))))
#:combine (λ (a b) (append a b))))
#| destructure : stx → env
info forthcoming. see tests |#
(define/memo* (destructure literals c-env arg pat)
#;(println `(destructure ,arg ,pat ,c-env))
(define D (curry destructure literals c-env))
(define (accumulate-matches pat x acc)
(bind acc
(λ (_) (bind (destructure literals #hash() x pat)
(curry append-hashes acc)))))
(define constructor-id?
(curry hash-has-key? literals))
(define literal?
(disjoin number? constructor-id? empty?))
; note the empty set case
(define pattern-variable?
(conjoin symbol? (negate literal?)))
(match* (pat arg)
[((? literal?) (== pat))
c-env]
[((? pattern-variable?) _)
(hash-set c-env pat arg)]
[(`(quote ,p) _)
#:when (equal? p arg)
c-env]
; annotation patterns
[(`(p/ (phash ,pairs ...) ,stx-pat)
`(p/ ,(? hash? ann-arg) ,stx-arg))
(bind (D ann-arg `(phash ,@pairs))
(λ (env1)
(destructure literals env1 stx-arg stx-pat)))]
[((list 'phash pairs ... and-val ''...)
(? hash? ann-arg))
(bind (D ann-arg `(phash ,@pairs))
(λ (new-env)
#;(println new-env)
(define remainder
(for/fold ([env ann-arg])
([pair pairs])
#;(println env)
(match pair
[`(,key ,value)
#;(println `(removing ,key))
(hash-remove env key)])))
#;(println remainder)
(hash-set new-env and-val remainder)))]
[((list 'phash pairs ... and-val '...)
(? hash? ann-arg))
(bind (D ann-arg `(phash ,@pairs))
(λ (new-env)
#;(println new-env)
(define remainder
(for/fold ([env ann-arg])
([pair pairs])
#;(println env)
(match pair
[`(,key ,value)
#;(println `(removing ,key))
(hash-remove env key)])))
#;(println remainder)
(hash-set new-env and-val remainder)))]
[(`(phash ,pairs ...)
(? hash? ann-arg))
(for/fold ([env c-env])
([pair pairs])
(match env
['no-match 'no-match]
[_
(match pair
[`(,key ,pat-value)
(bind (hash-ref ann-arg key 'no-match)
(λ (arg-value)
(destructure literals env arg-value pat-value)))])]))]
[(`(p/ ,ann-pat ,stx-pat) `(p/ ,ann-arg ,stx-arg))
; obviously not full generality
#:when (and (or (symbol? ann-pat)
(number? ann-pat)
(equal? '() ann-pat))
(equal? ann-pat ann-arg))
(D stx-arg stx-pat)]
; containment patterns
[(`(p⋱ ,context-name ,(app (curry D arg) (? hash? new-env)))
_) ; should this be (? list?) ?
(hash-union new-env (hash-set c-env context-name identity)
#:combine/key (λ (k v v1) v))]
; do i actually want to overwrite keys above?
; was getting an error in pre-fructure
; the below is exponential without memoization
[(`(p⋱ ,context-name ,find-pat)
`(,xs ...))
; split arg list at first match
(define-values (initial-segment terminal-segment)
(splitf-at xs
(λ (x)
(not (hash? (D x `(p⋱ ,context-name ,find-pat)))))))
; draw the rest of the owl
(match* (initial-segment terminal-segment)
[((== xs) _) 'no-match]
[(`(,is ...) `(,hit ,ts ...))
(define new-env (D hit `(p⋱ ,context-name ,find-pat)))
(hash-set new-env context-name
(compose (λ (x) `(,@is ,x ,@ts))
(hash-ref new-env context-name)))])]
[(`(p⋱+ ,context-name ,find-pat)
`(,xs ...))
(define (matcher stx)
(match (D stx find-pat)
['no-match #f]
[_ #t]))
(match-define (list ctx contents)
(multi-containment matcher xs))
#;(println `(find-pat ,find-pat ctx ,ctx contents ,contents))
(define new-env (hash-set c-env
context-name ctx))
#;(define list-of-hashes
(map (λ (x) (D x find-pat)) contents))
(define newer-env
(for/fold ([env new-env])
([c contents]
#;[x xs])
(append-hashes env (D c find-pat))))
newer-env]
; list and ellipses patterns
[(`(pcons ,first-pat ,rest-pat)
`(,first-arg ,rest-arg ...))
(bind (D (first arg) first-pat)
(λ (h) (bind (D rest-arg rest-pat)
; not sure how duplicates end up in here
; but they do, somehow, due to annotation patterns
(λ (x)
(hash-union
h x
#:combine/key
(λ (k v1 v2) (if (equal? v1 v2)
v1
(error "error")))))
#;(curry hash-union h))))]
[(`(p... ,p ,ps)
(? list?))
(define/match (greedy arg-init arg-tail)
[('() _)
(bind (D arg-tail ps)
(bind (D `() p)
; see above ...
(λ (x)
(λ (y)
(hash-union
x y
#:combine/key
(λ (k v1 v2) (if (equal? v1 v2)
v1
(error "error"))))))
#;(curry hash-union)))]
[(`(,as ... ,b) `(,cs ...))
(match (D cs ps)
['no-match (greedy as `(,b ,@cs))]
[new-env
(match (foldl (curry accumulate-matches p)
#hash() `(,@as ,b))
['no-match (greedy as `(,b ,@cs))]
[old-env (hash-union new-env old-env)])])])
(greedy arg '())]
[(_ _) 'no-match]))
#| destructure : literals → env → stx
info forthcoming. see tests |#
(define (restructure types env stx)
#;(println `(restructure ,types ,env ,stx))
(define R (curry restructure types env))
(define (constructor-id? id)
(hash-has-key? types id))
(define literal?
(disjoin number? boolean? string? constructor-id? empty?))
(define variable?
(conjoin symbol? (negate literal?)))
(match stx
[(? literal? d) d]
[(? variable? id)
(if (hash-has-key? env id)
(hash-ref env id)
id)
; HACK for fructure: treat unbound variables as literals
; introduced this when implementing pattern painting
; because when i create new transforms from painted structure
; the identifier chars in those structures are undeclared literals
#;(hash-ref env id)] ; todo: add error message
[`(quote ,d) d]
; list and ellipses templates
[`(pcons ,p ,ps)
(cons (R p) (R ps))]
[`(p... ,p ,ps)
(append (R p) (R ps))]
; containment templates
[`(p⋱ ,(? symbol? id) ,arg)
((hash-ref env id) (R arg))]
; wip
[`(p⋱+ ,(? symbol? id) ,arg)
(apply (hash-ref env id) (map R arg))]
; annotation template
[`(p/ (phash ,pairs ...) ,stx-tem)
`(p/ ,(R `(phash ,@pairs)) ,(R stx-tem))]
[(list 'phash pairs ... and-val ''...)
; NOTE HACKY DOUBLE-QUOTE ABOVE!!!!!!!
(define pair-hash
(for/hash ([pair pairs])
(match pair
[`(,key ,value)
(values key (R value))])))
#;(println `(blarg ,(hash-ref env and-val) ,pair-hash))
(hash-union (hash-ref env and-val) pair-hash
#:combine/key (λ (k v1 v2) v2))]
[`(phash ,pairs ...)
#;(println env)
(for/hash ([pair pairs])
(match pair
[`(,key ,value)
(values key (R value))]))]
[`(p/ ,ann-tem ,stx-tem)
; obviously not full generality
#:when (or (symbol? ann-tem)
(number? ann-tem)
(equal? ann-tem '()))
`(p/ ,ann-tem ,(R stx-tem))]))
#| runtime-match : literals → pattern/templates → stx → stx |#
(define/memo* (runtime-match literals pat-tems source)
#;(println `(runtime-match ,pat-tems ,source))
(define new-pat-tems (map runtime-match-rewriter pat-tems))
(match new-pat-tems
[`() 'no-match]
[`((,(app (compose desugar desugar-qq) pattern)
,(app (compose desugar desugar-qq) template))
,other-clauses ...)
#;(println `(pat-tem-src ,pattern ,template ,source))
#;(println `(des ,(destructure types #hash() source pattern)))
(define env (destructure literals #hash() source pattern))
(if (equal? 'no-match env)
(runtime-match literals other-clauses source)
(restructure literals env template))]))
(define/memo* (anno-runtime-match types pat-tems source)
(define new-pat-tems (map runtime-match-rewriter pat-tems))
(match new-pat-tems
[`() 'no-match]
[`((,(app (compose desugar
desugar-qq
desugar-annotation) pattern)
,(app (compose desugar
desugar-annotation) template))
,other-clauses ...)
(define env (destructure types #hash() source pattern))
(if (equal? 'no-match env)
(anno-runtime-match types other-clauses source)
(restructure types env template))]))
(module+ test
(check-equal? (desugar-annotation '(▹ / a))
'(p/ ▹ a))
(check-equal? (desugar-annotation '(p/ ▹ 2))
'(p/ ▹ 2))
(check-equal? (desugar-annotation '(p/ ▹ (p/ () 2)))
'(p/ ▹ (p/ () 2)))
(check-equal? (destructure #hash() #hash() '(p/ ▹ 1) '(p/ ▹ 1))
#hash())
(check-equal? (destructure #hash() #hash() '(p/ ▹ 1) '(p/ ▹ 1))
#hash())
(check-equal? (anno-runtime-match #hash() '(((▹ / 1) (▹ / 1)))
`(p/ ▹ 1))
`(p/ ▹ 1))
(check-equal? (anno-runtime-match #hash() '(((▹ / a) (▹ / 2)))
`(p/ ▹ 1))
`(p/ ▹ 2))
(define literals
#hash((app . ())
(λ . ())
(let . ())
(pair . ())
(◇ . ())
(▹ . ())
(⊙ . ())
(expr . ())))
(define initial-state
'(p/ ()
(◇ (p/ ▹
(p/ ()
(⊙ expr))))))
(check-equal? (anno-runtime-match
literals
'([⋱
(▹ (⊙ expr))
(app (▹ (⊙ expr)) (⊙ expr))])
initial-state)
'(p/ ()
(◇
(p/ ()
(app
(p/ ▹ (p/ () (⊙ expr)))
(p/ () (⊙ expr)))))))
(check-equal? (anno-runtime-match
literals
'([⋱
(▹ (⊙ expr))
(▹ 0)])
'(p/ ()
(◇
(p/ ()
(app (p/ ▹ (p/ () (⊙ expr)))
(p/ () (⊙ expr)))))))
'(p/ () (◇ (p/ () (app (p/ ▹ 0) (p/ () (⊙ expr)))))))
)
#| runtime-match-rewriter : pattern/templates → pattern/templates
an ad-hoc rewriting phase; possible seed for macro system |#
(define (runtime-match-rewriter pat-tem)
(match pat-tem
[(or `(,a ⋱ ,b) `(⋱ ,a ,b))
(let ([ctx (gensym)])
`((p⋱ ,ctx ,a) (p⋱ ,ctx ,b)))]
[_ pat-tem]))
#| ratch : looks like match but tastes like fructerm |#
(define-syntax-rule (ratch source clauses ...)
(runtime-match #hash() '(clauses ...) source))
; ratch example usage
(module+ test
(check-equal?
(ratch '(let ([a 1] [b 2]) 0)
[(form ([id init] ...) body)
(id ... init ...)])
(match '(let ([a 1] [b 2]) 0)
[`(,form ([,id ,init] ...) ,body)
`(,@id ,@init)])))
#| EXAMPLES & TESTS |#
(module+ test
; destructure examples and tests
(define (test-destr source pattern)
(destructure #hash() #hash()
source (desugar pattern)))
; destructure literal/variable tests
(check-equal? (test-destr 1 1)
#hash())
(check-equal? (test-destr 1 'a)
#hash((a . 1)))
(check-equal? (test-destr 'a 'a)
#hash((a . a)))
; destructure quote tests
(check-equal? (test-destr 'a '(quote a))
#hash())
(check-equal? (test-destr '(quote a) 'a)
#hash((a . (quote a))))
(check-equal? (test-destr 'a '(quote b))
'no-match)
(check-equal? (test-destr '(a 1) '((quote a) 1))
#hash())
(check-equal? (test-destr '(a 1) '((quote a) b))
#hash((b . 1)))
(check-equal? (test-destr '(a 1) '(quote (a 1)))
#hash())
; destructure quasiquote/unquote tests
(check-equal?
(ratch '(if 1 2 3)
[`(if ,a ,b ,c)
`(cond [,a ,b]
[else ,c])])
(match '(if 1 2 3)
[`(if ,a ,b ,c)
`(cond [,a ,b]
[else ,c])]))
;
; FIX BUG
#;
(check-equal?
(ratch '(if 1 2 3)
[`(if ,a ,b ,c)
`(cond [`,a ,b]
[else ,c])])
(match '(if 1 2 3)
[`(if ,a ,b ,c)
`(cond [`,a ,b]
[else ,c])]))
; destructure tests for pcons pattern
(check-equal? (test-destr '() '(pcons () anything))
'no-match)
(check-equal? (test-destr '(1) '(pcons 1 ()))
#hash())
(check-equal? (test-destr '(1) '(pcons a ()))
#hash((a . 1)))
(check-equal? (test-destr '(1 2) '(pcons 1 (2)))
#hash())
(check-equal? (test-destr '(1 2) '(pcons 1 (pcons 2 ())))
#hash())
(check-equal? (test-destr '(1 2 3) '(pcons a (2 3)))
#hash((a . 1)))
(check-equal? (test-destr '(1 2 3) '(pcons 1 (pcons 2 (pcons 3 ()))))
#hash())
; destructure tests for p... pattern
(check-equal? (test-destr '() '(p... a ()))
#hash((a . ())))
(check-equal? (test-destr '(1) '(p... a ()))
#hash((a . (1))))
(check-equal? (test-destr '(1 2) '(p... a (pcons 2 ())))
#hash((a . (1))))
; destructure tests for p... pattern with complex subpattern
(check-equal? (test-destr
'((1 1) (1 2) (4 5) 3 4)
'(p... (a b) (3 4)))
#hash((a . (1 1 4)) (b . (1 2 5))))
; destructure tests for ... multi-pattern
; FIX THIS BUG!!!!!!
#; (check-equal? (test-destr
'()
'(1 ...))
#hash())
(check-equal? (test-destr
'(1)
'(2 ...))
'no-match)
(check-equal? (test-destr
'(a)
'(1 ...))
'no-match)
(check-equal? (test-destr
'(1)
'(1 ...))
#hash())
(check-equal? (test-destr
'()
'(f ...))
#hash((f . ())))
(check-equal? (test-destr
'(1)
'(f ...))
#hash((f . (1))))
(check-equal? (test-destr
'(1)
'(1 f ...))
#hash((f . ())))
(check-equal? (test-destr
'(1 2 3 4 5)
'(1 2 d ...))
'#hash((d . (3 4 5))))
(check-equal? (test-destr
'(1 2 3 4 5)
'(1 2 3 d ... 5))
'#hash((d . (4))))
(check-equal? (test-destr
'(1 2 3 4 5)
'(a ... 2 b ... 5))
#hash((a . (1)) (b . (3 4))))
(check-equal? (test-destr
'(1 2 3 4 5)
'(1 a ... 2 b ... 5))
#hash((a . ()) (b . (3 4))))
(check-equal? (test-destr
'(1 2 3 4 5)
'(1 2 3 d ... 5 f ...))
#hash((f . ()) (d . (4))))
(check-equal? (test-destr
'(1 2 3 4 5 6)
'(1 2 3 d ... 5 f ... 6))
#hash((f . ()) (d . (4))))
(check-equal? (test-destr
'(1 2 3 4 5 6 7)
'(1 2 3 d ... 5 f ... 7))
#hash((f . (6)) (d . (4))))
(check-equal? (test-destr
'(1 2 3 4 4 5 6 6 6 7 8)
'(1 2 3 d ... 5 f ... 7 8))
#hash((f . (6 6 6)) (d . (4 4))))
; destructure tests for ... multi-pattern with complex subpattern
(check-equal? (test-destr
'(1 (4 1 (6 2)) (4 3 (6 4)))
'(1 (4 a (6 b)) ...))
#hash((a . (1 3)) (b . (2 4))))
; destructure tests for nested ... multi-pattern
(check-equal? (test-destr
'(1 (1 2 3) (4 5 6))
'(1 (a ...) ...))
#hash((a . ((1 2 3) (4 5 6)))))
(check-equal? (test-destr
'(1 (1 2 3) (1 5 6))
'(1 (1 a ...) ...))
#hash((a . ((2 3) (5 6)))))
(check-equal? (test-destr
'(1 (1 0 0 0 1 0 0) (1 0 1 0 0 0))
'(1 (1 a ... 1 b ...) ...))
#hash((a . ((0 0 0) (0)))
(b . ((0 0) (0 0 0)))))
; destructure tests for simple containment pattern
(define contain-test
(λ (source pattern)
(destructure #hash() #hash()
source (desugar pattern))))
(check-equal? ((hash-ref (contain-test
'(1)
'(a ⋱ 1))
'a)
1)
'(1))
(check-equal? ((hash-ref (contain-test
'(1 0)
'(a ⋱ 1))
'a)
1)
'(1 0))
(check-equal? ((hash-ref (contain-test
'(0 1)
'(a ⋱ 1))
'a)
1)
'(0 1))
(check-equal? ((hash-ref (contain-test
'(0 1 0)
'(a ⋱ 1))
'a)
1)
'(0 1 0))
(check-equal? ((hash-ref (contain-test
'(0 (0 1) 0)
'(a ⋱ 1))
'a)
1)
'(0 (0 1) 0))
; TODO: should this be valid? or only match lists???
(check-equal? ((hash-ref (contain-test
1
'(a ⋱ 1))
'a)
2)
2)
(check-equal? (hash-ref (contain-test
1
'(a ⋱ b))
'b)
1)
(check-equal? ((hash-ref (contain-test
'(0 2)
'(a ⋱ (0 b)))
'a)
'(0 3))
'(0 3))
(check-equal? ((hash-ref (contain-test
'(0 (0 2) 0)
'(a ⋱ (0 b)))
'a)
'(0 3))
'(0 (0 3) 0))
; integration tests: basic restructuring
(check-equal? (runtime-match #hash() '((a 2)) '1)
2)
(check-equal? (runtime-match #hash() '(((a b) b)) '(1 2))
2)
(check-equal? (runtime-match #hash() '(((a ...) (a ...))) '(1 2))
'(1 2))
; BUG!!!! returns '(0 (1 2)). Need to change restructuring approach
; possibly destructuring approach, for both ... and ⋱+
#;
(check-equal? (runtime-match #hash() '(((a ...) ((0 a) ...))) '(1 2))
'((0 1) (0 2)))
; notes on trying to fix this:
#; (match '(0 0 1 0 0 0)
[`(,a ... 1 ,b ...)
`((x ,a ,(y b) ...) ...)])
#; (match '(0 0 1 0 0 0)
[(p... a (pcons 1 (p... b '())))
(p... (pcons 'x (pcons a (p... (pcons y (pcons b '()))'())))'())])
#; (match '(0 0 1 0 0 0)
[`(,a ... 1 ,b ...)
`(,@(map (λ (a) `(x ,a ,@(map (λ (b) `(y ,b)) b))) a))])
#; (match '(0 0 1 0 0 0)
[`(,a ... 1 ,b ...)
`((x ,a ,(y b) ...) ...)])
; integration tests: ellipses restructuring
(check-equal? (runtime-match #hash() '(((a b ...) (b ... (a)))) '(1 2 3))
'(2 3 (1)))
(check-equal? (runtime-match #hash() '(((a b ...) (b ... (a)))) '(1))
'((1)))
; integration tests: basic containment de/restructuring
(check-equal? (runtime-match #hash()
'(((a ⋱ 1)
(a ⋱ 2)))
'(1))
'(2))
(check-equal? (runtime-match #hash()
'(((a ⋱ 1)
(a ⋱ 2)))
'(0 1))
'(0 2))
(check-equal? (runtime-match #hash()
'(((a ⋱ 1)
(a ⋱ 2)))
'(0 (0 0 1) 0))
'(0 (0 0 2) 0))
(check-equal? (runtime-match #hash()
'(((a ⋱ (0 b))
(a ⋱ (1 b))))
'(0 (0 2) 0))
'(0 (1 2) 0))
; todo: more examples!
; multi-containment pattern tests
(check-equal? ((hash-ref (contain-test
'(0 1)
'(a ⋱+ 1))
'a)
2)
'(0 2))
(check-equal? ((hash-ref (contain-test
'(0 1 1)
'(a ⋱+ 1))
'a)
2 3)
'(0 2 3))
#;
(check-equal? (runtime-match #hash()
'(((a ⋱+ (0 b))
(a ⋱+ ((1 b)))))
'(0 (0 2) 0))
'(0 (1 2) 0))
#;
(check-equal? (runtime-match #hash()
'(((a ⋱+ (0 b))
(a ⋱+ (1 b))))
'(0 (0 2) (0 3)))
'(0 (1 2) (1 3)))
) | true |
3d7d6ccca95c312cfea9c8581a29940a8f5e9d9b | 0ef2678b48fd4ace9b2b941224a04283a287e7ed | /cover-test/cover/tests/submods/prog.rktl | 01ea0dc3e65f2262715e9ee3ba27cf0d7fd70961 | [
"MIT"
]
| permissive | florence/cover | 7cdc72379f6afdf7c9e06a20f6581d19333c24d1 | bc17e4e22d47b1da91ddaa5eafefe28f4675e85c | refs/heads/master | 2022-05-31T21:40:14.776498 | 2020-03-10T13:59:25 | 2020-03-10T13:59:25 | 24,347,312 | 42 | 11 | MIT | 2022-05-15T12:22:00 | 2014-09-22T22:04:32 | Racket | UTF-8 | Racket | false | false | 12 | rktl | prog.rktl | ((1 35))
()
| false |
132621630d2dbce45bbf566b67feb8855dddb754 | 375fdeeab76639fdcff0aa64a9b30bd5d7c6dad9 | /go/board.rkt | 2a28ef4f22b0a539c6fb5837f784e1424658c0bf | []
| no_license | VincentToups/racket-lib | 64fdf405881e9da70753315d33bc617f8952bca9 | d8aed0959fd148615b000ceecd7b8a6128cfcfa8 | refs/heads/master | 2016-09-08T01:38:09.697170 | 2012-02-02T20:57:11 | 2012-02-02T20:57:11 | 1,755,728 | 15 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 841 | rkt | board.rkt | #lang racket
(require utilities/lists
racket/match
racket/dict
racket/gui
utilities/simple-infix)
(struct stone (x y index color))
(struct board (size stones))
(define black 'black)
(define white 'white)
(define (strictly-between n min max)
(and (> n min)
(< n max)))
(define (position-on-board? a-board x y)
(and ($ x strictly-between -1 (board-size a-board))
($ y strictly-between -1 (board-size a-board))))
(define (add-stone a-board color x y)
(if (and
(x y-on-board? a-board x y)
(x y-empty? a-board x y))
(copy-struct board a-board
[stones
(add-to-front
(stone x y (length (board-stones a-board))
color)
(board-stones a-board))])
#f))
| false |
93f9a1c4348e0a9113dcbdd8df816af430f03359 | 7bd256115d331bff8025f2db4643a07572bdabfe | /types.rkt | a34decde0bc54e09a4102cb86ffb885f70869447 | []
| no_license | endobson/contracts | 4e5faa929a42ea14f93f9925b4b1ed9bdd17751e | 20b5c86daff6800ce5eeb46b0a20ab9d2d124468 | refs/heads/master | 2020-04-10T20:10:22.436099 | 2013-10-07T00:16:42 | 2013-10-07T00:16:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 19,254 | rkt | types.rkt | #lang racket
(require
"combinators.rkt"
typed-racket/utils/utils
syntax/parse
(rep type-rep filter-rep object-rep)
(typecheck internal-forms)
(utils tc-utils require-contract any-wrap)
(env type-name-env)
(types resolve utils)
(prefix-in t: (types abbrev numeric-tower))
(private parse-type)
racket/match unstable/match syntax/struct syntax/stx racket/syntax racket/list
(only-in racket/contract -> ->* case-> cons/c flat-rec-contract contract-out any/c)
(for-template racket/base racket/contract racket/set (utils any-wrap)
(prefix-in t: (types numeric-predicates))
(only-in unstable/contract sequence/c)))
(require "structures.rkt" "combinators.rkt")
(provide
(contract-out
[type->static-contract
(parametric->/c (a) ((Type/c (-> a)) (#:typed-side boolean?) . ->* . (or/c a static-contract?)))]))
(define any-wrap/sc (chaperone/sc #'any-wrap/c))
(define (no-duplicates l)
(= (length l) (length (remove-duplicates l))))
(define (from-typed? side)
(case side
[(typed both) #t]
[(untyped) #f]))
(define (from-untyped? side)
(case side
[(untyped both) #t]
[(typed) #f]))
(define (flip-side side)
(case side
[(typed) 'untyped]
[(untyped) 'typed]
[(both) 'both]))
(struct triple (untyped typed both))
(define (triple-lookup trip side)
(case side
((untyped) (triple-untyped trip))
((typed) (triple-typed trip))
((both) (triple-both trip))))
(define (same sc)
(triple sc sc sc))
(define (type->static-contract type init-fail #:typed-side [typed-side #t])
(let/ec return
(define (fail) (return (init-fail)))
(let loop ([type type] [typed-side (if typed-side 'typed 'untyped)] [recursive-values (hash)])
(define (t->sc t #:recursive-values (recursive-values recursive-values))
(loop t typed-side recursive-values))
(define (t->sc/neg t #:recursive-values (recursive-values recursive-values))
(loop t (flip-side typed-side) recursive-values))
(define (t->sc/both t #:recursive-values (recursive-values recursive-values))
(loop t 'both recursive-values))
(define (t->sc/method t) (t->sc/function t fail typed-side recursive-values loop #t))
(define (t->sc/fun t) (t->sc/function t fail typed-side recursive-values loop #f))
(match type
[(or (App: _ _ _) (Name: _)) (t->sc (resolve-once type))]
[(Univ:) (if (from-typed? typed-side) any-wrap/sc any/sc)]
[(Mu: var (Union: (list (Value: '()) (Pair: elem-ty (F: var)))))
(listof/sc (t->sc elem-ty))]
[t (=> fail) (or (numeric-type->static-contract t) (fail))]
[(Base: sym cnt _ _)
(flat/sc #`(flat-named-contract '#,sym (flat-contract-predicate #,cnt)))]
[(Refinement: par p?)
(and/sc (t->sc par) (flat/sc p?))]
[(Union: elems)
(apply or/sc (map t->sc elems))]
[(and t (Function: _)) (t->sc/fun t)]
[(Set: t) (set/sc (t->sc t))]
[(Sequence: ts) (apply sequence/sc (map t->sc ts))]
[(Vector: t) (vectorof/sc (t->sc/both t))]
[(HeterogeneousVector: ts) (apply vector/sc (map t->sc/both ts))]
[(Box: t) (box/sc (t->sc/both t))]
[(Pair: t1 t2)
(cons/sc (t->sc t1) (t->sc t2))]
[(Promise: t)
(promise/sc (t->sc t))]
[(Opaque: p?)
(flat/sc #`(flat-named-contract (quote #,(syntax-e p?)) #,p?))]
[(Continuation-Mark-Keyof: t)
(continuation-mark-key/sc (t->sc t))]
;; TODO: this is not quite right for case->
[(Prompt-Tagof: s (Function: (list (arr: (list ts ...) _ _ _ _))))
(prompt-tag/sc (map t->sc ts) (t->sc s))]
;; TODO
[(F: v)
(triple-lookup
(hash-ref recursive-values v
(λ () (error 'type->static-contract
"Recursive value lookup failed. ~a ~a" recursive-values v)))
typed-side)]
[(Poly: vs b)
(if (not (from-untyped? typed-side))
;; in positive position, no checking needed for the variables
(let ((recursive-values (for/fold ([rv recursive-values]) ([v vs])
(hash-set rv v (same any/sc)))))
(t->sc b #:recursive-values recursive-values))
;; in negative position, use parameteric contracts.
(match-let ([(Poly-names: vs-nm b) type])
(define function-type?
(let loop ([ty b])
(match (resolve ty)
[(Function: _) #t]
[(Union: elems) (andmap loop elems)]
[(Poly: _ body) (loop body)]
[(PolyDots: _ body) (loop body)]
[_ #f])))
(unless function-type?
(fail))
(let ((temporaries (generate-temporaries vs-nm)))
(define rv (for/fold ((rv recursive-values)) ((temp temporaries)
(v-nm vs-nm))
(hash-set rv v-nm (same (impersonator/sc temp)))))
(parametric->/sc temporaries
(t->sc b #:recursive-values rv)))))]
[(Mu: n b)
(match-define (and n*s (list untyped-n* typed-n* both-n*)) (generate-temporaries (list n n n)))
(define rv
(hash-set recursive-values n
(triple (recursive-contract-use untyped-n*)
(recursive-contract-use typed-n*)
(recursive-contract-use both-n*))))
(case typed-side
[(both) (recursive-contract
(list both-n*)
(list (loop b 'both rv))
(recursive-contract-use both-n*))]
[(typed untyped)
;; TODO not fail in cases that don't get used
(define untyped (loop b 'untyped rv))
(define typed (loop b 'typed rv))
(define both (loop b 'both rv))
(recursive-contract
n*s
(list untyped typed both)
(recursive-contract-use (if (from-typed? typed-side) typed-n* untyped-n*)))])]
[(Instance: (? Mu? t))
(t->sc (make-Instance (resolve-once t)))]
[(Instance: (Class: _ _ (list (list names functions) ...)))
(object/sc (map list names (map t->sc/method functions)))]
;; init args not currently handled by class/c
[(Class: _ (list (list by-name-inits by-name-init-tys _) ...) (list (list names functions) ...))
(class/sc (append
(map list names (map t->sc/method functions))
(map list by-name-inits (map t->sc/neg by-name-init-tys)))
#f empty empty)]
[(Struct: nm par (list (fld: flds acc-ids mut?) ...) proc poly? pred?)
(cond
[(dict-ref recursive-values nm #f)]
[proc (fail)]
[poly?
(define nm* (generate-temporary #'n*))
(define fields
(for/list ([fty flds] [mut? mut?])
(t->sc fty #:recursive-values (hash-set
recursive-values
nm (recursive-contract-use nm*)))))
(recursive-contract (list nm*) (list (struct/sc nm (ormap values mut?) fields))
(recursive-contract-use nm*))]
[else (flat/sc #`(flat-named-contract '#,(syntax-e pred?) #,pred?))])]
[(Syntax: (Base: 'Symbol _ _ _)) identifier?/sc]
[(Syntax: t)
(syntax/sc (t->sc t))]
[(Value: v)
(flat/sc #`(flat-named-contract '#,v (lambda (x) (equal? x '#,v))))]
[(Param: in out)
(parameter/sc (t->sc in) (t->sc out))]
[(Hashtable: k v)
(hash/sc (t->sc k) (t->sc v))]
[else
(fail)]))))
(define (t->sc/function f fail typed-side recursive-values loop method?)
(define (t->sc t #:recursive-values (recursive-values recursive-values))
(loop t typed-side recursive-values))
(define (t->sc/neg t #:recursive-values (recursive-values recursive-values))
(loop t (flip-side typed-side) recursive-values))
(match f
[(Function: (list (top-arr:))) (case->/sc empty)]
[(Function: arrs)
;; Try to generate a single `->*' contract if possible.
;; This allows contracts to be generated for functions with both optional and keyword args.
;; (and don't otherwise require full `case->')
(define conv (match-lambda [(Keyword: kw kty _) (list kw (t->sc/neg kty))]))
(define (partition-kws kws) (partition (match-lambda [(Keyword: _ _ mand?) mand?]) kws))
(define (process-dom dom*) (if method? (cons any/sc dom*) dom*))
(cond
;; To generate a single `->*', everything must be the same for all arrs, except for positional
;; arguments which can increase by at most one each time.
;; Note: optional arguments can only increase by 1 each time, to avoid problems with
;; functions that take, e.g., either 2 or 6 arguments. These functions shouldn't match,
;; since this code would generate contracts that accept any number of arguments between
;; 2 and 6, which is wrong.
;; TODO sufficient condition, but may not be necessary
[(and
(> (length arrs) 1)
;; Keyword args, range and rest specs all the same.
(let* ([xs (map (match-lambda [(arr: _ rng rest-spec _ kws)
(list rng rest-spec kws)])
arrs)]
[first-x (first xs)])
(for/and ([x (in-list (rest xs))])
(equal? x first-x)))
;; Positionals are monotonically increasing by at most one.
(let-values ([(_ ok?)
(for/fold ([positionals (arr-dom (first arrs))]
[ok-so-far? #t])
([arr (in-list (rest arrs))])
(match arr
[(arr: dom _ _ _ _)
(define ldom (length dom))
(define lpositionals (length positionals))
(values dom
(and ok-so-far?
(or (= ldom lpositionals)
(= ldom (add1 lpositionals)))
(equal? positionals (take dom lpositionals))))]))])
ok?))
(match* ((first arrs) (last arrs))
[((arr: first-dom (Values: (list (Result: rngs (FilterSet: (Top:) (Top:)) (Empty:)) ...)) rst #f kws)
(arr: last-dom _ _ _ _)) ; all but dom is the same for all
(define mand-args (map t->sc/neg first-dom))
(define opt-args (map t->sc/neg (drop last-dom (length first-dom))))
(define-values (mand-kws opt-kws)
(let*-values ([(mand-kws opt-kws) (partition-kws kws)])
(values (map conv mand-kws)
(map conv opt-kws))))
(define range (map t->sc rngs))
(define rest (and rst (listof/sc (t->sc/neg rst))))
(function/sc mand-args opt-args mand-kws opt-kws rest range)])]
[else
(define ((f [case-> #f]) a)
(define (convert-arr arr)
(match arr
[(arr: dom (Values: (list (Result: rngs _ _) ...)) rst #f kws)
(let-values ([(mand-kws opt-kws) (partition-kws kws)])
;; Garr, I hate case->!
(when (and (not (empty? kws)) case->)
(fail))
(if case->
(arr/sc (map t->sc/neg dom) (and rst (t->sc/neg rst)) (map t->sc rngs))
(function/sc
(map t->sc/neg dom)
null
(map conv mand-kws)
(map conv opt-kws)
(and rst (t->sc/neg rst))
(map t->sc rngs))))]))
(match a
;; functions with no filters or objects
[(arr: dom (Values: (list (Result: rngs (FilterSet: (Top:) (Top:)) (Empty:)) ...)) rst #f kws)
(convert-arr a)]
;; functions with filters or objects
[(arr: dom (Values: (list (Result: rngs _ _) ...)) rst #f kws)
(if (from-untyped? typed-side)
(fail)
(convert-arr a))]
[_ (fail)]))
(unless (no-duplicates (for/list ([t arrs])
(match t
[(arr: dom _ _ _ _) (length dom)]
;; is there something more sensible here?
[(top-arr:) (int-err "got top-arr")])))
(fail))
(if (= (length arrs) 1)
((f #f) (first arrs))
(case->/sc (map (f #t) arrs)))])]
[_ (int-err "not a function" f)]))
(define-syntax-rule (numeric/sc name body)
(flat/sc #'(flat-named-contract 'name body)))
(module predicates racket/base
(provide nonnegative? nonpositive?)
(define nonnegative? (lambda (x) (>= x 0)))
(define nonpositive? (lambda (x) (<= x 0))))
(require (for-template 'predicates))
(define positive-byte/sc (numeric/sc Positive-Byte (and/c byte? positive?)))
(define byte/sc (numeric/sc Byte byte?))
(define positive-index/sc (numeric/sc Positive-Index (and/c t:index? positive?)))
(define index/sc (numeric/sc Index t:index?))
(define positive-fixnum/sc (numeric/sc Positive-Fixnum (and/c fixnum? positive?)))
(define nonnegative-fixnum/sc (numeric/sc Nonnegative-Fixnum (and/c fixnum? nonnegative?)))
(define nonpositive-fixnum/sc (numeric/sc Nonpositive-Fixnum (and/c fixnum? nonpositive?)))
(define fixnum/sc (numeric/sc Fixnum fixnum?))
(define positive-integer/sc (numeric/sc Positive-Integer (and/c exact-integer? positive?)))
(define natural/sc (numeric/sc Natural exact-nonnegative-integer?))
(define negative-integer/sc (numeric/sc Negative-Integer (and/c exact-integer? negative?)))
(define nonpositive-integer/sc (numeric/sc Nonpositive-Integer (and/c exact-integer? nonpostive?)))
(define integer/sc (numeric/sc Integer exact-integer?))
(define positive-rational/sc (numeric/sc Positive-Rational (and/c t:exact-rational? positive?)))
(define nonnegative-rational/sc (numeric/sc Nonnegative-Rational (and/c t:exact-rational? nonnegative?)))
(define negative-rational/sc (numeric/sc Negative-Rational (and/c t:exact-rational? negative?)))
(define nonpositive-rational/sc (numeric/sc Nonpositive-Rational (and/c t:exact-rational? nonpositive?)))
(define rational/sc (numeric/sc Rational t:exact-rational?))
(define flonum-zero/sc (numeric/sc Float-Zero (and/c flonum? zero?)))
(define nonnegative-flonum/sc (numeric/sc Nonnegative-Float (and/c flonum? nonnegative?)))
(define nonpositive-flonum/sc (numeric/sc Nonpositive-Float (and/c flonum? nonpositive?)))
(define flonum/sc (numeric/sc Float flonum?))
(define single-flonum-zero/sc (numeric/sc Single-Flonum-Zero (and/c single-flonum? zero?)))
(define inexact-real-zero/sc (numeric/sc Inexact-Real-Zero (and/c inexact-real? zero?)))
(define positive-inexact-real/sc (numeric/sc Positive-Inexact-Real (and/c inexact-real? positive?)))
(define nonnegative-single-flonum/sc (numeric/sc Nonnegative-Single-Flonum (and/c single-flonum? nonnegative?)))
(define nonnegative-inexact-real/sc (numeric/sc Nonnegative-Inexact-Real (and/c inexact-real? nonpositive?)))
(define negative-inexact-real/sc (numeric/sc Negative-Inexact-Real (and/c inexact-real? negative?)))
(define nonpositive-single-flonum/sc (numeric/sc Nonpositive-Single-Flonum (and/c single-flonum? nonnegative?)))
(define nonpositive-inexact-real/sc (numeric/sc Nonpositive-Inexact-Real (and/c inexact-real? nonpositive?)))
(define single-flonum/sc (numeric/sc Single-Flonum single-flonum?))
(define inexact-real/sc (numeric/sc Inexact-Real inexact-real?))
(define real-zero/sc (numeric/sc Real-Zero (and/c real? zero?)))
(define positive-real/sc (numeric/sc Positive-Real (and/c real? positive?)))
(define nonnegative-real/sc (numeric/sc Nonnegative-Real (and/c real? nonnegative?)))
(define negative-real/sc (numeric/sc Negative-Real (and/c real? negative?)))
(define nonpositive-real/sc (numeric/sc Nonpositive-Real (and/c real? nonpositive?)))
(define real/sc (numeric/sc Real real?))
(define exact-number/sc (numeric/sc Exact-Number (and/c number? exact?)))
(define inexact-complex/sc
(numeric/sc Inexact-Complex
(and/c number?
(lambda (x)
(and (inexact-real? (imag-part x))
(inexact-real? (real-part x)))))))
(define number/sc (numeric/sc Number number?))
(define (numeric-type->static-contract type)
(match type
;; numeric special cases
;; since often-used types like Integer are big unions, this would
;; generate large contracts.
[(== t:-PosByte type-equal?) positive-byte/sc]
[(== t:-Byte type-equal?) byte/sc]
[(== t:-PosIndex type-equal?) positive-index/sc]
[(== t:-Index type-equal?) index/sc]
[(== t:-PosFixnum type-equal?) positive-fixnum/sc]
[(== t:-NonNegFixnum type-equal?) nonnegative-fixnum/sc]
;; -NegFixnum is a base type
[(== t:-NonPosFixnum type-equal?) nonpositive-fixnum/sc]
[(== t:-Fixnum type-equal?) fixnum/sc]
[(== t:-PosInt type-equal?) positive-integer/sc]
[(== t:-Nat type-equal?) natural/sc]
[(== t:-NegInt type-equal?) negative-integer/sc]
[(== t:-NonPosInt type-equal?) nonpositive-integer/sc]
[(== t:-Int type-equal?) integer/sc]
[(== t:-PosRat type-equal?) positive-rational/sc]
[(== t:-NonNegRat type-equal?) nonnegative-rational/sc]
[(== t:-NegRat type-equal?) negative-rational/sc]
[(== t:-NonPosRat type-equal?) nonpositive-rational/sc]
[(== t:-Rat type-equal?) rational/sc]
[(== t:-FlonumZero type-equal?) flonum-zero/sc]
[(== t:-NonNegFlonum type-equal?) nonnegative-flonum/sc]
[(== t:-NonPosFlonum type-equal?) nonpositive-flonum/sc]
[(== t:-Flonum type-equal?) flonum/sc]
[(== t:-SingleFlonumZero type-equal?) single-flonum-zero/sc]
[(== t:-InexactRealZero type-equal?) inexact-real-zero/sc]
[(== t:-PosInexactReal type-equal?) positive-inexact-real/sc]
[(== t:-NonNegSingleFlonum type-equal?) nonnegative-single-flonum/sc]
[(== t:-NonNegInexactReal type-equal?) nonnegative-inexact-real/sc]
[(== t:-NegInexactReal type-equal?) negative-inexact-real/sc]
[(== t:-NonPosSingleFlonum type-equal?) nonpositive-single-flonum/sc]
[(== t:-NonPosInexactReal type-equal?) nonpositive-inexact-real/sc]
[(== t:-SingleFlonum type-equal?) single-flonum/sc]
[(== t:-InexactReal type-equal?) inexact-real/sc]
[(== t:-RealZero type-equal?) real-zero/sc]
[(== t:-PosReal type-equal?) positive-real/sc]
[(== t:-NonNegReal type-equal?) nonnegative-real/sc]
[(== t:-NegReal type-equal?) negative-real/sc]
[(== t:-NonPosReal type-equal?) nonpositive-real/sc]
[(== t:-Real type-equal?) real/sc]
[(== t:-ExactNumber type-equal?) exact-number/sc]
[(== t:-InexactComplex type-equal?) inexact-complex/sc]
[(== t:-Number type-equal?) number/sc]
[else #f]))
| true |
bda5f69fb8f031079e8395c24be91d523c08421f | 837d54d88486f4bee85b0f2d253f26ae7e1e0551 | /lens/private/main.rkt | 44f337ad590cb8d88352e4d86a7d3ff929e9d676 | [
"MIT"
]
| permissive | ecraven/lens | 061c5bbc828ada2e2c0b743f5f019890c9457998 | 97076bbc6c7277d9a8f624e8300c79de0c81920d | refs/heads/master | 2020-12-11T05:39:01.418458 | 2016-07-28T08:41:21 | 2016-07-28T08:41:21 | 64,378,239 | 0 | 0 | null | 2016-07-28T08:33:31 | 2016-07-28T08:33:30 | null | UTF-8 | Racket | false | false | 316 | rkt | main.rkt | #lang sweet-exp reprovide
except-in
combine-in
"base/main.rkt"
"compound/main.rkt"
"dict/dict.rkt"
"hash/main.rkt"
"list/main.rkt"
"stream/stream.rkt"
"string/main.rkt"
"struct/main.rkt"
"vector/main.rkt"
gen:lens
focus-lens
drop-lens
take-lens
use-applicable-lenses!
| false |
99f49c80340c2f73210ae96f8183db6acf0973a2 | d3250c138e5decbc204d5b9b0898480b363dbfa6 | /unity-synthesis/serial-arduino.rkt | 045938d33bc0bbcdb55780821daff2fb5203c693 | []
| no_license | chchen/comet | 3ddc6b11cd176f6f3a0f14918481b78b2a0367b0 | 1e3a0acb21a0a8beb0998b4650278ac9991e0266 | refs/heads/main | 2023-04-28T13:25:01.732740 | 2021-05-21T07:30:23 | 2021-05-21T07:30:23 | 368,667,043 | 8 | 2 | null | 2021-05-21T04:57:56 | 2021-05-18T21:10:01 | Racket | UTF-8 | Racket | false | false | 1,661 | rkt | serial-arduino.rkt | #lang rosette/safe
(require "config.rkt"
"serial.rkt"
"synth.rkt"
"arduino/backend.rkt"
"arduino/synth.rkt"
"arduino/mapping.rkt"
"arduino/verify.rkt")
;; (time
;; (let* ([prog recv-buf-test]
;; [sketch recv-buf-sketch]
;; [synth-map (unity-prog->synth-map prog)]
;; [verify-model (verify-loop prog sketch synth-map)])
;; verify-model))
;; (time
;; (print-arduino-program
;; (unity-prog->arduino-prog channel-test)))
(let* ([prog channel-fifo]
[impl (time (unity-prog->arduino-prog prog))])
(list (time (verify-arduino-prog prog impl))
impl))
;; (let* ([prog channel-test]
;; [impl (time (unity-prog->arduino-prog prog))])
;; (list (time (verify-arduino-prog prog impl))
;; impl))
;; (time (print-arduino-program
;; (unity-prog->arduino-prog sender)))
;; (verify-arduino-prog channel-recv-buf-test
;; channel-recv-buf-impl)
;; (let* ([prog receiver]
;; [synth-map (unity-prog->synth-map prog)]
;; [arduino-st->unity-st (synth-map-target-state->unity-state synth-map)]
;; [arduino-start-st (synth-map-target-state synth-map)]
;; [unity-start-st (arduino-st->unity-st arduino-start-st)]
;; [assign-traces (synth-traces-assign (unity-prog->synth-traces prog synth-map))])
;; assign-traces)
;; (time
;; (let* ([prog sender]
;; [synth-map (unity-prog->synth-map prog)])
;; (unity-prog->assign-state prog synth-map)))
;; (time
;; (let* ([prog channel-fifo]
;; [synth-map (unity-prog->synth-map prog)])
;; (unity-prog->synth-traces prog synth-map)))
| false |
b4c932a64acbe325bf979b2af5fa1c2d8fbedbc5 | 4bd59493b25febc53ac9e62c259383fba410ec0e | /Scripts/Task/rosetta-code-fix-code-tags/racket/rosetta-code-fix-code-tags.rkt | 1f24c83270095c05154a10c79f7e8c3d86798c69 | []
| no_license | stefanos1316/Rosetta-Code-Research | 160a64ea4be0b5dcce79b961793acb60c3e9696b | de36e40041021ba47eabd84ecd1796cf01607514 | refs/heads/master | 2021-03-24T10:18:49.444120 | 2017-08-28T11:21:42 | 2017-08-28T11:21:42 | 88,520,573 | 5 | 1 | null | null | null | null | UTF-8 | Racket | false | false | 707 | rkt | rosetta-code-fix-code-tags.rkt | #lang racket
(define lang-names '("X" "Y" "Z"))
(define rx
(regexp (string-join lang-names "|"
#:before-first "<((/?(?:code)?)(?:( )?("
#:after-last "))?)>")))
(let loop () ; does all in a single scan
(define m (regexp-match rx (current-input-port) 0 #f (current-output-port)))
(when m
(define-values [all pfx space lang] (apply values (cdr m)))
(printf "<~a>"
(cond [(not lang) (if (equal? pfx #"/code") #"/lang" all)]
[space (if (equal? pfx #"code") (bytes-append #"lang " lang) all)]
[(equal? pfx #"") (bytes-append #"lang " lang)]
[(equal? pfx #"/") #"/lang"]
[else all]))
(loop)))
| false |
e1a02aeadfb22173ab362e22c6e2456ddd7d193b | 4e0e6869643640f6bc01bf134a222e8f4f8b379d | /envy/environment.rkt | 086054eabb4f36f25e4c3ffd639ed66ae055f4b4 | []
| no_license | lexi-lambda/envy | 8352dbe41e73fae1a2ceed7f8c21cf44c3281a05 | 580610f63b66ee7503c32facfa8924505e5f35f1 | refs/heads/master | 2023-05-10T14:40:44.484216 | 2023-04-27T05:08:12 | 2023-04-27T05:08:12 | 41,614,014 | 17 | 4 | null | 2023-05-13T06:41:11 | 2015-08-30T02:25:31 | Racket | UTF-8 | Racket | false | false | 3,236 | rkt | environment.rkt | #lang typed/racket/base
(require (for-syntax racket/base
racket/dict
racket/string
racket/syntax
syntax/id-table
threading)
syntax/parse/define
"private/coerce.rkt")
(provide define-environment
define/provide-environment
define-environment-variable)
(define-for-syntax auto-type-table
(make-immutable-free-id-table
`((,#'String . ,#'(inst values String))
(,#'Symbol . ,#'string->symbol)
(,#'Boolean . ,#'string->boolean)
(,#'Number . ,#'string->number)
(,#'Integer . ,#'string->integer)
(,#'Positive-Integer . ,#'string->positive-integer)
(,#'Negative-Integer . ,#'string->negative-integer)
(,#'Nonnegative-Integer . ,#'string->nonnegative-integer))))
(define-syntax-parser define-environment-variable
#:literals (:)
[(_ (~describe "name" name:id)
(~optional (~describe "type" (~seq : type:id)) #:defaults ([type #'String]))
(~or (~optional (~seq #:name env-var-name:expr) #:defaults ([env-var-name #f]))
(~optional (~seq #:default default:expr) #:defaults ([default #f])))
...)
(with-syntax* ([env-var-name (or (attribute env-var-name)
(~> (syntax-e #'name)
symbol->string
string-upcase
(string-replace "-" "_")
(string-replace "?" "")))]
[coerce (dict-ref auto-type-table #'type)]
[fetch-env-var
(if (attribute default)
#'(require-environment-variable env-var-name coerce default)
#'(require-environment-variable env-var-name coerce))])
#'(define name fetch-env-var))])
(begin-for-syntax
(define-syntax-class environment-clause
#:attributes (name normalized)
(pattern name:id #:with normalized #'[name])
(pattern [name:id args ...] #:with normalized #'[name args ...])))
(define-syntax-parser define-environment
[(_ clause:environment-clause ...)
(with-syntax ([((normalized ...) ...) #'(clause.normalized ...)])
#'(begin (define-environment-variable normalized ...) ...))])
(define-syntax-parser define/provide-environment
[(_ clause:environment-clause ...)
(with-syntax ([(name ...) #'(clause.name ...)]
[((normalized ...) ...) #'(clause.normalized ...)])
#'(begin (begin (define-environment-variable normalized ...)
(provide name))
...))])
(: require-environment-variable (All [a b] (case-> (String (String -> a) -> a)
(String (String -> a) b -> (U a b)))))
(define require-environment-variable
(case-lambda
[(name parse)
(let ([value (getenv name)])
(unless value
(error 'envy "The required environment variable \"~a\" is not defined." name))
(parse value))]
[(name parse default)
(let ([value (getenv name)])
(if value (parse value) default))]))
| true |
1c72e86dae9b2db3ed440deb79810366405dfafd | 4cc0edb99a4c5d945c9c081391ae817b31fc33fd | /paint-by-numbers/solve.rkt | aa372c55751b99475d98e4018e693fbf85946c8e | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | racket/games | c8eaa92712405890cd1db19b8ba32b1620d885b8 | eba5c6fa54c524871badb8b0e205fe37640d6c3e | refs/heads/master | 2023-08-19T00:41:23.930448 | 2023-07-24T23:29:05 | 2023-07-24T23:29:05 | 27,138,761 | 54 | 33 | NOASSERTION | 2020-05-04T13:46:50 | 2014-11-25T17:59:40 | Racket | UTF-8 | Racket | false | false | 33,614 | rkt | solve.rkt | #lang racket
(provide/contract [solve (-> (listof (listof integer?)) ; row-info
(listof (listof integer?)) ; col-info
(-> number? number? symbol? ; set-entry
void?)
(-> number? void?) ; setup-progress
void)])
(define (solve row-info col-info set-entry setup-progress)
(local [
(define (pause) '(sleep 1/16))
; all test cases are commented out.
; to work on large lists, we must make filter tail-recursive.
; this one reverses.
; filter-rev : returns a list of all elements in a-list which
; satisfy the predicate. If a precedes b in a-list, and both
; occur in the result, then b will precede a in the result.
; ((A -> boolean) (list-of A) -> (list-of A))
(define (filter-rev fun a-list)
(foldl (lambda (elt built-list)
(if (fun elt)
(cons elt built-list)
built-list))
null
a-list))
;(equal? (filter-rev (lambda (x) (> x 13)) '(2 98 27 1 23 2 09))
; '(23 27 98))
; transpose : transposes a matrix represented as a list of lists
; ((list-of (list-of T)) -> (list-of (list-of T)))
(define (transpose list-list)
(apply map list list-list))
;(equal? (transpose '((a b c d e)
; (f g h i j)
; (k l m n o)))
; '((a f k)
; (b g l)
; (c h m)
; (d i n)
; (e j o)))
; TYPE-DECLARATIONS:
; there are three kinds of cell-list: the board-row-list, the tally-list, and the try-list.
;
; (type: board-row (list-of (union 'off 'on 'unknown)))
; (type: tally-row (list-of (union 'off 'on 'unknown 'maybe-off 'maybe-on 'mixed)))
; (type: try-row (list-of (union 'maybe-off 'maybe-on 'unknown)))
(define try-row? (listof (symbols 'maybe-off 'maybe-on 'unknown)))
(define try-batch? (listof (or/c number? (listof try-row?))))
;
; (type: board (list-of board-row))
; board-ref : returns the board element in (col,row);
; (board num num -> (union 'on 'off 'unknown))
(define (board-ref board row col)
(list-ref (list-ref board row) col))
; board-width : returns the width of the board
; (board -> num)
(define (board-width board)
(length (car board)))
; board-height : returns the height of the board
; (board -> num)
(define (board-height board)
(length board))
; extract-rows : returns the board as a list of rows
; (board -> board)
(define (extract-rows board)
board)
; extract-cols : returns the board as a list of columns
; (board -> board)
(define (extract-cols board)
(transpose board))
; reassemble-rows : turns a list of rows into a board
; (board -> board)
(define (reassemble-rows board-line-list)
board-line-list)
; reassemble-cols : turns a list of columns into a board
; (board -> board)
(define (reassemble-cols board-line-list)
(transpose board-line-list))
; entirely-unknown : does this row consist entirely of 'unknown?
(define (entirely-unknown row)
(andmap (lambda (x) (eq? x 'unknown)) row))
; finished? : does this board contain no unknown squares?
(define (finished? board)
(not (ormap (lambda (row) (ormap (lambda (cell) (eq? cell 'unknown)) row)) board)))
; threshold info : the threshold is the limit at which
; memoize-tries will simply give up.
(define initial-threshold 2000)
(define (next-threshold threshold)
(+ threshold 2000))
; procedures to simplify the construction of test cases:
; condensed->long-form : takes a tree of short-form symbols and
; converts them to their long form, following this mapping:
; u -> unknown | X -> off
; ? -> maybe-on | O -> on
; ! -> maybe-off | * -> mixed
(define (condensed->long-form symbol-tree)
(cond [(cons? symbol-tree)
(cons (condensed->long-form (car symbol-tree))
(condensed->long-form (cdr symbol-tree)))]
[(case symbol-tree
((u) 'unknown)
((?) 'maybe-on)
((!) 'maybe-off)
((X) 'off)
((O) 'on)
((*) 'mixed)
((()) '())
(else (error 'condensed->long-form "bad input: ~a" symbol-tree)))]))
;(equal? (condensed->long-form '(((? !) u) (* () X O)))
; '(((maybe-on maybe-off) unknown) (mixed () off on)))
; check-changed : check whether a tally-row reveals new information to be added
; to the grid
; (tally-row -> boolean)
(define (check-changed tally-list)
(ormap (lambda (cell)
(case cell
((off on unknown mixed) #f)
((maybe-off maybe-on) #t)
(else (error "unknown element found in check-changed: ~a" cell))))
tally-list))
;(and (equal? (check-changed '(off off on unknown mixed)) #f)
; (equal? (check-changed '(off on maybe-off on mixed)) #t)
; (equal? (check-changed '(off maybe-on on on unknown)) #t))
; rectify : transform a tally-row into a board row, by changing maybe-off
; to off and maybe-on to on.
; (tally-row -> board-row)
(define (rectify tally-list)
(map (lambda (cell)
(case cell
((off on unknown) cell)
((maybe-off) 'off)
((maybe-on) 'on)
((mixed) 'unknown)
(else (error "unknown element in rectified row"))))
tally-list))
;(equal? (rectify '(off on maybe-on mixed unknown maybe-off))
; '(off on on unknown unknown off))
; make-row-formulator:
; given a set of block lengths, create a function which accepts a
; set of pads and formulates a try-row:
; (num-list -> (num-list num -> (list-of (union 'maybe-off 'maybe-on 'unknown))))
(define (make-row-formulator blocks)
(lambda (pads)
(apply append
(let loop ([pads pads]
[blocks blocks])
(cond [(null? (cdr pads))
(if (null? blocks)
(list (build-list (car pads) (lambda (x) 'maybe-off)))
(list (cons 'maybe-off (build-list (apply + -1 (car pads) blocks) (lambda (x) 'unknown)))))]
[else
(cons (build-list (car pads) (lambda (x) 'maybe-off))
(cons (build-list (car blocks) (lambda (x) 'maybe-on))
(loop (cdr pads) (cdr blocks))))])))))
#|
(equal? ((make-row-formulator '(3 1 1 5)) '(1 2 1 3 3))
'(maybe-off maybe-on maybe-on maybe-on maybe-off maybe-off maybe-on maybe-off maybe-on
maybe-off maybe-off maybe-off maybe-on maybe-on maybe-on maybe-on maybe-on
maybe-off maybe-off maybe-off))
(equal? ((make-row-formulator '(3 1 1 5)) '(2 4 4))
'(maybe-off maybe-off
maybe-on maybe-on maybe-on
maybe-off maybe-off maybe-off maybe-off
maybe-on
unknown unknown unknown unknown unknown unknown unknown unknown unknown unknown))
|#
#| check-try :
see whether a try fits with the existing row information (curried)
(tally-row -> (try-row -> boolean))
|#
(define (check-try tally-list)
(lambda (try-list)
(andmap (lambda (tally try)
(or (eq? try 'unknown)
(case tally
((off) (eq? try 'maybe-off))
((on) (eq? try 'maybe-on))
(else #t))))
tally-list
try-list)))
#|
(equal? ((check-try '(unknown off on unknown unknown unknown))
'(maybe-on maybe-on maybe-on maybe-off maybe-off maybe-off))
#f)
(equal? ((check-try '(unknown off on unknown unknown unknown))
'(maybe-off maybe-off maybe-on maybe-on maybe-on maybe-off))
#t)
(equal? ((check-try '(unknown off on unknown unknown unknown))
'(unknown unknown unknown unknown unknown unknown))
#t)
|#
#| choose : like math. as in, "9 choose 3"
(num num -> num)
|#
(define (factorial a)
(if (<= a 1)
1
(* a (factorial (- a 1)))))
(define (choose a b)
(if (> b a)
(error 'choose "(choose ~v ~v): ~v is greater than ~v" a b b a)
(let ([b (max b (- a b))])
(/ (let loop ([x a])
(if (= x (- a b))
1
(* x (loop (- x 1)))))
(factorial b)))))
#|
(and
(= (choose 0 0) 1)
(= (choose 10 10) 1)
(= (choose 10 1) 10)
(= (choose 10 2) 45)
(= (choose 10 8) 45))
|#
#| initial-num-possibilities :
given a list of block lengths, calculate the number of ways they could fit
into a row of the given length. The easiest way to model this is to imagine
inserting blocks at given locations in a fixed set of spaces
(listof num) num -> num
|#
(define (initial-num-possibilities blocks size)
(choose (+ 1 (- size (apply + blocks))) (length blocks)))
#|
(= (initial-num-possibilities '(2 3 3 4) 40)
(choose 29 4))
|#
#| build-possibles:
builds a list of the possible rows. given a number of spaces, and a number
of bins to put the spaces in, and a row-formulator, and a line-checker predicate,
build-possibles makes a list of every possible row which passes the predicate.
If the number of possibilities grows larger than the threshold, the search is
aborted.
(num num ((list-of num) -> try-row) (try-row -> bool) num -> (union (list-of try-row) #f))
|#
(define (build-possibles things total-bins row-formulator line-checker threshold)
(let/ec escape
(let* ([built-list null]
[list-length 0]
[add-to-built-list
(lambda (new)
(if (= list-length threshold)
(escape #f)
(begin (set! built-list (cons new built-list))
(set! list-length (+ list-length 1)))))])
(let tree-traverse ([things things]
[bins total-bins]
[so-far-rev null])
(let* ([this-try-rev (cons things so-far-rev)]
[formulated (row-formulator (reverse this-try-rev))])
;(when (= debug-counter 0)
; (printf "~v\n~v\n" formulated (line-checker formulated)))
(when (or (= bins total-bins) (line-checker formulated))
(if (= bins 1)
(add-to-built-list formulated)
(let try-loop ([in-this-bin (if (= bins total-bins)
0
1)])
(unless (> (+ in-this-bin (- bins 2)) things)
(tree-traverse (- things in-this-bin)
(- bins 1)
(cons in-this-bin so-far-rev))
(try-loop (+ in-this-bin 1))))))))
built-list)))
#|
;build-possibles test case
(let* ([row-formulator-one (make-row-formulator '(2))]
[line-checker (check-try '(unknown unknown unknown on unknown unknown))]
[test-one (build-possibles 4 2 row-formulator-one line-checker 10000)]
[row-formulator-two (make-row-formulator '(1 1))]
[test-two (build-possibles 4 3 row-formulator-two line-checker 10000)])
(and
(equal? test-one
'((maybe-off maybe-off maybe-off maybe-on maybe-on maybe-off)
(maybe-off maybe-off maybe-on maybe-on maybe-off maybe-off)))
(equal? test-two
'((maybe-off maybe-off maybe-off maybe-on maybe-off maybe-on)
(maybe-off maybe-on maybe-off maybe-on maybe-off maybe-off)
(maybe-on maybe-off maybe-off maybe-on maybe-off maybe-off)))))
|#
#| spare-spaces:
calculates the number of spare spaces in a line. In other words,
line-length - sum-of-all-blocks
((list-of num) num -> num)
|#
(define (spare-spaces block-list line-length)
(let* ([black-spaces (apply + block-list)]
[spare-spaces (- line-length black-spaces)])
spare-spaces))
; first-pass:
; generates the information about row contents which can be inferred directly
; from the block info and nothing else (i.e., uses no information from an existing
; board.
; ((list-of (list-of num)) num -> (list-of (list-of (union 'on 'unknown))))
(define (first-pass info-list line-length)
(let ((row-pass
(lambda (block-list)
(let* ([spares (- (spare-spaces block-list line-length) (max 0 (- (length block-list) 1)))]
[shortened-blocks
(map (lambda (block-length) (- block-length spares))
block-list)]
[all-but-start
(foldr append null
(let build-row-loop ([blocks-left shortened-blocks])
(if (null? blocks-left)
null
(let ([extra-pad (if (null? (cdr blocks-left)) 0 1)])
(if (> (car blocks-left) 0)
(cons (build-list (car blocks-left) (lambda (x) 'on))
(cons (build-list (+ spares extra-pad) (lambda (x) 'unknown))
(build-row-loop (cdr blocks-left))))
(cons (build-list (+ spares extra-pad (car blocks-left))
(lambda (x) 'unknown))
(build-row-loop (cdr blocks-left))))))))]
[whole-row (append (build-list spares (lambda (x) 'unknown))
all-but-start)])
whole-row))))
(map row-pass info-list)))
#|
(let ([test-result (first-pass '((4 3) (5 1)) 10)])
(equal? test-result '((unknown unknown on on unknown unknown unknown on unknown unknown)
(unknown unknown unknown on on unknown unknown unknown unknown unknown))))
|#
#| unify-passes:
unify the result of running first-pass on both the rows and the columns
(let ([BOARD (list-of (list-of (union 'unknown 'on)))])
(BOARD BOARD -> BOARD))
|#
(define (unify-passes board-a board-b)
(let ([unify-rows
(lambda (row-a row-b)
(map (lambda (cell-a cell-b)
(case cell-a
((on) 'on)
(else cell-b)))
row-a row-b))])
(map unify-rows board-a board-b)))
#|
(let* ([board-a '((unknown unknown on) (on unknown unknown))]
[board-b '((unknown on unknown) (on on unknown))]
[test-result (unify-passes board-a board-b)])
(equal? test-result '((unknown on on) (on on unknown))))
|#
#| whole-first-pass:
take a set of row descriptions and the board dimensions and generate the
merged first-pass info
((list-of (list-of num)) (list-of (list-of num)) num num ->
(list-of board-row))
|#
(define (whole-first-pass row-info col-info width height)
(unify-passes (first-pass row-info width)
(transpose (first-pass col-info height))))
#| memoize-tries:
given the black block widths and the line length and some initial board
and a progress-bar updater, calculate all possibilities for each row.
If skip-unknowns is #t, rows whose content is entirely unknown will be
skipped, and #f returned for that row.
effect: updates the progress bar
((list-of (list-of num)) num (list-of board-row) (-> void) boolean -> (union (list-of try-row) #f))
|#
(define (memoize-tries info-list line-length board-rows old-tries threshold)
(let* ([unmemoized (filter number? old-tries)])
(if (null? unmemoized)
old-tries
(let* ([least-difficult
(apply min unmemoized)])
;(eprintf "guessed tries: ~v\n" least-difficult)
(map (lambda (old-try-set block-list board-row)
(cond [(and (number? old-try-set) (= old-try-set least-difficult))
(let ([spaces (spare-spaces block-list line-length)]
[bins (+ (length block-list) 1)]
[row-formulator (make-row-formulator block-list)]
[line-checker (check-try board-row)])
(or (build-possibles spaces bins row-formulator line-checker threshold)
(* 2 old-try-set)))]
[else old-try-set]))
old-tries
info-list
board-rows)))))
#|
(equal? (memoize-tries '((4) (1 3))
6
'((unknown on unknown unknown unknown unknown)
(unknown off unknown unknown unknown unknown))
void)
'(((maybe-on maybe-on maybe-on maybe-on maybe-off maybe-off)
(maybe-off maybe-on maybe-on maybe-on maybe-on maybe-off))
((maybe-on maybe-off maybe-on maybe-on maybe-on maybe-off)
(maybe-on maybe-off maybe-off maybe-on maybe-on maybe-on))))
|#
#| batch-try:
take a board-line list and a list of possibles, and trim it down by
checking each try-list against the appropriate board-line
((list-of board-row) (list-of (union (list-of try-row) #f)) -> (list-of (union (list-of try-row) #f)))
|#
(define (batch-try board-line-list try-list-list-list)
(map (lambda (line try-list-list)
(if (not (number? try-list-list))
(filter ; filter-rev
(let ([f (check-try line)])
(lambda (try-list) (f try-list)))
try-list-list)
try-list-list))
board-line-list
try-list-list-list))
#|
(equal? (batch-try '((unknown unknown unknown off)
(unknown on unknown unknown))
'(((maybe-on maybe-on maybe-on maybe-off)
(maybe-off maybe-on maybe-on maybe-on))
((maybe-on maybe-on maybe-off maybe-off)
(maybe-off maybe-on maybe-on maybe-off)
(maybe-off maybe-off maybe-on maybe-on))))
'(((maybe-on maybe-on maybe-on maybe-off))
((maybe-off maybe-on maybe-on maybe-off)
(maybe-on maybe-on maybe-off maybe-off))))
|#
; tabulate-try : take one possibility, and merge it with the row possibles
; (tally-list try-list) -> tally-list
(define (tabulate-try tally-list try-list)
(map (lambda (tally try)
(case tally
((off on mixed) tally)
((unknown) try)
((maybe-off maybe-on) (if (eq? try tally)
try
'mixed))
(else (error "unknown cell type during tabulate-try: ~a" tally))))
tally-list
try-list))
#|
(equal? (tabulate-try '(on off maybe-off maybe-off maybe-on maybe-on maybe-on)
'(on off mixed maybe-on maybe-on mixed maybe-off))
'(on off mixed mixed maybe-on mixed mixed))
|#
; batch-tabulate : take a board-line-list and a list of sets of tries which check with the board
; and tabulate them all to produce a new board line list (before rectification)
; (board-line-list try-list-list-opt-list) -> tally-list
(define (batch-tabulate board-line-list try-list-list-opt-list)
(map (lambda (board-line try-list-list-opt)
(if (not (number? try-list-list-opt))
(foldl (lambda (x y) (tabulate-try y x)) board-line try-list-list-opt)
board-line))
board-line-list
try-list-list-opt-list))
; (equal? (batch-tabulate '((unknown unknown unknown off)
; (unknown unknown on unknown))
; '(((maybe-on maybe-on maybe-off maybe-off)
; (maybe-off maybe-on maybe-on maybe-off))
; ((maybe-off maybe-on maybe-on maybe-off)
; (maybe-off maybe-off maybe-on maybe-on))))
; '((mixed maybe-on mixed off)
; (maybe-off mixed on mixed)))
(define (print-board board)
(for-each (lambda (row)
(for-each (lambda (cell)
(printf (case cell
((off) " ")
((unknown) ".")
((on) "#"))))
row)
(printf "\n"))
(extract-rows board)))
; animate-changes takes a board and draws it on the main screen
(define (animate-changes board draw-thunk outer-size inner-size)
(let outer-loop ([outer-index 0])
(if (= outer-index outer-size)
null
(let inner-loop ([inner-index 0])
(if (= inner-index inner-size)
(begin
(pause)
(outer-loop (+ outer-index 1)))
(begin
(draw-thunk board outer-index inner-index)
(inner-loop (+ inner-index 1))))))))
(define (draw-rows-thunk board row col)
(set-entry col row (board-ref board row col)))
(define (draw-cols-thunk board col row)
(set-entry col row (board-ref board row col)))
; (print-board '((on on unknown off)
; (on on unknown unknown)
; (unknown unknown on on)
; (off unknown on on)))
; do-lines takes a board-line-list and a try-list-list-list and returns two things: a tally-list-list
; and a new try-list-list-list
; (board-line-list try-list-list-opt-list) -> (tally-list-list try-list-list-opt-list)
(define do-lines
(contract
(->* (any/c try-batch?)
(values (listof (listof any/c)) try-batch?))
(lambda (board-line-list try-list-list-opt-list)
(let ([new-tries (batch-try board-line-list try-list-list-opt-list)])
(values (batch-tabulate board-line-list new-tries)
new-tries)))
'do-lines
'caller))
; full-set takes a board and a pair of try-list-list-lists and returns a new board, a new pair
; of try-list-list-lists, and a boolean (whether it's changed)
(define full-set
(contract
(->* (any/c try-batch? try-batch?)
(values any/c try-batch? try-batch? boolean?))
(lambda (board row-try-list-list-opt-list col-try-list-list-opt-list)
(let*-values ([(board-rows new-row-tries)
(do-lines (extract-rows board) row-try-list-list-opt-list)]
[(row-changed)
(ormap check-changed board-rows)]
[(new-board)
(reassemble-rows (map rectify board-rows))]
[( _ )
(when row-changed
(animate-changes new-board draw-rows-thunk
(board-height new-board)
(board-width new-board)))]
[(board-cols new-col-tries)
(do-lines (extract-cols new-board) col-try-list-list-opt-list)]
[(col-changed)
(ormap check-changed board-cols)]
[(final-board)
(reassemble-cols (map rectify board-cols))]
[( _ )
(when col-changed
(animate-changes final-board draw-cols-thunk
(board-width final-board)
(board-height final-board)))])
(values final-board new-row-tries new-col-tries (or row-changed col-changed))))
'full-set
'caller))
; on 2002-10-17, I wrapped another layer of looping around the inner loop.
; the purpose of this outer loop is to allow the solver to ignore rows (or
; columns) about which the solver knows nothing for as long as possible.
(define (local-solve row-info col-info)
(let* ([rows (length row-info)]
[cols (length col-info)]
[initial-board (whole-first-pass row-info col-info cols rows)]
[_ (animate-changes initial-board draw-cols-thunk
(board-width initial-board)
(board-height initial-board))])
(let outer-loop ([outer-board initial-board]
[skip-threshold initial-threshold]
[old-row-tries (map (lambda (info)
(initial-num-possibilities info (board-width initial-board)))
row-info)]
[old-col-tries (map (lambda (info)
(initial-num-possibilities info (board-height initial-board)))
col-info)])
(let* ([row-try-list-list-opt-list (memoize-tries row-info cols outer-board old-row-tries skip-threshold)]
[col-try-list-list-opt-list (memoize-tries col-info rows (transpose outer-board) old-col-tries skip-threshold)])
(let loop ([board outer-board]
[row-tries row-try-list-list-opt-list]
[col-tries col-try-list-list-opt-list]
[changed #t])
(if changed
(call-with-values (lambda () (full-set board row-tries col-tries))
loop)
(if (finished? board)
board
(if (equal? outer-board board)
(outer-loop board (next-threshold skip-threshold) row-tries col-tries)
(outer-loop board skip-threshold row-tries col-tries)))))))))
]
(local-solve row-info col-info)))
; test case:
;(require solve)
;
;(let* ([test-board (build-vector 20 (lambda (x) (make-vector 20 'bad-value)))]
; [set-board! (lambda (col row val)
; (vector-set! (vector-ref test-board row) col val))])
; (solve `((9 9) (6 10) (5 11) (4 3 5) (2 1 3) (2 4 2) (1 3 6) (5 1 1 1) (2 2 1 3 1) (7 4 1) (7 4 2) (1 3 9) (1 2 4 6) (1 6 9) (1 4 7) (2 1 4 2) (5 3 4) (5 7) (5 10) (5 11))
; `((1 8) (2 4 4) (4 1 2 4) (8 2 4) (6 1 3 7) (4 8 4) (3 7 1) (1 2) (1 2) (2 2 2 1) (3 2 1 1 1 2) (7 8 2) (3 7 4 2) (3 1 1 2 3 3) (3 4 6 3) (4 1 4 3) (4 1 4 4) (5 1 4 4) (7 4 5) (7 6 5))
; set-board!
; (lambda (x) (void)))
; (equal? (map (lambda (row)
; (apply string-append
; (map (lambda (x)
; (case x
; [(off) " "]
; [(on) "x"]))
; row)))
; (apply map list (map vector->list (vector->list test-board))))
;
; `("x xxxxxxxx "
; "xx xxxx xxxx "
; "xxxx x xx xxxx"
; "xxxxxxxx xx xxxx"
; "xxxxxx x xxx xxxxxxx"
; "xxxx xxxxxxxx xxxx"
; "xxx xxxxxxx x"
; "x xx "
; "x xx "
; " xx xx xx x"
; " xxx xx x x x xx"
; "xxxxxxx xxxxxxxx xx"
; "xxx xxxxxxx xxxx xx"
; "xxx x x xx xxx xxx"
; "xxx xxxx xxxxxx xxx"
; "xxxx x xxxx xxx"
; "xxxx x xxxx xxxx"
; "xxxxx x xxxx xxxx"
; "xxxxxxx xxxx xxxxx"
; "xxxxxxx xxxxxx xxxxx")))
| false |
2501f8909f063b06f080435461ce1ba3e832897a | 6ad6a306035858ad44e5e4f71a10ce23f83d781b | /3/35.rkt | f125da633d9325568834397dd8556714afd1933c | []
| no_license | lzq420241/sicp_exercise | 0217b334cef34910590656227db26a486eff907f | 84839a30376cbc263df6ec68883f3d6d284abd41 | refs/heads/master | 2020-04-24T01:28:31.427891 | 2017-04-24T00:01:33 | 2017-04-24T00:01:33 | 66,690,658 | 0 | 0 | null | null | null | null | UTF-8 | Racket | false | false | 223 | rkt | 35.rkt | #lang sicp
(#%require "retractor_lib.rkt")
(define A (make-connector))
(define B (make-connector))
(squarer A B)
(probe "data 1" A)
(probe "sq" B)
(set-value! A 8 'user)
(forget-value! A 'user)
(set-value! B 256 'user)
| false |
9e679f631c459d5c6d5673d3dc00473d1df821f6 | 2cfd2e7dbfec688de9d738a7ff047e3227678b8f | /clicker-cartoon/info.rkt | 774bc84832a88b5c49c777c2d1b07db2f3f21b6f | []
| no_license | thoughtstem/TS-K2-Languages | 52376f33ea8471da71edf50fe0708ec5bd0b0271 | 680ef0c5d8f9265a0114a612c25aa16c55abec88 | refs/heads/master | 2020-08-05T08:24:48.444660 | 2020-02-29T00:44:08 | 2020-02-29T00:44:08 | 212,463,806 | 0 | 0 | null | 2020-02-29T00:44:09 | 2019-10-02T23:52:06 | Racket | UTF-8 | Racket | false | false | 344 | rkt | info.rkt | #lang info
(define scribblings
'(("scribblings/manual.scrbl" ())))
(define deps '(
"https://github.com/thoughtstem/TS-K2-Languages.git?path=clicker-cartoon-collect"
"https://github.com/thoughtstem/TS-K2-Languages.git?path=clicker-cartoon-avoid"
"https://github.com/thoughtstem/TS-K2-Languages.git?path=clicker-cartoon-special"
))
| false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.