blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
171
content_id
stringlengths
40
40
detected_licenses
sequencelengths
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
unknown
revision_date
unknown
committer_date
unknown
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
unknown
gha_created_at
unknown
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
e9a52e12b35b4835f7c0d34134550eb74e914dde
e1cf61b84282c33b7a245f4d483883cf77739b91
/se3-bib/sim/simAppl/simCustomerView-module.rkt
7969d5f77abaeaef22dcd2e3b73a95ba56e814af
[]
no_license
timesqueezer/uni
c942718886f0366b240bb222c585ad7ca21afcd4
5f79a40b74240f2ff88faccf8beec7b1b3c28a7c
refs/heads/master
"2022-09-23T21:57:23.326315"
"2022-09-22T13:17:29"
"2022-09-22T13:17:29"
71,152,113
0
2
null
null
null
null
UTF-8
Racket
false
false
814
rkt
simCustomerView-module.rkt
#lang swindle #| ################################################################################ ## ## ## This file is part of the se3-bib Racket module v3.0 ## ## Copyright by Leonie Dreschler-Fischer, 2010 ## ## Ported to Racket v6.2.1 by Benjamin Seppke, 2015 ## ## ## ################################################################################ |# (require se3-bib/sim/simBase/sim-base-package se3-bib/sim/simAppl/simCustomerClass-module se3-bib/sim/simAppl/simCustomerImpl-module) (defmethod actor-picture ((c customer)) (picture-with-name c))
false
4414d54d1b07e0e14cb05bf04285fc936720ec88
3fe8cb649e5ed157a951b6224e70bc1e97b803ae
/plai/ch16/ch16.rkt
d0a7bd024c3c3b44fed8680d7d9463d9e1862bfd
[]
no_license
howell/courses
69ca4ba4b7c12792eee936e04ca7eefc537e697c
ce15bd5b30f15fbed5e80c13b70bc64696083e2b
refs/heads/master
"2021-01-18T02:51:44.334482"
"2015-06-10T22:29:31"
"2015-06-10T22:29:31"
24,762,289
0
0
null
null
null
null
UTF-8
Racket
false
false
1,494
rkt
ch16.rkt
#lang plai (define (make-contract pred?) (lambda (val) (if (pred? val) val (blame "violation")))) (define (blame s) (error 'contract "~a" s)) (define non-neg?-contract (make-contract (lambda (n) (and (number? n) (>= n 0))))) (define (real-sqrt-1 x) (sqrt (non-neg?-contract x))) (define (real-sqrt-2 x) (begin (non-neg?-contract x) (sqrt x))) (define d/dx (lambda (f) (lambda (x) (/ (- (f (+ x 0.001)) (f x)) 0.001)))) (define (even-list? l) (cond [(empty? l) #t] [else (and (even? (first l)) (even-list? (rest l)))])) (define even-list?-contract (make-contract (lambda (l) (and (list? l) (andmap number? l) (even-list? l))))) (define (immediate pred?) (lambda (val) (if (pred? val) val (blame val)))) (define (guard ctc val) (ctc val)) (define (function dom rng) (lambda (val) (if (procedure? val) (lambda (x) (rng (val (dom x)))) (blame val)))) (define-syntax (define/contract stx) (syntax-case stx (::) [(_ (f (id :: c) ...) b) (with-syntax ([(new-id ...) (generate-temporaries #'(id ...))]) #'(define f (lambda (new-id ...) (let ([id (guard c new-id)] ...) b))))])) (define num?-con (immediate number?)) (define a1 (guard (function (immediate number?) (immediate number?)) add1))
true
81fe42e4c764ac5f5d02d3e9665cbc872191ba8b
18c09f49ee1b6670426be9b0d10b6fb24f1475e4
/Task/Here-document/Racket/here-document-2.rkt
f577a41fb72d23e87cdbb1ab750c97de7f6aa933
[]
no_license
hitme/RosettaCodeData
579f07fe898b6642414281cf8567bac01f6098df
1f1ad4942732d2b45e67dd9264c3cc8924a72d78
refs/heads/master
"2021-01-13T04:37:54.198047"
"2013-04-12T23:18:05"
"2013-04-12T23:18:05"
null
0
0
null
null
null
null
UTF-8
Racket
false
false
392
rkt
here-document-2.rkt
#lang at-exp racket/base (require scribble/text) (define excited "!!!") (define (shout . text) @list{>>> @text <<<}) (output @list{Blah blah blah with indentation intact but respecting the indentation of the whole code and "free" \punctuations\ and even string interpolation-like @excited but really @shout{any code} })
false
5f132f2e581926d0d4a5337db9aef278f1c0c508
cc06424c5203c28d6aea69f8d5734f9acc067075
/src/test/map-test.rkt
c88c62d4d92fa587e7056b793ddc1bb3eb84cc16
[]
no_license
uwplse/syncro
48e5ab79793dfb631b85e39a19803e1b407854d0
cd89d345293f9512350b716ed9e938ff308a162b
refs/heads/master
"2021-01-23T10:55:06.557355"
"2017-11-24T23:26:15"
"2017-11-24T23:26:15"
93,102,017
2
1
null
"2017-11-24T23:26:16"
"2017-06-01T21:43:17"
Racket
UTF-8
Racket
false
false
2,134
rkt
map-test.rkt
#lang rosette (require rackunit rackunit/text-ui) (require "../rosette/map.rkt" "../rosette/types.rkt") (provide run-map-tests) (define tests (test-suite "Tests for map.rkt" (let () (define-symbolic b1 b2 boolean?) (define (check-all-pcs actual expected) (for ([formula (list (and b1 b2) (and b1 (not b2)) (and (not b1) b2) (and (not b1) (not b2)))] [result expected]) (let* ([model (solve (assert formula))] [eval-actual (evaluate actual model)]) (check-equal? eval-actual result (format "Got ~a, expected ~a for condition ~a" eval-actual result formula))))) (test-case "Symbolic operations" (define test-map (build-map 5 identity identity)) (check-equal? (map-keys test-map) (range 5)) (check-equal? (map-values test-map) (range 5)) (check-false (map-has-key? test-map 'a)) (check-true (map-has-key? test-map 2)) (for ([i 5]) (check-equal? (map-ref test-map i) i)) (when (and b1 b2) (map-set! test-map 1 'a)) (when (or b1 b2) (map-set! test-map 2 'b)) (check-all-pcs (map-ref test-map 1) '(a 1 1 1)) (check-all-pcs (map-ref test-map 2) '(b b b 2)) (unless b1 (map-set! test-map 1 (if (equal? (map-ref test-map 2) 'b) 'd 'c))) (check-all-pcs (map-ref test-map 1) '(a 1 d c)) (check-all-pcs (map-ref test-map 2) '(b b b 2))) (test-case "Multiple maps" (define test-map (if b1 (build-map 5 identity identity) (build-map 3 add1 (curry * 3)))) (when (and b1 b2) (map-set! test-map 1 'a)) (when (or b1 b2) (map-set! test-map 2 'b)) (check-all-pcs (map-ref test-map 1) '(a 1 0 0)) (check-all-pcs (map-ref test-map 2) '(b b b 3))) ))) (define (run-map-tests) (displayln "Running tests for map.rkt") (run-tests tests)) (module+ main (run-map-tests))
false
86986b41283fb2ccb8480c4250b2908f5d331f79
0eab3dd9232b8f2840f47eb830d34f17c0748206
/counter-example.rkt
660960a8d84ffbd11c26cc93825a443efa69671e
[ "Apache-2.0" ]
permissive
joergen7/plang
824feb3724b97f62a80a53ccb27cd8876e3fa350
8c969162d6fa2248e21edd208f70c60556b0da28
refs/heads/master
"2023-01-05T23:01:27.389871"
"2023-01-05T09:28:34"
"2023-01-05T09:28:34"
177,028,390
2
0
null
null
null
null
UTF-8
Racket
false
false
732
rkt
counter-example.rkt
#lang racket/base (require racket/place racket/serialize web-server/lang/serial-lambda) (define mys (serial-lambda (f) (define p (let ([p (place c (define f (deserialize (place-channel-get c))) (f c))]) (place-channel-put p (serialize f)) p)) (let-values ([(a b) (place-channel)]) (place-channel-put p (cons (serialize "pmatos") b)) a) (place-wait p))) (define f (serial-lambda (self) (let-values ([(m q) (let ([x (place-channel-get self)]) (values (deserialize (car x)) (cdr x)))]) (displayln (format "hello world ~a" m)))))
false
41f8cab30f55a76790f00075017f4d36d740869c
6c60c8d1303f357c2c3d137f15089230cb09479b
/compatibility-lib/mzlib/deflate.rkt
31d33e2f1711ef0e8055a12142ad14130932ecd0
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
racket/compatibility
6f96569a3e98909e1e89260eeedf4166b5e26890
5b2509e30e3b93ca9d6c9d6d8286af93c662d9a8
refs/heads/master
"2023-08-23T06:41:14.503854"
"2022-07-08T02:43:36"
"2022-07-14T18:00:20"
27,431,360
6
10
NOASSERTION
"2022-07-14T18:00:21"
"2014-12-02T12:23:20"
Racket
UTF-8
Racket
false
false
114
rkt
deflate.rkt
#lang racket/base ;; deprecated library, see `file/gzip` (require file/gzip) (provide (all-from-out file/gzip))
false
120bbb22e03ea78be05d44611e886b80f0d480cc
e37edd994adf5cd8a155bde537f99e53ca4cd31b
/Racket/Untitled.rkt
85539b8038ec6dfc24754645d0ff696e7d4b2b68
[]
no_license
Shouren/snippet
10d086b35f24beb226028e4ebcf8f410768e2fc4
39af8ece730b6614204f2e63387af421715345a5
refs/heads/master
"2023-06-22T14:49:23.272950"
"2019-10-01T13:02:33"
"2019-10-01T13:02:33"
37,904,567
0
0
null
"2023-06-21T22:09:15"
"2015-06-23T07:42:28"
Python
UTF-8
Racket
false
false
438
rkt
Untitled.rkt
#lang racket (require "Documents/Dev/testing/learn.rkt") (require slideshow) (require slideshow/code) (define-syntax code+pict (syntax-rules () [(code+pict expr) (hc-append 10 expr (code expr))])) (require racket/class racket/gui/base) (define f (new frame% [label "My Art"] [width 300] [height 300] [alignment '(center center)]))
true
72f8cbc86e00d8d7a5bdda3d568cd926b5b9401f
98fd12cbf428dda4c673987ff64ace5e558874c4
/sicp/v2/4.4/qEval.rkt
c535901c28c8b5e9d3b2c41ccdcb3d8de5e158ec
[ "Unlicense" ]
permissive
CompSciCabal/SMRTYPRTY
397645d909ff1c3d1517b44a1bb0173195b0616e
a8e2c5049199635fecce7b7f70a2225cda6558d8
refs/heads/master
"2021-12-30T04:50:30.599471"
"2021-12-27T23:50:16"
"2021-12-27T23:50:16"
13,666,108
66
11
Unlicense
"2019-05-13T03:45:42"
"2013-10-18T01:26:44"
Racket
UTF-8
Racket
false
false
24,627
rkt
qEval.rkt
; Data directed dispatch table ; ============================ ; See section 3.3 https://sarabander.github.io/sicp/html/3_002e3.xhtml#DOCF152 and ; Chapter 2 for details. (define (make-table) (let ((local-table (list '*table*))) (define (lookup key-1 key-2) (let ((subtable (assoc key-1 (cdr local-table)))) (if subtable (let ((record (assoc key-2 (cdr subtable)))) (if record (cdr record) #f)) #f))) (define (insert! key-1 key-2 value) (let ((subtable (assoc key-1 (cdr local-table)))) (if subtable (let ((record (assoc key-2 (cdr subtable)))) (if record (set-cdr! record value) (set-cdr! subtable (cons (cons key-2 value) (cdr subtable))))) (set-cdr! local-table (cons (list key-1 (cons key-2 value)) (cdr local-table))))) 'ok) (define (dispatch m) (cond ((eq? m 'get) lookup) ((eq? m 'put) insert!) (else (error "Unknown operation: TABLE" m)))) dispatch)) (define table (make-table)) (define operation-table (make-table)) (define get (operation-table 'get)) (define put (operation-table 'put)) (define (tagged-list? exp tag) (if (pair? exp) (eq? (car exp) tag) #f)) ; Stream stuff ; ============ (define the-empty-stream '()) (define (display-line x) (newline) (display x)) (define (memo-proc proc) (let ((already-run? #f) (result #f)) (lambda () (if (not already-run?) (begin (set! result (proc)) (set! already-run? #t) result) result)))) (define (cons-stream a b) (cons a (delay b))) (define (stream-car stream) (car stream)) (define (stream-cdr stream) (force (cdr stream))) (define (stream-null? s) (equal? s the-empty-stream)) (define (stream-for-each proc s) (if (stream-null? s) 'done (begin (proc (stream-car s)) (stream-for-each proc (stream-cdr s))))) (define (stream-map proc s) (if (stream-null? s) the-empty-stream (cons-stream (proc (stream-car s)) (stream-map proc (stream-cdr s))))) (define (stream-append s1 s2) (if (stream-null? s1) s2 (cons-stream (stream-car s1) (stream-append (stream-cdr s1) s2)))) (define (display-stream s) (stream-for-each display-line s)) ; 4.4.4.1 The driver loop ; ======================= (define input-prompt "? ") (define output-prompt "> ") #| "When the query is instantiated, any variables that remain unbound are transformed back to theinput representation before being printed. These transformations are performed by the two procedures query-syntax-process and contract-question-mark (4.4.4.7)." ^ This maybe the variable name munging that Ableson mentions in the video, to prevent variable name collisions. |# (define (query-driver-loop) (prompt-for-input input-prompt) ; "Before doing any processing on an input expression, the driver loop transforms ; it syntactically into a form that makes the processing more efficient. " (let ((q (query-syntax-process (read)))) (cond ((assertion-to-be-added? q) (add-rule-or-assertion! (add-assertion-body q)) (newline) (display "Assertion added to database.") (query-driver-loop)) (else (newline) (display output-prompt) (display-stream (stream-map ; this lambda instantiates the query with a frame from the stream? (lambda (frame) (instantiate q frame (lambda (var frame) (contract-question-mark var)))) ; ; this kicks off the process by evaling the query without any constraints: (qeval q (singleton-stream '())))) (query-driver-loop))))) (define (prompt-for-input string) (newline) (newline) (display string) (newline)) (define (instantiate exp frame unbound-var-handler) (define (copy exp) (cond ((var? exp) (let ((binding (binding-in-frame exp frame))) (if binding (copy (binding-value binding)) (unbound-var-handler exp frame)))) ((pair? exp) (cons (copy (car exp)) (copy (cdr exp)))) (else exp))) (copy exp)) ; 4.4.4.2: The Evaluator ; ====================== #| The qeval procedure, called by the query-driver-loop, is the basic evaluator of the query system. It takes as inputs a query and a stream of frames, and it returns a stream of extended frames. It identifies special forms by a data-directed dispatch using get and put. Any query that is not identified as a special form is assumed to be a simple query, to be processed by simple-query. |# (define (qeval query frame-stream) (let ((qproc (get (type query) 'qeval))) (if qproc (qproc (contents query) frame-stream) (simple-query query frame-stream)))) #| Simple-query takes as arguments a simple query (a pattern) together with a stream of frames, and it returns the stream formed by extending each frame by all data-base matches of the query. |# (define (simple-query query-pattern frame-stream) (stream-flatmap (lambda (frame) (stream-append-delayed (find-assertions query-pattern frame) (delay (apply-rules query-pattern frame)))) frame-stream)) #| Conjoin processes the stream of frames to find the stream of all possible frame extensions that satisfy the first query in the conjunction. Then, using this as the new frame stream, it recursively applies conjoin to the rest of the queries. |# (define (conjoin conjuncts frame-stream) (if (empty-conjunction? conjuncts) frame-stream (conjoin (rest-conjuncts conjuncts) (qeval (first-conjunct conjuncts) frame-stream)))) ; The expression (put 'and 'qeval conjoin) ;sets up qeval to dispatch to conjoin when an and form is encountered. (define (disjoin disjuncts frame-stream) (if (empty-disjunction? disjuncts) the-empty-stream (interleave-delayed (qeval (first-disjunct disjuncts) frame-stream) (delay (disjoin (rest-disjuncts disjuncts) frame-stream))))) (put 'or 'qeval disjoin) #|We attempt to extend each frame in the input stream to satisfy the query being negated, and we include a given frame in the output stream only if it cannot be extended. |# (define (negate operands frame-stream) (stream-flatmap (lambda (frame) (if (stream-null? (qeval (negated-query operands) (singleton-stream frame))) (singleton-stream frame) the-empty-stream)) frame-stream)) (put 'not 'qeval negate) #| Each frame in the stream is used to instantiate the variables in the pattern, the indicated predicate is applied, and the frames for which the predicate returns false are filtered out of the input stream. |# (define (lisp-value test frame-stream) ; test will be something like `> ?amount 30000` (stream-flatmap (lambda (frame) (if (execute (instantiate test frame (lambda (var frame) (error "Unknow pattern var: LISP-VALUE" var)))) (singleton-stream frame) the-empty-stream)) frame-stream)) (put 'lisp-value 'qeval lisp-value) #| "Execute must eval the predicate expression to get the procedure to apply. However, it must not evaluate the arguments, since they are already the actual arguments, not expressions whose evaluation (in Lisp) will produce the arguments." Ie: `> ?amount 30000` |# (define user-initial-environment (scheme-report-environment 5)) (define (execute exp) (apply (eval (predicate exp) user-initial-environment) (args exp))) #| always-true is used by the rule-body selector (4.4.4.7) to provide bodies for rules that were defined without bodies |# (define (always-true ignore frame-stream) frame-stream) (put 'always-true 'qeval always-true) ; 4.4.4.3: Finding assertions/pattern matching ; ============================================ #| Find-assertions, called by simple-query, takes as input a pattern and a frame. It returns a stream of frames, each extending the given one by a data-base match of the given pattern. It uses fetch-assertions to get a stream of all the assertions in the data base that should be checked for a match against the pattern and the frame. The reason for fetch-assertions here is that we can often apply simple tests that will eliminate many of the entries in the data base from the pool of candidates for a successful match. |# (define (find-assertions pattern frame) (stream-flatmap (lambda (datum) (check-an-assertion datum pattern frame)) (fetch-assertions pattern frame))) (define (check-an-assertion assertion query-pat query-frame) (let ((match-result (pattern-match query-pat assertion query-frame))) (if (eq? match-result 'failed) the-empty-stream (singleton-stream match-result)))) (define (pattern-match pat dat frame) (cond ((eq? frame 'failed) 'failed) ((equal? pat dat) frame) ((var? pat) (extend-if-consistent pat dat frame)) ; If the pattern and the data are both pairs, we (recursively) match the car of the ; pattern against the car of the data to produce a frame; in this frame we then ; match the cdr of the pattern against the cdr of the data. ; ; Eg: match the list ((a b) c (a b)) against (?x c ?x); or (?x a ?y) and (?y ?z a) ((and (pair? pat) (pair? dat)) (pattern-match (cdr pat) (cdr dat) (pattern-match (car pat) (car dat) frame))) (else 'failed))) (define (extend-if-consistent var dat frame) ; Is there a binding for this variable? (let ((binding (binding-in-frame var frame))) (if binding #| Match, in the frame, the data against the value of the variable in the frame: For example, suppose we have a frame in which ?x is bound to (f ?y) and ?y is unbound, and we wish to augment this frame by a binding of ?x to (f b). We look up ?x and find that it is bound to (f ?y). This leads us to match (f ?y) against the proposed new value (f b) in the same frame. This match extends the frame by adding a binding of ?y to b. ?X remains bound to (f ?y). *We never modify a stored binding and we never store more than one binding for a given variable.* |# (pattern-match (binding-value binding) dat frame) ; No binding: add the binding of the variable to the data: (extend var dat frame)))) ; 4.4.4.4: Rules and Unification ; ============================== #| Apply-rules is the rule analog of find-assertions (4.4.4.3). It takes as input a pattern and a frame, and it forms a stream of extension frames by applying rules from the data base. Stream-flatmap maps apply-a-rule down the stream of possibly applicable rules (selected by fetch-rules, 4.4.4.5) and combines the resulting streams of frames. |# (define (apply-rules pattern frame) (stream-flatmap (lambda (rule) (apply-a-rule rule pattern frame)) (fetch-rules pattern frame))) (define (apply-a-rule rule query-pattern query-frame) (let ((clean-rule (rename-variables-in rule))) (let ((unify-result (unify-match query-pattern (conclusion clean-rule) query-frame))) (if (eq? unify-result 'failed) the-empty-stream (qeval (rule-body clean-rule) (singleton-stream unify-result)))))) (define (rename-variables-in rule) (let ((rule-application-id (new-rule-application-id))) (define (tree-walk exp) (cond ((var? exp) (make-new-variable exp rule-application-id)) ((pair? exp) (cons (tree-walk (car exp)) (tree-walk (cdr exp)))) (else exp))) (tree-walk rule))) #| The unification algorithm is implemented as a procedure that takes as inputs two patterns and a frame and returns either the extended frame or the symbol failed. The unifier is like the pattern matcher except that it is symmetrical—variables are allowed on both sides of the match. Unify-match is basically the same as pattern-match, except that there is extra code to handle the case where the object on the right side of the match is a variable. |# (define (unify-match p1 p2 frame) (cond ((eq? frame 'failed) 'failed) ((equal? p1 p2) frame) ((var? p1) (extend-if-possible p1 p2 frame)) ((var? p2) (extend-if-possible p2 p1 frame)) ((and (pair? p1) (pair? p2)) (unify-match (cdr p1) (cdr p2) (unify-match (car p1) (car p2) frame))) (else 'failed))) #| In unification, as in one-sided pattern matching, we want to accept a proposed extension of the frame only if it is consistent with existing bindings. The procedure extend-if-possible used in unification is the same as the extend-if-consistent used in pattern matching except for two special checks, marked “***” in the program below. In the first case, if the variable we are trying to match is not bound, but the value we are trying to match it with is itself a (different) variable, it is necessary to check to see if the value is bound, and if so, to match its value. If both parties to the match are unbound, we may bind either to the other. |# (define (extend-if-possible var val frame) (let ((binding (binding-in-frame var frame))) (cond (binding (unify-match (binding-value binding) val frame)) ((var? val) (let ((binding (binding-in-frame val frame))) ; *** (if binding (unify-match var (binding-value binding) frame) (extend var val frame)))) ((depends-on? val var frame) 'failed) ; *** This is for binding that imply a fixed-point equation (else (extend var val frame))))) (define (depends-on? exp var frame) (define (tree-walk e) (cond ((var? e) (if (equal? var e) #t (let ((b (binding-in-frame e frame))) (if b (tree-walk (binding-value b)) #f)))) ((pair? e) (or (tree-walk (car e)) (tree-walk (cdr e)))) (else #f))) (tree-walk exp)) ; 4.4.4.5: Maintaining the database ; ================================= (define THE-ASSERTIONS the-empty-stream) (define (fetch-assertions pattern frame) (if (use-index? pattern) (get-indexed-assertions pattern) (get-all-assertions))) (define (get-all-assertions) THE-ASSERTIONS) (define (get-indexed-assertions pattern) (get-stream (index-key-of pattern) 'assertion-stream)) (define (get-stream key1 key2) (let ((s (get key1 key2))) (if s s the-empty-stream))) (define THE-RULES the-empty-stream) (define (fetch-rules pattern frame) (if (use-index? pattern) (get-indexed-rules pattern) (get-all-rules))) (define (get-all-rules) THE-RULES) (define (get-indexed-rules pattern) (stream-append (get-stream (index-key-of pattern) 'rule-stream) (get-stream '? 'rule-stream))) (define (add-rule-or-assertion! assertion) (if (rule? assertion) (add-rule! assertion) (add-assertion! assertion))) (define (add-assertion! assertion) (store-assertion-in-index assertion) (let ((old-assertions THE-ASSERTIONS)) (set! THE-ASSERTIONS (cons-stream assertion old-assertions)) 'ok)) (define (add-rule! rule) (store-rule-in-index rule) (let ((old-rules THE-RULES)) (set! THE-RULES (cons-stream rule old-rules)) 'ok)) (define (store-assertion-in-index assertion) (if (indexable? assertion) (let ((key (index-key-of assertion))) (let ((current-assertion-stream (get-stream key 'assertion-stream))) (put key 'assertion-stream (cons-stream assertion current-assertion-stream)))))) (define (store-rule-in-index rule) (let ((pattern (conclusion rule))) (if (indexable? pattern) (let ((key (index-key-of pattern))) (let ((current-rule-stream (get-stream key 'rule-stream))) (put key 'rule-stream (cons-stream rule current-rule-stream))))))) (define (indexable? pat) (or (constant-symbol? (car pat)) (var? (car pat)))) (define (index-key-of pat) (let ((key (car pat))) (if (var? key) '? key))) (define (use-index? pat) (constant-symbol? (car pat))) ; 4.4.4.6: Stream Operations ; ========================== (define (stream-append-delayed s1 delayed-s2) (if (stream-null? s1) (force delayed-s2) (cons-stream (stream-car s1) (stream-append-delayed (stream-cdr s1) delayed-s2)))) (define (interleave-delayed s1 delayed-s2) (if (stream-null? s1) (force delayed-s2) (cons-stream (stream-car s1) (interleave-delayed (force delayed-s2) (delay (stream-cdr s1)))))) #| Stream-flatmap, which is used throughout the query evaluator to map a procedure over a stream of frames and combine the resulting streams of frames, is the stream analog of the flatmap procedure introduced for ordinary lists in 2.2.3. Unlike ordinary flatmap, however, we accumulate the streams with an interleaving process, rather than simply appending them (see Exercise 4.72 and Exercise 4.73). Question: What is flatten-stream doing? |# (define (stream-flatmap proc s) (flatten-stream (stream-map proc s))) (define (flatten-stream stream) (if (stream-null? stream) the-empty-stream (interleave-delayed (stream-car stream) (delay (flatten-stream (stream-cdr stream)))))) (define (singleton-stream x) (cons-stream x the-empty-stream)) ; 4.4.4.7: Query Syntax Procedures ; ================================ (define (type exp) (if (pair? exp) (car exp) (error "Unknown expression TYPE" exp))) (define (contents exp) (if (pair? exp) (cdr exp) (error "Unknown expression CONTENTS" exp))) (define (assertion-to-be-added? exp) (eq? (type exp) 'assert!)) (define (add-assertion-body exp) (car (contents exp))) ; The syntax definitions for the and, or, not, and lisp-value special forms: (define (empty-conjunction? exps) (null? exps)) (define (first-conjunct exps) (car exps)) (define (rest-conjuncts exps) (cdr exps)) (define (empty-disjunction? exps) (null? exps)) (define (first-disjunct exps) (car exps)) (define (rest-disjuncts exps) (cdr exps)) (define (negated-query exps) (car exps)) (define (predicate exps) (car exps)) (define (args exps) (cdr exps)) ; The syntax of rules: (define (rule? statement) (tagged-list? statement 'rule)) (define (conclusion rule) (cadr rule)) (define (rule-body rule) (if (null? (cddr rule)) '(always-true) (caddr rule))) ; query-syntax-process transform a pattern from, eg: ; (job ?x ?y) into (job (? x) (? y)) (define (query-syntax-process exp) (map-over-symbols expand-question-mark exp)) (define (map-over-symbols proc exp) (cond ((pair? exp) (cons (map-over-symbols proc (car exp)) (map-over-symbols proc (cdr exp)))) ((symbol? exp) (proc exp)) (else exp))) (define (expand-question-mark symbol) ; a symbol: 'foo ; a string: "foo" (let ((chars (symbol->string symbol))) (if (string=? (substring chars 0 1) "?") (list '? (string->symbol (substring chars 1 (string-length chars)))) symbol))) (define (var? exp) (tagged-list? exp '?)) (define (constant-symbol? exp) (symbol? exp)) ; Rule counter, incremented each time a rule is applied, to provide unique ; variable names, preventing name collision: (define rule-counter 0) (define (new-rule-application-id) (set! rule-counter (+ 1 rule-counter)) rule-counter) (define (make-new-variable var rule-application-id) (cons '? (cons rule-application-id (cdr var)))) (define (contract-question-mark variable) (string->symbol (string-append "?" (if (number? (cadr variable)) (string-append (symbol->string (caddr variable))"-"(number->string (cadr variable))) (symbol->string (cadr variable)))))) ; 4.4.4.8 Frames and Bindings ; =========================== ; Frames are represented as lists of bindings, which are variable-value pairs: (define (make-binding variable value) (cons variable value)) (define (binding-variable binding) (car binding)) (define (binding-value binding) (cdr binding)) (define (binding-in-frame variable frame) (assoc variable frame)) (define (extend variable value frame) (cons (make-binding variable value) frame)) ; Add assertions to DB ; ==================== (define (add assertion) (let ((q (query-syntax-process assertion))) (add-rule-or-assertion! q)) (newline) (display "Startup assertion added") ) (add '(address (Bitdiddle Ben) (Slumerville (Ridge Road) 10))) (add '(job (Bitdiddle Ben) (computer wizard))) (add '(salary (Bitdiddle Ben) 60000)) (add '(address (Hacker Alyssa P) (Cambridge (Mass Ave) 78))) (add '(job (Hacker Alyssa P) (computer programmer))) (add '(salary (Hacker Alyssa P) 40000)) (add '(supervisor (Hacker Alyssa P) (Bitdiddle Ben))) (add '(address (Fect Cy D) (Cambridge (Ames Street) 3))) (add '(rule (lives-near ?person-1 ?person-2) (and (address ?person-1 (?town . ?rest-1)) (address ?person-2 (?town . ?rest-2)) (not (same ?person-1 ?person-2))))) (add '(rule (same ?x ?x))) (add '(job (Fect Cy D) (computer programmer))) (add '(salary (Fect Cy D) 35000)) (add '(supervisor (Fect Cy D) (Bitdiddle Ben))) (add '(address (Tweakit Lem E) (Boston (Bay State Road) 22))) (add '(job (Tweakit Lem E) (computer technician))) (add '(salary (Tweakit Lem E) 25000)) (add '(supervisor (Tweakit Lem E) (Bitdiddle Ben))) (add '(address (Reasoner Louis) (Slumerville (Pine Tree Road) 80))) (add '(job (Reasoner Louis) (computer programmer trainee))) (add '(salary (Reasoner Louis) 30000)) (add '(supervisor (Reasoner Louis) (Hacker Alyssa P))) (add '(supervisor (Bitdiddle Ben) (Warbucks Oliver))) (add '(address (Warbucks Oliver) (Swellesley (Top Heap Road)))) (add '(job (Warbucks Oliver) (administration big wheel))) (add '(salary (Warbucks Oliver) 150000)) (add '(address (Scrooge Eben) (Weston (Shady Lane) 10))) (add '(job (Scrooge Eben) (accounting chief accountant))) (add '(salary (Scrooge Eben) 75000)) (add '(supervisor (Scrooge Eben) (Warbucks Oliver))) (add '(address (Cratchet Robert) (Allston (N Harvard Street) 16))) (add '(job (Cratchet Robert) (accounting scrivener))) (add '(salary (Cratchet Robert) 18000)) (add '(supervisor (Cratchet Robert) (Scrooge Eben))) (add '(address (Aull DeWitt) (Slumerville (Onion Square) 5))) (add '(job (Aull DeWitt) (administration secretary))) (add '(salary (Aull DeWitt) 25000)) (add '(supervisor (Aull DeWitt) (Warbucks Oliver))) (add '(can-do-job (computer wizard) (computer programmer))) (add '(can-do-job (computer wizard) (computer technician))) (add '(can-do-job (computer programmer) (computer programmer trainee))) (add '(can-do-job (administration secretary) (administration big wheel))) (add '(rule (wheel ?person) (and (supervisor ?middle-manager ?person) (supervisor ?x ?middle-manager)))) (add '(rule (outranked-by ?staff-person ?boss) (or (supervisor ?staff-person ?boss) (and (supervisor ?staff-person ?middle-manager) (outranked-by ?middle-manager ?boss))))) (add '(meeting accounting (Monday 9am))) (add '(meeting administration (Monday 10am))) (add '(meeting computer (Wednesday 3pm))) (add '(meeting administration (Friday 1pm))) (add '(meeting whole-company (Wednesday 4pm))) (add '(rule (append-to-form () ?y ?y))) (add '(rule (append-to-form (?u . ?v) ?y (?u . ?z)) (append-to-form ?v ?y ?z))) (add '(rule (meeting-time ?person ?day-and-time) (or (meeting whole-company ?day-and-time) (and (job ?person (?division . ?job)) (meeting ?division ?day-and-time) )))) ; GO ; == (query-driver-loop)
false
1c40c74f61c31f1c1ba7c286a045cc6c124fde15
3e934e1eb7037ebc9ef5461e66981383cab6d373
/examples/heap/heap-lang.rkt
7b69790913b9d149ae2a078f04abe8034f5bb8d3
[ "MIT" ]
permissive
GaloisInc/SEEC
7f28bd1a48a1092be63586683f8138615e6a92ad
36c3f50b08038d4133acaf94ede7e09a97e1693c
refs/heads/master
"2023-06-07T23:21:38.954186"
"2021-07-06T23:39:14"
"2021-07-06T23:39:14"
308,738,514
5
0
null
null
null
null
UTF-8
Racket
false
false
19,063
rkt
heap-lang.rkt
#lang seec (require seec/private/util) (require seec/private/monad) (require racket/format) (require (only-in racket/base build-list raise-argument-error raise-arguments-error)) (require (file "lib.rkt")) (provide (all-defined-out)) ; Heap allocator model ; blocks have the form | In use? | size | payload ... | ; blocks in the freelist have the form | 0 | size | fw | bw | ... | ; state is initialize with wilderness (in use? = 0, not in the freelist) and freelist = null (define-grammar heap-model (pointer ::= natural null) (offset ::= integer) (nnvalue ::= integer) (value ::= nnvalue pointer) (buf-loc ::= natural) (buf ::= list<value>) (heap-loc ::= pointer) (heap ::= list<value>) (action ::= (read buf-loc buf-loc) ; place the element at pointer (1)buf-loc in heap into the buffer at (2)buf-loc (write buf-loc buf-loc); place the element at (1)buf-loc in buffer into the heap pointer (2)buf-loc (copy buf-loc buf-loc) ; overwrite (2) with value of (1) (incr buf-loc) ; add 1 to value at buf-loc (decr buf-loc) ; remove 1 to value at buf-loc (free buf-loc) ; free the object at the pointer held in buf-loc in buffer (alloc buf-loc)) ; alloc an object with n blocks, placing its pointer in buffer at buf-loc (interaction ::= list<action>) (action-hl ::= (read heap-loc buf-loc) (write buf-loc heap-loc) (copy buf-loc buf-loc) (incr buf-loc) (decr buf-loc) (free heap-loc) (alloc buf-loc)) (interaction-hl ::= list<action-hl>) (saction ::= (set buf-loc nnvalue)) (setup ::= list<saction>) (complete-interaction ::= (setup interaction)) (state-con ::= (buf heap pointer))) (struct state (buf heap pointer)) (define (make-state b h p) (state b h p)) ; from state-con to state (define (make-state-struct s) (match s [(heap-model (b:buf h:heap p:pointer)) (make-state b h p)])) ; from state to state-con (define (make-state-con s) (heap-model (,(state->buf s) ,(state->heap s) ,(state->pointer s)))) (define state->buf state-buf) (define state->heap state-heap) (define state->pointer state-pointer) (define (fold f l s) (match l [(heap-model nil) s] [(heap-model (cons hd:any l+:list<any>)) (f s (fold f l+ s))])) ;; lifted list operations (define (s-length s) (match s [(heap-model nil) 0] [(heap-model (cons any h:any)) (+ 1 (s-length h))])) (define (head s) (match s [(heap-model (cons x:any any)) x] [_ (assert #f) ])) (define (tail s) (match s [(heap-model (cons any tl:any)) tl] [_ (assert #f) ])) ; get the first nth value from the head of l (define (first-nth n l) (if (equal? n 0) (heap-model nil) (heap-model (cons ,(head l) ,(first-nth (- n 1) (tail l)))))) (define (skip n l) (if (equal? n 0) l (let ([tl (tail l)]) (skip (- n 1) tl)))) (define (append s1 s2) (match s1 [(heap-model nil) s2] [(heap-model (cons hd:any tl:any)) (heap-model (cons ,hd ,(append tl s2)))])) (define (drop-nth n l) (append (first-nth n l) (skip (+ n 1) l))) ; fails if out of bound ;(define/debug #:suffix (nth s i) (define (nth s i) (for/all ([i i #:exhaustive]) ; (-> any/c natural-number/c any/c) (if (equal? i 0) (head s) (let ([ts (tail s)]) (nth ts (- i 1)))))) (define (opt-nth s i) (if (and (<= 0 i) (< i (s-length s))) (nth s i) *fail*)) (define (map f l) (match l [(heap-model nil) l] [(heap-model (cons hd:any l+:any)) (heap-model (cons ,(f hd) ,(map f l+)))])) ; add v at the end of list s (define (enqueue s v) (match s [(heap-model nil) (heap-model (cons ,v nil))] [(heap-model (cons hd:any s+:any)) (heap-model (cons ,hd ,(enqueue s+ v)))])) ; replace the ith element in l with v ; list* -> integer* -> value* -> list* (define (replace l i v) (match i [(heap-model 0) (do tl <- (tail l) (heap-model (cons ,v ,tl)))] [(heap-model i:natural) (do hl <- (head l) tl <- (tail l) rl <- (replace tl (- i 1) v) (heap-model (cons ,hl ,rl)))])) ; remove the first occurence of v from the list (define (remove-one-elem l v) (match l [(heap-model nil) l] [(heap-model (cons hd:any l+:any)) (if (equal? hd v) l+ (heap-model (cons ,hd ,(remove-one-elem l+ v))))])) (define (and-seec-list f l) (match l [(heap-model nil) #t] [(heap-model (cons hd:any l+:any)) (and (f hd) (and-seec-list f l+))])) ; create a list repeating v i times (define (repeat v i) (if (equal? i 0) (heap-model nil) (heap-model (cons ,v ,(repeat v (- i 1)))))) ; returns a string concatenating ; f applied to each of the elements ; of vs (define (print-list f vs) (match vs [(heap-model nil) ""] [(heap-model (cons v:any vs+:list<any>)) (format "~a, ~a" (f v) (print-list f vs+))])) ; return the address of the nth block (define (block-addr n) (+ (* n 4) 2)) ; return #t if h doesn't contain any allocated blocks (define (empty-heap? h) (match h [(heap-model nil) #t] [(heap-model (cons v-alloc:natural (cons v-size:natural h+:heap))) (if (equal? v-alloc 0) (empty-heap? (skip v-size h+)) #f)] [(heap-model any) #f])) ; return #t if the heap consists of allocated and unallocated blocks of size 2 (define (valid-heap? h) (match h [(heap-model nil) #t] [(heap-model (cons v-alloc:natural (cons 2:natural (cons any (cons any h+:heap))))) (if (or (equal? v-alloc 0) (equal? v-alloc 1)) (valid-heap? h+) #f)] [(heap-model any) #f])) ; write value at the ith position of cell (define (write hp i v) ;(-> any/c natural-number/c any/c any/c) (if (equal? i 0) (heap-model (,v ,(tail hp))) (heap-model (,(head hp) ,(write (tail hp) (- i 1) v))))) ; init a state with buf size b-i and heap size (in cells) h-i ; heap has a wilderness (unused block not in free list) of size (h-i*4)-2 ; buf -> natural -> state* (define (init-state b h-i) (if (< h-i 1) false (let* ([payload (repeat (heap-model 0) (- (* h-i 4) 2))] [hp (heap-model (cons ,(- (* h-i 4) 2) ,payload))] [hp+ (heap-model (cons 0 ,hp))]) (state b hp+ (heap-model null))))) (define (init-empty-state b-i h-i) (init-state (repeat (heap-model 0) b-i) h-i)) ; set loc bl in buffer of s to val (define (state-buf-set bl v s) (let* ([b (state->buf s)] [b+ (replace b bl v)]) (state b+ (state->heap s) (state->pointer s)))) (define (state-fp-set fp s) (state (state->buf s) (state->heap s) fp)) ; check if p is a valid pointer in s->heap (define (state-safe-write i s) (< i (s-length (state->heap s)))) ; check if the size of the buf and heap of the state are exactly bs and hs. (define (state-size bs hs) (lambda (s) (and (equal? (s-length (state->buf s)) bs) (equal? (s-length (state->heap s)) hs)))) ; pointer* -> boolean (define (is-null? p) (match p [(heap-model null) #t] [(heap-model n:integer) #f])) (define (pointer-addr p) (match p [(heap-model n:natural) n])) (define (find-interaction-size size i) (begin (define i* (heap-model interaction size)) (define sol (solve (assert (equal? i* i)))) (if (unsat? sol) (displayln "UNSAT") (displayln "SAT")))) ; calculate the address of a heap-loc in the heap (define (heap-loc-addr hl) (match hl [(heap-model n:natural) n])) (define (interpret-alloc-no-free h) (match h [(heap-model (cons in-use:value h+1:heap)) (match h+1 [(heap-model (cons size:value h+2:heap)) (if (and (equal? in-use (heap-model 0)) (> size 1)) ; need enough space for that alloc (match h+2 ; skip 2 [(heap-model (cons p1:value h+3:heap)) (match h+3 [(heap-model (cons p2:value h+4:heap)) (if (> size 4) ; need to create a new wilderness (match h+4 [(heap-model (cons p3:value h+5:heap)) (match h+5 [(heap-model (cons p4:value h+6:heap)) (cons 2 (heap-model (cons 1 (cons 2 (cons ,p1 (cons ,p2 (cons 0 (cons ,(- size 4) ,h+6))))))))])]) ; free block is fully used (i.e. 2 or 3...) (cons 2 (heap-model (cons 1 (cons ,size ,h+2)))))])]) ; block is in use or too small, move to rest of heap (let* ([r (interpret-alloc-no-free (skip size h+2))]) (match r [(cons i hr) (let* ([new-i (+ i (+ size 2))] [old-payload (first-nth size h+2)] [old-block (heap-model (cons ,in-use (cons ,size ,old-payload)))] [new-hr (append old-block hr)]) (cons new-i new-hr))])))])])) ; reallocate the block at the head of the free-list ; heap* -> natural -> (pointer* x heap*) ; returns new free pointer X new heap (define (interpret-alloc-free h n) (let* ([newf (nth h n)] ; get the tail of the free-list [h+ (replace h (- n 2) (heap-model 1))]) ; alloc the head of the free-list (match newf [(heap-model nf:natural) (do h++ <- (replace h+ (+ nf 1) (heap-model null)) ; change the new head's backward pointer to be null (cons newf h++))] [(heap-model null) (cons newf h+)]))) ; free block at p in h, adding it to the free-list headed at f ;; (1) find the size of block (at p-1) ;; (2) add p to the fp list ;; (3) set prev-in-use (at p+sz) to 0 ;;; Returns the updated heap (define (interpret-free h f p) (match p [(heap-model n:natural) (do size <- (nth h (- n 1)) (match size [(heap-model sz:natural) (do h+ <- (replace h (- n 2) (heap-model 0)) h++ <- (replace h+ n f) h+++ <- (replace h++ (+ n 1) (heap-model null)) (match f [(heap-model null) h+++] [(heap-model nf:natural) (do h+4 <- (replace h+++ (+ nf 1) p) h+4)]))] [_ (assert #f) ]))])) (define (interpret-action a s) (for/all ([a a]) (let ([b (state->buf s)] [h (state->heap s)] [f (state->pointer s)]) (match a [(heap-model (copy bl0:buf-loc bl1:buf-loc)) (let* ([val (nth b bl0)] [b+ (replace b bl1 val)]) (state b+ h f))] [(heap-model (free bl:buf-loc)) (let* ([p (nth b bl)] [b+ (replace b bl (heap-model null))] [h+ (interpret-free h f p)]) (state b+ h+ p))] [(heap-model (alloc bl:buf-loc)) (match f [(heap-model n:natural) (let* ([ph+ (interpret-alloc-free h n)] [b+ (replace b bl f)]) (state b+ (cdr ph+) (car ph+)))] [(heap-model null) (let* ([ph+ (interpret-alloc-no-free h)] [b+ (replace b bl (heap-model ,(car ph+)))]) (state b+ (cdr ph+) f))])] [(heap-model (incr bl:buf-loc)) (let* ([val (nth b bl)] [b+ (replace b bl (+ val 1))]) (state b+ h f))] [(heap-model (decr bl:buf-loc)) (let* ([val (nth b bl)] [b+ (replace b bl (- val 1))]) (state b+ h f))] [(heap-model (read bhl:buf-loc bl:buf-loc)) (let* ([loc (nth b bhl)] ; get the pointer [val (nth h loc)] ; get the value at the location [b+ (replace b bl val)]) ; place the value in the buffer (state b+ h f))] [(heap-model (write bl:buf-loc bhl:buf-loc)) (let* ([val (nth b bl)] [loc (nth b bhl)] [h+ (write h loc val)]) (state b h+ f))])))) (define (interpret-interaction i s) (match i [(heap-model (cons a:action i+:interaction)) (interpret-interaction i+ (interpret-action a s))] [(heap-model nil) s])) (define/debug #:suffix (interpret-action-hl a s) (for/all ([a a]) (debug-display "~a" a) (let ([b (state->buf s)] [h (state->heap s)] [f (state->pointer s)]) (match a [(heap-model (copy bl0:buf-loc bl1:buf-loc)) (let* ([val (nth b bl0)] [b+ (replace b bl1 val)]) (state b+ h f))] [(heap-model (free p:heap-loc)) (let* ([h+ (interpret-free h f p)]) (state b h+ p))] [(heap-model (alloc bl:buf-loc)) (match f [(heap-model n:natural) (let* ([ph+ (interpret-alloc-free h n)] [b+ (replace b bl f)]) (state b+ (cdr ph+) (car ph+)))] [(heap-model null) (let* ([ph+ (interpret-alloc-no-free h)] [b+ (replace b bl (heap-model ,(car ph+)))]) (state b+ (cdr ph+) f))])] [(heap-model (incr bl:buf-loc)) (let* ([val (nth b bl)] [b+ (replace b bl (+ val 1))]) (state b+ h f))] [(heap-model (decr bl:buf-loc)) (let* ([val (nth b bl)] [b+ (replace b bl (- val 1))]) (state b+ h f))] [(heap-model (read hl:heap-loc bl:buf-loc)) (let* ([val (nth h hl)] ; get the value at the location [b+ (replace b bl val)]) ; place the value in the buffer (state b+ h f))] [(heap-model (write bl:buf-loc hl:buf-loc)) (let* ([val (nth b bl)] [h+ (write h hl val)]) (state b h+ f))])))) (define (interpret-interaction-hl i s) (match i [(heap-model (cons a:action-hl i+:interaction-hl)) (interpret-interaction-hl i+ (interpret-action-hl a s))] [(heap-model nil) s])) (define (interpret-saction a s) (match a [(heap-model (set bl:buf-loc v:nnvalue)) (state-buf-set bl v s)])) (define (interpret-setup setup s) (match setup [(heap-model nil) s] [(heap-model (cons a:saction setup+:setup)) (interpret-setup setup+ (interpret-saction a s))])) (define (interpret-complete-interaction ci s) (match ci [(heap-model (v:setup i:interaction)) (interpret-interaction i (interpret-setup v s))])) (define (default-val val def) (match val [(heap-model null) def] [(heap-model i:integer) i])) (define (obs-buf n s) (nth (state->buf s) n)) (define (obs-buf-def n def s) (default-val (obs-buf n s) def)) (define (obs-heap n s) (nth (state->heap s) n)) (define (obs-heap-def n def s) (default-val (obs-heap n s) def)) (define heap-lang-link (lambda (inte state) (match state [(heap-model (b:buf h:heap p:pointer)) (cons inte (make-state b h p))]))) (define-language heap-lang #:grammar heap-model #:expression state-con #:size 10 #:context action #:size 3 #:link heap-lang-link #:evaluate (uncurry interpret-action)) (define-language heap-lang-hl #:grammar heap-model #:expression state-con #:size 10 #:context interaction-hl #:size 3 #:link heap-lang-link #:evaluate (uncurry interpret-interaction-hl)) (define (synthesize-interaction-gadget size ctx spec) (let* ([sol (find-ctx-gadget heap-lang spec #:context-size size #:expression (make-state-con ctx))]) (if sol (first sol) #f))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Pretty-printing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (print-nnvalue nv) (match nv [(heap-model i:integer) (format "~a" i)])) (define (print-pointer p) (match p [(heap-model n:natural) (format "~a" n)] [(heap-model null) "null"])) (define (print-value v) (match v [(heap-model p:pointer) (print-pointer p)] [(heap-model nv:nnvalue) (print-nnvalue nv)])) (define (display-buf b) (define (display-buf+ b addr) (match b [(heap-model nil) (displayln "")] [(heap-model (cons h:value b+:buf)) (displayln (format "~a > ~a" (~a addr #:width 2) (print-value h))) (display-buf+ b+ (+ addr 1))])) (display-buf+ b 0)) (define (print-list-value h) (match h [(heap-model nil) ""] [(heap-model (cons v:value h+:heap)) (let ([sh+ (print-list-value h+)]) (format " ~a |~a " (~a (print-value v) #:width 4) (~a sh+)))])) (define (display-heap h) (define (display-heap+ h addr) (match h [(heap-model nil) (displayln "")] [(heap-model (cons h1:value (cons h2:value (cons h3:value (cons h4:value h+:heap))))) (displayln (format "~a > | ~a | ~a | ~a | ~a |" (~a addr #:width 2) (~a (print-value h1) #:width 4) (~a (print-value h2) #:width 4) (~a (print-value h3) #:width 4) (~a (print-value h4) #:width 4))) (display-heap+ h+ (+ addr 4))] [(heap-model any) (display (format "~a > |" (~a addr #:width 2))) (displayln (print-list-value h)) ])) (display-heap+ h 0)) (define (display-state s) (begin (displayln "BUFFER:") (display-buf (state->buf s)) (displayln "HEAP:") (display-heap (state->heap s)) (displayln "FP HEAD:") (displayln (print-pointer (state->pointer s))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; TESTING heap-model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define d (init-empty-state 4 2)) (define aa0 (heap-model (alloc 0))) (define aa1 (heap-model (alloc 1))) (define aw (heap-model (write 2 0))) (define ar (heap-model (read 0 3))) (define af0 (heap-model (free 0))) (define af1 (heap-model (free 1))) (define d+ (interpret-action aa0 d)) (define d++ (interpret-action aa1 d+)) (define d+3* (interpret-action af0 d++)) (define d+3** (interpret-action af1 d++)) (define d+4* (interpret-action af1 d+3*)) (define d+5* (interpret-action aa0 d+4*)) (define d+4** (interpret-action af0 d+3**)) (define d+3 (state-buf-set 2 7 d++)) (define d+4 (interpret-action aw d+3)) (define d+5 (interpret-action ar d+4)) (define (clear-buf s) (state (repeat (heap-model null) 4) (state->heap s) (state->pointer s))) (define dc (clear-buf d+3*))
false
0b6898007b4d7f8990bcddfed9b4f689f79254d8
18a51a897441d33155dda9b1969c1d4898820530
/base/parser/python-grammar.rkt
c2700546674b770ae86f11de7d2dd0413c313dfb
[ "Apache-2.0" ]
permissive
jpolitz/lambda-py
6fc94e84398363c6bb2e547051da9db6466ab603
a2d1be7e017380414429a498435fb45975f546dd
refs/heads/master
"2019-04-21T09:36:42.116912"
"2013-04-16T13:30:44"
"2013-04-16T13:30:44"
7,525,003
1
0
null
"2013-01-09T22:32:47"
"2013-01-09T16:54:10"
Racket
UTF-8
Racket
false
false
6,050
rkt
python-grammar.rkt
#lang ragg # Grammar for Python # Note: Changing the grammar specified in this file will most likely # require corresponding changes in the parser module # (../Modules/parsermodule.c). If you can't make the changes to # that module yourself, please co-ordinate the required changes # with someone who can; ask around on python-dev for help. Fred # Drake <fdrake@acm.org> will probably be listening there. # NOTE WELL: You should also follow all the steps listed in PEP 306, # "How to Change Python's Grammar" # Start symbols for the grammar: # single_input is a single interactive statement; # file_input is a module or sequence of commands read from an input file; # eval_input is the input for the eval() and input() functions. # NB: compound_stmt in single_input is followed by extra NEWLINE! file_input: (NEWLINE | stmt)* single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE eval_input: testlist NEWLINE* decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE decorators: decorator+ decorated: decorators (classdef | funcdef) funcdef: 'def' NAME parameters ['->' test] ':' suite parameters: '(' [typedargslist] ')' typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [',' ['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]] | '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef) tfpdef: NAME [':' test] varargslist: (vfpdef ['=' test] (',' vfpdef ['=' test])* [',' ['*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef]] | '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef) vfpdef: NAME stmt: simple_stmt | compound_stmt simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | nonlocal_stmt | assert_stmt) expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist_star_expr))*) testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [','] augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=') # For normal assignments, additional restrictions enforced by the interpreter del_stmt: 'del' exprlist pass_stmt: 'pass' flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt break_stmt: 'break' continue_stmt: 'continue' return_stmt: 'return' [testlist] yield_stmt: yield_expr raise_stmt: 'raise' [test ['from' test]] import_stmt: import_name | import_from import_name: 'import' dotted_as_names # note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) import_as_name: NAME ['as' NAME] dotted_as_name: dotted_name ['as' NAME] import_as_names: import_as_name (',' import_as_name)* [','] dotted_as_names: dotted_as_name (',' dotted_as_name)* dotted_name: NAME ('.' NAME)* global_stmt: 'global' NAME (',' NAME)* nonlocal_stmt: 'nonlocal' NAME (',' NAME)* assert_stmt: 'assert' test [',' test] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] while_stmt: 'while' test ':' suite ['else' ':' suite] for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] try_stmt: ('try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite)) with_stmt: 'with' with_item (',' with_item)* ':' suite with_item: test ['as' expr] # NB compile.c makes sure that the default except clause is last except_clause: 'except' [test ['as' NAME]] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT test: or_test ['if' or_test 'else' test] | lambdef test_nocond: or_test | lambdef_nocond lambdef: 'lambda' [varargslist] ':' test lambdef_nocond: 'lambda' [varargslist] ':' test_nocond or_test: and_test ('or' and_test)* and_test: not_test ('and' not_test)* not_test: 'not' not_test | comparison comparison: expr (comp_op expr)* # <> isn't actually a valid comparison operator in Python. It's here for the # sake of a __future__ import described in PEP 401 comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' star_expr: '*' expr expr: xor_expr ('|' xor_expr)* xor_expr: and_expr ('^' and_expr)* and_expr: shift_expr ('&' shift_expr)* shift_expr: arith_expr (('<<'|'>>') arith_expr)* arith_expr: term (('+'|'-') term)* term: factor (('*'|'/'|'%'|'//') factor)* factor: ('+'|'-'|'~') factor | power power: atom trailer* ['**' factor] atom: ('(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False') testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME subscriptlist: subscript (',' subscript)* [','] subscript: test | [test] ':' [test] [sliceop] sliceop: ':' [test] exprlist: (expr|star_expr) (',' (expr|star_expr))* [','] testlist: test (',' test)* [','] dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) | (test (comp_for | (',' test)* [','])) ) classdef: 'class' NAME ['(' [arglist] ')'] ':' suite arglist: (argument ',')* (argument [','] |'*' test (',' argument)* [',' '**' test] |'**' test) # The reason that keywords are test nodes instead of NAME is that using NAME # results in an ambiguity. ast.c makes sure it's a NAME. argument: test [comp_for] | test '=' test # Really [keyword '='] test comp_iter: comp_for | comp_if comp_for: 'for' exprlist 'in' or_test [comp_iter] comp_if: 'if' test_nocond [comp_iter] # not used in grammar, but may appear in "node" passed from Parser to Compiler encoding_decl: NAME yield_expr: 'yield' [testlist]
false
70703181fa00f765dbbdd1c02ee951d558d3d54a
8913c7639fb1439b1f35f513ac05c2023ce39acc
/noizy/noizy-test.rkt
712f1e77749eaa0a290b7f8fbe387b58bd19eabe
[ "MIT" ]
permissive
krcz/zygote
124791acabaf48c62ee602f94c788916adec36c4
1f6298f0a73fd0320bc3ba5abe5f00a805fed8fc
refs/heads/master
"2022-02-27T19:00:08.302486"
"2020-02-02T15:08:53"
"2020-02-02T15:08:53"
183,607,857
20
0
null
null
null
null
UTF-8
Racket
false
false
476
rkt
noizy-test.rkt
#lang typed/racket (require "c-syntax-render.rkt" "c-semantics.rkt" "c-types.rkt" (prefix-in cs: "c-syntax-defs.rkt")) (define x (variable "x" ct:Int)) (define a (variable "a" ct:Int)) (define b (variable "b" ct:Int)) (define c (variable "c" ct:Int)) (to-stdout render-ex (processing-result-repr (expression-process (+ a (* b (* c x))) (void)))) (to-stdout render-ex (processing-result-repr (expression-process (* a (+ b (+ c x))) (void))))
false
80876fd163321ddea950bdd688b77791b530d973
ea28b962949105fb27622bad2de8a7e0c765f1f2
/newton.rkt
eaae9c5e62a2291dd5bd6c3166961af081ca4ab0
[]
no_license
even4void/scratch
5493c213036f7ba36ec9921de0abc7c3eb29287a
d6d58148753ca77800ddc04b56240eba621bc86a
refs/heads/master
"2023-06-08T22:05:00.563639"
"2023-05-27T17:49:34"
"2023-05-27T17:49:34"
191,911,467
0
0
null
null
null
null
UTF-8
Racket
false
false
550
rkt
newton.rkt
#lang racket (define +tol+ 1e-6) (define (derivative f step) (lambda (x) (/ (- (f (+ x step)) (f (- x step))) (* 2 step)))) (define (nextx f x) (- x (/ (f x) ((derivative f 1) x)))) (define (root-find f) (lambda (guess) (define (ok? guess) (< (abs (- guess (nextx f guess)))) +tol+) (define (iter guess) (if (ok? guess) (displayln guess) (iter (nextx f guess)))) (iter 1))) (define (g x) (- (* 3 x x) 2)) (root-find g)
false
c6e80628baf91d79f882d6aa5aba0a8afeae1237
33b7db4ac6a5a60c533ac223b8470562ab25136d
/fra/schema.rkt
fa5017c61a03eb7dcc7fb0fcc87a32d48c70a81f
[]
no_license
markuspf/fra
bab327cc0062b7c771c871aa0e90fa72700ac287
151ca5afbb8e732e0da89198cf0b982625233b87
refs/heads/master
"2023-03-15T19:17:59.532395"
"2017-12-13T17:15:05"
"2017-12-13T17:15:05"
null
0
0
null
null
null
null
UTF-8
Racket
false
false
2,436
rkt
schema.rkt
#lang racket/base (require racket/contract racket/list racket/set) ;; XXX These seem pretty inefficient (define (schema . elems) (apply list elems)) (define (schema-length s) (length s)) (define schema/c (listof symbol?)) (define (schema-ref s a) (index a s)) (define (schema-disjoint-union s1 s2) (append s1 s2)) (define (schema-replace* renaming s) (for/list ([old (in-list s)]) (hash-ref renaming old old))) (define (hash-keys ht) (hash-map ht (lambda (k v) k))) (define (hash-values ht) (hash-map ht (lambda (k v) v))) (define (no-duplicates? s) (define seen? (make-hasheq)) (for/and ([e (in-list s)]) (begin0 (hash-ref seen? e #t) (hash-set! seen? e #f)))) (define (schema-valid-renaming? renaming s) (and (schema-subset? (hash-keys renaming) s) (no-duplicates? (hash-values renaming)))) (define (index a s) (let loop ([n 0] [s s]) (if (empty? s) (error 'index "Not an element: ~e" a) (if (equal? (first s) a) n (loop (add1 n) (rest s)))))) (define (schema-intersection s1 s2) (set->list (set-intersect (list->set s1) (list->set s2)))) (define (schema-difference s1 s2) (set->list (set-subtract (list->set s1) (list->set s2)))) (define (schema-union s1 s2) (set->list (set-union (list->set s1) (list->set s2)))) (define (schema-subset? s1 s2) (subset? (list->set s1) (list->set s2))) (define (schema-disjoint? s1 s2) (set-empty? (set-intersect (list->set s1) (list->set s2)))) (define (schema-orderi-equal? s1 s2) (set=? (list->set s1) (list->set s2))) (provide/contract [schema/c contract?] [schema (() () #:rest (listof symbol?) . ->* . schema/c)] [schema-length (schema/c . -> . exact-nonnegative-integer?)] [schema-ref (schema/c symbol? . -> . exact-nonnegative-integer?)] [schema-replace* ((hash/c symbol? symbol?) schema/c . -> . schema/c)] [schema-valid-renaming? ((hash/c symbol? symbol?) schema/c . -> . boolean?)] [schema-disjoint? (schema/c schema/c . -> . boolean?)] [schema-orderi-equal? (schema/c schema/c . -> . boolean?)] [schema-subset? (schema/c schema/c . -> . boolean?)] [schema-disjoint-union (schema/c schema/c . -> . schema/c)] [schema-union (schema/c schema/c . -> . schema/c)] [schema-intersection (schema/c schema/c . -> . schema/c)] [schema-difference (schema/c schema/c . -> . schema/c)])
false
d4c7bdfdb2cd3d9c0be6881b22730603ea70390b
9508c612822d4211e4d3d926bbaed55e21e7bbf3
/tests/dsls/cmdline/example.rkt
0cd22a3a652eedb6a7ba1d8cb6ba8cd18ff60595
[ "MIT", "Apache-2.0" ]
permissive
michaelballantyne/syntax-spec
4cfb17eedba99370edc07904326e3c78ffdb0905
f3df0c72596fce83591a8061d048ebf470d8d625
refs/heads/main
"2023-06-20T21:50:27.017126"
"2023-05-15T19:57:55"
"2023-05-15T19:57:55"
394,331,757
13
1
NOASSERTION
"2023-06-19T23:18:13"
"2021-08-09T14:54:47"
Racket
UTF-8
Racket
false
false
884
rkt
example.rkt
#lang racket/base (require "cmdline.rkt" "sugar.rkt" (for-syntax racket/base syntax/parse)) (define (existing-file/p str) (if (file-exists? str) str (raise-user-error "expected path to exisiting file"))) (module+ main (define/command-line-options #:options [verbose-mode (switch/o ("-v" "--verbose") "Compile with verbose messages")] [profiling-on (switch/o ("-p" "--profile") "Compile with profiling")] [optimize-level (choice/o #:default 0 ["--optimize-level" [lvl (int-range/p 0 3)] "set optimization level to <lvl>" lvl] (numbered-flags/f "--o" [0 3] "optimization level"))] [output (required/o "-o" outfile "the output filename" outfile)] [link-flags (list/o ["-l" "--link-flags"] lf "Add a flag <lf> for the linker")] #:arguments [file-to-compile existing-file/p]))
false
6132cf7e71dcf670bc9671b6697d4e58e607bb0c
8edcf9e3c0d2555330214878e83d996ef3a9ccb2
/lang-work/test.rkt
35c52c0be7ada2fbb5ae472573a7c7d737513845
[]
no_license
odanoburu/racket-summer-school
ed786f9f907f2ba7d4c65dcbc071204dc011e842
d78ec7727dd382f14f83dd0cc145bbbbd6252329
refs/heads/master
"2020-03-22T16:47:17.014211"
"2018-07-18T21:27:38"
"2018-07-18T21:27:38"
140,351,277
0
0
null
null
null
null
UTF-8
Racket
false
false
450
rkt
test.rkt
#lang pl-checklist-demo What kind of programming language do you propose to make? ( ) concurrent ( ) declarative ( ) imperative ( ) functional ( ) asynchronous ( ) typed ( ) untyped ( ) semi-typed ( ) non-terminating (x) lazy ( ) deterministic ( ) literate ( ) illiterate ( ) Forth-like ( ) Algol-inspired ( ) BASIC-infused ( ) Lispy ( ) modular ( ) multiprocess ( ) scalable ( ) unreasonable ( ) cloud-based ( ) ARM-compatible ( ) RISC-optimized
false
f16f5e2e4150540cb2da2ae307e077c0f2b12319
d7a26ae5f1825a28e68cbfcce657cd88e4a33583
/Core Programming/002 - How to Code - Simple Data/week04/assignment4a.rkt
59d154376f1d25154b39eee449bf8900c76e23c2
[]
no_license
GrantDarling/computer-science-curriculum
c1d896750ffdabd3edc4ae70aec13a850c83d8fa
1f2468965b4ddf77f099b887ccdf203f97c4817d
refs/heads/master
"2023-05-31T16:12:17.637545"
"2021-06-27T01:05:27"
"2021-06-27T01:05:27"
268,005,967
0
0
null
null
null
null
UTF-8
Racket
false
false
5,873
rkt
assignment4a.rkt
;; #1 ;; Data definitions: ; ; Remember the data definition for a list of numbers we designed in Lecture 5f: ; (if this data definition does not look familiar, please review the lecture) ; ;; ListOfNumber is one of: ;; - empty ;; - (cons Number ListOfNumber) ;; interp. a list of numbers (define LON1 empty) (define LON2 (cons 60 (cons 42 empty))) #; (define (fn-for-lon lon) (cond [(empty? lon) (...)] [else (... (first lon) (fn-for-lon (rest lon)))])) ;; Template rules used: ;; - one of: 2 cases ;; - atomic distinct: empty ;; - compound: (cons Number ListOfNumber) ;; - self-reference: (rest lon) is ListOfNumber ;; ================= ;; Functions: ; ; PROBLEM: ; ; Design a function that consumes a list of numbers and doubles every number ; in the list. Call it double-all. ; ;; ListOfNumber -> ListOfNumber ;; Doubles every number in list (check-expect (double-all empty) empty) (check-expect (double-all LON2) (cons 120 (cons 84 empty))) (check-expect (double-all (cons 10 (cons 20 (cons 50 empty)))) (cons 20 (cons 40 (cons 100 empty)))) (define (double-all lon) (cond [(empty? lon) empty] [else (cons (* 2 (first lon)) (double-all (rest lon)))])) ;; #2 ;; ================= ;; Data definitions: ; ; PROBLEM A: ; ; Design a data definition to represent a list of booleans. Call it ListOfBoolean. ; ;; ListOfBoolean is one of: ;; - empty ;; - (cons Number ListOfBoolean) ;; interp. a list of booleans (define LOB1 empty) (define LOB2 (cons true (cons false empty))) #; (define (fn-for-lob lob) (cond [(empty? lob) (...)] [else (... (first lob) (fn-for-lob (rest lob)))])) ;; Template rules used: ;; - one of: 2 cases ;; - atomic distinct: empty ;; - compound: (cons Boolean ListOfBoolean) ;; - self-reference: (rest lob) is ListOfBoolean ;; ================= ;; Functions: ; ; PROBLEM B: ; ; Design a function that consumes a list of boolean values and produces true ; if every value in the list is true. If the list is empty, your function ; should also produce true. Call it all-true? ; ;; ListOfBooleans -> Boolean ;; Returns true if all list values return true (check-expect (all-true? empty) true) (check-expect (all-true? (cons true empty)) true) (check-expect (all-true? (cons false empty)) false) (check-expect (all-true? (cons false (cons false empty))) false) (check-expect (all-true? (cons true (cons true empty))) true) (define (all-true? lob) (cond [(empty? lob) true] [else (cond [(false? (first lob)) false] [else (all-true? (rest lob))])])) ;; #3 ;; ================= ;; Data definitions: ; ; Remember the data definition for a list of numbers we designed in Lecture 5f: ; (if this data definition does not look familiar, please review the lecture) ; ;; ListOfNumber is one of: ;; - empty ;; - (cons Number ListOfNumber) ;; interp. a list of numbers (define LON3 empty) (define LON4 (cons 60 (cons 42 empty))) #; (define (fn-for-lon lon) (cond [(empty? lon) (...)] [else (... (first lon) (fn-for-lon (rest lon)))])) ;; Template rules used: ;; - one of: 2 cases ;; - atomic distinct: empty ;; - compound: (cons Number ListOfNumber) ;; - self-reference: (rest lon) is ListOfNumber ;; ================= ;; Functions: ; ; PROBLEM: ; ; Design a function that consumes a list of numbers and produces the largest number ; in the list. You may assume that all numbers in the list are greater than 0. If ; the list is empty, produce 0. ; ;; ListOfNumber -> Number ;; Returns the highest number (check-expect (highest-number empty) 0) (check-expect (highest-number (cons 10 empty)) 10) (check-expect (highest-number (cons 8 (cons 100 empty))) 100) (check-expect (highest-number (cons 99 (cons 8 (cons 100 empty)))) 100) (define (highest-number lon) (cond [(empty? lon) 0] [else (cond [(empty? (rest lon)) (first lon)] [(> (first lon) (first (rest lon))) (highest-number (cons (first lon) (rest (rest lon))))] [else (highest-number (rest lon))])])) (require 2htdp/image) ;; #4 ;; ================= ;; Data definitions: ; ; PROBLEM A: ; ; Design a data definition to represent a list of images. Call it ListOfImage. ; ;; ListOfImage is one of: ;; - empty ;; - (cons String ListOfImage) ;; interp. a list of images (define LOI-1 empty) (define LOI-2 (cons (rectangle 20 40 "solid" "red") empty)) (define LOI-3 (cons (rectangle 30 30 "solid" "blue") (cons (rectangle 10 20 "solid" "pink") empty))) (define LOI-4 (cons (rectangle 30 30 "solid" "blue") (cons (rectangle 30 30 "solid" "blue") (cons (rectangle 10 20 "solid" "pink") empty)))) #; (define (fn-for-loi loi) (cond [(empty? loi) (...)] ;BASE CASE [else (... (first loi) ;Image (fn-for-loi (rest loi)))])) ;NATURAL RECURSION ;; / ;; / ;; COMBINATION ;; Template rules used: ;; - one of: 2 cases ;; - atomic distinct: empty ;; - compound: (cons Image ListOfImage) ;; - self-reference: (rest loi) is ListOfImage ;; ================= ;; Functions: ; ; PROBLEM B: ; ; Design a function that consumes a list of images and produces a number ; that is the sum of the areas of each image. For area, just use the image's ; width times its height. ; ;; ListOfImage -> Number ;; Sum of the area of each image (check-expect (sum-images LOI-1) 0) (check-expect (sum-images LOI-2) 800) (check-expect (sum-images LOI-3) 1100) (check-expect (sum-images LOI-4) 2000) (define (sum-images loi) (cond [(empty? loi) 0] [else (+ (* (image-width (first loi)) (image-height (first loi))) (sum-images (rest loi)))]))
false
3c5193438a28d234000c6c7dc041d47b8cbc50b3
5f83eb0c32f15aeed5993a3ad5ededb6f31fe7aa
/racket/arm64/bpf_jit_comp.rkt
e4f9a7586cae9dc6d4e15a9a2aeb5f3817570084
[]
no_license
uw-unsat/jitterbug
45b54979b156c0f5330012313052f8594abd6f14
78d1e75ad506498b585fbac66985ff9d9d05952d
refs/heads/master
"2023-07-11T09:15:21.433725"
"2023-06-18T04:10:48"
"2023-07-03T20:12:41"
244,440,882
46
5
null
null
null
null
UTF-8
Racket
false
false
18,953
rkt
bpf_jit_comp.rkt
#lang rosette ; This file is translated and adapted from arch/arm64/net/bpf_jit_comp.c, ; which is licensed under: ; ; SPDX-License-Identifier: GPL-2.0-only ; ; BPF JIT compiler for ARM64 ; ; Copyright (C) 2014-2016 Zi Shen Lim <zlim.lnx@gmail.com> (require "bpf_jit.rkt" "../lib/bpf-common.rkt" "../lib/spec/bpf.rkt" "../common.rkt" "../lib/bvaxiom.rkt" (prefix-in core: serval/lib/core) (prefix-in bpf: serval/bpf)) (provide (all-defined-out)) (define TMP_REG_1 'tmp-r1) (define TMP_REG_2 'tmp-r2) (define TCALL_CNT 'tcc) (define TMP_REG_3 'tmp-r3) (define regmap (list ; return value from in-kernel function, and exit value from eBPF (cons BPF_REG_0 (A64_R 7)) ; arguments from eBPF program to in-kernel function (cons BPF_REG_1 (A64_R 0)) (cons BPF_REG_2 (A64_R 1)) (cons BPF_REG_3 (A64_R 2)) (cons BPF_REG_4 (A64_R 3)) (cons BPF_REG_5 (A64_R 4)) ; callee saved registers that in-kernel function will preserve (cons BPF_REG_6 (A64_R 19)) (cons BPF_REG_7 (A64_R 20)) (cons BPF_REG_8 (A64_R 21)) (cons BPF_REG_9 (A64_R 22)) ; read-only frame pointer to access stack (cons BPF_REG_FP (A64_R 25)) ; temporary registers for internal BPF JIT (cons TMP_REG_1 (A64_R 10)) (cons TMP_REG_2 (A64_R 11)) (cons TMP_REG_3 (A64_R 12)) ; tail_call_cnt (cons TCALL_CNT (A64_R 26)) ; temporary register for blinding constants (cons BPF_REG_AX (A64_R 9)) )) (define (bpf2a64 r) (define e (assoc r regmap)) (assert e (format "unknown BPF register: ~a" r)) (cdr e)) (struct context (insns idx epilogue-offset offset program-length stack-size aux) #:mutable #:transparent) (define (emit insn ctx) (for/all ([insns (context-insns ctx) #:exhaustive]) ; logical-immediate instructions might produce unions with (infeasible) AARCH64_BREAK_FAULT (for/all ([insn insn #:exhaustive]) (set-context-insns! ctx (vector-append insns (vector insn))))) (set-context-idx! ctx (bvadd (bv 1 32) (context-idx ctx)))) (define (emit_a64_mov_i is64 reg val ctx) (define hi (extract 15 0 (bvashr val (bv 16 32)))) (define lo (extract 15 0 (bvand val (bv #xffff 32)))) (cond [(bitvector->bool (bvand hi (bv #x8000 16))) (cond [(bveq hi (bv #xffff 16)) (emit (A64_MOVN is64 reg (bvnot lo) 0) ctx)] [else (emit (A64_MOVN is64 reg (bvnot hi) 16) ctx) (when (! (bveq lo (bv #xffff 16))) (emit (A64_MOVK is64 reg lo 0) ctx))])] [else (emit (A64_MOVZ is64 reg lo 0) ctx) (when (bitvector->bool hi) (emit (A64_MOVK is64 reg hi 16) ctx))])) (define (i64_i16_blocks val inverse) (define (block n) (if (! (bveq (bvand (bvlshr val (bv n 64)) (bv #xffff 64)) (if inverse (bv #xffff 64) (bv #x0000 64)))) (bv 1 32) (bv 0 32))) (bvadd (block 0) (block 16) (block 32) (block 48))) (define-syntax-rule (while #:fuel fuel c body ...) (letrec ([loop (lambda (n) (cond [(<= n 0) (core:bug #:msg "while: out of fuel")] [c (begin body ... (loop (- n 1)))] [else (void)]))]) (loop fuel))) (define (emit_a64_mov_i64 reg val ctx) (define nrm_tmp val) (define rev_tmp (bvnot val)) (cond [(bvzero? (bvlshr nrm_tmp (bv 32 64))) (emit_a64_mov_i (bv 0 1) reg (extract 31 0 val) ctx)] [else (define inverse (bvslt (i64_i16_blocks nrm_tmp #t) (i64_i16_blocks nrm_tmp #f))) (define shift (smax (round_down (if inverse (bvsub (fls64 rev_tmp) (bv 1 64)) (bvsub (fls64 nrm_tmp) (bv 1 64))) (bv 16 64)) (bv 0 64))) (cond [inverse (emit (A64_MOVN (bv 1 1) reg (bvand (bvlshr rev_tmp shift) (bv #xffff 64)) shift) ctx)] [else (emit (A64_MOVZ (bv 1 1) reg (bvand (bvlshr nrm_tmp shift) (bv #xffff 64)) shift) ctx)]) (set! shift (bvsub shift (bv 16 64))) (while #:fuel 4 (bvsge shift (bv 0 64)) (when (! (bveq (bvand (bvlshr nrm_tmp shift) (bv #xffff 64)) (if inverse (bv #xffff 64) (bv 0 64)))) (emit (A64_MOVK (bv 1 1) reg (bvand (bvlshr nrm_tmp shift) (bv #xffff 64)) shift) ctx)) (set! shift (bvsub shift (bv 16 64))))])) ; Kernel addresses in the vmalloc space use at most 48 bits, and the ; remaining bits are guaranteed to be 0x1. So we can compose the address ; with a fixed length movn/movk/movk sequence. (define (emit_addr_mov_i64 reg val ctx) (define tmp val) (define shift (bv 0 32)) ; Encode the assumption about kernel addresses. (assume (equal? (extract 63 48 val) (bv -1 16))) (emit (A64_MOVN (bv 1 1) reg (bvand (bvnot tmp) (bv #xffff 64)) shift) ctx) (while #:fuel 3 (bvslt shift (bv 32 32)) (set! tmp (bvlshr tmp (bv 16 64))) (set! shift (bvadd shift (bv 16 32))) (emit (A64_MOVK (bv 1 1) reg (bvand tmp (bv #xffff 64)) shift) ctx))) (define (bpf2a64_offset bpf_insn off ctx) ; bpf_insn++; (set! bpf_insn (bvadd1 bpf_insn)) (define (offset x) (core:bug-on (bvslt x (bv 0 32)) #:msg "ctx->offset[x] where x < 0") ((context-offset ctx) x)) ; * Whereas arm64 branch instructions encode the offset ; * from the branch itself, so we must subtract 1 from the ; * instruction offset. ; return ctx->offset[bpf_insn + off] - (ctx->offset[bpf_insn] - 1); (bvsub (offset (bvadd bpf_insn off)) (bvsub1 (offset bpf_insn)))) (define (epilogue_offset ctx) (define to (context-epilogue-offset ctx)) (define from (context-idx ctx)) (bvsub to from)) (define (check_imm bits imm) (core:bug-on (|| (&& (bvsgt imm (bv 0 32)) (! (bvzero? (bvashr imm (bv bits 32))))) (&& (bvslt imm (bv 0 32)) (! (bvzero? (bvashr (bvnot imm) (bv bits 32)))))) #:msg (format "check_imm~a: ~a" bits imm))) (define (check_imm26 imm) (check_imm 26 imm)) (define (check_imm19 imm) (check_imm 19 imm)) (define (is_addsub_imm imm) ; optionally shifted imm12 (|| (bvzero? (bvand imm (bvnot (bv #xfff 32)))) (bvzero? (bvand imm (bvnot (bv #xfff000 32)))))) (define (STACK_ALIGN sz) (bvand (bvadd sz (bv 15 (type-of sz))) (bvnot (bv 15 (type-of sz))))) (define (build_prologue ctx ebpf_from_cbpf) (define aux (context-aux ctx)) (define stack_depth (bpf-prog-aux-stack_depth aux)) (define r6 (bpf2a64 BPF_REG_6)) (define r7 (bpf2a64 BPF_REG_7)) (define r8 (bpf2a64 BPF_REG_8)) (define r9 (bpf2a64 BPF_REG_9)) (define fp (bpf2a64 BPF_REG_FP)) (define tcc (bpf2a64 TCALL_CNT)) ; Save FP and LR registers to stay align with ARM64 AAPCS (emit (A64_PUSH A64_FP A64_LR A64_SP) ctx) (emit (A64_MOV (bv 1 1) A64_FP A64_SP) ctx) ; Save callee-saved registers (emit (A64_PUSH r6 r7 A64_SP) ctx) (emit (A64_PUSH r8 r9 A64_SP) ctx) (emit (A64_PUSH fp tcc A64_SP) ctx) (emit (A64_MOV (bv 1 1) fp A64_SP) ctx) (set-context-stack-size! ctx (STACK_ALIGN stack_depth)) ; Set up function call stack (emit (A64_SUB_I (bv 1 1) A64_SP A64_SP (context-stack-size ctx)) ctx) (void)) (define (build_epilogue ctx) (define r0 (bpf2a64 BPF_REG_0)) (define r6 (bpf2a64 BPF_REG_6)) (define r7 (bpf2a64 BPF_REG_7)) (define r8 (bpf2a64 BPF_REG_8)) (define r9 (bpf2a64 BPF_REG_9)) (define fp (bpf2a64 BPF_REG_FP)) ; We're done with BPF stack (emit (A64_ADD_I (bv 1 1) A64_SP A64_SP (context-stack-size ctx)) ctx) ; Restore fs (x25) and x26 (emit (A64_POP fp (A64_R 26) A64_SP) ctx) ; Restore callee-saved register (emit (A64_POP r8 r9 A64_SP) ctx) (emit (A64_POP r6 r7 A64_SP) ctx) ; Restore FP/LR registers (emit (A64_POP A64_FP A64_LR A64_SP) ctx) ; Set return value (emit (A64_MOV (bv 1 1) (A64_R 0) r0) ctx) (emit (A64_RET A64_LR) ctx) (void)) (define (emit_cond_jmp code i off ctx) (define off32 (sign-extend off (bitvector 32))) (define jmp_offset (bpf2a64_offset i off32 ctx)) (check_imm19 jmp_offset) (define jmp_cond (case (BPF_OP code) [(BPF_JEQ) A64_COND_EQ] [(BPF_JGT) A64_COND_HI] [(BPF_JLT) A64_COND_CC] [(BPF_JGE) A64_COND_CS] [(BPF_JLE) A64_COND_LS] [(BPF_JSET BPF_JNE) A64_COND_NE] [(BPF_JSGT) A64_COND_GT] [(BPF_JSLT) A64_COND_LT] [(BPF_JSGE) A64_COND_GE] [(BPF_JSLE) A64_COND_LE])) (emit (A64_B_COND jmp_cond jmp_offset) ctx)) (define (build_insn i insn next-insn ctx) (define code (bpf:insn-code insn)) (define dst (bpf2a64 (bpf:insn-dst insn))) (define src (bpf2a64 (bpf:insn-src insn))) (define tmp (bpf2a64 TMP_REG_1)) (define tmp2 (bpf2a64 TMP_REG_2)) (define tmp3 (bpf2a64 TMP_REG_3)) (define off (bpf:insn-off insn)) (define imm (bpf:insn-imm insn)) (define off32 (sign-extend off (bitvector 32))) (define is64 (bool->bitvector (|| (equal? (BPF_CLASS code) 'BPF_ALU64) (equal? (BPF_CLASS code) 'BPF_JMP)))) (define isdw (bool->bitvector (equal? (BPF_SIZE code) 'BPF_DW))) (case code ; dst = src [((BPF_ALU BPF_MOV BPF_X) (BPF_ALU64 BPF_MOV BPF_X)) (emit (A64_MOV is64 dst src) ctx)] ; dst = dst OP src [((BPF_ALU BPF_ADD BPF_X) (BPF_ALU64 BPF_ADD BPF_X)) (emit (A64_ADD is64 dst dst src) ctx)] [((BPF_ALU BPF_SUB BPF_X) (BPF_ALU64 BPF_SUB BPF_X)) (emit (A64_SUB is64 dst dst src) ctx)] [((BPF_ALU BPF_AND BPF_X) (BPF_ALU64 BPF_AND BPF_X)) (emit (A64_AND is64 dst dst src) ctx)] [((BPF_ALU BPF_OR BPF_X) (BPF_ALU64 BPF_OR BPF_X)) (emit (A64_ORR is64 dst dst src) ctx)] [((BPF_ALU BPF_XOR BPF_X) (BPF_ALU64 BPF_XOR BPF_X)) (emit (A64_EOR is64 dst dst src) ctx)] [((BPF_ALU BPF_MUL BPF_X) (BPF_ALU64 BPF_MUL BPF_X)) (emit (A64_MUL is64 dst dst src) ctx)] ; The original C code mixes DIV and MOD and split again. ; Simply split DIV and MOD to make it more explicit. [((BPF_ALU BPF_DIV BPF_X) (BPF_ALU64 BPF_DIV BPF_X)) (emit (A64_UDIV is64 dst dst src) ctx)] [((BPF_ALU BPF_MOD BPF_X) (BPF_ALU64 BPF_MOD BPF_X)) (emit (A64_UDIV is64 tmp dst src) ctx) (emit (A64_MSUB is64 dst dst tmp src) ctx)] [((BPF_ALU BPF_LSH BPF_X) (BPF_ALU64 BPF_LSH BPF_X)) (emit (A64_LSLV is64 dst dst src) ctx)] [((BPF_ALU BPF_RSH BPF_X) (BPF_ALU64 BPF_RSH BPF_X)) (emit (A64_LSRV is64 dst dst src) ctx)] [((BPF_ALU BPF_ARSH BPF_X) (BPF_ALU64 BPF_ARSH BPF_X)) (emit (A64_ASRV is64 dst dst src) ctx)] ; dst = -dst [((BPF_ALU BPF_NEG) (BPF_ALU64 BPF_NEG)) (emit (A64_NEG is64 dst dst) ctx)] ; dst = BSWAP##imm(dst) [((BPF_ALU BPF_END BPF_FROM_LE)) (cond [(bveq imm (bv 16 32)) (emit (A64_UXTH is64 dst dst) ctx)] [(bveq imm (bv 32 32)) (emit (A64_UXTW is64 dst dst) ctx)] [(bveq imm (bv 64 32)) (void)])] [((BPF_ALU BPF_END BPF_FROM_BE)) (cond [(bveq imm (bv 16 32)) (emit (A64_REV16 is64 dst dst) ctx) (emit (A64_UXTH is64 dst dst) ctx)] [(bveq imm (bv 32 32)) (emit (A64_REV32 is64 dst dst) ctx)] [(bveq imm (bv 64 32)) (emit (A64_REV64 dst dst) ctx)])] ; dst = imm [((BPF_ALU BPF_MOV BPF_K) (BPF_ALU64 BPF_MOV BPF_K)) (emit_a64_mov_i is64 dst imm ctx)] ; dst = dst OP imm [((BPF_ALU BPF_ADD BPF_K) (BPF_ALU64 BPF_ADD BPF_K)) ; PATCH (cond [(is_addsub_imm imm) (emit (A64_ADD_I is64 dst dst imm) ctx)] [(is_addsub_imm (bvneg imm)) (emit (A64_SUB_I is64 dst dst (bvneg imm)) ctx)] [else (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_ADD is64 dst dst tmp) ctx)])] [((BPF_ALU BPF_SUB BPF_K) (BPF_ALU64 BPF_SUB BPF_K)) ; PATCH (cond [(is_addsub_imm imm) (emit (A64_SUB_I is64 dst dst imm) ctx)] [(is_addsub_imm (bvneg imm)) (emit (A64_ADD_I is64 dst dst (bvneg imm)) ctx)] [else (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_SUB is64 dst dst tmp) ctx)])] [((BPF_ALU BPF_AND BPF_K) (BPF_ALU64 BPF_AND BPF_K)) ; PATCH (define a64_insn (A64_AND_I is64 dst dst imm)) (cond [(! (equal? a64_insn AARCH64_BREAK_FAULT)) (emit a64_insn ctx)] [else (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_AND is64 dst dst tmp) ctx)])] [((BPF_ALU BPF_OR BPF_K) (BPF_ALU64 BPF_OR BPF_K)) ; PATCH (define a64_insn (A64_ORR_I is64 dst dst imm)) (cond [(! (equal? a64_insn AARCH64_BREAK_FAULT)) (emit a64_insn ctx)] [else (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_ORR is64 dst dst tmp) ctx)])] [((BPF_ALU BPF_XOR BPF_K) (BPF_ALU64 BPF_XOR BPF_K)) ; PATCH (define a64_insn (A64_EOR_I is64 dst dst imm)) (cond [(! (equal? a64_insn AARCH64_BREAK_FAULT)) (emit a64_insn ctx)] [else (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_EOR is64 dst dst tmp) ctx)])] [((BPF_ALU BPF_MUL BPF_K) (BPF_ALU64 BPF_MUL BPF_K)) (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_MUL is64 dst dst tmp) ctx)] [((BPF_ALU BPF_DIV BPF_K) (BPF_ALU64 BPF_DIV BPF_K)) (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_UDIV is64 dst dst tmp) ctx)] [((BPF_ALU BPF_MOD BPF_K) (BPF_ALU64 BPF_MOD BPF_K)) (emit_a64_mov_i is64 tmp2 imm ctx) (emit (A64_UDIV is64 tmp dst tmp2) ctx) (emit (A64_MSUB is64 dst dst tmp tmp2) ctx)] [((BPF_ALU BPF_LSH BPF_K) (BPF_ALU64 BPF_LSH BPF_K)) (emit (A64_LSL is64 dst dst imm) ctx)] [((BPF_ALU BPF_RSH BPF_K) (BPF_ALU64 BPF_RSH BPF_K)) (emit (A64_LSR is64 dst dst imm) ctx)] [((BPF_ALU BPF_ARSH BPF_K) (BPF_ALU64 BPF_ARSH BPF_K)) (emit (A64_ASR is64 dst dst imm) ctx)] ; JUMP off [((BPF_JMP BPF_JA)) (define jmp_offset (bpf2a64_offset i off32 ctx)) (check_imm26 jmp_offset) (emit (A64_B jmp_offset) ctx)] ; IF (dst COND src) JUMP off [((BPF_JMP BPF_JEQ BPF_X) (BPF_JMP BPF_JGT BPF_X) (BPF_JMP BPF_JLT BPF_X) (BPF_JMP BPF_JGE BPF_X) (BPF_JMP BPF_JLE BPF_X) (BPF_JMP BPF_JNE BPF_X) (BPF_JMP BPF_JSGT BPF_X) (BPF_JMP BPF_JSLT BPF_X) (BPF_JMP BPF_JSGE BPF_X) (BPF_JMP BPF_JSLE BPF_X) (BPF_JMP32 BPF_JEQ BPF_X) (BPF_JMP32 BPF_JGT BPF_X) (BPF_JMP32 BPF_JLT BPF_X) (BPF_JMP32 BPF_JGE BPF_X) (BPF_JMP32 BPF_JLE BPF_X) (BPF_JMP32 BPF_JNE BPF_X) (BPF_JMP32 BPF_JSGT BPF_X) (BPF_JMP32 BPF_JSLT BPF_X) (BPF_JMP32 BPF_JSGE BPF_X) (BPF_JMP32 BPF_JSLE BPF_X)) (emit (A64_CMP is64 dst src) ctx) (emit_cond_jmp code i off ctx)] [((BPF_JMP BPF_JSET BPF_X) (BPF_JMP32 BPF_JSET BPF_X)) (emit (A64_TST is64 dst src) ctx) (emit_cond_jmp code i off ctx)] ; IF (dst COND imm) JUMP off [((BPF_JMP BPF_JEQ BPF_K) (BPF_JMP BPF_JGT BPF_K) (BPF_JMP BPF_JLT BPF_K) (BPF_JMP BPF_JGE BPF_K) (BPF_JMP BPF_JLE BPF_K) (BPF_JMP BPF_JNE BPF_K) (BPF_JMP BPF_JSGT BPF_K) (BPF_JMP BPF_JSLT BPF_K) (BPF_JMP BPF_JSGE BPF_K) (BPF_JMP BPF_JSLE BPF_K) (BPF_JMP32 BPF_JEQ BPF_K) (BPF_JMP32 BPF_JGT BPF_K) (BPF_JMP32 BPF_JLT BPF_K) (BPF_JMP32 BPF_JGE BPF_K) (BPF_JMP32 BPF_JLE BPF_K) (BPF_JMP32 BPF_JNE BPF_K) (BPF_JMP32 BPF_JSGT BPF_K) (BPF_JMP32 BPF_JSLT BPF_K) (BPF_JMP32 BPF_JSGE BPF_K) (BPF_JMP32 BPF_JSLE BPF_K)) ; PATCH (cond [(is_addsub_imm imm) (emit (A64_CMP_I is64 dst imm) ctx)] [(is_addsub_imm (bvneg imm)) (emit (A64_CMN_I is64 dst (bvneg imm)) ctx)] [else (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_CMP is64 dst tmp) ctx)]) (emit_cond_jmp code i off ctx)] [((BPF_JMP BPF_JSET BPF_K) (BPF_JMP32 BPF_JSET BPF_K)) ; PATCH (define a64_insn (A64_TST_I is64 dst imm)) (cond [(! (equal? a64_insn AARCH64_BREAK_FAULT)) (emit a64_insn ctx)] [else (emit_a64_mov_i is64 tmp imm ctx) (emit (A64_TST is64 dst tmp) ctx)]) (emit_cond_jmp code i off ctx)] [((BPF_JMP BPF_CALL)) (define r0 (bpf2a64 BPF_REG_0)) (define &addr (box (void))) (define &fixed (box (void))) (bpf_jit_get_func_addr ctx insn &addr &fixed) (emit_addr_mov_i64 tmp (unbox &addr) ctx) (emit (A64_BLR tmp) ctx) (emit (A64_MOV (bv 1 1) r0 (A64_R 0)) ctx)] [((BPF_JMP BPF_EXIT)) (cond [(equal? i (bvsub1 (context-program-length ctx))) ; Break (void)] [else (define jmp_offset (epilogue_offset ctx)) (check_imm26 jmp_offset) (emit (A64_B jmp_offset) ctx)])] [((BPF_LD BPF_IMM BPF_DW)) (define next-imm (bpf:insn-imm next-insn)) (define imm64 (bvor (bvshl (zero-extend next-imm (bitvector 64)) (bv 32 64)) (zero-extend imm (bitvector 64)))) (emit_a64_mov_i64 dst imm64 ctx)] ; LDX: dst = *(size *)(src + off) [((BPF_LDX BPF_MEM BPF_W) (BPF_LDX BPF_MEM BPF_H) (BPF_LDX BPF_MEM BPF_B) (BPF_LDX BPF_MEM BPF_DW)) (emit_a64_mov_i (bv #b1 1) tmp off32 ctx) (case (BPF_SIZE code) [(BPF_W) (emit (A64_LDR32 dst src tmp) ctx)] [(BPF_H) (emit (A64_LDRH dst src tmp) ctx)] [(BPF_B) (emit (A64_LDRB dst src tmp) ctx)] [(BPF_DW) (emit (A64_LDR64 dst src tmp) ctx)])] ; ST: *(size *)(dst + off) = imm [((BPF_ST BPF_MEM BPF_W) (BPF_ST BPF_MEM BPF_H) (BPF_ST BPF_MEM BPF_B) (BPF_ST BPF_MEM BPF_DW)) ; Load imm to a register then store it */ (emit_a64_mov_i (bv #b1 1) tmp2 off32 ctx) (emit_a64_mov_i (bv #b1 1) tmp imm ctx) (case (BPF_SIZE code) [(BPF_W) (emit (A64_STR32 tmp dst tmp2) ctx)] [(BPF_H) (emit (A64_STRH tmp dst tmp2) ctx)] [(BPF_B) (emit (A64_STRB tmp dst tmp2) ctx)] [(BPF_DW) (emit (A64_STR64 tmp dst tmp2) ctx)])] ; STX: *(size *)(dst + off) = src [((BPF_STX BPF_MEM BPF_W) (BPF_STX BPF_MEM BPF_H) (BPF_STX BPF_MEM BPF_B) (BPF_STX BPF_MEM BPF_DW)) (emit_a64_mov_i (bv #b1 1) tmp off32 ctx) (case (BPF_SIZE code) [(BPF_W) (emit (A64_STR32 src dst tmp) ctx)] [(BPF_H) (emit (A64_STRH src dst tmp) ctx)] [(BPF_B) (emit (A64_STRB src dst tmp) ctx)] [(BPF_DW) (emit (A64_STR64 src dst tmp) ctx)])] ; STX XADD: lock *(u32 *)(dst + off) += src [((BPF_STX BPF_XADD BPF_W) ;STX XADD: lock *(u64 *)(dst + off) += src (BPF_STX BPF_XADD BPF_DW)) (define reg (cond [(bvzero? off) dst] [else (emit_a64_mov_i (bv #b1 1) tmp off32 ctx) (emit (A64_ADD (bv #b1 1) tmp tmp dst) ctx) tmp])) (emit (A64_STADD isdw reg src) ctx)] [else (assert #f (format "Unrecognized code: ~v" code))]) (context-insns ctx))
true
23330535e698f0349c2bfc375f027c0183333f0b
69e94593296c73bdfcfc2e5a50fea1f5c5f35be1
/practice/Racket/bnode-to-gnode.rkt
c2493128ca953b8ad378d6abbe31f5ce71898472
[]
no_license
nirajmahajan/CS152
7e64cf4b8ec24ed9c37ecc72c7731816089e959b
ef75b37715422bf96648554e74aa5ef6e36b9eb3
refs/heads/master
"2020-05-29T18:02:08.993097"
"2019-05-29T20:35:06"
"2019-05-29T20:35:06"
189,293,837
0
0
null
null
null
null
UTF-8
Racket
false
false
1,273
rkt
bnode-to-gnode.rkt
#lang racket (struct bnode (lt rt) #:transparent) (struct leaf (val) #:transparent) (struct gnode (val ls) #:transparent) (define (b->g btr) (match btr [(bnode (leaf vl) (leaf vr)) (gnode vl (list (gnode vr '())))] [(bnode (leaf vl) rt) (gnode vl (list (b->g rt)))] [(bnode lt (leaf vr)) (gnode (gnode-val (b->g lt)) (append (gnode-ls (b->g lt)) (list (gnode vr '()))))] [(bnode lt rt) (gnode (gnode-val (b->g lt)) (append (gnode-ls (b->g lt)) (list (b->g rt))))])) (define (last-del l) (reverse (cdr (reverse l)))) (define (g->b gtr) (match gtr [(gnode val '()) (leaf val)] [(gnode val lst) (bnode (g->b (gnode val (last-del lst))) (g->b (last lst)))])) (define gtr (gnode 'f (list (gnode 'g (list (gnode 'x '()))) (gnode 'h (list (gnode 'y '()) (gnode 'z '()))) (gnode 'i '())))) (define btr (bnode (bnode (bnode (leaf 'f) (bnode (leaf 'g) (leaf 'x))) (bnode (bnode (leaf 'h) (leaf 'y)) (leaf 'z))) (leaf 'i)))
false
82b677475eba6c0d349d7640ea1b6f55db478940
bbc6f7b30f79e1f8faff58ab3c27ae59ebf788fe
/slideshow-doc/scribblings/slideshow/ss.rkt
dcb9f77b62189e3a4942e366f61d3fa3317e255a
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
racket/slideshow
f84c101d84b8ae37bf3e9eb6358beb05014f0cdc
ad38bd11ccc0882500f1b9c8e391450c381fea4e
refs/heads/master
"2023-08-21T03:22:26.575238"
"2023-07-21T15:25:45"
"2023-07-21T17:07:33"
27,411,846
36
21
NOASSERTION
"2023-07-21T17:07:35"
"2014-12-02T02:47:47"
Racket
UTF-8
Racket
false
false
330
rkt
ss.rkt
#lang racket/base (require scribble/manual) (provide (all-from-out scribble/manual)) (require (for-label (except-in racket only drop) slideshow/base pict)) (provide (for-label (all-from-out racket slideshow/base pict)))
false
9d9b04445daae37918bb502444fd826cd741dc2d
ce6fd26c7cbe45479b8c3b1cfd358ed256146fb4
/admiral-edu/util/common.rkt
07dd977c7ac80ff0ce077ab25d294d5b1f1c5825
[]
no_license
jbclements/admiral-edu-server
ee9b9747490dcf472f01516f27681f37fa60b5c6
79c2778dd43d07e92ab02fb75955ec6060ed6861
refs/heads/master
"2020-04-12T03:57:33.455872"
"2016-10-25T00:15:25"
"2016-11-17T06:11:21"
62,004,530
1
1
null
"2019-12-13T22:19:10"
"2016-06-26T19:19:25"
Racket
UTF-8
Racket
false
false
108
rkt
common.rkt
#lang racket/base (require racket/string) (provide lines) (define (lines data) (string-split data "\n"))
false
17ef7a11a87fe2dfbb5891304a69e572d90efd98
5d8f5baee689450c9a18ca1715f88d3b2678e411
/pdp-1/set00/24.rkt
a893f2f13d389b6e615110bf16fd3d562884e546
[]
no_license
dingkple/racket
c6dca248708fb7119208b182b29fecf7b74c94d2
e11dd4dccc2633d8c86a30c1ef100fce9a065589
refs/heads/master
"2021-04-29T03:48:30.260116"
"2017-01-04T18:19:44"
"2017-01-04T18:19:44"
78,037,659
0
0
null
null
null
null
UTF-8
Racket
false
false
1,043
rkt
24.rkt
;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname |24|) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; product : List -> Number ;; Returns the product of the numbers in the given list ;; Examples: ;; (product empty) = 0 ;; (product (list 1)) = 1 ;; (product (list 1 2 3 4) = 24 (define (product lst) (cond [(empty? lst) 0] [else (* (first lst) (product_helper (rest lst)))])) ;; product : List -> Number ;; Returns the product of the numbers in the given list ;; Examples: ;; (product empty) = 0 ;; (product (list 1)) = 1 ;; (product (list 1 2 3 4) = 24 (define (product_helper lst) (cond [(empty? lst) 1] [else (* (first lst) (product_helper (rest lst)))])) (check-expect (product (list 1 2 3 4)) 24) (check-expect (product (list 1)) 1) (check-expect (product (list)) 0)
false
9c05e47be8984e7a92eb546220c4252d29f3c27a
5bbc152058cea0c50b84216be04650fa8837a94b
/experimental/postmortem/experiments/adaptor/without-adaptor/tetris/typed/elim.rkt
ad8d393553ce309664c8048744c685d7ba2ac3b8
[]
no_license
nuprl/gradual-typing-performance
2abd696cc90b05f19ee0432fb47ca7fab4b65808
35442b3221299a9cadba6810573007736b0d65d4
refs/heads/master
"2021-01-18T15:10:01.739413"
"2018-12-15T18:44:28"
"2018-12-15T18:44:28"
27,730,565
11
3
null
"2018-12-01T13:54:08"
"2014-12-08T19:15:22"
Racket
UTF-8
Racket
false
false
1,411
rkt
elim.rkt
#lang typed/racket (require benchmark-util) (define-type Color Symbol) (require/typed/check "data.rkt" [#:struct posn ([x : Real] [y : Real])] [#:struct block ([x : Real] [y : Real] [color : Color])] [#:struct tetra ([center : posn] [blocks : (Listof Block)])] [#:struct world ([tetra : tetra] [blocks : (Listof Block)])]) (require/typed 2htdp/image [#:opaque Image image?]) (define-type Posn posn) (define-type Block block) (define-type Tetra tetra) (define-type World world) (define-type BSet (Listof Block)) (require/typed/check "bset.rkt" [blocks-move (-> Real Real BSet BSet)] [full-row? (-> BSet Natural Boolean)] [blocks-union (-> BSet BSet BSet)] [blocks-row (-> BSet Real BSet)]) (require/typed/check "consts.rkt" [board-height Integer]) ;; Eliminate all full rows and shift down appropriately. (: eliminate-full-rows (-> BSet BSet)) (define (eliminate-full-rows bs) (elim-row bs board-height 0)) (: elim-row (-> BSet Integer Integer BSet)) (define (elim-row bs i offset) (cond [(< i 0) empty] [(full-row? bs i) (elim-row bs (sub1 i) (add1 offset))] [else (blocks-union (elim-row bs (sub1 i) offset) (blocks-move 0 offset (blocks-row bs i)))])) (provide eliminate-full-rows)
false
3b414659fbccc847066d8373f67de5796facc1bc
df0ba5a0dea3929f29358805fe8dcf4f97d89969
/exercises/lab/exercises/04-start-more-lists.rkt
550c137858a1c9aa18803f15414d41e93fdaea6e
[ "MIT" ]
permissive
triffon/fp-2019-20
1c397e4f0bf521bf5397f465bd1cc532011e8cf1
a74dcde683538be031186cf18367993e70dc1a1c
refs/heads/master
"2021-12-15T00:32:28.583751"
"2021-12-03T13:57:04"
"2021-12-03T13:57:04"
210,043,805
14
31
MIT
"2019-12-23T23:39:09"
"2019-09-21T19:41:41"
Racket
UTF-8
Racket
false
false
4,041
rkt
04-start-more-lists.rkt
#lang racket ; MORE LISTS ; TODO: reminder foldr ; TODO: talk about how it replaces cons ; and it being a "recursion scheme" ; similarly to "iterate" for nats (define (my-foldr f v xs) void) ; TODO: sum using foldr (define (sum xs) void) ; TODO: write function and show it's hard to do with foldr (define (minus-from n xs) void) ; TODO: another example of inconvenience (define (divide-by n xs) void) ; TODO: also not efficient - no tail recursion ; TODO: example of efficient sum-iter (define (sum-iter xs) void) ; TODO: show foldl ; and what it does to lists (define (foldl f nv xs) void) ; TODO: talk about monoidal operations ; and how they act the same with foldl ; EXERCISE: reimplement minus-from and divide-by with foldl (define (minus-from-foldl n xs) void) (define (divide-by-foldl n xs) void) ; EXERCISE: Reverse (naively using append, maybe foldr?) ; Reverse a list (define (my-reverse xs) void) ; EXAMPLES: ; (my-reverse '()) ;-- '() ; (my-reverse '(1 2 3)) ;-- '(3 2 1) ; EXERCISE: Reverse iteratively! ; HINT: Use an accumulator! (define (my-reverse-iter xs) void) ; EXAMPLES: ; (my-reverse-iter '()) ;-- '() ; (my-reverse-iter '(1 2 3)) ;-- '(3 2 1) ; EXERCISE: Reverse with foldl ; HINT: Define a helper flip function: ; which swaps the arguments of a function ; ((my-flip remainder) 3 7) ;-- 1 ; ((my-flip -) 6 10) ;-- 4 (define (my-flip f) void) (define (my-reverse-foldl xs) void) ; EXAMPLES: ; (my-reverse-foldl '()) ;-- '() ; (my-reverse-foldl '(1 2 3)) ;-- '(3 2 1) ; now we can easily define our minus-from with correct brackets (define (minus-from-foldl n xs) void) ; EXERCISE: "Zip" two lists together, pointwise ; From two lists pointwise make a list tuples! ; Look at the examples! (define (zip xs ys) void) ; EXAMPLES: ; (zip '(1 2 3) '()) ;-- '() ; (zip '(1 2 3) '(4 5 6)) ;-- '((1 . 4) (2 . 5) (3 . 6)) ; (zip '(1 2) '(4 5 6 7 8)) ;-- '((1 . 4) (2 . 5)) ; EXERCISE: Generalised zip ; Also get a "zipping function" instead of cons-ing elements together. (define (zip-with f xs ys) void) ; EXAMPLES: ; (zip-with + '(1 1 1) '(2 3 4)) ;-- '(3 4 5) ; (zip-with * '(2 1) '(2 3 4)) ;-- '(4 3) ; EXERCISE: Concatenate lists ; Write a function that given a list of lists, "flattens" it to once level. (define (concat xss) void) ; EXAMPLES: ; (concat '(())) ;-- '() ; (concat '((1 2 3) (4 5 6) (7 8 9))) ;-- '(1 2 3 4 5 6 7 8 9) ; (concat '((1) () (7 8 9))) ;-- '(1 7 8 9) ; ...wait, haven't I seen this pattern somewhere before?? ; EXERCISE: Concat with foldr (define (concat-foldr xss) void) ; ...but we can also do it with foldl, since append is associative! ; EXERCISE: Concat with foldl (define (concat-foldl xss) void) ; EXERCISE: Cartesian product ; let's do a cartesian product, now that we've seen a zip ; zip was a pairwise way to combine lists, this is "each with each" way to combine lists ; i.e. for each x in xs we cons x with each y in ys (define (cartesian xs ys) void) ; EXAMPLES: ; (cartesian '(1 2 3) '()) ;-- () ; (cartesian '(1 2 3) '(4 5)) ;-- (((1 . 4) (2 . 4) (3 . 4)) ((1 . 5) (2 . 5) (3 . 5))) ; (cartesian '(1 2) '(4 5 6)) ;-- (((1 . 4) (2 . 4)) ((1 . 5) (2 . 5)) ((1 . 6) (2 . 6))) ; EXERCISE: flatten - "recursive concat" ; We want a function that "concats" arbitrarily nested lists ; HINT: Look at these three cases and think about how to make each of them ; into "a list of depth 1": ; 1) the empty list ; 2) a non-empty list ; 3) something that isn't a list (define (flatten xss) void) ; EXAMPLES: ; (flatten '((1 2 3) 4 () ((5 (6)) 7) (((8))))) ;-- '(1 2 3 4 5 6 7 8) ; finally something that we discussed only briefly with some of you (so I guess we didn't do this in class) ; EXERCISE: Recursive reverse ; Reverse a list, but also reverse all lists that are elements of it. ; HINT: Use a similar case breakdown to the flatten function. ; Maybe this is actually another recursion scheme just like foldr/iterate :thinking: (define (uber-reverse xs) void) ; EXAMPLES: ; (uber-reverse '((1 2 3) 4 () ((5 (6)) 7) (((8))))) ;-- '((((8))) (7 ((6) 5)) () 4 (3 2 1))
false
49687ccad473b62ab8d8e4589d46bf3eaa0194f3
52c2225c9f44c0da28ca1fd44606a8d197c8eac8
/EOPL/ch2/2.12-test.rkt
db63ec0a867398fb5c56ee4db06c0aae7a643d59
[]
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
286
rkt
2.12-test.rkt
#lang eopl (require rackunit "2.12.rkt") (require rackunit/text-ui) (define astack (push 1 (push 2 (empty-stack)))) (define stack-tests (test-suite "Tests for stack" (check-equal? (top astack) 1) (check-equal? (top (pop astack)) 2))) (run-tests stack-tests)
false
f994299a28a1d21ce4a7dfe48f86bb2d2b6a66ff
5dfeeeea0d845413f14fb9422c12395dd6835b17
/count.rkt
50f5fb81449cebcaa0a9a21826efae38280bf316
[]
no_license
acieroid/racket-concurrency
6cd7b0f0f29dcd637ec6407570fc3f93324b2f9d
bd0edeffd46aa15a8233357fb827895c6bd24d5f
refs/heads/master
"2020-05-18T00:15:45.588825"
"2019-05-06T14:16:12"
"2019-05-06T14:16:12"
184,056,682
0
0
null
null
null
null
UTF-8
Racket
false
false
1,183
rkt
count.rkt
#lang racket (require "actors.rkt") (define N (int-top)) (define producer-actor (a/actor "producer" (counter) (increment () (letrec ((loop (lambda (n) (if (> n 0) (begin (a/send counter increment) (loop (- n 1))) 'done)))) (loop N) (a/send counter retrieve a/self) (a/become producer-actor counter))) (result (count) (if (= count N) (display "Success!") (error "Error!")) (a/terminate)))) (define counting-actor (a/actor "counting" (count) (increment () (a/become counting-actor (+ count 1))) (retrieve (to) (a/send to result count) (a/terminate)))) (define counter (a/create counting-actor 0)) (define producer (a/create producer-actor counter)) (a/send producer increment) (a/wait)
false
117f4c53e0872f9c2b08e2fb4b9e3a07f73212c9
b6a5637b6d3fc8ad1b7996c62ec73b6d895c5e95
/3.5-streams.rkt
6c1bc7991dbb54c5d2c9a1eca27572280c8d219f
[ "MIT" ]
permissive
abelkov/sicp-musings
8911b5215b42fc21c15699b11cdb68727852d399
49373974eb3df8e12ad086ddfabda14b95f139ba
refs/heads/master
"2021-06-12T03:55:16.842917"
"2017-01-31T19:02:45"
"2017-01-31T19:02:45"
null
0
0
null
null
null
null
UTF-8
Racket
false
false
3,566
rkt
3.5-streams.rkt
#lang racket (define (smallest-divisor n) (find-divisor n 2)) (define (square x) (* x x)) (define (enumerate-interval a b) (if (> a b) null (cons a (enumerate-interval (+ a 1) b)))) (define (find-divisor n test-divisor) (cond ((> (square test-divisor) n) n) ((divides? test-divisor n) test-divisor) (else (find-divisor n (+ test-divisor 1))))) (define (divides? a b) (= (remainder b a) 0)) (define (prime? n) (= n (smallest-divisor n))) (define (sum-primes1 a b) (define (iter count accum) (cond ((> count b) accum) ((prime? count) (iter (+ count 1) (+ count accum))) (else (iter (+ count 1) accum)))) (iter a 0)) (define (sum-primes2 a b) (foldl + 0 (filter prime? (enumerate-interval a b)))) ;;;;; Streams ;;;;; ; stream implementation (define empty-stream null) (define stream-null? null?) (define (stream? s) (cond [(not (pair? s)) #f] [(stream-null? s) #t] [#t (stream? (stream-cdr s))])) (define (stream-car stream) (car stream)) (define (stream-cdr stream) (force (cdr stream))) (define-syntax cons-stream (syntax-rules () [(cons-stream a b) (cons a (delay b))])) ; utility functions (define (stream-ref s n) (if (= n 0) (stream-car s) (stream-ref (stream-cdr s) (- n 1)))) (define (stream-filter pred s) (cond [(stream-null? s) empty-stream] [(pred (stream-car s)) (cons-stream (stream-car s) (stream-filter pred (stream-cdr s)))] [#t (stream-filter pred (stream-cdr s))])) (define (stream-for-each proc s) (if (stream-null? s) 'done (begin (proc (stream-car s)) (stream-for-each proc (stream-cdr s))))) (define (stream-enumerate-interval a b) (if (> a b) empty-stream (cons-stream a (stream-enumerate-interval (+ a 1) b)))) ; for printing (define (display-stream s) (stream-for-each display-line s)) (define (display-line x) (newline) (display x)) ; ex 3.50 (define (stream-map proc . argstreams) (if (stream-null? (car argstreams)) empty-stream (cons-stream (apply proc (map stream-car argstreams)) (apply stream-map (cons proc (map stream-cdr argstreams)))))) (define (my-map proc . args) (define (my-inner-map proc args) (if (null? args) null (cons (proc (car args)) (my-inner-map proc (cdr args))))) (if (null? (car args)) null (let [(firsts (my-inner-map car args)) (rests (my-inner-map cdr args))] (cons (apply proc firsts) (apply my-map proc rests))))) ; ex 3.51 (define (show x) (display-line x) x) (define x (stream-map show (stream-enumerate-interval 0 10))) ;(stream-ref x 5) ;(stream-ref x 7) ; ex 3.52 (define sum 0) (define (accum x) (set! sum (+ x sum)) sum) (define seq (stream-map accum (stream-enumerate-interval 1 20))) (define y (stream-filter even? seq)) (define z (stream-filter (lambda (x) (= (remainder x 5) 0)) seq)) ;(stream-ref y 7) ;(display-stream z) ; tests ;(my-map + ; (list 1 2 3) ; (list 40 50 60) ; (list 700 800 900)) (define stream1 (stream-enumerate-interval 1 10)) (define stream2 (stream-enumerate-interval 11 110)) ;(display-stream ; (stream-map + ; stream1 ; stream2))
true
a94402266bb2e4a0d89d86e3ad1449991faea786
fc6465100ab657aa1e31af6a4ab77a3284c28ff0
/results/fair-24/stlc-sub-2-ordered.rktd
f34df1da3354a36c9a847c3d755c6ae98cffdf65
[]
no_license
maxsnew/Redex-Enum-Paper
f5ba64a34904beb6ed9be39ff9a5e1e5413c059b
d77ec860d138cb023628cc41f532dd4eb142f15b
refs/heads/master
"2020-05-21T20:07:31.382540"
"2017-09-04T14:42:13"
"2017-09-04T14:42:13"
17,602,325
0
0
null
null
null
null
UTF-8
Racket
false
false
2,202
rktd
stlc-sub-2-ordered.rktd
(start 2015-06-21T19:45:22 (#:model "stlc-sub-2" #:type ordered)) (gc-major 2015-06-21T19:45:23 (#:amount 23183200 #:time 291)) (heartbeat 2015-06-21T19:45:23 (#:model "stlc-sub-2" #:type ordered)) (gc-major 2015-06-21T19:45:23 (#:amount 427536 #:time 248)) (counterexample 2015-06-21T19:45:28 (#:model "stlc-sub-2" #:type ordered #:counterexample ((λ (b int) (λ (a int) a)) 0) #:iterations 4847 #:time 4515)) (new-average 2015-06-21T19:45:28 (#:model "stlc-sub-2" #:type ordered #:average 4515.0 #:stderr +nan.0)) (counterexample 2015-06-21T19:45:32 (#:model "stlc-sub-2" #:type ordered #:counterexample ((λ (b int) (λ (a int) a)) 0) #:iterations 4847 #:time 4370)) (new-average 2015-06-21T19:45:32 (#:model "stlc-sub-2" #:type ordered #:average 4442.5 #:stderr 72.5)) (heartbeat 2015-06-21T19:45:33 (#:model "stlc-sub-2" #:type ordered)) (counterexample 2015-06-21T19:45:36 (#:model "stlc-sub-2" #:type ordered #:counterexample ((λ (b int) (λ (a int) a)) 0) #:iterations 4847 #:time 3714)) (new-average 2015-06-21T19:45:36 (#:model "stlc-sub-2" #:type ordered #:average 4199.666666666667 #:stderr 246.4145107559843)) (counterexample 2015-06-21T19:45:39 (#:model "stlc-sub-2" #:type ordered #:counterexample ((λ (b int) (λ (a int) a)) 0) #:iterations 4847 #:time 3109)) (new-average 2015-06-21T19:45:39 (#:model "stlc-sub-2" #:type ordered #:average 3927.0 #:stderr 323.5848677961729)) (counterexample 2015-06-21T19:45:42 (#:model "stlc-sub-2" #:type ordered #:counterexample ((λ (b int) (λ (a int) a)) 0) #:iterations 4847 #:time 3096)) (new-average 2015-06-21T19:45:42 (#:model "stlc-sub-2" #:type ordered #:average 3760.8 #:stderr 300.74364498688914)) (heartbeat 2015-06-21T19:45:43 (#:model "stlc-sub-2" #:type ordered)) (counterexample 2015-06-21T19:45:45 (#:model "stlc-sub-2" #:type ordered #:counterexample ((λ (b int) (λ (a int) a)) 0) #:iterations 4847 #:time 3104)) (new-average 2015-06-21T19:45:45 (#:model "stlc-sub-2" #:type ordered #:average 3651.3333333333335 #:stderr 268.85084671203435)) (finished 2015-06-21T19:45:45 (#:model "stlc-sub-2" #:type ordered #:time-ms 21913 #:attempts 29082 #:num-counterexamples 6 #:rate-terms/s 1327.1573951535618 #:attempts/cexp 4847.0))
false
f8185d22a762404948e04932add19fcc7ae52248
ec56bff00cd6951bb9eb85fefb13465a973c9959
/private/test-ukkonen2.rkt
de57df3f6442e92d53c72812c2c6fb070ad8558b
[]
permissive
jbclements/suffixtree
f29e2d87e42a9d52f23c19563414e1ef9c0c0d39
b46cb2ecbd0cc33d2c7afc0948b6415f23863c78
refs/heads/master
"2022-09-01T20:24:49.535599"
"2022-07-19T15:14:53"
"2022-07-19T15:14:53"
228,895,348
2
2
BSD-3-Clause
"2022-07-19T15:14:54"
"2019-12-18T18:03:49"
Racket
UTF-8
Racket
false
false
16,818
rkt
test-ukkonen2.rkt
#lang racket/base (require "test-common-definitions.rkt" "ukkonen2.rkt") (define ukkonen-test-suite (test-suite "ukkonen test suite" (test-case "empty construction" (let-values (((root tree) (root-and-tree))) (check-equal? (list) (node-children root)) (check-label-equal? (make-label "") (node-up-label root)) (check-eq? #f (node-suffix-link root)))) (test-case "adding a leaf." (let-values (((root tree) (root-and-tree))) (node-add-leaf! root (make-label "bookkeeper")) (check-equal? 1 (length (node-children root))))) (test-case "tree-contains? #t on empty tree" (let-values (((root tree) (root-and-tree))) (check-true (tree-contains? tree (make-label ""))))) (test-case "tree-contains? #f on empty tree" (let-values (((root tree) (root-and-tree))) (check-false (tree-contains? tree (make-label "munging"))))) (test-case "tree-contains? on whole tree" (let-values (((root tree) (root-and-tree))) (node-add-leaf! root (make-label "fezzick")) (check-true (tree-contains? tree (make-label "fezzick"))))) (test-case "tree-contains? on prefix" (let-values (((root tree) (root-and-tree))) (node-add-leaf! root (make-label "wesley")) (check-true (tree-contains? tree (make-label "wes"))))) (test-case "tree-contains? failing" (let-values (((root tree) (root-and-tree))) (node-add-leaf! root (make-label "inigo")) (check-false (tree-contains? tree (make-label "montoya"))))) (test-case "tree-contains? passing through two nodes" (let-values (((root tree) (root-and-tree))) (node-up-split! (node-add-leaf! root (make-label "inconcievable")) 5) (check-true (tree-contains? tree (make-label "inconcievable"))))) (test-case "adding two leaves." (let-values (((root tree) (root-and-tree))) (node-add-leaf! root (make-label "bookkeeper")) (node-add-leaf! root (make-label "ookkeeper")) (check-equal? 2 (length (node-children root))))) (test-case "finding children" (let-values (((root tree) (root-and-tree))) (let ((leaf-1 (node-add-leaf! root (make-label "blah"))) (leaf-2 (node-add-leaf! root (make-label "lah")))) (check-eq? leaf-1 (node-find-child root #\b)) (check-eq? leaf-2 (node-find-child root #\l)) (check-false (node-find-child root #\a))))) (test-case "test splitting" (let-values (((root tree) (root-and-tree))) (let* ((leaf (node-add-leaf! root (make-label "ssi"))) (joint (node-up-split! leaf 1))) (check-equal? 1 (length (node-children root))) (check-eq? root (node-parent joint)) (check-eq? joint (node-parent leaf)) (check-eq? joint (node-find-child root #\s)) (check-eq? leaf (node-find-child joint #\s))))) (test-case "node-up-splice-leaf!" (let-values (((root tree) (root-and-tree))) (let ((leaf (node-add-leaf! root (make-label "aaz")))) (let-values (((joint split-leaf) (node-up-splice-leaf! leaf 1 (make-label "z")))) (check-label-equal? (make-label "z") (node-up-label split-leaf)) (check-label-equal? (make-label "az") (node-up-label leaf)) (check-label-equal? (make-label "a") (node-up-label (node-parent split-leaf))))))) (test-case "following" (let-values (((root tree) (root-and-tree))) (let ((leaf (node-add-leaf! root (make-label "delicious")))) (node-follow/k root (make-label "delicious") (lambda (node) #t) (lambda (node offset) (fail)) (lambda (node label label-offset) (fail)) (lambda (node offset label label-offset) (fail))) (node-follow/k root (make-label "deli") (lambda (node) (fail)) (lambda (node offset) (check-eq? node leaf) (check-equal? 4 offset)) (lambda (node label label-offset) (fail)) (lambda (node offset label label-offset) (fail))) (node-follow/k root (make-label "yummy") (lambda (node) (fail)) (lambda (node offset) (fail)) (lambda (node label label-offset) (check-eq? root node) (check-label-equal? (make-label "yummy") (sublabel label label-offset))) (lambda (node offset label label-offset) (fail))) (node-follow/k root (make-label "done") (lambda (node) (fail)) (lambda (node offset) (fail)) (lambda (node label label-offset) (fail)) (lambda (node offset label label-offset) (check-eq? leaf node) (check-equal? 1 offset) (check-label-equal? (make-label "one") (sublabel label label-offset))))))) (test-case "test skip-counting" (let-values (((root tree) (root-and-tree))) (let* ((some-node (node-add-leaf! root (make-label "arabidopsis"))) (another-leaf (node-add-leaf! some-node (make-label "thaliana")))) (let-values (((node offset) (skip-count root (make-label "arabidopsist")))) (check-eq? another-leaf node) (check-equal? 1 offset))))) (test-case "test skip-counting on end" (let-values (((root tree) (root-and-tree))) (let* ((some-node (node-add-leaf! root (make-label "crunchy"))) (another-leaf (node-add-leaf! some-node (make-label "bacon")))) (let-values (((node offset) (skip-count root (make-label "crunchy")))) (check-equal? 7 offset) (check-eq? some-node node))))) (test-case "test skip-counting on empty string" (let-values (((root tree) (root-and-tree))) (let* ((some-node (node-add-leaf! root (make-label "power"))) (another-leaf (node-add-leaf! some-node (make-label "rangers")))) (let-values (((node offset) (skip-count root (make-label "")))) (check-equal? 0 offset) (check-eq? root node))))) (test-case "skip-counting within the tree on empty string" (let-values (((root tree) (root-and-tree))) (let ((leaf (node-add-leaf! root (make-label "blah")))) (let-values (((node offset) (skip-count leaf (make-label "")))) (check-eq? leaf node) (check-equal? 4 offset))))) (test-case "simple suffix tree adding with single character" (let-values (((root tree) (root-and-tree))) (suffix-tree-add! tree (make-label "a")) (check-not-false (node-find-child root #\a)))) (test-case "simple suffix tree adding: aa --- implicit tree" (let-values (((root tree) (root-and-tree))) (suffix-tree-add! tree (make-label "aa")) (let ((child (node-find-child root #\a))) (check-not-false child) (check-label-equal? (make-label "aa") (node-up-label child))))) (test-case "simple suffix tree adding: aa with sentinel --- explicit tree" (let*-values (((root tree) (root-and-tree)) ((label) (string->label/with-sentinel "aa")) ((a-label) (make-label "a")) ((sentinel-label) (sublabel label (sub1 (label-length label))))) (suffix-tree-add! tree label) (let ((child (node-find-child root (label-ref a-label 0)))) (check-not-false child) (check-label-equal? a-label (node-up-label child)) (check-not-false (node-find-child child (label-ref a-label 0))) (check-label-equal? (sublabel label 1) (node-up-label (node-find-child child (label-ref a-label 0))))))) (test-case "simple suffix tree adding: a$" (let-values (((root tree) (root-and-tree))) (suffix-tree-add! tree (make-label "a$")) (check-not-false (node-find-child root #\a)) (check-label-equal? (make-label "a$") (node-up-label (node-find-child root #\a))) (check-not-false (node-find-child root #\$)) (check-label-equal? (make-label "$") (node-up-label (node-find-child root #\$))))) (test-case "missisippi example: missisippi$" (let-values (((root tree) (root-and-tree))) (suffix-tree-add! tree (make-label "mississippi$")) (check tree-contains? tree (make-label "mississippi$")) (check tree-contains? tree (make-label "ississippi$")) (check tree-contains? tree (make-label "ssissippi$")) (check tree-contains? tree (make-label "sissippi$")) (check tree-contains? tree (make-label "issippi$")) (check tree-contains? tree (make-label "ssippi$")) (check tree-contains? tree (make-label "sippi$")) (check tree-contains? tree (make-label "ippi$")) (check tree-contains? tree (make-label "ppi$")) (check tree-contains? tree (make-label "pi$")) (check tree-contains? tree (make-label "i$")) (check tree-contains? tree (make-label "$")) (check tree-contains? tree (make-label "")))) (test-case "missisippi$ example as a vector of symbols" (let* ((v (list->vector '(m i s s i s s i p p i $))) (label (vector->label v))) (let-values (((root tree) (root-and-tree))) (suffix-tree-add! tree label) (for-each-sublabel (lambda (s) (check tree-contains? tree s)) label)))) (test-case "test all substrings of binary strings of length 8" (let loop ((n 0)) (when (< n 256) (let-values (((root tree) (root-and-tree))) (let ((binary-label (make-label (string-append (zfill (number->string n 2) 8) "$")))) (suffix-tree-add! tree binary-label) (for-each-sublabel (lambda (s) (check tree-contains? tree s (string-append "couldn't find " (label->string s) " in " (label->string binary-label)))) binary-label) (loop (add1 n))))))) (test-case "testing jump-to-suffix on node with suffix link" (let*-values (((tree nodes) (tree-structure-for-00000100$)) ((node offset) (jump-to-suffix (list-ref nodes 8)))) (check-eq? (list-ref nodes 0) node) (check-equal? 0 offset))) (test-case "another jump-to-suffix test." (let-values (((root tree) (root-and-tree))) (let* ((leaf (node-add-leaf! root (make-label "00000100$"))) (joint (node-up-split! leaf 4))) (let-values (((n o) (jump-to-suffix joint))) (check-eq? root n) (check-false o))))) (test-case "jumping-to-suffix on root should return (values root #f)" (let*-values (((root tree) (root-and-tree)) ((n o) (jump-to-suffix root))) (check-eq? root n) (check-false o))) (test-case "find-next-extension-point at root should point to the root" (let-values (((root tree) (root-and-tree))) (let-values (((node offset i*) (find-next-extension-point/add-suffix-link! root (make-label "hercules") 0 0))) (check-eq? node root) (check-equal? 0 offset) (check-equal? 0 i*)))) (test-case "looking for the next extension point" (let-values (((tree nodes) (tree-structure-for-00000100$))) (let-values (((node offset i*) (find-next-extension-point/add-suffix-link! (list-ref nodes 6) (make-label "00000100$") 8 7))) (check-eq? node (list-ref nodes 8)) (check-equal? 1 offset) (check-equal? 8 i*)))) (test-case "find-next-extension on beginning of 00$ construction" (let-values (((root tree) (root-and-tree))) (let ((leaf (node-add-leaf! root (make-label "00$")))) (let-values (((extension-node extension-offset i*) (find-next-extension-point/add-suffix-link! root (make-label "001$") 1 1))) (check-eq? leaf extension-node) (check-equal? 1 extension-offset) (check-equal? 2 i*))))) (test-case "find-next-extension intensional failure" (let-values (((root tree) (root-and-tree))) (let ((leaf (node-add-leaf! root (make-label "000000")))) (let-values (((extension-node extension-offset i*) (find-next-extension-point/add-suffix-link! root (make-label "000000") 1 1))) (check-false extension-node) (check-false extension-offset) (check-false i*))))) (test-case "extend-at-point! at the root" (let*-values (((root tree) (root-and-tree)) ((label) (make-label "foo$")) ((first-char) #\f)) (check-false (node-find-child root first-char)) (let ((last-active-node (extend-at-point! root 0 label 0))) (check-eq? last-active-node root) (check-not-false (node-find-child root first-char))))) (test-case "extend-at-point with splice" (let-values (((root tree) (root-and-tree))) (let ((leaf (node-add-leaf! root (make-label "001")))) (let ((new-active-point (extend-at-point! leaf 1 (make-label "001") 2))) (check-label-equal? (make-label "0") (node-up-label new-active-point)) (check-label-equal? (make-label "01") (node-up-label leaf)) (check-not-false (node-find-child new-active-point #\1)))))) (test-case "suffix-tree-add! on two single elements" (let-values (((root tree) (root-and-tree)) ((label-1 label-2) (values (make-label "$") (make-label "!")))) (suffix-tree-add! tree label-1) (suffix-tree-add! tree label-2) (for-each-sublabel (lambda (s) (check tree-contains? tree s)) label-1) (for-each-sublabel (lambda (s) (check tree-contains? tree s)) label-2))) (test-case "suffix-tree-add! on two short strings" (let-values (((root tree) (root-and-tree)) ((label-1 label-2) (values (make-label "a$") (make-label "a!")))) (suffix-tree-add! tree label-1) (suffix-tree-add! tree label-2) (check tree-contains? tree (make-label "a")) (check tree-contains? tree (make-label "a$")) (check tree-contains? tree (make-label "$")) (check tree-contains? tree (make-label "a!")) (check tree-contains? tree (make-label "!")) (check tree-contains? tree (make-label "")) )) ;; FIXME: Refactor pairwise comparison of these strings. (test-case "suffix-tree-add! on two strings" (let-values (((root tree) (root-and-tree)) ((label-1 label-2) (values (make-label "aaazzz$") (make-label "aaazza!")))) (suffix-tree-add! tree label-1) (suffix-tree-add! tree label-2) (for-each-sublabel (lambda (s) (check tree-contains? tree s)) label-1) (for-each-sublabel (lambda (s) (check tree-contains? tree s)) label-2))) )) (printf "ukkonen tests~%") (void (run-tests ukkonen-test-suite))
false
72e80c97641121374f8d986e3dd5c7a1029f8e53
2acb0183876eb4653d4d8d507a921246c644cc38
/06-interpreters/section6_video_code_files/scratch.rkt
e4cecf5e882dcf6edac280ae3ed5e83a2ae283db
[]
no_license
peilundai/UW-Programming-Languages-on-Coursera
d19aed8fb93483e75f90b80b686dba9f547a70f8
deed618ff58407a6e9334a5f9c1f69edf3cf2500
refs/heads/master
"2022-04-11T17:25:22.113736"
"2020-03-12T04:01:39"
"2020-03-12T04:01:39"
null
0
0
null
null
null
null
UTF-8
Racket
false
false
703
rkt
scratch.rkt
#lang racket (provide (all-defined-out)) ;(define (Const i) (list 'Const i)) ;(define (Negate e) (list 'Negate e)) ;(define (Add e1 e2) (list 'Add e1 e2)) ;(define (Multiply e1 e2) (list 'Multiply e1 e2)) ; ;(define (Const? x) (eq? (car x) 'Const)) ;(define (Negate? x) (eq? (car x) 'Negate)) ;(define (Add? x) (eq? (car x) 'Add)) ;(define (Multiply? x) (eq? (car x) 'Multiply)) ;; struct ;(struct foo (bar baz quux) #:transparent #:mutable) ;(define a (foo 1 2 3)) ;(foo? a) ;(foo-bar a) ; ;(struct const (int)) ;(struct negate (e)) ;(struct add (e1 e2)) ;(struct multiply (e1 e2)) ;(define ee (const 1)) ; concrete syntax (string) ; abstract syntax (tree) AST ;
false
9b7284be3d061650db125a9e91399bccd5878b58
745e4fcc48a8e4789deb7702e9393b532e40daa0
/quest9.rkt
4f1f0417185baa88aa721b82c8f57da7e38de033
[]
no_license
thoughtstem/ts-curric-game-engine
6e0aff852f34c77628001f460b15a57485673bac
afb330290be8c0dba4d0bff2a8b132b8c7033031
refs/heads/master
"2020-03-30T18:15:52.535260"
"2018-12-08T19:01:56"
"2018-12-08T19:01:56"
151,491,590
0
0
null
null
null
null
UTF-8
Racket
false
false
6,641
rkt
quest9.rkt
#lang racket (provide quest9) (require ts-racket) (require ts-curric-common) (require net/sendurl) (require (prefix-in p: pict/code)) (require (prefix-in p: pict)) (require racket/runtime-path) (define-runtime-path images "images") (require "./common.rkt") (define load-copy-wall-and-lava (activity-instructions "Load/Copy Wall & Lava Code" '() (list (instruction-basic "TS Magic Load: 'tsgd_wall_and_lava'.") (instruction-basic "Copy/Paste the code BEFORE (define lost?).") (instruction-goal "your new code in your project")) (p:scale-to-fit (local-bitmap "tsgd_paste_code_here.png") 320 320 #:mode 'preserve))) (define wall-lava-code-img (p:scale (p:code (wall-entity (posn 450 250)) (wall-entity (posn 150 300)) (lava-entity (posn 300 150))) 4 )) (define add-wall-and-lava (activity-instructions "Add Walls & Lava" '() (list (instruction-basic "Find the (start-game) code, make a new line AFTER (enemy-entity), and type:") (instruction-image (text-with-image " " wall-lava-code-img) 640 140 "") (instruction-basic "Test the game.") (instruction-goal "your walls and lava in game.")) (p:scale-to-fit (local-bitmap "tsgd_add_walls_and_lava.png") 300 320 #:mode 'preserve))) ;(with-award 2 add-physical-colliders) (define add-physical-colliders (activity-instructions "Add Physical Colliders" '() (list (instruction-basic "Add a (physical-collider) component to BOTH the hero-entity and the enemy-entity.") (instruction-basic "Type it anywhere BEFORE (on-collide) or (on-edge).") (instruction-goal "the hero and the enemy colliding with walls.")) (p:scale-to-fit (local-bitmap "tsgd_add_colliders.png") 320 320 #:mode 'preserve))) (define death-by-lava-code-img (p:scale (p:code (on-collide "lava" die)) 4 )) (define death-by-lava (activity-instructions "Add Death by Lava" '() (list (instruction-basic "Find (define (hero-entity) ...)") (instruction-basic "Add the following component:") (instruction-image (text-with-image " " death-by-fireball-code-img) 640 140 "") (instruction-basic "You can comment out other lines with ';' to make testing easier. If you have rage mode on the enemy, disable that too.") (instruction-goal "your hero dying by the lava.")) (p:scale-to-fit (local-bitmap "tsgd_add_death_lava.png") 250 320 #:mode 'preserve))) ;(with-award 2 draw-walls-and-lava) (define replace-the-walls-and-lava (activity-instructions "Draw Your Own Walls & Lava" '() (list (instruction-basic "Draw new \"wall\" and \"lava\" sprites and save it.") (instruction-basic "Find (define (wall-entity)) and replace (rectangle 80 40 \"solid\" \"white\") with your image.") (instruction-basic "Repeat for the lava-entity.") (instruction-goal "your new walls and lava in game.")) (p:scale-to-fit (local-bitmap "tsgd_wall_and_lava.png") 320 320 #:mode 'preserve))) ; (with-award 2 add-bounce-to-fireball) (define add-bounce-to-fireball (activity-instructions "Make the Fireball Bounce" '() (list (instruction-basic "Find (define (fireball-entity) ...)") (instruction-basic "Make a new line AFTER (rotation-style ...) and type:") (instruction-image (p:scale (codify "(on-collide \"wall\" (bounce))") 2) 640 60 "") (instruction-basic "Test the game.") (instruction-goal "the fireballs bouncing off walls.")) (p:scale-to-fit (local-bitmap "tsgd_add_bounce.png") 300 320 #:mode 'preserve))) ; (with-award 1 add-after-time-die) (define add-after-time-die (activity-instructions "After Time - Remove Bad Guys" '() (list (instruction-basic "Find your moving sprite definition (bad-chest-entity, if you didn't rename it).") (instruction-basic "Make a new line AFTER (every-tick ...) and type:") (instruction-image (p:scale (codify "(after-time 500 die)") 2) 640 60 "") (instruction-goal "the wave of bad guys ending.")) (p:scale-to-fit (local-bitmap "tsgd_add_after_time_die.png") 300 320 #:mode 'preserve))) ; (with-award 1 add-after-time-spawn) (define add-after-time-spawn (activity-instructions "After Time - Spawn Boss" '() (list (instruction-basic "Remove (enemy-entity) from (start-game ...).") (instruction-basic "Change the enemy-entity's position to (posn 0 0).") (instruction-basic "Add the following component to lava-entity.") (instruction-image (p:scale (codify "(after-time 600 (spawn (enemy-entity)))") 2) 640 60 "") (instruction-goal "the boss spawning after 600.")) (p:scale-to-fit (local-bitmap "tsgd_spawn_boss.png") 250 320 #:mode 'preserve))) ;day 10 Walls and Lava (define day9-2dgame (list (with-award 0 open-file) (with-award 1 load-copy-wall-and-lava) (with-award 2 add-wall-and-lava) (with-award 1 add-physical-colliders) (with-award 1 death-by-lava) (with-award 2 replace-the-walls-and-lava) (choose "any" (list (with-award 1 add-bounce-to-fireball) (with-award 1 add-after-time-die) (with-award 2 add-after-time-spawn) )) )) (define (quest9) (map shrink (make-picts "red" "Q9-" day9-2dgame (settings (bg (local-bitmap "bg-arcade.png")) (MARIO) (MARIO-BONUS) (MARIO-BONUS)))))
false
546060cd720c6d87c1cf4ad97f68f0d2d279b530
627680558b42ab91471b477467187c3f24b99082
/results/24-hr-old/stlc-sub-4-search.rktd
5c9cb291adddaf63225f4a19989f2cc37bc6a272
[]
no_license
bfetscher/dissertation
2a579aa919d6173a211560e20630b3920d108412
148d7f9bb21ce29b705522f7f4967d63bffc67cd
refs/heads/master
"2021-01-12T12:57:45.507113"
"2016-10-06T06:54:21"
"2016-10-06T06:54:21"
70,130,350
0
1
null
"2016-10-06T14:01:38"
"2016-10-06T06:58:19"
Racket
UTF-8
Racket
false
false
93,534
rktd
stlc-sub-4-search.rktd
(start 2014-10-12T19:12:21 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:12:21 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:12:22 (#:amount 20202656 #:time 263)) (heartbeat 2014-10-12T19:12:31 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:12:41 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:12:51 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:13:01 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:13:09 (#:amount 87919160 #:time 265)) (heartbeat 2014-10-12T19:13:11 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:13:21 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:13:31 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:13:41 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:13:51 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:14:01 (#:amount 80528712 #:time 290)) (heartbeat 2014-10-12T19:14:01 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:14:11 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:14:20 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (C ((int → int) → (int → int))) (λ (i (int → ((list int) → (list int)))) (λ (p ((list int) → (list int))) (λ (i int) i)))) (λ (b (int → int)) b)) cons) ((λ (j ((list int) → (list int))) j) (cons ((λ (G int) G) ((λ (K (int → (int → (int → ((list int) → (list int)))))) 3) (λ (z int) (λ (P int) cons))))))) #:iterations 1858 #:time 119083)) (new-average 2014-10-12T19:14:20 (#:model "stlc-sub-4" #:type search #:average 119083.0 #:stderr +nan.0)) (heartbeat 2014-10-12T19:14:21 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:14:31 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:14:41 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:14:51 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:15:01 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:15:08 (#:amount 123270488 #:time 276)) (heartbeat 2014-10-12T19:15:11 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:15:21 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:15:31 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:15:41 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:15:51 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:15:59 (#:amount 83538512 #:time 246)) (heartbeat 2014-10-12T19:16:01 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:16:11 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:16:21 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:16:31 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:16:41 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:16:51 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:16:58 (#:amount 118331664 #:time 272)) (heartbeat 2014-10-12T19:17:01 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:17:11 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:17:21 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:17:31 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:17:41 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:17:51 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:17:53 (#:amount 85131096 #:time 282)) (heartbeat 2014-10-12T19:18:01 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:18:11 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:18:14 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (P ((int → int) → (int → int))) (λ (F (list int)) (λ (F (((((list int) → int) → int) → int) → (int → ((list int) → (list int))))) F))) (λ (s (int → int)) s)) nil) ((λ (SM (((((list int) → int) → int) → int) → (int → ((list int) → (list int))))) SM) (λ (c ((((list int) → int) → int) → int)) cons))) (λ (S (((list int) → int) → int)) 0)) (hd ((λ (N (list int)) N) ((λ (U (list int)) nil) nil)))) ((((((λ (v ((list int) → (((int → int) → ((int → (list int)) → ((list int) → (int → int)))) → (int → ((list int) → (list int)))))) v) (λ (E (list int)) (λ (oT ((int → int) → ((int → (list int)) → ((list int) → (int → int))))) cons))) ((λ (s ((list int) → (int → ((list int) → (list int))))) nil) (λ (T (list int)) (λ (F int) (λ (v (list int)) nil))))) (λ (q (int → int)) (λ (I (int → (list int))) (λ (Zt (list int)) (λ (I int) 3))))) 1) nil)) #:iterations 3816 #:time 233559)) (new-average 2014-10-12T19:18:14 (#:model "stlc-sub-4" #:type search #:average 176321.0 #:stderr 57237.99999999999)) (heartbeat 2014-10-12T19:18:21 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:18:31 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:18:40 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (i (((list int) → int) → ((list int) → int))) cons) (λ (Xoo ((list int) → int)) Xoo)) ((λ (G int) G) 0)) (((λ (U (int → (int → int))) (λ (T ((int → (list int)) → (int → ((list int) → (list int))))) ((λ (T (list int)) T) nil))) +) (λ (A (int → (list int))) ((λ (C (int → (list int))) cons) A)))) #:iterations 387 #:time 25686)) (new-average 2014-10-12T19:18:40 (#:model "stlc-sub-4" #:type search #:average 126109.33333333334 #:stderr 60110.51780493808)) (heartbeat 2014-10-12T19:18:41 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:18:51 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:18:57 (#:amount 117457568 #:time 276)) (heartbeat 2014-10-12T19:19:01 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:19:11 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:19:21 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:19:31 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:19:42 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:19:44 (#:model "stlc-sub-4" #:type search #:counterexample ((((((λ (qk ((list int) → (list int))) (λ (C ((list int) → ((int → (list int)) → (int → int)))) (λ (C (((list int) → int) → ((list int) → int))) C))) tl) (λ (a (list int)) (λ (y (int → (list int))) (λ (a int) a)))) (λ (e ((list int) → int)) e)) ((λ (s (int → int)) hd) (λ (I int) I))) ((λ (q (list int)) nil) nil)) #:iterations 1030 #:time 64098)) (new-average 2014-10-12T19:19:44 (#:model "stlc-sub-4" #:type search #:average 110606.5 #:stderr 45243.50800667428)) (gc-major 2014-10-12T19:19:49 (#:amount 83563840 #:time 312)) (heartbeat 2014-10-12T19:19:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:20:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:20:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:20:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:20:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:20:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:20:52 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:20:53 (#:amount 121344936 #:time 258)) (heartbeat 2014-10-12T19:21:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:21:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:21:22 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:21:31 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (T (((list int) → int) → ((list int) → int))) (λ (U int) (λ (Q int) (λ (W ((list int) → int)) (λ (W (list int)) W))))) (λ (U ((list int) → int)) U)) 0) 0) (((λ (aV ((int → (int → int)) → ((list int) → int))) aV) (λ (L (int → (int → int))) hd)) +)) #:iterations 1676 #:time 108008)) (new-average 2014-10-12T19:21:31 (#:model "stlc-sub-4" #:type search #:average 110086.8 #:stderr 35049.32379005335)) (heartbeat 2014-10-12T19:21:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:21:42 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:21:48 (#:amount 83294464 #:time 287)) (heartbeat 2014-10-12T19:21:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:22:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:22:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:22:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:22:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:22:42 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:22:50 (#:amount 121042024 #:time 271)) (heartbeat 2014-10-12T19:22:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:23:02 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:23:08 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (R ((list int) → ((int → ((list int) → int)) → (int → ((int → int) → (int → int)))))) (R nil)) ((λ (u ((list int) → ((int → ((list int) → int)) → (int → ((int → int) → (int → int)))))) u) (λ (RC (list int)) (λ (E (int → ((list int) → int))) (λ (EO int) (λ (E (int → int)) E)))))) (λ (O int) hd)) ((λ (p ((list int) → (list int))) 0) tl)) (((λ (P (int → (int → int))) P) +) ((λ (Qj (int → (int → int))) 2) +))) #:iterations 1539 #:time 96139)) (new-average 2014-10-12T19:23:08 (#:model "stlc-sub-4" #:type search #:average 107762.16666666667 #:stderr 28711.913652021023)) (heartbeat 2014-10-12T19:23:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:23:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:23:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:23:42 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:23:45 (#:amount 85575472 #:time 292)) (heartbeat 2014-10-12T19:23:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:24:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:24:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:24:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:24:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:24:42 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:24:50 (#:amount 117019864 #:time 270)) (heartbeat 2014-10-12T19:24:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:25:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:25:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:25:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:25:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:25:42 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:25:45 (#:amount 83784096 #:time 308)) (heartbeat 2014-10-12T19:25:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:26:02 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:26:07 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (c (int → (int → int))) (λ (k ((list int) → ((list int) → (int → ((list int) → (list int)))))) (λ (k (int → (int → (list int)))) k))) (λ (iRp int) (λ (g int) g))) (λ (u (list int)) (λ (g (list int)) cons))) (((λ (W ((list int) → ((list int) → int))) (λ (tB (int → (int → (list int)))) tB)) (λ (G (list int)) hd)) (λ (pfS int) (λ (V int) nil)))) ((((λ (R ((list int) → (list int))) +) ((λ (g ((list int) → (list int))) (λ (A (list int)) A)) (cons 0))) ((λ (HU int) HU) 0)) ((λ (x int) ((λ (j int) j) x)) ((λ (N int) N) 0)))) #:iterations 2834 #:time 179812)) (new-average 2014-10-12T19:26:07 (#:model "stlc-sub-4" #:type search #:average 118055.0 #:stderr 26358.69835828122)) (heartbeat 2014-10-12T19:26:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:26:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:26:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:26:42 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:26:49 (#:amount 120628448 #:time 270)) (heartbeat 2014-10-12T19:26:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:27:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:27:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:27:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:27:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:27:42 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:27:43 (#:amount 84491376 #:time 283)) (heartbeat 2014-10-12T19:27:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:28:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:28:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:28:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:28:32 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:28:34 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (a (((list int) → (list int)) → ((int → int) → ((list int) → (((list int) → int) → ((list int) → int)))))) a) (((λ (O ((list int) → (list int))) (λ (Y (((list int) → (list int)) → ((int → int) → ((list int) → (((list int) → int) → ((list int) → int)))))) Y)) tl) (λ (i ((list int) → (list int))) (λ (e (int → int)) (λ (N (list int)) (λ (e ((list int) → int)) e)))))) tl) (+ 0)) ((λ (w (int → int)) nil) ((λ (s (int → int)) s) (λ (Ne int) Ne)))) #:iterations 2401 #:time 147071)) (new-average 2014-10-12T19:28:34 (#:model "stlc-sub-4" #:type search #:average 121682.0 #:stderr 23113.65101746461)) (gc-major 2014-10-12T19:28:41 (#:amount 118644808 #:time 266)) (heartbeat 2014-10-12T19:28:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:28:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:29:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:29:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:29:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:29:32 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:29:33 (#:amount 85116296 #:time 281)) (heartbeat 2014-10-12T19:29:42 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:29:44 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (mp (int → ((list int) → int))) (λ (w ((list int) → (list int))) (λ (w int) w))) (λ (l int) hd)) ((λ (jmZ ((list int) → (list int))) jmZ) ((λ (v int) (λ (A (list int)) A)) 4))) ((+ 0) ((λ (M (int → int)) 1) (λ (Nt int) 2)))) #:iterations 1136 #:time 70318)) (new-average 2014-10-12T19:29:44 (#:model "stlc-sub-4" #:type search #:average 115974.88888888889 #:stderr 21168.17868250757)) (heartbeat 2014-10-12T19:29:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:30:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:30:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:30:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:30:32 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:30:36 (#:amount 117674960 #:time 268)) (heartbeat 2014-10-12T19:30:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:30:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:31:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:31:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:31:22 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:31:30 (#:amount 85289360 #:time 285)) (heartbeat 2014-10-12T19:31:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:31:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:31:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:32:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:32:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:32:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:32:32 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:32:34 (#:amount 117280496 #:time 267)) (heartbeat 2014-10-12T19:32:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:32:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:33:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:33:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:33:22 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:33:28 (#:amount 86659936 #:time 281)) (heartbeat 2014-10-12T19:33:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:33:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:33:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:34:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:34:12 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:34:14 (#:model "stlc-sub-4" #:type search #:counterexample (((λ (B ((((list int) → int) → ((list int) → int)) → (int → ((list int) → (list int))))) B) ((λ (p ((list int) → int)) (λ (l (((list int) → int) → ((list int) → int))) (λ (P int) (λ (l (list int)) l)))) hd)) (((λ (Y (int → ((list int) → (list int)))) (λ (B ((list int) → int)) (λ (i ((list int) → int)) i))) cons) ((λ (Q (list int)) hd) ((λ (oC (list int)) oC) nil)))) #:iterations 4235 #:time 269364)) (new-average 2014-10-12T19:34:14 (#:model "stlc-sub-4" #:type search #:average 131313.8 #:stderr 24367.10128559042)) (heartbeat 2014-10-12T19:34:22 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:34:31 (#:amount 115444928 #:time 273)) (heartbeat 2014-10-12T19:34:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:34:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:34:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:35:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:35:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:35:22 (#:amount 86260528 #:time 277)) (heartbeat 2014-10-12T19:35:22 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:35:32 (#:model "stlc-sub-4" #:type search #:counterexample ((cons ((λ (B ((list int) → int)) 0) hd)) (((((λ (y int) (λ (b (int → ((list int) → int))) (λ (a (int → int)) (λ (b (list int)) b)))) 0) (λ (E int) hd)) (λ (DSTe int) DSTe)) ((λ (B (int → (int → int))) ((λ (Ac (list int)) Ac) nil)) +))) #:iterations 1296 #:time 78437)) (new-average 2014-10-12T19:35:32 (#:model "stlc-sub-4" #:type search #:average 126506.81818181818 #:stderr 22558.97007997975)) (heartbeat 2014-10-12T19:35:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:35:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:35:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:36:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:36:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:36:22 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:36:26 (#:amount 115877504 #:time 264)) (heartbeat 2014-10-12T19:36:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:36:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:36:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:37:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:37:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:37:20 (#:amount 84831024 #:time 291)) (heartbeat 2014-10-12T19:37:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:37:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:37:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:37:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:38:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:38:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:38:22 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:38:24 (#:amount 118590384 #:time 268)) (heartbeat 2014-10-12T19:38:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:38:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:38:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:39:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:39:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:39:18 (#:amount 85449600 #:time 290)) (heartbeat 2014-10-12T19:39:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:39:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:39:42 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:39:47 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (r ((list int) → ((int → ((list int) → (list int))) → (int → ((((list int) → (list int)) → (list int)) → (((list int) → (list int)) → (list int))))))) r) (λ (n (list int)) (λ (W (int → ((list int) → (list int)))) (λ (R int) (λ (W (((list int) → (list int)) → (list int))) W))))) nil) cons) ((+ 0) ((λ (C (list int)) 0) nil))) #:iterations 4024 #:time 255453)) (new-average 2014-10-12T19:39:47 (#:model "stlc-sub-4" #:type search #:average 137252.3333333333 #:stderr 23228.331230689528)) (heartbeat 2014-10-12T19:39:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:40:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:40:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:40:21 (#:amount 116920560 #:time 271)) (heartbeat 2014-10-12T19:40:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:40:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:40:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:40:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:41:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:41:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:41:16 (#:amount 84069136 #:time 296)) (heartbeat 2014-10-12T19:41:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:41:32 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:41:36 (#:model "stlc-sub-4" #:type search #:counterexample ((((((λ (Y (int → ((list int) → (list int)))) (λ (C ((list int) → (list int))) (λ (C (((list int) → int) → ((list int) → int))) C))) cons) tl) (λ (tR ((list int) → int)) hd)) ((λ (y (int → ((list int) → (list int)))) hd) cons)) (((λ (U (list int)) (λ (tE ((list int) → int)) nil)) ((λ (J (list int)) J) nil)) ((λ (O int) hd) 2))) #:iterations 1735 #:time 108881)) (new-average 2014-10-12T19:41:36 (#:model "stlc-sub-4" #:type search #:average 135069.92307692306 #:stderr 21478.12299893078)) (heartbeat 2014-10-12T19:41:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:41:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:42:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:42:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:42:20 (#:amount 120815072 #:time 266)) (heartbeat 2014-10-12T19:42:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:42:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:42:42 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:42:48 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (A ((int → int) → (((list int) → (list int)) → ((int → ((list int) → (list int))) → (int → ((list int) → (list int))))))) A) (λ (Dz (int → int)) (λ (W ((list int) → (list int))) (λ (W (int → ((list int) → (list int)))) W)))) (λ (z int) z)) tl) cons) (hd ((cons ((λ (n int) n) 0)) nil))) (((λ (k (int → int)) (λ (i (list int)) i)) (λ (uqD int) uqD)) ((λ (l (int → ((list int) → (list int)))) nil) cons))) #:iterations 1156 #:time 72289)) (new-average 2014-10-12T19:42:48 (#:model "stlc-sub-4" #:type search #:average 130585.57142857142 #:stderr 20384.253282815123)) (heartbeat 2014-10-12T19:42:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:43:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:43:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:43:16 (#:amount 84892576 #:time 290)) (heartbeat 2014-10-12T19:43:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:43:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:43:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:43:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:44:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:44:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:44:19 (#:amount 118510528 #:time 221)) (heartbeat 2014-10-12T19:44:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:44:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:44:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:44:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:45:02 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:45:11 (#:amount 85388000 #:time 284)) (heartbeat 2014-10-12T19:45:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:45:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:45:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:45:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:45:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:46:02 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:46:12 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:46:14 (#:amount 117289960 #:time 265)) (heartbeat 2014-10-12T19:46:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:46:32 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:46:42 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:46:52 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:47:02 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:47:08 (#:amount 84299912 #:time 297)) (heartbeat 2014-10-12T19:47:12 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:47:22 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:47:33 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:47:42 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (x ((((list int) → (list int)) → ((list int) → (list int))) → (((list int) → (list int)) → ((list int) → (list int))))) x) ((λ (X (int → int)) (λ (F (((list int) → (list int)) → ((list int) → (list int)))) F)) (λ (D int) D))) (λ (H ((list int) → (list int))) H)) (cons 2)) ((((((λ (G ((list int) → (list int))) (λ (I (int → (int → int))) (λ (I (((list int) → (list int)) → ((list int) → (list int)))) I))) tl) +) (λ (yL ((list int) → (list int))) (λ (T (list int)) T))) (λ (n (list int)) n)) ((λ (p (list int)) p) ((λ (l (int → ((list int) → (list int)))) nil) (λ (rikO int) tl))))) #:iterations 4670 #:time 293877)) (new-average 2014-10-12T19:47:42 (#:model "stlc-sub-4" #:type search #:average 141471.66666666666 #:stderr 21877.442275346337)) (heartbeat 2014-10-12T19:47:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:47:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:48:03 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:48:12 (#:amount 120436200 #:time 263)) (heartbeat 2014-10-12T19:48:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:48:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:48:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:48:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:48:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:49:03 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:49:05 (#:amount 85922464 #:time 240)) (heartbeat 2014-10-12T19:49:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:49:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:49:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:49:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:49:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:50:03 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:50:07 (#:amount 116960848 #:time 269)) (heartbeat 2014-10-12T19:50:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:50:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:50:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:50:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:50:53 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:50:54 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (dd (((list int) → (list int)) → ((int → ((list int) → (list int))) → ((((((list int) → int) → ((list int) → int)) → (int → int)) → ((((list int) → int) → ((list int) → int)) → (int → int))) → (((((list int) → int) → ((list int) → int)) → (int → int)) → ((((list int) → int) → ((list int) → int)) → (int → int))))))) dd) (λ (hO ((list int) → (list int))) (λ (c (int → ((list int) → (list int)))) (λ (s (((((list int) → int) → ((list int) → int)) → (int → int)) → ((((list int) → int) → ((list int) → int)) → (int → int)))) s)))) (cons 1)) cons) (λ (F ((((list int) → int) → ((list int) → int)) → (int → int))) F)) ((λ (mmv ((list int) → (list int))) (λ (i (((list int) → int) → ((list int) → int))) (λ (i int) i))) tl)) (((λ (Z ((list int) → ((list int) → (list int)))) (λ (E ((list int) → (list int))) (λ (D ((list int) → int)) D))) (λ (ph (list int)) tl)) (cons 0))) #:iterations 3035 #:time 192569)) (new-average 2014-10-12T19:50:54 (#:model "stlc-sub-4" #:type search #:average 144665.25 #:stderr 20712.16176438777)) (gc-major 2014-10-12T19:51:01 (#:amount 85524392 #:time 283)) (heartbeat 2014-10-12T19:51:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:51:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:51:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:51:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:51:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:51:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:52:03 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:52:05 (#:amount 117926432 #:time 260)) (heartbeat 2014-10-12T19:52:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:52:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:52:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:52:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:52:53 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:52:57 (#:amount 83740576 #:time 253)) (counterexample 2014-10-12T19:52:59 (#:model "stlc-sub-4" #:type search #:counterexample (((λ (V (int → ((list int) → (list int)))) (λ (v int) (λ (s int) (λ (v (list int)) v)))) ((λ (A (int → ((list int) → (list int)))) cons) cons)) (((((λ (F (((list int) → (list int)) → (int → (int → int)))) F) (λ (h ((list int) → (list int))) +)) tl) 2) ((λ (yK int) yK) 0))) #:iterations 1997 #:time 125001)) (new-average 2014-10-12T19:52:59 (#:model "stlc-sub-4" #:type search #:average 143508.5294117647 #:stderr 19490.043788831543)) (heartbeat 2014-10-12T19:53:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:53:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:53:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:53:33 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:53:33 (#:model "stlc-sub-4" #:type search #:counterexample ((((((λ (I ((list int) → int)) (λ (M (list int)) (λ (M (((list int) → (list int)) → ((list int) → (list int)))) M))) hd) nil) (λ (v ((list int) → (list int))) tl)) tl) ((λ (L int) nil) 1)) #:iterations 522 #:time 34131)) (new-average 2014-10-12T19:53:33 (#:model "stlc-sub-4" #:type search #:average 137432.0 #:stderr 19354.047358377702)) (heartbeat 2014-10-12T19:53:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:53:53 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:54:02 (#:amount 120924032 #:time 268)) (heartbeat 2014-10-12T19:54:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:54:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:54:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:54:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:54:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:54:53 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:54:53 (#:amount 83768096 #:time 290)) (heartbeat 2014-10-12T19:55:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:55:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:55:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:55:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:55:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:55:53 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:55:58 (#:amount 121164336 #:time 265)) (heartbeat 2014-10-12T19:56:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:56:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:56:23 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:56:25 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (r ((list int) → int)) (λ (v ((list int) → int)) (λ (v (((list int) → (list int)) → ((list int) → ((list int) → int)))) v))) (λ (h (list int)) 1)) hd) (((λ (N ((list int) → (list int))) (λ (z ((list int) → int)) (λ (bWc ((list int) → (list int))) (λ (z (list int)) hd)))) (λ (K (list int)) K)) hd)) (cons 1)) (tl nil)) (tl ((cons ((λ (U ((list int) → int)) 0) hd)) nil))) #:iterations 2687 #:time 171785)) (new-average 2014-10-12T19:56:25 (#:model "stlc-sub-4" #:type search #:average 139240.05263157896 #:stderr 18396.16316919915)) (counterexample 2014-10-12T19:56:31 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (ur ((list int) → int)) (λ (m ((list int) → (list int))) (λ (JB (int → int)) (λ (L (int → (list int))) (λ (V (list int)) (λ (m ((list int) → int)) m)))))) hd) (cons 3)) (((λ (n ((int → (list int)) → ((list int) → (list int)))) (λ (d int) (λ (w int) w))) (λ (i (int → (list int))) tl)) (((((λ (Te ((list int) → (list int))) (λ (g ((((list int) → int) → (list int)) → (int → int))) +)) (λ (w (list int)) w)) (λ (pR (((list int) → int) → (list int))) (λ (b int) b))) ((λ (a int) a) 0)) 0))) #:iterations 141 #:time 6406)) (new-average 2014-10-12T19:56:31 (#:model "stlc-sub-4" #:type search #:average 132598.35 #:stderr 18673.220163092978)) (heartbeat 2014-10-12T19:56:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:56:43 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:56:52 (#:amount 84532504 #:time 293)) (heartbeat 2014-10-12T19:56:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:57:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:57:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:57:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:57:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:57:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:57:53 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:57:55 (#:amount 119962336 #:time 268)) (heartbeat 2014-10-12T19:58:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:58:13 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T19:58:17 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (AG ((list int) → (list int))) (λ (c (((list int) → int) → int)) (λ (z (int → int)) (λ (c (int → int)) c)))) tl) ((λ (xXE (int → ((list int) → (int → ((int → (list int)) → (int → (int → (int → int)))))))) (λ (T ((list int) → int)) 5)) (λ (A int) (λ (d (list int)) (λ (eS int) (λ (x (int → (list int))) (λ (Ml int) +))))))) (+ ((λ (p int) p) 1))) #:iterations 1699 #:time 105451)) (new-average 2014-10-12T19:58:17 (#:model "stlc-sub-4" #:type search #:average 131305.61904761905 #:stderr 17808.756665709658)) (heartbeat 2014-10-12T19:58:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:58:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:58:43 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:58:51 (#:amount 85855440 #:time 282)) (heartbeat 2014-10-12T19:58:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:59:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:59:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:59:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:59:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:59:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T19:59:53 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T19:59:54 (#:amount 117267800 #:time 259)) (heartbeat 2014-10-12T20:00:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:00:13 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:00:17 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (i ((((((int → (list int)) → int) → ((int → (list int)) → int)) → (((list int) → int) → ((list int) → int))) → ((((int → (list int)) → int) → ((int → (list int)) → int)) → (((list int) → int) → ((list int) → int)))) → (((((int → (list int)) → int) → ((int → (list int)) → int)) → (((list int) → int) → ((list int) → int))) → ((((int → (list int)) → int) → ((int → (list int)) → int)) → (((list int) → int) → ((list int) → int)))))) i) (λ (q (((((int → (list int)) → int) → ((int → (list int)) → int)) → (((list int) → int) → ((list int) → int))) → ((((int → (list int)) → int) → ((int → (list int)) → int)) → (((list int) → int) → ((list int) → int))))) q)) (λ (v ((((int → (list int)) → int) → ((int → (list int)) → int)) → (((list int) → int) → ((list int) → int)))) v)) (((λ (M ((int → (int → int)) → ((((int → (list int)) → int) → ((int → (list int)) → int)) → (((list int) → int) → ((list int) → int))))) M) (λ (X (int → (int → int))) (λ (w (((int → (list int)) → int) → ((int → (list int)) → int))) (λ (w ((list int) → int)) w)))) +)) (λ (Mt ((int → (list int)) → int)) Mt)) hd) ((cons 4) ((λ (m (int → int)) nil) (λ (h int) h)))) #:iterations 1843 #:time 120360)) (new-average 2014-10-12T20:00:17 (#:model "stlc-sub-4" #:type search #:average 130808.04545454546 #:stderr 16987.272010833036)) (heartbeat 2014-10-12T20:00:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:00:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:00:43 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:00:48 (#:amount 84109784 #:time 299)) (heartbeat 2014-10-12T20:00:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:01:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:01:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:01:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:01:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:01:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:01:53 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:01:57 (#:amount 120657504 #:time 267)) (heartbeat 2014-10-12T20:02:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:02:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:02:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:02:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:02:43 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:02:50 (#:amount 84944840 #:time 244)) (heartbeat 2014-10-12T20:02:53 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:02:56 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (v ((list int) → (list int))) ((λ (q ((((list int) → int) → (list int)) → (((list int) → int) → (list int)))) (λ (q (int → (int → int))) q)) (λ (o (((list int) → int) → (list int))) o))) (λ (M (list int)) nil)) +) ((λ (W (int → (int → ((list int) → (list int))))) 1) (λ (k int) cons))) ((λ (iY (int → int)) 3) (λ (yo int) yo))) #:iterations 2480 #:time 158175)) (new-average 2014-10-12T20:02:56 (#:model "stlc-sub-4" #:type search #:average 131997.91304347827 #:stderr 16275.453202789104)) (heartbeat 2014-10-12T20:03:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:03:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:03:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:03:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:03:43 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:03:43 (#:model "stlc-sub-4" #:type search #:counterexample (((λ (W (int → int)) W) (+ ((λ (C int) C) 3))) (((((λ (k ((list int) → (((list int) → int) → ((list int) → int)))) k) ((λ (K ((int → int) → int)) (λ (b (list int)) (λ (b ((list int) → int)) b))) (λ (k (int → int)) 2))) nil) hd) ((λ (F (list int)) F) ((λ (m (list int)) m) nil)))) #:iterations 803 #:time 47906)) (new-average 2014-10-12T20:03:43 (#:model "stlc-sub-4" #:type search #:average 128494.08333333334 #:stderr 15971.631147575094)) (gc-major 2014-10-12T20:03:52 (#:amount 118442448 #:time 265)) (heartbeat 2014-10-12T20:03:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:04:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:04:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:04:23 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:04:24 (#:model "stlc-sub-4" #:type search #:counterexample ((((((λ (e ((int → (int → ((int → int) → (int → (int → ((list int) → (list int))))))) → ((int → ((list int) → (list int))) → (((list int) → ((int → int) → ((list int) → int))) → ((list int) → ((int → int) → ((list int) → int))))))) e) ((λ (O ((int → (int → ((int → int) → (int → (int → ((list int) → (list int))))))) → ((int → ((list int) → (list int))) → (((list int) → ((int → int) → ((list int) → int))) → ((list int) → ((int → int) → ((list int) → int))))))) O) (λ (D (int → (int → ((int → int) → (int → (int → ((list int) → (list int)))))))) (λ (J (int → ((list int) → (list int)))) (λ (J ((list int) → ((int → int) → ((list int) → int)))) J))))) (λ (k int) (λ (s int) (λ (z (int → int)) (λ (q int) (λ (E int) tl)))))) cons) (λ (L (list int)) (λ (L (int → int)) hd))) ((cons 0) ((λ (t (list int)) t) nil))) #:iterations 681 #:time 40072)) (new-average 2014-10-12T20:04:24 (#:model "stlc-sub-4" #:type search #:average 124957.20000000001 #:stderr 15722.43954056325)) (heartbeat 2014-10-12T20:04:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:04:43 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:04:44 (#:amount 84445056 #:time 293)) (counterexample 2014-10-12T20:04:47 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (h (int → (int → int))) (λ (P ((int → (list int)) → (int → (list int)))) (λ (LndX (int → int)) (λ (P int) P)))) +) (λ (c (int → (list int))) c)) (λ (i int) i)) ((+ 0) 3)) #:iterations 388 #:time 23164)) (new-average 2014-10-12T20:04:47 (#:model "stlc-sub-4" #:type search #:average 121042.07692307694 #:stderr 15604.752023950721)) (heartbeat 2014-10-12T20:04:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:05:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:05:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:05:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:05:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:05:43 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:05:45 (#:amount 119871608 #:time 261)) (heartbeat 2014-10-12T20:05:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:06:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:06:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:06:23 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:06:32 (#:amount 87699776 #:time 294)) (heartbeat 2014-10-12T20:06:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:06:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:06:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:07:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:07:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:07:23 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:07:26 (#:amount 113013280 #:time 227)) (counterexample 2014-10-12T20:07:30 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (n ((int → ((list int) → ((list int) → ((list int) → ((int → int) → (int → int)))))) → (int → ((list int) → ((list int) → ((list int) → ((int → int) → (int → int)))))))) n) (((λ (D (int → (int → int))) (λ (v ((list int) → (list int))) (λ (v (int → ((list int) → ((list int) → ((list int) → ((int → int) → (int → int))))))) v))) +) (cons 2))) (λ (v int) (λ (M (list int)) (λ (p (list int)) (λ (I (list int)) (λ (h (int → int)) h)))))) ((+ 0) 1)) ((cons 1) ((cons 0) ((λ (T (list int)) T) nil)))) #:iterations 2877 #:time 163188)) (new-average 2014-10-12T20:07:30 (#:model "stlc-sub-4" #:type search #:average 122603.03703703705 #:stderr 15096.596683081529)) (heartbeat 2014-10-12T20:07:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:07:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:07:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:08:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:08:13 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:08:16 (#:amount 83846872 #:time 255)) (heartbeat 2014-10-12T20:08:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:08:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:08:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:08:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:09:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:09:13 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:09:15 (#:amount 121135904 #:time 268)) (heartbeat 2014-10-12T20:09:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:09:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:09:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:09:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:10:03 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:10:09 (#:amount 84614440 #:time 292)) (heartbeat 2014-10-12T20:10:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:10:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:10:33 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:10:41 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (l (int → (int → int))) (λ (y ((list int) → (list int))) (λ (y (((list int) → int) → (int → (int → int)))) y))) +) tl) (((λ (tr (((list int) → (list int)) → (int → ((list int) → (list int))))) (λ (j (((list int) → int) → (int → (int → int)))) j)) (λ (F ((list int) → (list int))) cons)) ((λ (a int) (λ (d ((list int) → int)) +)) 1))) (λ (M (list int)) 0)) (hd nil)) (((λ (h ((list int) → int)) h) hd) (((λ (J ((list int) → (list int))) J) tl) nil))) #:iterations 3049 #:time 190943)) (new-average 2014-10-12T20:10:41 (#:model "stlc-sub-4" #:type search #:average 125043.75000000001 #:stderr 14750.77025857396)) (heartbeat 2014-10-12T20:10:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:10:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:11:03 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:11:13 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:11:15 (#:amount 119620128 #:time 259)) (heartbeat 2014-10-12T20:11:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:11:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:11:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:11:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:12:03 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:12:06 (#:amount 85289032 #:time 270)) (heartbeat 2014-10-12T20:12:13 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:12:22 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (n (((list int) → (list int)) → int)) (λ (uj ((list int) → int)) (λ (y (int → int)) y))) (λ (QK ((list int) → (list int))) 1)) ((λ (A (int → ((int → (list int)) → (list int)))) hd) ((λ (I (((int → int) → int) → ((list int) → (list int)))) (λ (ac int) (λ (j (int → (list int))) nil))) (λ (x ((int → int) → int)) tl)))) ((((λ (z ((list int) → ((list int) → (list int)))) (λ (i (((list int) → (list int)) → ((int → int) → (int → int)))) (λ (M (int → int)) (λ (i int) i)))) (λ (t (list int)) tl)) (λ (gh ((list int) → (list int))) (λ (v (int → int)) v))) (+ ((λ (QX int) QX) ((λ (Y (int → int)) 5) (λ (R int) R)))))) #:iterations 1643 #:time 101169)) (new-average 2014-10-12T20:12:22 (#:model "stlc-sub-4" #:type search #:average 124220.48275862071 #:stderr 14256.826950918126)) (heartbeat 2014-10-12T20:12:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:12:33 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:12:43 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:12:53 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:13:03 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:13:05 (#:amount 118395408 #:time 265)) (heartbeat 2014-10-12T20:13:13 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:13:23 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:13:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:13:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:13:54 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:13:54 (#:amount 85992032 #:time 270)) (heartbeat 2014-10-12T20:14:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:14:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:14:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:14:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:14:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:14:54 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:14:58 (#:amount 116825344 #:time 258)) (heartbeat 2014-10-12T20:15:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:15:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:15:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:15:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:15:44 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:15:48 (#:amount 85342480 #:time 234)) (heartbeat 2014-10-12T20:15:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:16:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:16:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:16:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:16:34 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:16:43 (#:amount 118170752 #:time 227)) (heartbeat 2014-10-12T20:16:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:16:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:17:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:17:14 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:17:17 (#:model "stlc-sub-4" #:type search #:counterexample (((λ (C (list int)) (λ (P ((list int) → ((list int) → int))) (λ (P int) P))) ((cons 0) nil)) (((λ (Z int) (λ (Q ((int → int) → (int → ((list int) → (list int))))) (λ (D (list int)) hd))) 0) (λ (P (int → int)) cons))) #:iterations 5032 #:time 295487)) (new-average 2014-10-12T20:17:17 (#:model "stlc-sub-4" #:type search #:average 129929.36666666668 #:stderr 14909.661158794881)) (heartbeat 2014-10-12T20:17:24 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:17:34 (#:amount 91065264 #:time 236)) (heartbeat 2014-10-12T20:17:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:17:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:17:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:18:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:18:14 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:18:15 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (X (((list int) → (list int)) → ((int → int) → (int → int)))) X) ((λ (e (int → (int → int))) (λ (b ((list int) → (list int))) (λ (b (int → int)) b))) +)) (cons 1)) (((λ (G (int → (int → int))) G) +) ((λ (u (int → int)) 1) (λ (v int) v)))) #:iterations 1088 #:time 58105)) (new-average 2014-10-12T20:18:15 (#:model "stlc-sub-4" #:type search #:average 127612.45161290324 #:stderr 14605.625116757796)) (heartbeat 2014-10-12T20:18:24 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:18:25 (#:amount 107228720 #:time 256)) (heartbeat 2014-10-12T20:18:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:18:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:18:54 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:19:04 (#:model "stlc-sub-4" #:type search #:counterexample ((((((λ (u (int → (int → int))) (λ (Y ((list int) → int)) (λ (Y (((int → (int → int)) → ((list int) → ((list int) → (list int)))) → ((int → (int → int)) → ((list int) → ((list int) → (list int)))))) Y))) +) hd) (λ (W ((int → (int → int)) → ((list int) → ((list int) → (list int))))) W)) (λ (O (int → (int → int))) (λ (p (list int)) (λ (X (list int)) X)))) ((λ (j ((list int) → (list int))) +) (cons (hd nil)))) #:iterations 764 #:time 48780)) (new-average 2014-10-12T20:19:04 (#:model "stlc-sub-4" #:type search #:average 125148.93750000001 #:stderr 14354.804736395243)) (heartbeat 2014-10-12T20:19:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:19:14 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:19:17 (#:amount 85341416 #:time 278)) (heartbeat 2014-10-12T20:19:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:19:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:19:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:19:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:20:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:20:14 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:20:20 (#:amount 118031080 #:time 265)) (heartbeat 2014-10-12T20:20:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:20:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:20:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:20:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:21:04 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:21:11 (#:amount 84210256 #:time 256)) (heartbeat 2014-10-12T20:21:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:21:24 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:21:29 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (y ((((list int) → (list int)) → (list int)) → (int → int))) (λ (L ((list int) → (list int))) (λ (L ((list int) → (int → (int → (int → int))))) L))) (λ (n (((list int) → (list int)) → (list int))) (λ (D int) D))) (cons ((λ (Sc int) Sc) 2))) ((λ (IZX ((list int) → (int → (int → (int → int))))) IZX) ((λ (a ((list int) → int)) (λ (y (list int)) (λ (H int) +))) hd))) #:iterations 2370 #:time 144992)) (new-average 2014-10-12T20:21:29 (#:model "stlc-sub-4" #:type search #:average 125750.24242424243 #:stderr 13926.000013942086)) (heartbeat 2014-10-12T20:21:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:21:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:21:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:22:04 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:22:05 (#:amount 120651032 #:time 260)) (heartbeat 2014-10-12T20:22:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:22:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:22:34 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:22:40 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (A ((list int) → (list int))) (λ (SS (int → (((list int) → (list int)) → ((((list int) → (list int)) → ((list int) → (list int))) → ((list int) → (list int)))))) SS)) tl) ((λ (yi (int → (((list int) → (list int)) → ((((list int) → (list int)) → ((list int) → (list int))) → ((list int) → (list int)))))) yi) (λ (WU int) (λ (i ((list int) → (list int))) (λ (K (((list int) → (list int)) → ((list int) → (list int)))) (λ (i (list int)) i)))))) ((+ 0) 1)) tl) ((λ (r ((int → (list int)) → (int → ((list int) → (list int))))) (λ (h ((list int) → (list int))) tl)) (λ (FG (int → (list int))) cons))) (((((λ (q (((list int) → (int → int)) → (int → ((list int) → (list int))))) q) (λ (w ((list int) → (int → int))) cons)) (λ (R (list int)) (λ (PZEl int) PZEl))) 0) nil)) #:iterations 1358 #:time 70457)) (new-average 2014-10-12T20:22:40 (#:model "stlc-sub-4" #:type search #:average 124123.9705882353 #:stderr 13607.732541487254)) (heartbeat 2014-10-12T20:22:44 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:22:50 (#:amount 86835416 #:time 280)) (heartbeat 2014-10-12T20:22:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:23:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:23:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:23:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:23:34 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:23:39 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (p (list int)) (λ (E int) (λ (E (int → (((list int) → (list int)) → ((list int) → ((list int) → int))))) E))) nil) 2) ((λ (D (int → (((list int) → (list int)) → ((list int) → ((list int) → int))))) D) (λ (r int) (λ (S ((list int) → (list int))) (λ (Y (list int)) hd))))) 0) (cons 0)) ((cons 2) (tl nil))) #:iterations 1012 #:time 59122)) (new-average 2014-10-12T20:23:39 (#:model "stlc-sub-4" #:type search #:average 122266.77142857143 #:stderr 13343.103416623086)) (heartbeat 2014-10-12T20:23:44 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:23:45 (#:amount 115024640 #:time 263)) (heartbeat 2014-10-12T20:23:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:24:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:24:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:24:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:24:34 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:24:36 (#:amount 84291616 #:time 261)) (heartbeat 2014-10-12T20:24:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:24:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:25:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:25:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:25:24 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:25:28 (#:amount 120342992 #:time 262)) (heartbeat 2014-10-12T20:25:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:25:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:25:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:26:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:26:14 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:26:15 (#:amount 85435184 #:time 241)) (heartbeat 2014-10-12T20:26:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:26:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:26:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:26:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:27:04 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:27:07 (#:amount 118252496 #:time 230)) (heartbeat 2014-10-12T20:27:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:27:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:27:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:27:44 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:27:54 (#:amount 85405120 #:time 260)) (heartbeat 2014-10-12T20:27:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:28:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:28:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:28:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:28:34 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:28:44 (#:amount 118406664 #:time 220)) (heartbeat 2014-10-12T20:28:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:28:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:29:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:29:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:29:24 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:29:25 (#:amount 86851128 #:time 276)) (heartbeat 2014-10-12T20:29:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:29:44 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:29:45 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (M (int → ((list int) → (list int)))) (λ (P ((list int) → ((list int) → int))) (λ (P ((((int → int) → int) → ((int → int) → (int → int))) → (((int → int) → int) → ((int → int) → (int → int))))) P))) cons) (λ (Y (list int)) hd)) ((λ (V ((((int → int) → int) → ((int → int) → (int → int))) → (((int → int) → int) → ((int → int) → (int → int))))) V) (λ (c (((int → int) → int) → ((int → int) → (int → int)))) c))) (((λ (yN (int → (int → int))) (λ (k (int → int)) (λ (E ((int → int) → int)) (λ (k (int → int)) k)))) +) ((((λ (jpx (((int → int) → int) → ((list int) → ((list int) → (list int))))) (λ (v (((int → int) → (int → ((list int) → ((list int) → (list int))))) → (int → int))) v)) (λ (i ((int → int) → int)) (λ (k (list int)) tl))) (λ (D ((int → int) → (int → ((list int) → ((list int) → (list int)))))) (λ (b int) b))) (λ (W (int → int)) (λ (L int) (λ (C (list int)) tl)))))) #:iterations 6866 #:time 365577)) (new-average 2014-10-12T20:29:45 (#:model "stlc-sub-4" #:type search #:average 129025.38888888889 #:stderr 14622.800554313615)) (heartbeat 2014-10-12T20:29:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:30:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:30:14 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:30:17 (#:amount 115672896 #:time 222)) (heartbeat 2014-10-12T20:30:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:30:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:30:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:30:54 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:31:03 (#:amount 85248840 #:time 239)) (heartbeat 2014-10-12T20:31:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:31:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:31:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:31:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:31:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:31:54 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:31:59 (#:amount 118704360 #:time 260)) (heartbeat 2014-10-12T20:32:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:32:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:32:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:32:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:32:44 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:32:49 (#:amount 85657872 #:time 237)) (heartbeat 2014-10-12T20:32:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:33:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:33:14 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:33:18 (#:model "stlc-sub-4" #:type search #:counterexample ((((((λ (V (int → ((list int) → (list int)))) (λ (C (list int)) (λ (C (int → ((list int) → (list int)))) C))) cons) nil) cons) ((λ (L int) L) 0)) (((λ (F (int → int)) tl) (+ 0)) (tl (tl nil)))) #:iterations 4029 #:time 213384)) (new-average 2014-10-12T20:33:18 (#:model "stlc-sub-4" #:type search #:average 131305.35135135136 #:stderr 14403.692120999423)) (heartbeat 2014-10-12T20:33:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:33:34 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:33:38 (#:amount 117854816 #:time 227)) (heartbeat 2014-10-12T20:33:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:33:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:34:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:34:14 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:34:23 (#:amount 84201880 #:time 273)) (heartbeat 2014-10-12T20:34:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:34:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:34:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:34:54 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:35:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:35:14 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:35:18 (#:amount 120881680 #:time 258)) (heartbeat 2014-10-12T20:35:24 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:35:34 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:35:44 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:35:54 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:36:03 (#:amount 84922336 #:time 253)) (heartbeat 2014-10-12T20:36:04 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:36:14 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:36:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:36:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:36:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:36:55 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:37:04 (#:amount 119400000 #:time 232)) (heartbeat 2014-10-12T20:37:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:37:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:37:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:37:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:37:45 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:37:50 (#:amount 86943744 #:time 278)) (heartbeat 2014-10-12T20:37:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:38:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:38:15 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:38:21 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (x ((int → int) → ((int → int) → (((list int) → (list int)) → ((list int) → (list int)))))) x) (λ (um (int → int)) (λ (A (int → int)) (λ (A ((list int) → (list int))) A)))) (+ 0)) (+ ((λ (T ((list int) → (list int))) 0) tl))) #:iterations 5572 #:time 302625)) (new-average 2014-10-12T20:38:21 (#:model "stlc-sub-4" #:type search #:average 135813.76315789475 #:stderr 14726.603217571488)) (heartbeat 2014-10-12T20:38:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:38:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:38:44 (#:amount 115290656 #:time 258)) (heartbeat 2014-10-12T20:38:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:38:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:39:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:39:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:39:25 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:39:29 (#:amount 84263856 #:time 254)) (heartbeat 2014-10-12T20:39:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:39:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:39:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:40:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:40:15 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:40:23 (#:amount 120536032 #:time 231)) (heartbeat 2014-10-12T20:40:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:40:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:40:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:40:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:41:05 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:41:06 (#:amount 86324488 #:time 249)) (counterexample 2014-10-12T20:41:09 (#:model "stlc-sub-4" #:type search #:counterexample (((((((λ (nx ((((list int) → int) → (((list int) → (list int)) → (int → ((list int) → (list int))))) → (((list int) → (int → ((list int) → (list int)))) → ((int → ((list int) → (list int))) → (((list int) → ((list int) → int)) → ((list int) → ((list int) → int))))))) nx) (λ (G (((list int) → int) → (((list int) → (list int)) → (int → ((list int) → (list int)))))) (λ (r ((list int) → (int → ((list int) → (list int))))) (λ (C (int → ((list int) → (list int)))) (λ (r ((list int) → ((list int) → int))) r))))) (λ (TV ((list int) → int)) (λ (b ((list int) → (list int))) cons))) ((λ (T (int → int)) (λ (t (list int)) cons)) (+ 0))) cons) ((λ (H ((list int) → int)) (λ (mF (list int)) hd)) hd)) ((cons 1) ((cons ((λ (n (int → (int → int))) 2) +)) nil))) #:iterations 3157 #:time 168334)) (new-average 2014-10-12T20:41:09 (#:model "stlc-sub-4" #:type search #:average 136647.58974358975 #:stderr 14368.243625470057)) (heartbeat 2014-10-12T20:41:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:41:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:41:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:41:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:41:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:42:05 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:42:07 (#:amount 116549984 #:time 265)) (heartbeat 2014-10-12T20:42:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:42:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:42:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:42:45 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:42:49 (#:amount 86335328 #:time 276)) (heartbeat 2014-10-12T20:42:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:43:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:43:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:43:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:43:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:43:45 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:43:52 (#:amount 116473400 #:time 269)) (heartbeat 2014-10-12T20:43:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:44:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:44:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:44:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:44:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:44:45 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:44:49 (#:amount 84287728 #:time 257)) (heartbeat 2014-10-12T20:44:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:45:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:45:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:45:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:45:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:45:38 (#:amount 121477720 #:time 224)) (counterexample 2014-10-12T20:45:42 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (N (int → ((list int) → (list int)))) (λ (p (int → ((list int) → (list int)))) (λ (n (list int)) (λ (p (list int)) p)))) (λ (r int) (λ (K (list int)) K))) cons) nil) ((λ (A (list int)) A) ((cons ((λ (h ((list int) → (list int))) 1) tl)) nil))) #:iterations 4800 #:time 272241)) (new-average 2014-10-12T20:45:42 (#:model "stlc-sub-4" #:type search #:average 140037.42500000002 #:stderr 14408.854454897511)) (heartbeat 2014-10-12T20:45:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:45:55 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:46:02 (#:model "stlc-sub-4" #:type search #:counterexample (((λ (Z ((list int) → (list int))) (λ (p int) (λ (p (list int)) p))) ((λ (E ((list int) → (list int))) E) tl)) ((+ 3) 0)) #:iterations 404 #:time 19945)) (new-average 2014-10-12T20:46:02 (#:model "stlc-sub-4" #:type search #:average 137108.34146341466 #:stderr 14355.03576664716)) (heartbeat 2014-10-12T20:46:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:46:15 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:46:21 (#:amount 84518216 #:time 264)) (heartbeat 2014-10-12T20:46:25 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:46:34 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (j ((int → int) → (int → int))) (λ (p ((list int) → ((list int) → int))) (λ (p ((int → ((list int) → (list int))) → (int → ((list int) → (list int))))) p))) (λ (x (int → int)) x)) (λ (y (list int)) hd)) (λ (VG (int → ((list int) → (list int)))) cons)) ((((λ (H ((int → int) → ((int → (list int)) → (int → (list int))))) (λ (i ((list int) → (list int))) (λ (d int) (λ (x int) tl)))) (λ (oN (int → int)) (λ (k (int → (list int))) k))) ((λ (x (int → int)) tl) (λ (Lt int) Lt))) 3)) #:iterations 673 #:time 32660)) (new-average 2014-10-12T20:46:34 (#:model "stlc-sub-4" #:type search #:average 134621.4761904762 #:stderr 14228.100153996193)) (heartbeat 2014-10-12T20:46:35 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:46:40 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (y ((int → int) → (int → int))) (λ (nj (((list int) → (list int)) → ((list int) → (list int)))) (λ (T ((list int) → (list int))) (λ (V (list int)) (λ (p (((list int) → (list int)) → (list int))) (λ (F (list int)) (λ (g (list int)) (λ (v (int → int)) (λ (g int) (λ (V int) V)))))))))) (λ (M (int → int)) M)) ((λ (E (((int → (list int)) → int) → (list int))) (λ (t ((list int) → (list int))) t)) (λ (F ((int → (list int)) → int)) nil))) tl) ((cons 0) ((λ (Y (list int)) Y) nil))) #:iterations 118 #:time 5435)) (new-average 2014-10-12T20:46:40 (#:model "stlc-sub-4" #:type search #:average 131617.13953488375 #:stderr 14214.398088266631)) (heartbeat 2014-10-12T20:46:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:46:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:47:05 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:47:08 (#:amount 120021168 #:time 267)) (heartbeat 2014-10-12T20:47:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:47:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:47:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:47:45 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:47:52 (#:amount 85047360 #:time 240)) (heartbeat 2014-10-12T20:47:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:48:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:48:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:48:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:48:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:48:42 (#:amount 118920640 #:time 261)) (heartbeat 2014-10-12T20:48:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:48:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:49:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:49:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:49:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:49:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:49:37 (#:amount 83947088 #:time 292)) (counterexample 2014-10-12T20:49:44 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (X ((int → (int → int)) → (((list int) → (list int)) → ((list int) → (list int))))) X) (λ (T (int → (int → int))) (λ (R ((list int) → (list int))) (λ (R (list int)) R)))) ((λ (n (int → (int → int))) n) +)) (cons 0)) #:iterations 3295 #:time 184060)) (new-average 2014-10-12T20:49:44 (#:model "stlc-sub-4" #:type search #:average 132809.02272727276 #:stderr 13938.638669704287)) (heartbeat 2014-10-12T20:49:45 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:49:51 (#:model "stlc-sub-4" #:type search #:counterexample ((((((λ (FT (((list int) → (list int)) → (((list int) → int) → (((list int) → int) → ((list int) → int))))) FT) ((λ (N ((list int) → (list int))) (λ (d ((list int) → (list int))) (λ (Sy ((list int) → int)) (λ (d ((list int) → int)) d)))) (λ (z (list int)) z))) (cons ((λ (z int) z) 0))) hd) ((((λ (G ((list int) → (list int))) (λ (G (((list int) → int) → ((list int) → int))) G)) tl) (λ (g ((list int) → int)) g)) hd)) (((λ (C ((list int) → (list int))) C) (cons 0)) (((λ (u ((list int) → int)) (λ (j (list int)) nil)) hd) nil))) #:iterations 153 #:time 7050)) (new-average 2014-10-12T20:49:51 (#:model "stlc-sub-4" #:type search #:average 130014.37777777782 #:stderr 13909.017602656158)) (heartbeat 2014-10-12T20:49:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:50:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:50:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:50:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:50:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:50:35 (#:amount 120854768 #:time 265)) (heartbeat 2014-10-12T20:50:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:50:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:51:05 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:51:12 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (z ((list int) → (list int))) (λ (db (((int → int) → (list int)) → ((int → int) → (list int)))) tl)) tl) ((λ (c ((list int) → int)) (λ (m ((int → int) → (list int))) m)) hd)) (((λ (D (int → ((list int) → (list int)))) tl) cons) ((λ (g (((int → int) → (int → ((list int) → (list int)))) → (list int))) (g (λ (b (int → int)) cons))) ((((λ (gy (int → int)) (λ (d ((list int) → int)) (λ (d (((int → int) → (int → ((list int) → (list int)))) → (list int))) d))) (λ (PJe int) 1)) hd) ((λ (B (((int → int) → (int → ((list int) → (list int)))) → (list int))) B) (λ (Yx ((int → int) → (int → ((list int) → (list int))))) nil)))))) #:iterations 1252 #:time 81289)) (new-average 2014-10-12T20:51:12 (#:model "stlc-sub-4" #:type search #:average 128955.13043478265 #:stderr 13644.465462207758)) (heartbeat 2014-10-12T20:51:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:51:25 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:51:31 (#:amount 86008920 #:time 281)) (heartbeat 2014-10-12T20:51:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:51:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:51:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:52:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:52:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:52:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:52:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:52:36 (#:amount 117208256 #:time 265)) (heartbeat 2014-10-12T20:52:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:52:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:53:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:53:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:53:25 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:53:32 (#:amount 84678752 #:time 289)) (heartbeat 2014-10-12T20:53:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:53:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:53:55 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:54:00 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (P ((list int) → (((list int) → int) → ((list int) → int)))) P) (((λ (it int) (λ (i ((list int) → (int → (int → int)))) (λ (m (list int)) (λ (i ((list int) → int)) i)))) 1) ((λ (KG (list int)) (λ (q (list int)) +)) nil))) ((λ (T (int → (int → ((list int) → (list int))))) nil) (λ (f int) (λ (D int) tl)))) ((λ (f ((list int) → int)) hd) hd)) ((cons 0) ((λ (gz (list int)) nil) nil))) #:iterations 2561 #:time 168476)) (new-average 2014-10-12T20:54:00 (#:model "stlc-sub-4" #:type search #:average 129796.00000000004 #:stderr 13377.455308641105)) (counterexample 2014-10-12T20:54:03 (#:model "stlc-sub-4" #:type search #:counterexample ((((λ (d (((int → int) → int) → ((int → int) → int))) (λ (E (int → int)) (λ (E ((list int) → (list int))) E))) (λ (V ((int → int) → int)) V)) (+ 2)) ((λ (k ((list int) → (list int))) k) (cons 0))) #:iterations 32 #:time 2533)) (new-average 2014-10-12T20:54:03 (#:model "stlc-sub-4" #:type search #:average 127144.68750000004 #:stderr 13361.484033160423)) (heartbeat 2014-10-12T20:54:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:54:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:54:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:54:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:54:36 (#:amount 119516520 #:time 262)) (heartbeat 2014-10-12T20:54:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:54:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:55:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:55:15 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:55:23 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (a ((list int) → (list int))) (λ (d ((list int) → (int → int))) (λ (d ((list int) → (int → ((list int) → (list int))))) d))) (λ (Z (list int)) Z)) (λ (EU (list int)) (λ (S int) S))) (λ (j (list int)) cons)) ((((λ (p ((int → int) → ((int → int) → (int → int)))) cons) (λ (K (int → int)) (λ (Z (int → int)) Z))) 0) ((λ (H (list int)) H) nil))) #:iterations 1242 #:time 80120)) (new-average 2014-10-12T20:55:23 (#:model "stlc-sub-4" #:type search #:average 126185.00000000004 #:stderr 13121.103127234013)) (heartbeat 2014-10-12T20:55:25 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:55:33 (#:amount 85208608 #:time 291)) (heartbeat 2014-10-12T20:55:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:55:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:55:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:56:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:56:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:56:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:56:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:56:39 (#:amount 118949952 #:time 262)) (heartbeat 2014-10-12T20:56:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:56:55 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T20:57:03 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (E ((list int) → (list int))) (λ (d (((list int) → int) → (list int))) (λ (e (int → (int → int))) (λ (d (list int)) d)))) tl) (λ (h ((list int) → int)) nil)) ((λ (s (int → (int → int))) s) +)) ((cons 0) ((λ (a ((int → ((list int) → (list int))) → (list int))) (a cons)) (λ (Fl (int → ((list int) → (list int)))) nil)))) #:iterations 1522 #:time 100012)) (new-average 2014-10-12T20:57:03 (#:model "stlc-sub-4" #:type search #:average 125661.54000000004 #:stderr 12866.655500015913)) (heartbeat 2014-10-12T20:57:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:57:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:57:25 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:57:31 (#:amount 83849360 #:time 297)) (heartbeat 2014-10-12T20:57:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:57:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:57:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:58:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:58:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:58:25 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:58:27 (#:amount 121819888 #:time 230)) (heartbeat 2014-10-12T20:58:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:58:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:58:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:59:05 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:59:06 (#:amount 91553856 #:time 236)) (heartbeat 2014-10-12T20:59:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:59:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:59:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T20:59:45 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T20:59:49 (#:amount 106014352 #:time 218)) (heartbeat 2014-10-12T20:59:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:00:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:00:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:00:25 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:00:28 (#:amount 85308056 #:time 241)) (heartbeat 2014-10-12T21:00:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:00:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:00:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:01:05 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:01:14 (#:amount 118308344 #:time 228)) (heartbeat 2014-10-12T21:01:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:01:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:01:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:01:45 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:01:54 (#:amount 84577632 #:time 259)) (heartbeat 2014-10-12T21:01:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:02:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:02:15 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T21:02:20 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (S (int → (((list int) → (list int)) → ((int → ((list int) → (list int))) → (int → ((list int) → (list int))))))) S) (λ (F int) (λ (L ((list int) → (list int))) (λ (L (int → ((list int) → (list int)))) L)))) 0) (λ (E (list int)) E)) (((λ (q ((int → ((list int) → (list int))) → (int → ((list int) → (list int))))) q) (λ (j (int → ((list int) → (list int)))) cons)) (λ (D int) tl))) #:iterations 6571 #:time 317682)) (new-average 2014-10-12T21:02:20 (#:model "stlc-sub-4" #:type search #:average 129426.64705882357 #:stderr 13161.864068344843)) (heartbeat 2014-10-12T21:02:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:02:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:02:42 (#:amount 120190064 #:time 228)) (heartbeat 2014-10-12T21:02:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:02:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:03:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:03:15 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:03:21 (#:amount 85700984 #:time 241)) (heartbeat 2014-10-12T21:03:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:03:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:03:45 (#:model "stlc-sub-4" #:type search)) (counterexample 2014-10-12T21:03:50 (#:model "stlc-sub-4" #:type search #:counterexample (((((λ (r ((list int) → (list int))) ((λ (C ((int → int) → (list int))) (λ (IK (int → int)) (λ (h (int → (int → (int → int)))) tl))) (λ (I (int → int)) nil))) tl) (λ (y int) y)) (λ (D int) +)) ((cons ((λ (x int) x) 0)) ((((λ (i ((list int) → (list int))) (λ (W (int → int)) (λ (W (list int)) W))) (λ (w (list int)) w)) (+ 0)) nil))) #:iterations 1976 #:time 90634)) (new-average 2014-10-12T21:03:50 (#:model "stlc-sub-4" #:type search #:average 128680.63461538465 #:stderr 12927.812210873091)) (heartbeat 2014-10-12T21:03:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:04:05 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:04:06 (#:amount 117886456 #:time 228)) (heartbeat 2014-10-12T21:04:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:04:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:04:35 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:04:45 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:04:46 (#:amount 88360536 #:time 245)) (heartbeat 2014-10-12T21:04:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:05:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:05:15 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:05:25 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:05:35 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:05:38 (#:amount 112581800 #:time 241)) (heartbeat 2014-10-12T21:05:45 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:05:55 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:06:05 (#:model "stlc-sub-4" #:type search)) (heartbeat 2014-10-12T21:06:15 (#:model "stlc-sub-4" #:type search)) (gc-major 2014-10-12T21:06:20 (#:amount 85417464 #:time 234)) (counterexample 2014-10-12T21:06:20 (#:model "stlc-sub-4" #:type search #:counterexample (((λ (e ((((list int) → (list int)) → ((list int) → (list int))) → ((list int) → (list int)))) e) (λ (Pr (((list int) → (list int)) → ((list int) → (list int)))) (Pr tl))) (((λ (v (int → int)) (λ (J (int → (((int → int) → int) → ((int → (list int)) → ((list int) → int))))) (λ (J ((list int) → (list int))) J))) (λ (F int) F)) ((λ (Y (int → (((int → int) → int) → ((int → (list int)) → ((list int) → int))))) Y) (λ (K int) (λ (Y ((int → int) → int)) (λ (Y (int → (list int))) hd)))))) #:iterations 3014 #:time 149914)) (new-average 2014-10-12T21:06:20 (#:model "stlc-sub-4" #:type search #:average 129081.26415094343 #:stderr 12687.872288321392)) (finished 2014-10-12T21:06:20 (#:model "stlc-sub-4" #:type search #:time-ms 6841320 #:attempts 116499 #:num-counterexamples 53 #:rate-terms/s 17.02873129746891 #:attempts/cexp 2198.0943396226417))
false
955f8bd5d51f7a09913b8ad5f37c79ef2dc7bbae
f5e4988a19f0aed24d02c13b74d488057526617c
/src/extended-eval.rkt
e3d01fc20822fc3ddf4b9b397ecab107c48c5eb8
[]
no_license
hmrg-grmh/akeep-abstract-racket
6f0c809bb387ba73f55c6bc0cca1dbbed76f2034
101eb681bec64f4413e61a051e1b5bcdb0bcc79f
refs/heads/master
"2021-05-27T02:07:23.567506"
"2013-03-12T16:39:29"
"2013-03-12T16:39:29"
null
0
0
null
null
null
null
UTF-8
Racket
false
false
28,457
rkt
extended-eval.rkt
#lang racket (require compiler/compiler compiler/zo-parse compiler/zo-marshal "priminfo.rkt") (define (compile-bytecode expr) (let ([tmp (make-temporary-file)]) (call-with-output-file tmp #:exists 'truncate (λ (p) (parameterize ([current-namespace (make-base-namespace)]) (write (compile expr) p)))) (begin0 (call-with-input-file tmp zo-parse) (delete-file tmp)))) (define ip->bytecode (lambda (ip) (zo-parse ip))) (define zo-file->bytecode (lambda (fn) (call-with-input-file fn ip->bytecode))) (define source-file->bytecode (let ([compile-file (let ([compile-files (compile-zos #f)]) (lambda (fn dir) (compile-files (list fn) dir)))]) (lambda (fn) (let ([dir (make-temporary-file "rkt-compile-tmp-~a" 'directory)]) (parameterize ([current-namespace (make-base-namespace)] [compile-context-preservation-enabled #t]) (compile-file fn dir)) (zo-file->bytecode (path-replace-suffix (path->complete-path fn dir) "_rkt.zo")))))) (define source->bytecode (lambda (expr) (ip->bytecode (let ([out (open-output-bytes)]) (parameterize ([current-namespace (make-base-namespace)] [compile-context-preservation-enabled #t]) (write (compile expr) out)) (close-output-port out) (open-input-bytes (get-output-bytes out)))))) ;; ;; output grammar: ;; Prog --> `(,<Expr> ,<TextSegPart> ...) ;; Expr --> (loc <offset>) ;; | (loc-clr <offset>) ;; | (loc-noclr <offset>) ;; | (loc-box <offset>) ;; | (loc-box-clr <offset>) ;; | (loc-box-noclr <offset>) ;; | (let-one <Expr> <Expr>) ;; | (let-void <offset> <Expr>) ;; | (let-void-box <offset> <Expr>) ;; | (install-value <offset> <Expr> <Expr>) ;; | (install-value-box <offset> <Expr> <Expr>) ;; | (boxenv <offset> <Expr>) ;; | (application <Expr> <Expr> ...) ;; | (seq <Expr> ...) ;; | (branch <Expr> <Expr> <Expr>) ;; | (let-rec <Expr> ... <Expr>) ;; | (lam (<ts> ...) (<free-n> ...) <Expr>) ;; | (proc-const (<ts> ...) <Expr>) ;; | (indirect <symbol>) ;; | (case-lam <Expr>) ;; | (constant <const>) ;; | (quote <symbol>) ;; maybe a variable reference? ;; | (primval <prim-symbol>) ;; TextSegPart --> (<symbol> <Expr>) ;; (define (impl->model expr) (define cycled (cycle-points expr)) (define text-addr (make-hasheq)) (define next-loc (let ([suffix 0]) (λ () (set! suffix (add1 suffix)) (string->symbol (format "x~s" suffix))))) (define text-seg '()) (cons (let recur ([e expr]) (match e [(compilation-top _ _ e) (recur e)] [(localref #f n #f #t #f) `(loc ,n)] [(localref #f n #t _ #f) `(loc-clr ,n)] [(localref #f n #f #f #f) `(loc-noclr ,n)] [(localref #t n #f #t #f) `(loc-box ,n)] [(localref #t n #t _ #f) `(loc-box-clr ,n)] [(localref #t n #f #f #f) `(loc-box-noclr ,n)] [(let-one r b #f #f) `(let-one ,(recur r) ,(recur b))] [(let-void n #f b) `(let-void ,n ,(recur b))] [(let-void n #t b) `(let-void-box ,n ,(recur b))] [(install-value 1 n #f r b) `(install-value ,n ,(recur r) ,(recur b))] [(install-value 1 n #t r b) `(install-value-box ,n ,(recur r) ,(recur b))] [(boxenv n b) `(boxenv ,n ,(recur b))] [(application f as) `(application ,(recur f) ,@(map recur as))] [(seq es) `(seq ,@(map recur es))] [(branch c t e) `(branch ,(recur c) ,(recur t) ,(recur e))] [(let-rec rs b) `(let-rec ,@(map recur rs) ,(recur b))] [(lam _ _ _ τs #f ns `(val/ref ...) _ _ b) `(lam ,τs ,(vector->list ns) ,(recur b))] [(closure l _) (define (model-rep) (match-let ([`(lam ,τs () ,b) (recur l)]) `(proc-const ,τs ,b))) (if (hash-ref cycled e #f) `(indirect ,(let ([x (hash-ref text-addr e #f)]) (or x (let ([x (next-loc)]) (hash-set! text-addr e x) (set! text-seg (cons (list x (model-rep)) text-seg)) x)))) (model-rep))] [(case-lam _ ls) `(case-lam ,@(map recur ls))] [(? void?) `(constant ,(void))] [(? number?) `(constant ,e)] [(? boolean?) `(constant ,e)] [(? symbol?) `',e] ;; I think this corresponds to a variable reference (not sure) ;; "extended" cases [(primval n) `(primval ,(lookup-primitive n))] [_ (error 'impl->model "unrecognized form ~s" e)])) text-seg)) (define (cycle-points expr) (define seen (make-hasheq)) (let recur ([e expr]) (when (zo? e) ; i.e., not a literal (if (hash-ref seen e #f) (unless (closure? e) (error 'cycle-refs "illegal cycle through ~s" e)) (begin (hash-set! seen e #t) (match e [(compilation-top _ _ e) (recur e)] [(localref _ _ _ _ _) (void)] [(let-one r b _ _) (recur r) (recur b)] [(let-void _ _ b) (recur b)] [(install-value _ _ _ r b) (recur r) (recur b)] [(boxenv _ b) (recur b)] [(application f as) (recur f) (for-each recur as)] [(seq es) (for-each recur es)] [(branch c t e) (recur c) (recur t) (recur e)] [(let-rec rs b) (for-each recur rs) (recur b)] [(lam _ _ _ _ _ _ _ _ _ b) (recur b)] [(closure l _) (recur l)] [(case-lam _ ls) (for-each recur ls)] [_ (void)]))))) seen) ;; ;; input grammar: ;; Prog --> `(,<Expr> ,<TextSegPart> ...) ;; Expr --> (loc <offset>) ;; | (loc-clr <offset>) ;; | (loc-noclr <offset>) ;; | (loc-box <offset>) ;; | (loc-box-clr <offset>) ;; | (loc-box-noclr <offset>) ;; | (let-one <Expr> <Expr>) ;; | (let-void <offset> <Expr>) ;; | (let-void-box <offset> <Expr>) ;; | (install-value <offset> <Expr> <Expr>) ;; | (install-value-box <offset> <Expr> <Expr>) ;; | (boxenv <offset> <Expr>) ;; | (application <Expr> <Expr> ...) ;; | (seq <Expr> ...) ;; | (branch <Expr> <Expr> <Expr>) ;; | (let-rec <Expr> ... <Expr>) ;; | (lam (<ts> ...) (<free-n> ...) <Expr>) ;; | (proc-const (<ts> ...) <Expr>) ;; | (indirect <symbol>) ;; | (case-lam <Expr> ...) ;; | (constant <const>) ;; | (quote <symbol>) ;; maybe a variable reference? ;; | (primval <prim-symbol>) ;; TextSegPart --> (<symbol> <Expr>) ;; ;; ---- ;; output grammar: ;; Prog --> (prog ([<symbol> <Expr>] ...) <Expr>) ;; TextSeg (removed) ;; Expr (unchanged) (define (model->prog pair) `(prog ,(cdr pair) ,(car pair))) (define-syntax rec (syntax-rules () [(_ id expr) (letrec ([id expr]) id)])) (define-syntax trace-define (syntax-rules () [(_ (name . args) body0 body1 ...) (define name (let ([depth 0]) (lambda targs (set! depth (+ depth 1)) (let loop ([n depth]) (unless (zero? n) (display #\|) (loop (- n 1)))) (pretty-print (cons 'name targs)) (call-with-values (lambda () (apply (lambda args body0 body1 ...) targs)) (lambda targs (set! depth (- depth 1)) (let loop ([n depth]) (unless (zero? n) (display #\|) (loop (- n 1)))) (if (= (length targs) 1) (pretty-print (car targs)) (pretty-print (cons 'values targs))) (apply values targs))))))] [(_ name lexpr) (define name (let ([depth 0]) (lambda args (set! depth (+ depth 1)) (let loop ([n depth]) (unless (zero? n) (write #\|) (loop (- n 1)))) (pretty-print (cons 'name args)) (call-with-values (lambda () (apply lexpr args)) (lambda args (set! depth (- depth 1)) (let loop ([n depth]) (unless (zero? n) (write #\|) (loop (- n 1)))) (if (= (length args) 1) (pretty-print (car args)) (pretty-print (cons 'values args))) (apply values args))))))])) (define next-symbol (let ([n 0]) (lambda () (begin0 (string->symbol (string-append "t." (number->string n))) (set! n (+ n 1)))))) ;; ;; input grammar: ;; Prog --> (prog ([<symbol> <Expr>] ...) <Expr>) ;; Expr --> (loc <offset>) ;; | (loc-clr <offset>) ;; | (loc-noclr <offset>) ;; | (loc-box <offset>) ;; | (loc-box-clr <offset>) ;; | (loc-box-noclr <offset>) ;; | (let-one <Expr> <Expr>) ;; | (let-void <offset> <Expr>) ;; | (let-void-box <offset> <Expr>) ;; | (install-value <offset> <Expr> <Expr>) ;; | (install-value-box <offset> <Expr> <Expr>) ;; | (boxenv <offset> <Expr>) ;; | (application <Expr> <Expr> ...) ;; | (seq <Expr> ...) ;; | (branch <Expr> <Expr> <Expr>) ;; | (let-rec <Expr> ... <Expr>) ;; | (lam (<ts> ...) (<free-n> ...) <Expr>) ;; | (proc-const (<ts> ...) <Expr>) ;; | (indirect <symbol>) ;; | (case-lam <Expr> ...) ;; | (constant <const>) ;; | (quote <symbol>) ;; maybe a variable reference? ;; | (primval <prim-symbol>) ;; ;; ----- ;; output grammar: ;; Prog --> (prog ([<symbol> <Expr>] ...) <Expr>) ;; Expr --> (ref <ref-type> <symbol>) ;; | (boxref <ref-type> <symbol>) ;; | (let ([<symbol> <Expr>] ...) <Expr>) ;; | (set! <symbol> <Expr>) ;; | (set-box! <symbol> <Expr>) ;; | (boxenv <symbol>) ;; | (application <Expr> <Expr> ...) ;; | (seq <Expr> ...) ;; | (let-rec ([<symbol> <Expr>]) <Expr>) ;; | (lam ((<symbol> : <ts>) ...) <Expr>) ;; | (case-lam <Expr> ...) ;; | (constant <const>) ;; | (quote <symbol>) ;; | (primval <prim>) ;; (define (reintroduce-variables x) (define (next-symbol* n env) (for/fold ([ls '()] [env env]) ([n n]) (let ([x (next-symbol)]) (values (cons x ls) (cons x env))))) (define (Expr* env e*) (if (null? e*) '() (cons (Expr env (car e*)) (Expr* env (cdr e*))))) (define (Expr env x) (match x [`(loc ,n) `(ref normal ,(list-ref env n))] [`(loc-clr ,n) `(ref clr ,(list-ref env n))] [`(loc-noclr ,n) `(ref noclr ,(list-ref env n))] [`(loc-box ,n) `(boxref normal ,(list-ref env n))] [`(loc-box-clr ,n) `(boxref clr ,(list-ref env n))] [`(loc-box-noclr ,n) `(boxref noclr ,(list-ref env n))] [`(let-one ,e0 ,e1) (let ([x (next-symbol)]) `(let ([,x ,(Expr env e0)]) ,(Expr (cons x env) e1)))] [`(let-void ,n (let-rec ,e* ... ,e)) (let-values ([(x* env) (next-symbol* n env)]) (let ([e* (Expr* env e*)] [e (Expr env e)]) `(let-rec ,(map (lambda (x e) (list x e)) x* e*) ,e)))] [`(let-void ,n ,e) (let-values ([(x* env) (next-symbol* n env)]) `(let ,(map (lambda (x) (list x `(constant ,(void)))) x*) ,(Expr env e)))] [`(let-void-box ,n ,e) (let-values ([(x* env) (next-symbol* n env)]) `(let ,(map (lambda (x) (list x `(constant ,(void)))) x*) ,(let loop ([x* x*]) (if (null? x*) (Expr env e) `(seq (boxenv ,(car x*)) ,(loop (cdr x*)))))))] [`(install-value ,n ,e0 ,e1) `(seq (set! ,(list-ref env n) ,(Expr env e0)) ,(Expr env e1))] [`(install-value-box ,n ,e0 ,e1) `(seq (set-box! ,(list-ref env n) ,(Expr env e0)) ,(Expr env e1))] [`(boxenv ,n ,e) `(seq (boxenv ,(list-ref env n)) ,(Expr env e))] [`(application ,e ,e* ...) (let-values ([(rx* env) (next-symbol* e* env)]) `(application ,(Expr env e) ,@(Expr* env e*)))] [`(seq ,e* ...) `(seq ,@(Expr* env e*))] [`(branch ,e0 ,e1 ,e2) `(branch ,(Expr env e0) ,(Expr env e1) ,(Expr env e2))] [`(let-rec ,e* ... ,e) (if (null? e*) (Expr env e) (error 'reintroduce-variables "found let-rec outside of let-void ~s" x))] [`(lam (,ts* ...) (,n* ...) ,e) (let ([free-x* (map (lambda (n) (list-ref env n)) n*)]) (let-values ([(x* env) (next-symbol* ts* env)]) (let ([env (append free-x* env)]) `(lam ,(map (lambda (x ts) (list x ': ts)) x* ts*) ,(Expr env e)))))] [`(proc-const (,ts* ...) ,e) (let-values ([(x* env) (next-symbol* ts* env)]) `(lam ,(map (lambda (x ts) (list x ': ts)) x* ts*) ,(Expr env e)))] [`(indirect ,x) `(ref indirect ,x)] [`(case-lam ,e* ...) `(case-lam ,@(Expr* env e*))] [`(constant ,c) `(constant ,c)] [`(quote ,s) `(quote ,s)] [`(primval ,pr) `(primval ,pr)])) (define (Prog x) (match x [`(prog ([,x* ,e*] ...) ,e) (let ([e* (Expr* '() e*)] [e (Expr '() e)]) `(prog ,(map list x* e*) ,e))])) (Prog x)) ;; ;; input grammar: ;; Prog --> (prog ([<symbol> <Expr>] ...) <Expr>) ;; Expr --> (ref <ref-type> <symbol>) ;; | (boxref <ref-type> <symbol>) ;; | (let ([<symbol> <Expr>] ...) <Expr>) ;; | (set! <symbol> <Expr>) ;; | (set-box! <symbol> <Expr>) ;; | (boxenv <symbol>) ;; | (application <Expr> <Expr> ...) ;; | (seq <Expr> ...) ;; | (let-rec ([<symbol> <Expr>] ...) <Expr>) ;; | (lam ((<symbol> : <ts>) ...) <Expr>) ;; | (case-lam <Expr> ...) ;; | (constant <const>) ;; | (quote <symbol>) ;; | (primval <prim>) ;; ;; ------ ;; output grammar: ;; Prog --> (prog ([<symbol> <Lamda>] ...) <Expr>) ;; Lambda --> (lam ((<symbol> : <ts>) ...) <Expr>) ;; Expr --> <Lambda> ;; | (ref <ref-type> <symbol>) ;; | (boxref <ref-type> <symbol>) ;; | (let ([<symbol> <Expr>] ...) <Expr>) ;; | (set! <symbol> <Expr>) ;; | (set-box! <symbol> <Expr>) ;; | (boxenv <symbol> <Expr>) ;; | (application <Expr> <Expr> ...) ;; | (seq <Expr> <Expr> <Expr> ...) ;; | (let-rec ([<symbol> <Lambda>] ...) <Expr>) ;; | (case-lam <Lambda> ...) ;; | (constant <const>) ;; | (quote <symbol>) ;; | (primval <prim>) ;; (define (check-grammar x) (define (Expr! e) (match e [`(lam ((,x* : ,ts*) ...) ,e) (Expr! e)] [`(ref ,type ,x) (void)] [`(boxref ,type ,x) (void)] [`(let ([,x* ,e*] ...) ,e) (for-each Expr! e*) (Expr! e)] [`(set! ,x ,e) (Expr! e)] [`(set-box! ,x ,e) (Expr! e)] [`(boxenv ,x) (void)] [`(application ,e ,e* ...) (Expr! e) (for-each Expr! e*)] [`(seq ,e0 ,e1 ,e* ...) (Expr! e0) (Expr! e1) (for-each Expr! e*)] [`(branch ,e0 ,e1 ,e2) (Expr! e0) (Expr! e1) (Expr! e2)] [`(let-rec ([,x* ,le*] ...) ,e) (for-each Lambda! le*) (Expr! e)] [`(case-lam ,le* ...) (for-each Lambda! le*)] [`(constant ,c) (void)] [`(quote ,x) (void)] [`(primval ,prim) (void)] [_ (error 'check-grammar "unmatched language form ~s" e)])) (define (Lambda! le) (match le [`(lam ((,x* : ,ts*) ...) ,e) (Expr! e)] [_ (error 'check-grammar "invalid lambda expression ~s" le)])) (define (Prog! x) (match x [`(prog ([,x* ,le*] ...) ,e) (for-each Lambda! le*) (Expr! e)] [_ (error 'check-grammar "invalid program form ~s" x)])) (Prog! x) x) ;; ;; input grammar: ;; Prog --> (prog ([<symbol> <Lamda>] ...) <Expr>) ;; Lambda --> (lam ((<symbol> : <ts>) ...) <Expr>) ;; Expr --> <Lambda> ;; | (ref <ref-type> <symbol>) ;; | (boxref <ref-type> <symbol>) ;; | (let ([<symbol> <Expr>] ...) <Expr>) ;; | (set! <symbol> <Expr>) ;; | (set-box! <symbol> <Expr>) ;; | (boxenv <symbol>) ;; | (application <Expr> <Expr> ...) ;; | (seq <Expr> <Expr> <Expr> ...) ;; | (branch <Expr> <Expr> <Expr>) ;; | (let-rec ([<symbol> <Lambda>] ...) <Expr>) ;; | (case-lam <Lambda> ...) ;; | (constant <const>) ;; | (quote <symbol>) ;; | (primval <prim>) ;; ;; ------ ;; output grammar: ;; Lambda --> (lam ((<symbol> : <ts>) ...) <Expr>) ;; AExpr --> <Lambda> ;; | (case-lam <Expr> ...) ;; | (boxref <ref-type> <symbol>) ;; | (constant <const>) ;; | (primval <prim>) ;; | (primcall <prim> <AExpr> ...) ;; | (quote <symbol>) ;; CExpr --> (application <AExpr> <AExpr> ...) ;; | (branch <AExpr> <AExpr> <AExpr>) ;; | (set! <symbol> <AExpr>) ;; | (set-box! <symbol> <AExpr>) ;; | (boxenv <symbol>) ;; | (let-rec ([<symbol> <Lambda>] ...) <Expr>) ;; Expr --> <AExpr> ;; | <CExpr> ;; | (seq <Expr> <Expr>) ;; | (let (<symbol> <Expr>) <Expr>) ;; (define (to-anormal-form x) (define (build-seq* e0 e1 e*) (if (null? e*) `(seq ,e0 ,e1) `(seq ,e0 ,(build-seq* e1 (car e*) (cdr e*))))) (define (build-let rx* re* body) (if (null? rx*) body (build-let (cdr rx*) (cdr re*) (let ([x (car rx*)]) (if x `(let (,x ,(car re*)) ,body) `(seq ,(car re*) ,body)))))) (define (AExpr* rx* re* e*) (if (null? e*) (values rx* re* '()) (let-values ([(rx* re* e) (AExpr rx* re* (car e*))]) (let-values ([(rx* re* e*) (AExpr* rx* re* (cdr e*))]) (values rx* re* (cons e e*)))))) (define (Binding* rx* re* x* e*) (if (null? x*) (values rx* re*) (let-values ([(rx* re* e) (CExpr rx* re* (car e*))]) (Binding* (cons (car x*) rx*) (cons e re*) (cdr x*) (cdr e*))))) (define (Lam le) (match le [`(lam (,x* ...) ,e) (let ([e (Expr e)]) `(lam ,x* ,e))])) (define (AExpr rx* re* e) (match e [`(let ([,x* ,e*] ...) ,body) (let-values ([(rx* re*) (Binding* rx* re* x* e*)]) (AExpr rx* re* body))] [`(seq ,e* ... ,e) (let ([re* (foldl (lambda (e re*) (cons (Expr e) re*)) re* e*)] [rx* (foldl (lambda (e rx*) (cons (next-symbol) rx*)) rx* e*)]) (AExpr rx* re* e))] [`(ref ,ref-type ,x) (values rx* re* e)] [`(boxref ,ref-type ,x) (values rx* re* e)] [`(application (primval ,prim) ,e* ...) (let-values ([(rx* re* e*) (AExpr* rx* re* e*)]) (values rx* re* `(primcall ,prim ,@e*)))] [`(application ,e ,e* ...) (let-values ([(rx* re* e) (AExpr rx* re* e)]) (let-values ([(rx* re* e*) (AExpr* rx* re* e*)]) (let ([t (next-symbol)]) (values (cons t rx*) (cons `(application ,e ,@e*) re*) `(ref normal ,t)))))] [`(set! ,x ,e) (let-values ([(rx* re* e) (AExpr rx* re* e)]) (values (cons #f rx*) (cons `(set! ,x ,e) re*) `(constant ,(void))))] [`(set-box! ,x ,e) (let-values ([(rx* re* e) (AExpr rx* re* e)]) (values (cons #f rx*) (cons `(set-box! ,x ,e) re*) `(constant ,(void))))] [`(boxenv ,x) (values (cons #f rx*) (cons `(boxenv ,x) re*) `(constant ,(void)))] [`(branch ,e0 ,e1 ,e2) (let-values ([(rx* re* e0) (AExpr rx* re* e0)]) (let ([e1 (Expr e1)] [e2 (Expr e2)] [t (next-symbol)]) (values (cons t rx*) (cons `(branch ,e0 ,e1 ,e2) re*) `(varref normal ,t))))] [`(let-rec ([,x* ,le*] ...) ,e) (let ([le* (map Lam le*)] [e (Expr e)] [t (next-symbol)]) (values (cons t rx*) (cons `(let-rec ,(map list x* le*) ,e) re*) `(ref normal ,t)))] [`(case-lam ,le* ...) (let ([le* (map Lam le*)]) (values rx* re* `(case-lam ,@le*)))] [`(constant ,const) (values rx* re* `(constant ,const))] [`(quote ,x) (values rx* re* `(quote ,x))] [`(primval ,x) (values rx* re* `(primval ,x))] [`(lam ((,x* : ,t*) ...) ,e) (let ([e (Expr e)]) (values rx* re* `(lam ,(map (lambda (x t) (list x ': t)) x* t*) ,e)))])) (define (CExpr rx* re* e) (match e [`(let ([,x* ,e*] ...) ,body) (let-values ([(rx* re*) (Binding* rx* re* x* e*)]) (CExpr rx* re* body))] [`(seq ,e* ... ,e) (let ([re* (foldl (lambda (e re*) (cons (Expr e) re*)) re* e*)] [rx* (foldl (lambda (e rx*) (cons (next-symbol) rx*)) rx* e*)]) (CExpr rx* re* e))] [`(application (primval ,prim) ,e* ...) (let-values ([(rx* re* e*) (AExpr* rx* re* e*)]) (values rx* re* `(primcall ,prim ,@e*)))] [`(application ,e ,e* ...) (let-values ([(rx* re* e) (AExpr rx* re* e)]) (let-values ([(rx* re* e*) (AExpr* rx* re* e*)]) (values rx* re* `(application ,e ,@e*))))] [`(set! ,x ,e) (let-values ([(rx* re* e) (AExpr rx* re* e)]) (values rx* re* `(set! ,x ,e)))] [`(set-box! ,x ,e) (let-values ([(rx* re* e) (AExpr rx* re* e)]) (values rx* re* `(set-box! ,x ,e)))] [`(boxenv ,x) (values rx* re* `(boxenv ,x))] [`(branch ,e0 ,e1 ,e2) (let-values ([(rx* re* e0) (AExpr rx* re* e0)]) (let ([e1 (Expr e1)] [e2 (Expr e2)]) (values rx* re* `(branch ,e0 ,e1 ,e2))))] [`(let-rec ([,x* ,le*] ...) ,e) (let ([le* (map Lam le*)] [e (Expr e)]) (values rx* re* `(let-rec ,(map list x* le*) ,e)))] [`(case-lam ,le* ...) (let ([le* (map Lam le*)]) (values rx* re* `(case-lam ,@le*)))] [_ (AExpr rx* re* e)])) (define (Expr e) (match e [`(seq ,e0 ,e1 ,e* ...) (let ([e0 (Expr e0)] [e1 (Expr e1)] [e* (map Expr e*)]) (build-seq* e0 e1 e*))] [`(let ([,x* ,e*] ...) ,body) (let-values ([(rx* re*) (Binding* '() '() x* e*)]) (let ([body (Expr body)]) (build-let rx* re* body)))] [_ (let-values ([(rx* re* body) (CExpr '() '() e)]) (build-let rx* re* body))])) (define (Prog p) (match p [`(prog ([,x* ,le*] ...) ,e) (let ([le* (map Lam le*)] [e (Expr e)]) `(let-rec ,(map list x* le*) ,e))])) (Prog x)) ;; output grammar: ;; Lambda --> (lam ((<symbol> : <ts>) ...) <Expr>) ;; AExpr --> <Lambda> ;; | (case-lam <Expr> ...) ;; | (boxref <ref-type> <symbol>) ;; | (constant <const>) ;; | (primval <prim>) ;; | (primcall <prim> <AExpr> ...) ;; | (quote <symbol>) ;; CExpr --> (application <AExpr> <AExpr> ...) ;; | (branch <AExpr> <AExpr> <AExpr>) ;; | (set! <symbol> <AExpr>) ;; | (set-box! <symbol> <AExpr>) ;; | (boxenv <symbol>) ;; | (let-rec ([<symbol> <Lambda>] ...) <Expr>) ;; | <AExpr> ;; Expr --> <CExpr> ;; | (seq <Expr> <Expr>) ;; | (let (<symbol> <Expr>) <Expr>) ;; (define (cesk x) (define (empty-env) '()) (define (extend-env rho x addr) (cons (cons x addr) rho)) (define (extend-env* rho x* addr*) (foldl (lambda (x addr rho) (extend-env rho x addr)) rho x* addr*)) (define (apply-env rho x) (cond [(assq x rho) => cdr] [else (error 'apply-env "reference to unbound variable ~s" x)])) (define (empty-store) '()) (define (extend-store s addr val) (cons (cons addr val) s)) (define (extend-store* s addr* val*) (foldl (lambda (addr val rho) (extend-store s addr val)) s addr* val*)) (define (apply-store s addr) (cond [(assq addr s) => cdr] [else (error 'apply-store "reference to unallocated variable ~s" addr)])) (define (allocate s x) (gensym x)) (define (allocate* s x*) (map (lambda (x) (allocate s x)) x*)) (define (PrepPrimArgs e) e) (define (apply-proc e arg* s k) (define (return-vals x* expr rho) (let ([addr* (allocate* s (map car x*))]) (let ([rho (extend-env* rho (map car x*) addr*)]) (let ([s (extend-store* s addr* arg*)]) (values expr rho s k))))) (define (find-clause x** expr* arg* k) (let ([l (length arg*)]) (let loop ([x** x**] [expr* expr*]) (if (null? x**) (error 'apply-proc "incorrect number of arguments") (let ([x* (car x**)]) (if (= (length x*) l) (k x* (car expr*)) (loop (cdr x**) (cdr expr*)))))))) (match e [`(clo (,x* ...) ,expr ,rho) (return-vals x* expr rho)] [`(case-clo ,x** ,e* ,rho) (find-clause x** e* arg* (lambda (x* expr) (return-vals x* expr rho)))] [_ (error 'apply-proc "attempt to apply non-procedure value ~s" e)])) (define (apply-kont k val s) (match k [`(letk ,x ,rho ,e ,k) (let ([addr (allocate s x)]) (let ([rho (extend-env rho x addr)]) (let ([s (extend-store s addr val)]) (values e rho s k))))] [`(seqk ,rho ,expr ,k) (values expr rho s k)] [`(halt) (values val (empty-env) (empty-store) k)])) (define (AExpr e rho s) (match e [`(constant ,c) c] [`(lam (,x* ...) ,e) `(clo ,x* ,e ,rho)] [`(case-lam (lam (,x** ...) ,e*) ...) `(case-clo ,x** ,e* ,rho)] [`(ref ,ref-type ,x) (apply-store s (apply-env rho x))] [`(boxref ,ref-type ,x) (unbox (apply-store s (apply-env rho x)))] [`(primval ,x) (eval x)] [`(primcall ,prim ,e* ...) (let ([e* (map (lambda (e) (AExpr e rho s)) e*)]) (let ([e* (map PrepPrimArgs e*)]) (apply (eval prim) e*)))] [`(quote ,x) x])) (define (step e rho s k) (match e [`(let (,x0 ,e0) ,e1) (values e0 rho s `(letk ,x0 ,rho ,e1 ,k))] [`(seq ,e0 ,e1) (values e0 rho s `(seqk ,rho ,e1 ,k))] [`(application ,e ,e* ...) (let ([e (AExpr e rho s)] [e* (map (lambda (e) (AExpr e rho s)) e*)]) (apply-proc e e* s k))] [`(branch ,e0 ,e1 ,e2) (let ([e0 (AExpr e0 rho s)]) (values (if (eq? e0 #f) e2 e1) rho s k))] [`(set! ,x ,e) (let ([s (extend-store s (apply-env x) (AExpr e rho s))]) (apply-kont k `(constant ,(void))) s)] [`(set-box! ,x ,e) (let ([b (apply-store s (apply-env rho x))]) (set-box! b (AExpr e rho s)) (apply-kont k `(constant ,(void)) s))] [`(boxenv ,x) (let ([addr (apply-env rho x)]) (let ([val (apply-store s addr)]) (let ([s (extend-store s addr (box val))]) (apply-kont k `(constant ,(void)) s))))] [`(let-rec ([,x* ,le*] ...) ,e) (let ([addr* (allocate* s x*)]) (let ([rho (extend-env* rho x* addr*)]) (let ([le* (map (lambda (le) (AExpr le rho s)) le*)]) (let ([s (extend-store* s addr* le*)]) (values e rho s k)))))] [_ (apply-kont k (AExpr e rho s) s)])) (define (value-exp? exp) (if (pair? exp) (and (not (memq (car exp) '(let seq application brnch set! set-box! boxenv let-rec))) (memq (car exp) '(clo case-clo)) #t) #t)) (define (step-driver exp rho s k) (let-values ([(exp rho s k) (step exp rho s k)]) (if (and (value-exp? exp) (match k [`(halt) #t] [_ #f])) exp (step-driver exp rho s k)))) (step-driver x (empty-env) (empty-store) `(halt))) (define racket-source->bytecode (compose impl->model source->bytecode)) (define racket-source-file->bytecode (compose impl->model source-file->bytecode)) (define racket-zo-file->bytecode (compose impl->model zo-file->bytecode)) (define-syntax passes (syntax-rules () [(_ ?x f ...) (let* ([x ?x] [x (f x)] ...) x)])) (define (racket-source->anormal-form x) (passes x source->bytecode impl->model model->prog reintroduce-variables check-grammar to-anormal-form)) (provide (all-defined-out))
true
d286b1e9398f8649992125a5b653cb05b4a66725
471a04fa9301455c51a890b8936cc60324a51f27
/srfi-lib/srfi/%3a8/receive.rkt
670412617a494b0aa6729e985a409d1ab82b30b9
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
racket/srfi
e79e012fda6d6bba1a9445bcef461930bc27fde8
25eb1c0e1ab8a1fa227750aa7f0689a2c531f8c8
refs/heads/master
"2023-08-16T11:10:38.100847"
"2023-02-16T01:18:44"
"2023-02-16T12:34:27"
27,413,027
10
10
NOASSERTION
"2023-09-14T14:40:51"
"2014-12-02T03:22:45"
HTML
UTF-8
Racket
false
false
36
rkt
receive.rkt
#lang s-exp srfi/provider srfi/%3a8
false
0d1a88a4cb5650b1b8d3565070a1f72a6f046798
3ff658af1c58e6009d60aba7f7a0192590c828ce
/pd2af/server/libs/odysseus/report/widgets/gantt.rkt
8ea09042e013bb1c097755f8012d250c977debcc
[]
no_license
acanalpay/pd2af-converter
ab994f52deacd96bc423365b1719bc734cae7b08
b4c812172d747d32ae286db7b2efcdcf10fb7409
refs/heads/master
"2023-06-06T08:10:42.247438"
"2021-06-30T07:38:35"
"2021-06-30T07:38:35"
381,607,483
0
0
null
null
null
null
UTF-8
Racket
false
false
14,904
rkt
gantt.rkt
#lang racket (require "../../lib/_all.rkt") (require "../../graphics/svg.rkt") (require "../../graphics/color.rkt") (require "../../tabtree/tab-tree.rkt") (require "../../tabtree/html.rkt") (provide draw-gantt draw-longtime-gantt) ; constants (define y0 50) (define track-h 27) ; height per one job bar (define colors (string-split "black #00B6F2 #0096B2 #CC46C7 #89B836 #F29A4C #B22E2A #4C57DB #74D95F" " ")) ; (define colors (string-split "black #3EA6B2 #5656C2 #559139 #618AB8 #984EB8 #53AB4D" " ")) (define (get-afters element jobs) (if-not ($ after element) #f (let* ((after ($ after element)) (after-ids (string-split after ",")) (afters (for/fold ((res empty)) ((a after-ids)) (let* ((after-parts (string-split a "+")) (after-id (first after-parts)) (increment (if (> (length after-parts) 1) (second after-parts) 0)) (after (@id after-id jobs))) (if after (pushr res (list after increment)) res))))) afters))) (define-catch (get-start-time element jobs) (let* ( (start ($ start element)) (afters (get-afters element jobs)) (with ($ with element)) (with-parts (and with (string-split with "+"))) (with-related-element (and with-parts (first with-parts))) (with-related-element (@id with-related-element jobs)) (with-increment (and with-parts (> (length with-parts) 1) (second with-parts))) (start (cond ((and afters (not-empty? afters)) (d+ (car (sort (map (λ (x) (d+ (get-end-time (first x) jobs) (days-count (second x)))) afters) d>)) 1)) ; as finishing day is inclusive, then increase calculated day by one ((and with with-related-element) (d+ (get-start-time with-related-element jobs) (if with-increment (days-count with-increment) 0))) (start start) (else (exit) (error (format "Cannot define start time for ~a" ($ id element))))))) start)) (define (get-end-time element jobs) (let* ( (start (get-start-time element jobs)) (len ($ length element)) (len (if len (dec (days-count len)) 0)) ; +2d = 2 days, and as the end day is inclusive, decrease resulting day by one (end (or ($ end element) (d+ start len)))) end)) (define-catch (get-start-month element jobs) (let* ( (start ($ start element)) (afters (get-afters element jobs)) (with ($ with element)) (with-parts (and with (string-split with "+"))) (with-related-element (and with-parts (first with-parts))) (with-related-element (@id with-related-element jobs)) (with-increment (and with-parts (> (length with-parts) 1) (second with-parts))) (start (cond ((and afters (not-empty? afters)) (inc (car (sort (map (λ (x) (+ (get-end-month (first x) jobs) (months-count (second x)))) afters) d>)))) ((and with with-related-element) (+ (get-start-month with-related-element jobs) (if with-increment (months-count with-increment) 0))) ((not start) (error (format "Undefined start date for '~a'" ($ id element)))) (else (date->month start))))) start)) (define-catch (get-end-month element jobs) (let* ( (start (get-start-month element jobs)) (len ($ length element)) (len (if (false? len) 0 (months-count len))) (end (and ($ end element) (date->month ($ end element)))) (end (or end (+ start len -1)))) end)) (define (get-first-after element jobs) (let* ( (afters (get-afters element jobs)) (result (if (and afters (not-empty? (cleanmap afters))) (apply min (map (λ (x) ($ _order (first x))) afters)) #f))) result)) ;;; Gantt by days (define-catch (draw-gantt tabtree-file path svg-width svg-height #:tick-dates (tick-dates 'all) #:tracks (tracks-description-path "root.tracks")) (let* ((tabtree (parse-tab-tree tabtree-file)) (path (split path ".")) (tracks (get-$3 (split tracks-description-path ".") tabtree)) (jobs (get-$3 path tabtree)) (start-times (map (λ (x) (get-start-time x jobs)) jobs)) (end-times (map (λ (x) (get-end-time x jobs)) jobs)) (min-start-time (apply min (map date->days start-times))) (max-end-time (apply max (map date->days end-times))) (days-length (+ 3 (- max-end-time min-start-time))) (step (/f svg-width days-length)) (users-list empty) ) (g (str ; ticks (for/fold ((res "")) ((tick (range 0 (inc days-length)))) (let* ((aday (+ min-start-time tick)) (adate (days->date aday)) (full-adate (days->date aday #:year #t)) (is-leap-year? (leap-year? (->number (third (split full-adate "."))))) (adate-day (->number (first (split adate ".")))) (adate-month (second (split adate "."))) (adate-month-abbr (string-titlecase (month-name adate-month #:lang 'ru))) (first-day? (equal? 1 adate-day)) (adate (->string adate-day)) (canvas-height (- svg-height 50)) (y1 20)) (str res "\n" (line 'stroke "grey" 'stroke-width "1" 'opacity 0.5 'x1 (* step tick) 'y1 y1 'x2 (* step tick) 'y2 (+ y1 canvas-height)) "\n" (when (holiday? (days->date aday #:year #t)) (rect 'x (* step tick) 'y y1 'width step 'height canvas-height 'class "holiday-bg")) "\n" ; today (when (equal? (current-date) full-adate) (rect 'x (* step tick) 'y y1 'width step 'height canvas-height 'class "today-bg")) (when first-day? (g (line 'stroke "grey" 'stroke-width "1" 'opacity 0.8 'x1 (* step tick) 'y1 (- y1 25) 'x2 (* step tick) 'y2 (+ y1 canvas-height)) (text (@ 'x (+ (* 0.5 step) (* step tick)) 'y 12 'class "month-byday") adate-month-abbr))) (when (or (equal? tick-dates 'all) (indexof? (map ->string '(1 3 5 7 10 12 15 17 20 23 25 27 29)) adate)) (text (@ 'x (+ (* 0.5 step) (* step tick)) 'y 33 'class "labels") adate)) "\n" ))) ; bars (for/fold ((res "")) ((job jobs) (i (in-naturals))) (let* ( (track ($ track job)) (track (and track (car (split track ",")))) (color (or ($ color (@id track tracks)) ($ color (@id "Unknown" tracks)))) (_ (--- color)) (color (if (equal? ($ status job) "done") "#bbb" color)) ; (color/shadow (color/desaturate color -55) 15) (start-date (get-start-time job jobs)) (end-date (get-end-time job jobs)) (start (- (date->days start-date) min-start-time)) (end (- (date->days end-date) min-start-time)) (x1 (* step start)) (x2 (* step (inc end))) ; make the end day inclusive (width (- x2 x1)) (y (* track-h i)) (min_order (apply min (map (λ (x) ($ _order x)) jobs))) (first-after (get-first-after job jobs)) (y-first-after (if first-after (* track-h (- first-after min_order)) #f)) (h (- track-h 3)) ) (str res "\n" (g (@ 'transform (format "translate(0,~a)" y0)) ; convergence line (when y-first-after (str (line 'x1 x1 'y1 (+ y h) 'x2 x1 'y2 y-first-after 'class "convergence_line") "\n")) ; bar (title (or ($ title job) ($ goal job))) (rect 'x x1 'y y 'width width 'height h 'fill color 'opacity 0.6) "\n" ; (text (@ 'x (+ x 6) 'y (+ y 18) 'class "job_title_shadow") (namefy ($ id job))) "\n" (text (@ 'x (+ x1 5) 'y (+ y (/ track-h 2.0) 2) 'class "job_title") (namefy ($ id job))) "\n" ) ) )) ; legend ; (for/fold ; ((res "")) ; ((user users-list) (i (in-naturals))) ; (str ; res "\n" ; (rect 'x (* i 100) 'y (- svg-height 20) 'width 20 'height 10 'fill (list-ref (rest colors) i)) ; (text (@ 'x (+ 25 (* i 100)) 'y (- svg-height 10)) user))) )))) ;;; Gantt by months (define-catch (draw-longtime-gantt tabtree-file path svg-width svg-height #:ticks (ticks 'all) #:legend (legend #f)) (let* ((tabtree (parse-tab-tree tabtree-file)) (path (split path ".")) (jobs (get-$3 path tabtree)) (start-months (map (λ (x) (get-start-month x jobs)) jobs)) (end-months (map (λ (x) (get-end-month x jobs)) jobs)) (initial-month ($ start (get-$2 path tabtree))) (initial-month (if (equal? initial-month "<current>") (current-date) initial-month)) (min-start-month (if initial-month (date->month initial-month) (apply min (map ->number start-months)))) (max-end-month (apply max (map ->number end-months))) (months-length (- max-end-month min-start-month -2)) (step (/f svg-width months-length)) (users-list empty) ; geometry (header-height 50) (footer-height 20) (y0 header-height) ; upper part height (canvas-height (- svg-height header-height footer-height)) (y1 (- y0 25)) ; where top labels start (bottom-y (+ header-height canvas-height footer-height)) (y2 bottom-y) ) (g (str ; ticks (for/fold ((res "")) ((tick (range 0 (inc months-length)))) (let* ( (amonth (+ min-start-month tick)) (first-month? (= 1 (remainder amonth 12))) (month-abbr (month-name amonth #:lang 'ru)) (month-abbr (string-titlecase month-abbr))) (str res "\n" (g (@ 'class "ticks") (line 'stroke "grey" 'stroke-width "1" 'opacity 0.3 'x1 (* step tick) 'y1 (+ y1 (* (- y0 y1) 0.5)) 'x2 (* step tick) 'y2 (+ y0 canvas-height)) "\n" (when (odd? amonth) (rect 'x (* step tick) 'y y0 'width step 'height canvas-height 'class "odd-bg")) "\n" ; today (when (equal? (current-month) amonth) (rect 'x (* step tick) 'y y1 'width step 'height canvas-height 'class "even-bg")) (when first-month? (g (text (@ 'x (+ (* step tick) (* step 6)) 'y 20 'class "year") (->string (month->year amonth))) (line 'stroke "grey" 'stroke-width "1" 'opacity 0.8 'x1 (* step tick) 'y1 y1 'x2 (* step tick) 'y2 (+ y0 canvas-height)))) (when (equal? ticks 'all) (text (@ 'x (+ (* 0.5 step) (* step tick)) 'y (- y0 7) 'class "month") month-abbr)) (when (and (equal? legend 'my-age) (equal? (month-name amonth) "august")) (text (@ 'x (+ (* 0.5 step) (* step tick)) 'y y2 'class "age") (->string (- (month->year amonth) 1979)))) "\n" )))) (line 'stroke "grey" 'stroke-width "1" 'opacity 0.3 'x1 0 'y1 y0 'x2 (* step (inc months-length)) 'y2 y0) "\n" ; bars (for/fold ((res "")) ((job jobs) (i (in-naturals))) (let* ( (user ($ user job)) (user (and user (car (split user ",")))) (_ (set! users-list (if (indexof? users-list user) users-list (pushr users-list user)))) (color (if user (list-ref colors (indexof users-list user)) (list-ref colors 0))) (color (if (empty? (filter true? users-list)) (list-ref colors 1) color)) (color (if (equal? ($ status job) "done") "#bbb" color)) ; (color/shadow (color/desaturate color -55) 15) (start-month (get-start-month job jobs)) (end-month (get-end-month job jobs)) (start (- start-month min-start-month)) (end (- end-month min-start-month)) (x1 (* step start)) (x2 (* step (inc end))) (width (- x2 x1)) (y (* track-h i)) (min_order (apply min (map (λ (x) ($ _order x)) jobs))) (first-after (get-first-after job jobs)) (y-first-after (if first-after (* track-h (- first-after min_order)) #f)) (h (- track-h 5)) ) (str res "\n" (g (@ 'transform (format "translate(0,~a)" y0)) ; convergence line (when y-first-after (str (line 'x1 x1 'y1 (+ y h) 'x2 x1 'y2 y-first-after 'class "convergence_line") "\n")) ; bar (title ($ title job)) (rect 'x x1 'y y 'width width 'height h 'fill color 'opacity 0.6) "\n" ; (text (@ 'x (+ x 6) 'y (+ y 18) 'class "job_title_shadow") (namefy ($ id job))) "\n" (text (@ 'x (+ x1 5) 'y (+ y (/ track-h 2.0) 2) 'class "job_title") (namefy ($ id job))) "\n" ) ) )) ; legend ; (for/fold ; ((res "")) ; ((user users-list) (i (in-naturals))) ; (str ; res "\n" ; (rect 'x (* i 100) 'y (- svg-height 20) 'width 20 'height 10 'fill (list-ref (rest colors) i)) ; (text (@ 'x (+ 25 (* i 100)) 'y (- svg-height 10)) user))) ))))
false
78dcae802723b180e430f5633287ac5d78a33590
633b68f9fae15634d26d770b31923228f1043406
/brownpl/interpreter/xinterp.rkt
c117818d484cfcb6b32b86de6eedc450bb3a84f0
[]
no_license
chriscnc/plai
10e6699c7848946ed6dd2a014bfbb21aca37f83e
25f767332c4446f632dc05ac7aa7fe04290bb5be
refs/heads/master
"2020-05-20T12:27:35.843026"
"2016-11-11T01:57:31"
"2016-11-11T01:57:31"
70,285,926
0
0
null
null
null
null
UTF-8
Racket
false
false
6,594
rkt
xinterp.rkt
#lang plai-typed (print-only-errors true) (define-type Binding [binding (name : symbol) (named-expr : CFWAE)]) (define-type CFWAE [num (n : number)] [binop (op : symbol) (lhs : CFWAE) (rhs : CFWAE)] [with (lob : (listof Binding)) (body : CFWAE)] [id (name : symbol)] [if0 (c : CFWAE) (t : CFWAE) (e : CFWAE)] [fun (args : (listof symbol)) (body : CFWAE)] [app (f : CFWAE) (args : (listof CFWAE))]) (define-type Env [mtEnv] [anEnv (name : symbol) (value : CFWAE-Value) (env : Env)]) (define-type CFWAE-Value [numV (n : number)] [closureV (params : (listof symbol)) (body : CFWAE) (env : Env)]) (define (extend-env [b : Binding] [env : Env]) : Env (let ([name (binding-name b)] [expr-val (interp (binding-named-expr b) env)]) (anEnv name expr-val env))) ;; parse : expression -> CFWAE ; This procedure parses an expression into a CFWAE (define (parse [sexp : s-expression]) : CFWAE (cond [(s-exp-number? sexp) (num (s-exp->number sexp))] [(s-exp-symbol? sexp) (id (s-exp->symbol sexp))] [(s-exp-list? sexp) (let ([sl (s-exp->list sexp)]) (if (s-exp-list? (first sl)) (app (parse (first sl)) (map parse (rest sl))) (case (s-exp->symbol (first sl)) [(+) (binop '+ (parse (second sl)) (parse (third sl)))] [(-) (binop '- (parse (second sl)) (parse (third sl)))] [(*) (binop '* (parse (second sl)) (parse (third sl)))] [(/) (binop '/ (parse (second sl)) (parse (third sl)))] [(if0) (if0 (parse (second sl)) (parse (third sl)) (parse (fourth sl)))] [(fun) (let ([args (s-exp->list (second sl))] [body (parse (third sl))]) (fun (map s-exp->symbol args) body))] [(with) (let* ([id-expr-pairs (s-exp->list (second sl))] [bindings (map pair->Binding id-expr-pairs)] [body (parse (third sl))]) (with bindings body))] [else (app (parse (first sl)) (map parse (rest sl)))] )))] [else (error 'parse "Parse error")])) (define (pair->Binding [pair : s-expression]) : Binding (let ([id (first (s-exp->list pair))] [expr (second (s-exp->list pair))]) (binding (s-exp->symbol id) (parse expr)))) (define (lookup-op [op-sym : symbol]) : (number number -> number) (case op-sym ['+ +] ['- -] ['* *] ['/ /] [else (error 'lookup-op "Invalid operation")])) (define (lookup-env [name : symbol] [env : Env]) : CFWAE-Value (type-case Env env [mtEnv () (error 'lookup-env "Symbol not found")] [anEnv (n v e) (if (symbol=? name n) v (lookup-env name e))])) ;;(define-type CFWAE ;; [app (f : CFWAE) (args : (listof CFWAE))]) ;; interp : CFWAE -> CFWAE-Value ;; This procedure evaluates a CFWAE expression, producing a CFWAE-Value. (define (interp [expr : CFWAE] [env : Env]) : CFWAE-Value (type-case CFWAE expr [num (n) (numV n)] [id (name) (lookup-env name env)] [binop (op-sym lhs rhs) (let ([op-f (lookup-op op-sym)] [lhs-val (interp lhs env)] [rhs-val (interp rhs env)]) (if (and (numV? lhs-val) (numV? rhs-val)) (if (zero? (numV-n rhs-val)) (error 'binop "Division by zero") (numV (op-f (numV-n lhs-val) (numV-n rhs-val)))) (error 'binop "Arguments not numbers")))] [if0 (c t e) (let ([c-val (interp c env)]) (if (numV? c-val) (if (zero? (numV-n c-val)) (interp t env) (interp e env)) (error 'if0 "test expression not a number")))] [with (lob body) (let* ([names (map binding-name lob)] [unique-names (distinct names)]) (if (equal? (length names) (length unique-names)) (let ([new-env (foldr extend-env env lob)]) (interp body new-env)) (error 'with "duplicate binding")))] [fun (args body) (closureV args body env)] [app (f args) (let* ([c (interp f env)] [params (closureV-params c)] [body (closureV-body c)] [c-env (closureV-env c)]) (if (equal? (length args) (length params)) (let* ([bindings (map2 binding params args)] [new-env (foldr extend-env env bindings)]) (interp body new-env)) (error 'app "wrong number of args")))] )) (define (distinct [lst : (listof 'a)]) : (listof 'a) (letrec ([f (lambda (lst acc) (cond [(empty? lst) acc] [else (if (member (first lst) acc) (f (rest lst) acc) (f (rest lst) (cons (first lst) acc)))]))]) (reverse (f lst (list))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; tests ;; testing helper (define (eval x) (interp (parse x) (mtEnv))) ;; test interpreter (test (numV 42) (eval '42)) (test (numV 9) (eval '{/ {+ {* 4 4} {- 4 2}} 2})) (test/exn (eval '{/ 7 0}) "Division by zero") ;; need tests for when you pass non-number args to a binop (test (numV 1) (eval '{if0 0 1 2})) (test (numV 2) (eval '{if0 1 1 2})) ;(test/exn (parse '{if0 {fun {x} {x}} 1 2}) "test expression not a number") (test (numV 7) (eval '{with {{x 2} {y 3}} {with {{z {+ x y}}} {+ x z}}})) (test/exn (eval '{with {{x 2} {x 3}} {+ x 2}}) "duplicate binding") (test (numV 42) (eval '{with {{f {fun {x} x}}} {f 42}})) (test (numV 6) (eval '{{fun {x y} {* x y}} 2 3})) (test/exn (eval '{{fun {x} x} 42 32}) "wrong number of arg") ;; test distinct (test (list 'a 'b) (distinct (list 'a 'a 'b 'b))) ;; test lookup-op (test 3 ((lookup-op '+) 1 2)) (test 3 ((lookup-op '-) 4 1)) (test 3 ((lookup-op '*) 1 3)) (test 3 ((lookup-op '/) 9 3)) ;; test lookup-env (test/exn (lookup-env 'x (mtEnv)) "Symbol not found") (test (numV 42) (lookup-env 'x (anEnv 'x (numV 42) (mtEnv)))) (test (numV 42) (lookup-env 'x (anEnv 'x (numV 42) (anEnv 'x (numV 32) (mtEnv))))) (test (numV 24) (lookup-env 'y (anEnv 'x (numV 42) (anEnv 'y (numV 24) (mtEnv))))) ;; test parse (test (num 42) (parse '42)) (test (binop '+ (num 42) (num 42)) (parse '{+ 42 42})) (test (binop '- (num 42) (num 42)) (parse '{- 42 42})) (test (binop '* (num 42) (num 42)) (parse '{* 42 42})) (test (binop '/ (num 42) (num 42)) (parse '{/ 42 42})) (test (if0 (num 0) (num 1) (num 2)) (parse '{if0 0 1 2})) (test (if0 (num 0) (num 1) (num 2)) (parse '{if0 0 1 2})) (test (if0 (fun (list 'x 'y) (binop '* (id 'x) (id 'y))) (num 1) (num 2)) (parse '{if0 {fun {x y} {* x y}} 1 2})) (test (fun (list 'x 'y) (binop '+ (id 'x) (id 'y))) (parse '{fun {x y} {+ x y}})) (test (with (list (binding 'x (num 1)) (binding 'y (num 2))) (binop '+ (id 'x) (id 'y))) (parse '{with {{x 1} {y 2}} {+ x y}})) (test (app (id 'f) (list (num 1) (num 2))) (parse '{f 1 2}))
false
caac82caa227d81bd2e0abb42e07a0b489edf497
2bf8a26fa490c5e41d3ef85601bae134d4f35660
/Homework/hw6_1.rkt
65d0d629d8ff91b31884103d518821a7deb2e7d8
[]
no_license
TotalChest/Doctor
a9e5c7af842141bef5750732273b85d48c8d8008
10313f3ce6824358455c9af054af373f0a9ccbaa
refs/heads/master
"2023-01-27T11:13:28.403948"
"2020-12-08T09:52:06"
"2020-12-08T09:52:06"
293,253,623
0
0
null
null
null
null
UTF-8
Racket
false
false
1,106
rkt
hw6_1.rkt
#lang scheme/base (require scheme/mpair) (define (make-queue) (mcons 'queue '()) ) (define (queue? q) (and (mpair? q) (eq? 'queue (mcar q)) ) ) (define (empty-queue? q) (and (queue? q) (null? (mcdr q)) ) ) (define (insert-queue! q e) (if (queue? q) (set-mcdr! q (mcons e (mcdr q))) q ) ) (define (front-queue q) (if (and (queue? q) (not (empty-queue? q))) (let loop ((curr (mcdr q))) (if (null? (mcdr curr)) (mcar curr) (loop (mcdr curr)) ) ) "empty queue" ) ) (define (delete-queue! q) (if (and (queue? q) (not (empty-queue? q))) (let loop ((curr q) (next (mcdr q))) (if (null? (mcdr next)) (set-mcdr! curr '()) (loop (mcdr curr) (mcdr next)) ) ) q ) ) (define A (make-queue)) (queue? A) (empty-queue? A) A (insert-queue! A 10) A (insert-queue! A 20) (insert-queue! A 4) A (front-queue A) (front-queue A) (delete-queue! A) A (delete-queue! A) A
false
3310d4804096210f6e4bdc1a627e0533463122c8
cfdfa191f40601547140a63c31e933b16323cf84
/racket/monadic-eval/units/sto-set-unit.rkt
3b6f41efe35303fb997ef10281d617bd322eb5c6
[]
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
772
rkt
sto-set-unit.rkt
#lang racket/unit (require racket/match racket/set "../signatures.rkt" "../store.rkt" "../syntax.rkt") (import monad^ return-vals^ return-ans^) (export env^ sto^ ref^) (define ext hash-set) (define (update-sto s a v) (hash-set s a (set v))) (define ((get r x) σ) ((return-vals (lookup σ r x)) σ)) (define ((alloc f v) s) (match f [(cons (lam x e) r) (define a (next s)) (return-ans a (join-sto s a v))])) (define ((ralloc x e ρ) s) (define a (next s)) (return-ans a (join-sto s a (cons e (hash-set ρ x a))))) (define ((new v) s) (define a (next s)) (return-ans a (join-sto s a v))) (define ((sbox a v) s) (return-ans a (update-sto s a v))) (define ((ubox a) s) ((return-vals (lookup-sto s a)) s))
false
3d64b0212849a8bbea37d2fb33aa2f7c24cf623b
b08b7e3160ae9947b6046123acad8f59152375c3
/Programming Language Detection/Experiment-2/Dataset/Train/Racket/number-names.rkt
e7501685476ef10887b7f80d7faecbd8343a9b1f
[]
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,562
rkt
number-names.rkt
#lang racket (define smalls (map symbol->string '(zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen))) (define tens (map symbol->string '(zero ten twenty thirty forty fifty sixty seventy eighty ninety))) (define larges (map symbol->string '(thousand million billion trillion quadrillion quintillion sextillion septillion octillion nonillion decillion undecillion duodecillion tredecillion quattuordecillion quindecillion sexdecillion septendecillion octodecillion novemdecillion vigintillion))) (define (integer->english n) (define (step div suffix separator [subformat integer->english]) (define-values [q r] (quotient/remainder n div)) (define S (if suffix (~a (subformat q) " " suffix) (subformat q))) (if (zero? r) S (~a S separator (integer->english r)))) (cond [(< n 0) (~a "negative " (integer->english (- n)))] [(< n 20) (list-ref smalls n)] [(< n 100) (step 10 #f "-" (curry list-ref tens))] [(< n 1000) (step 100 "hundred" " and ")] [else (let loop ([N 1000000] [D 1000] [unit larges]) (cond [(null? unit) (error 'integer->english "number too big: ~e" n)] [(< n N) (step D (car unit) ", ")] [else (loop (* 1000 N) (* 1000 D) (cdr unit))]))])) (for ([n 10]) (define e (expt 10 n)) (define r (+ (* e (random e)) (random e))) (printf "~s: ~a\n" r (integer->english r)))
false
ad0ae617c93bcff1590935723fda3a85c237fffb
51a53a16e2ab9fe5cfae68b5710788db7d9dd1f3
/examples/ancestors-alist.rkt
098f2264bfdb325871e2aad0502124530b6b9e5a
[]
no_license
spdegabrielle/inference
09b41c4af9cfee2be36c3a20bdcbed551f69f87c
b407fd29d0a82f3262ddd9ced3259117b9448f40
refs/heads/master
"2021-01-20T05:54:24.793208"
"2013-10-14T20:19:09"
"2013-10-14T20:19:09"
null
0
0
null
null
null
null
UTF-8
Racket
false
false
1,661
rkt
ancestors-alist.rkt
#lang scheme/base ;;; PLT Scheme Inference Collection ;;; ancestors-alist.ss ;;; ;;; Ancestors is a trivial knowledge-based system that determines ;;; a given person's ancestors based on asserted parent relationships. (require (planet williams/inference/inference)) (define-ruleset ancestors-ruleset) (define-rule (initialize ancestors-ruleset) (?start <- (start)) ==> (retract ?start) (printf "Please enter the first name of a~n") (printf "person whose ancestors you would~n") (printf "like to find:~n") (assert `(request ,(read)))) (define-rule (print-ancestors ancestors-ruleset) (?request <- (request ?name)) (parents ?name (mother . ?mother) (father . ?father)) ==> (retract ?request) (when ?mother (printf "~a is an ancestor via ~a~n" ?mother ?name) (assert `(request ,?mother))) (when ?father (printf "~a is an ancestor via ~a~n" ?father ?name) (assert `(request ,?father)))) (define-rule (remove-request ancestors-ruleset #:priority -100) (?request <- (request ?)) ==> (retract ?request)) (define (find-ancestors) (with-new-inference-environment (activate ancestors-ruleset) (assert '(parents penelope (mother . jessica) (father . jeremy))) (assert '(parents jessica (mother . mary-elizabeth) (father . homer))) (assert '(parents jeremy (mother . jenny) (father . steven))) (assert '(parents steven (mother . loree) (father . john))) (assert '(parents loree (mother . #f) (father . jason))) (assert '(parents homer (mother . stephanie) (father . #f))) (start-inference))) (find-ancestors)
false
e8a33fa64d14d76300a3eddf6690cb91e7a42afe
6a47ed441de05bc9aea4d1f31d5e04e7c6c51d17
/typed-racket-lib/typed-racket/language-info.rkt
56b7e99ad5162c2b13a98122f0b0dddf5696380f
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jbclements/typed-racket
4050f63544d83b52afe8fc2b93a448f9a008ff90
1e4c236e187711c44b1660ba6e4b8938ce50cae9
refs/heads/master
"2022-06-04T01:08:16.687724"
"2022-05-05T05:50:29"
"2022-05-05T05:50:29"
228,487,098
0
0
NOASSERTION
"2019-12-16T22:27:55"
"2019-12-16T22:27:54"
null
UTF-8
Racket
false
false
538
rkt
language-info.rkt
#lang racket/base (require typed-racket/typed-reader) (provide get-info configure) (define ((get-info arg) key default) (case key [(configure-runtime) `(#(typed-racket/language-info configure ()))] [else default])) ;; options currently always empty (define (configure options) (namespace-require 'racket/base) (eval '(begin (require (for-syntax typed-racket/utils/tc-utils racket/base)) (begin-for-syntax (set-box! typed-context? #t))) (current-namespace)) (current-readtable (readtable)))
false
0509f81eb0edfc24bb4bd3e6f8adb3dde077ca48
2868e93c35545b9462fa30a45ed03e0a4f9bbb1d
/data/6.2/acquire-2016-04-23T12:21:54.rktd
5dbfb1fdff1f453e38597411380058c3ec3cbcb8
[]
no_license
sabauma/gradual-typing-performance
125df5cc82c2ab66b6ff408b02e88922d587fa03
8b15eefdb3fb029b899fb0538535e411a3060ab0
refs/heads/master
"2020-04-05T23:23:44.364157"
"2016-10-13T16:32:45"
"2016-10-13T16:32:45"
51,944,336
0
0
null
"2016-02-17T18:16:48"
"2016-02-17T18:16:48"
null
UTF-8
Racket
false
false
25,937
rktd
acquire-2016-04-23T12:21:54.rktd
;; #(-j 25 -r /home/ben/code/racket/6.2/bin benchmarks/acquire) ;; 6.2 ;; base @ <unknown-commit> ;; typed-racket @ 67cc0ca1 ;; TODO incomplete! #( (211 207 207 217 208 208 206 208 209 207 207 205 205 206 208 212 210 205 208 208 209 208 207 212 204 213 208 208 213 215 210) (420 429 420 446 413 428 422 406 417 414) (243 236 234 243 238 248 248 242 248 245) (433 425 433 438 448 433 424 429 447 427) (433 438 434 450 446 444 423 433 423 440) (598 577 601 605 620 604 605 602 614 595) (454 445 436 431 436 442 438 435 436 434) (608 614 608 619 613 621 599 591 595 595) (603 594 599 592 596 598 595 605 593 595) (793 768 769 751 763 764 762 760 757 762) (590 608 588 583 585 586 599 606 585 594) (760 773 748 731 765 761 761 762 755 752) (741 737 740 724 727 731 722 739 721 725) (882 887 886 893 887 883 886 886 872 850 868 881 877 872 885 866 871 847 884 877 879 853 886 880 869 884 880 892 887 900 897) (720 713 726 722 700 712 712 714 728 724) (868 880 869 889 888 877 857 883 871 881) (629 628 629 626 630 618 625 637 611 636) (807 784 791 796 793 787 800 787 782 769) (641 633 653 640 635 638 634 623 623 635) (795 787 791 794 788 792 798 782 810 809) (755 763 754 755 749 741 768 767 744 767) (1126 1115 1088 1107 1116 1100 1107 1115 1142 1141) (911 934 931 931 936 921 899 916 919 950) (1108 1118 1120 1128 1125 1132 1132 1122 1127 1147) (514 508 496 513 478 508 507 483 507 506) (730 722 697 738 729 747 733 728 726 706) (504 491 502 488 502 499 505 513 505 512) (721 716 709 718 705 707 722 689 711 721) (677 667 683 675 673 671 664 674 674 666) (868 873 878 867 867 874 869 862 868 856) (671 666 670 670 673 659 660 661 667 674) (857 870 878 872 875 859 868 873 873 875) (332 331 332 337 306 336 331 330 325 338 336 325 331 334 333 325 336 331 329 339 335 310 328 329 331 334 328 342 339 337 329) (545 542 556 545 542 554 550 549 512 550 549 523 557 552 552 555 527 556 562 556 546 535 543 554 562 559 550 554 536 550 555) (347 344 348 347 348 351 352 350 355 347) (546 566 548 554 563 559 558 544 563 556) (521 514 513 500 519 517 519 519 512 519) (722 724 723 732 721 714 729 718 718 722) (509 519 532 535 530 530 535 526 531 529) (711 732 731 734 723 731 728 737 737 740) (787 783 770 772 775 773 762 765 764 772) (943 995 975 980 977 948 964 971 980 959) (765 778 779 789 778 770 753 752 783 770) (987 967 978 974 969 971 970 969 966 952) (871 864 892 895 890 865 885 892 890 864) (1050 1054 1085 1086 1085 1029 1094 1089 1081 1036) (878 878 875 877 901 893 876 864 867 877) (1079 1075 1056 1058 1044 1065 1060 1046 1070 1049) (786 799 780 789 772 767 801 796 798 812) (979 999 990 991 969 997 994 985 991 1016) (813 807 809 789 818 793 792 814 824 800) (1017 1031 1033 1009 1006 1008 994 995 992 1002) (922 901 903 899 905 900 888 908 912 916) (1097 1103 1094 1112 1082 1095 1108 1093 1109 1121) (937 954 900 928 932 950 922 940 924 924) (1106 1104 1120 1132 1104 1113 1090 1100 1132 1131) (559 557 543 543 555 534 560 563 553 570) (737 741 731 734 747 731 753 761 760 744) (540 544 560 548 541 537 539 541 549 547) (741 741 723 745 745 735 746 749 739 744) (657 643 647 647 660 652 648 647 657 664) (862 859 852 675 671 677 678 677 681 679 678 673 670 673 674 673 667 675 676 671 670 667 666 670 659 633 638 635 635 636 634) (488 487 485 489 490 478 487 484 484 485) (865 865 848 861 862 852 879 888 871 870) (294 290 287 292 290 294 290 295 292 273 288 272 293 280 294 293 294 286 291 289 294 286 273 285 270 290 289 294 288 286 295) (519 531 530 529 515 532 534 526 499 527) (312 309 309 297 305 306 306 305 308 307) (537 541 534 543 542 542 532 543 532 540) (537 537 534 539 548 547 539 542 531 549) (735 731 737 757 755 774 740 744 754 754) (551 557 532 562 550 539 548 560 554 554) (747 748 734 750 760 745 761 768 768 759) (745 730 727 731 725 750 725 746 741 727) (946 954 949 944 948 942 951 943 957 951) (732 733 732 723 730 704 706 715 728 722) (947 964 940 947 939 943 943 942 942 947 931 923 943 933 953 956 946 959 943 967 950 962 942 925 930 940 918 939 934 935 943) (901 885 910 901 914 896 895 900 890 880) (1097 1088 1063 1088 1107 1085 1057 1067 1052 1061) (872 844 856 846 859 868 859 844 857 880) (1058 1070 1058 1040 1058 1085 1085 1081 1057 1084) (802 793 784 790 776 773 767 788 790 784) (1003 1008 987 988 977 990 996 990 991 995) (784 807 805 815 797 779 806 785 785 792) (991 984 1013 1010 993 989 991 988 990 986 996 988 977 986 987 776 787 782 777 779 779 774 753 778 783 749 739 734 744 745 737) (966 970 933 981 976 956 960 953 934 937) (1145 1121 1153 1152 1155 1130 1141 1130 1158 1151) (969 961 969 966 968 970 969 970 957 988) (1210 1158 1183 1204 1147 1143 1176 1191 1164 1155) (486 488 497 493 490 486 473 477 478 482) (723 709 689 705 702 692 706 700 684 686) (484 482 493 489 490 478 472 484 483 469) (711 713 721 697 674 690 703 688 715 676) (665 660 659 656 662 652 649 649 649 636) (842 852 838 844 836 841 842 840 850 866) (643 616 645 642 647 646 643 636 650 653) (845 848 844 842 834 838 842 820 838 846) (267 312 307 308 303 290 306 306 305 303 294 300 308 301 306 310 293 303 306 301 305 302 308 309 308 315 304 297 304 304 308) (550 519 540 529 541 534 544 543 533 528) (320 323 321 323 318 304 314 321 326 321) (537 539 523 542 540 532 545 529 526 529) (489 499 503 469 502 502 479 500 499 488) (685 696 706 696 702 687 689 695 681 702) (515 491 505 506 499 515 499 504 482 503) (701 697 701 699 711 678 701 703 701 718) (735 728 739 734 731 728 731 724 729 741) (965 928 933 951 911 906 939 932 939 937) (743 740 747 739 749 743 747 697 735 726 716 721 751 739 755 748 746 749 735 747 748 749 734 737 724 739 716 734 726 731 715) (949 935 943 954 944 953 955 961 945 929) (867 858 841 851 841 838 826 844 851 843) (1054 1069 1032 1048 1069 1053 1070 1067 1056 1058) (852 864 860 848 828 859 844 840 807 843) (1037 1038 1030 1032 1028 1042 999 1018 1025 1038) (796 825 818 814 815 828 813 829 789 828) (1007 975 1009 1026 1001 1021 1021 1031 1020 1027) (809 805 853 840 835 834 819 841 838 799) (1042 1056 1036 1019 1011 1029 1029 1013 977 994) (923 941 960 940 951 927 939 936 938 931) (1135 1143 1127 1124 1106 1108 1107 1122 1105 1097) (922 917 942 920 920 935 922 930 935 921) (1113 1120 1144 1132 1104 1162 1126 1143 1109 1143) (486 502 505 494 505 500 495 470 500 500) (548 549 556 555 550 553 552 559 559 558) (396 394 387 392 396 395 398 394 382 393) (550 544 543 546 548 529 541 530 532 547) (455 458 456 453 452 454 454 457 453 445) (589 583 589 562 581 585 582 592 582 579) (587 604 593 594 601 576 587 607 609 601) (768 766 796 785 804 797 803 782 777 791) (263 266 269 261 270 272 266 268 271 267) (515 511 506 512 508 506 506 519 488 517) (289 290 293 284 289 292 294 295 290 291) (515 515 527 515 523 511 525 517 510 518) (503 513 512 503 514 496 507 509 502 513) (705 730 733 719 724 730 727 724 733 690) (507 523 507 508 521 530 528 514 524 526) (719 726 719 732 703 717 726 718 720 728) (714 730 720 731 732 716 728 716 720 709) (925 963 928 940 951 924 943 939 933 930) (737 721 726 734 732 723 727 724 712 723) (948 924 960 937 952 972 938 922 958 926) (862 859 875 857 845 878 845 878 882 858) (1050 1040 1053 1054 1067 1058 1053 1046 1082 1058) (844 845 838 831 824 850 846 855 852 837) (1036 1029 1041 1032 1043 1047 1044 1044 1050 1050) (761 762 764 772 757 767 749 748 760 746) (972 966 992 976 978 988 961 968 969 941) (759 760 766 745 774 759 766 780 774 764) (972 971 974 976 968 958 962 920 923 962 971 987 987 998 1003 948 944 1010 980 993 976 995 993 976 978 985 975 992 974 978 979) (931 914 913 906 922 903 909 906 922 913) (1125 1129 1114 1117 1079 1088 1105 1107 1127 1106) (932 929 957 908 915 920 935 925 912 926) (1134 1140 1122 1133 1115 1119 1116 1116 1122 1126) (502 509 513 515 502 519 507 506 494 510) (661 706 741 742 722 732 748 739 723 710) (503 490 506 487 504 508 500 504 492 503) (740 727 711 702 706 719 703 703 715 711) (645 628 623 625 635 631 624 631 624 639) (852 867 861 836 855 852 853 863 862 871) (622 626 586 632 628 628 616 614 630 625 623 620 617 632 625 612 624 632 634 643 625 638 646 631 628 630 637 624 632 633 628) (844 872 865 838 866 856 853 863 866 852) (333 306 336 330 340 338 338 331 323 327) (557 527 525 561 552 556 552 518 561 547) (356 356 358 336 356 356 347 349 356 357 355 351 355 352 357 352 354 353 350 335 350 355 358 350 347 344 352 355 348 361 344) (562 536 554 550 553 546 547 560 566 555) (517 524 510 484 512 512 503 518 504 504) (724 710 701 716 727 717 711 708 711 693) (525 517 505 520 516 508 522 507 509 516) (680 677 675 672 678 665 659 643 661 647) (773 773 783 770 801 790 788 787 792 784) (992 987 982 983 982 983 975 981 1002 996) (764 774 778 774 780 775 773 775 788 766) (987 967 970 984 962 970 1009 990 966 981) (867 871 868 829 846 872 872 882 859 879) (1063 1062 1067 1069 1072 1060 1075 1071 1067 1096) (880 864 872 870 859 874 879 861 857 872) (1043 1047 1048 1065 1049 1058 1043 1055 1069 1069) (805 798 797 812 801 802 808 805 808 818) (1007 991 1010 1020 1007 968 1015 1020 996 1015) (814 798 801 785 805 803 817 811 809 807) (1011 1012 1005 1022 1022 1005 994 985 1008 1026) (931 897 916 913 919 925 929 896 923 896) (1113 1124 1141 1091 1113 1078 1097 1085 1080 1083) (875 917 892 913 919 911 917 923 905 932) (1103 1093 1093 1107 1086 1078 1102 1098 1107 1130) (563 564 555 545 560 569 556 572 561 571) (755 761 756 761 765 774 767 767 779 792) (558 554 543 538 546 554 563 564 560 565) (723 737 743 741 728 754 766 736 759 758) (613 607 611 607 602 486 484 486 487 492 478 490 488 482 484 485 479 484 484 485 489 485 485 490 479 487 486 481 484 486 486) (854 864 872 850 861 870 876 862 861 876) (659 646 647 669 645 644 664 653 665 665) (872 851 869 873 859 855 869 843 847 834) (291 285 287 284 295 294 300 290 290 291) (505 542 529 536 499 535 535 533 537 521) (308 315 314 315 308 303 306 307 313 304) (538 532 545 539 550 541 552 540 540 545) (533 529 526 516 517 531 528 522 538 523) (715 729 713 731 735 724 747 755 726 727) (538 527 535 540 547 537 542 536 537 544) (737 743 740 736 736 741 745 731 745 749) (726 712 730 734 723 737 710 731 757 744) (924 947 953 950 949 926 946 947 949 979) (728 714 732 706 719 707 719 736 736 737) (958 924 960 961 944 924 934 930 952 941) (874 845 847 841 868 856 869 868 867 853) (1059 1071 1081 1071 1066 1033 1076 1055 1058 1013) (860 842 863 850 851 844 857 834 857 847) (1055 1049 1074 1052 1066 1073 1066 1106 1092 1099) (794 800 783 805 808 807 823 794 826 804) (999 998 1021 1001 1011 986 1006 998 1009 1019) (812 821 792 812 824 796 801 787 792 722) (1027 1026 1001 1013 1012 1016 1020 1024 1021 1006) (976 941 935 960 967 948 971 954 949 949) (1170 1179 1177 1115 1118 1091 1136 1134 1134 1146) (933 951 954 951 944 940 963 964 969 976) (1153 1168 1142 1196 1167 1168 1173 1148 1129 1151) (488 503 497 492 467 491 478 485 491 491) (708 693 711 712 700 702 697 699 701 697) (483 485 496 465 477 480 468 488 470 487) (720 713 685 702 708 708 699 700 667 691) (605 619 609 605 605 595 615 603 616 606) (806 836 835 816 823 823 842 828 835 837) (602 601 603 600 612 608 605 599 581 599) (834 827 828 827 813 834 835 830 812 854) (282 307 307 306 299 309 309 304 301 306 305 290 308 303 290 304 305 308 305 310 310 305 312 308 311 304 305 307 307 310 311) (520 538 536 531 538 541 539 537 548 548) (320 318 327 320 312 323 321 312 318 317) (551 535 548 548 522 551 534 540 542 542) (484 486 491 491 493 479 489 487 480 491) (654 692 686 687 680 680 683 694 687 683) (394 392 393 401 391 393 397 398 394 394) (693 689 685 697 682 680 626 657 695 686 674 688 696 690 693 693 692 692 685 687 695 682 682 677 686 686 671 678 679 694 691) (739 755 765 741 738 749 763 744 750 755) (970 953 964 954 938 968 940 942 939 940) (762 769 772 753 756 764 754 728 751 765) (945 956 952 941 945 929 898 944 949 956) (817 846 808 833 836 827 834 841 834 836) (1014 1008 998 1026 1032 1042 1036 1048 1025 1061) (823 830 833 837 822 814 829 843 819 847) (1002 1034 1025 1046 1041 1028 1024 1032 1031 1019) (813 831 813 827 837 836 846 827 830 801) (1018 1027 1026 996 1032 1049 1041 1030 1015 1038) (831 787 816 832 842 833 844 834 806 817) (1047 1036 1042 1051 1039 1039 1042 1039 1034 1034) (920 920 906 935 930 933 939 928 908 929) (1108 1128 1108 1096 1115 1116 1119 1114 1108 1127) (893 948 929 940 942 922 905 928 924 927) (1139 1108 1106 1118 1136 1125 1132 1120 1137 1107) (503 500 498 507 508 501 498 496 482 493) (666 663 664 671 674 669 672 676 673 662) (430 437 431 429 438 435 428 432 439 426) (606 620 610 614 557 483 489 491 491 482 490 489 485 487 462 461 460 468 464 465 460 464 458 462 464 464 463 464 466 457 470) (592 594 542 548 602 598 596 588 599 588 598 584 591 600 592 588 587 601 596 588 588 580 601 598 592 597 602 589 591 595 597) (791 786 793 788 794 803 792 790 779 802) (603 602 602 611 605 610 599 614 618 608) (782 793 787 797 781 814 776 790 771 796) (1059 1074 1063 1060 1037 1058 1084 1057 1089 1079) (1269 1266 1229 1260 1274 1262 1285 1285 1265 1296) (1074 1055 1094 1077 1089 1067 1063 1070 1073 1066) (1326 1295 1312 1304 1313 1268 1295 1304 1285 1291) (763 756 781 767 762 761 754 764 752 742) (991 991 1012 1019 997 990 988 987 993 967) (772 782 773 778 759 769 773 765 764 751) (1035 991 985 985 993 1002 1009 985 998 997) (1456 1447 1435 1453 1430 1435 1446 1448 1423 1400) (1700 1719 1712 1653 1700 1707 1623 1627 1619 1644) (1443 1445 1471 1431 1461 1492 1467 1447 1435 1442) (1667 1679 1680 1691 1683 1613 1697 1714 1656 1670) (1128 1116 1109 1126 1065 1093 1120 1131 1109 1103) (1306 1308 1325 1317 1329 1334 1299 1248 1275 1285) (1034 1019 1003 1025 1022 1014 1025 1009 1017 1008) (1202 1211 1188 1166 1107 1128 1121 1114 1130 1109) (1105 1110 1089 1090 1111 1096 1091 1090 1098 1096) (1492 1446 1451 1464 1444 1412 1400 1445 1446 1464) (1244 1281 1270 1281 1262 1290 1287 1261 1266 1264) (1506 1485 1508 1531 1496 1486 1498 1489 1501 1492) (970 959 957 974 965 959 978 960 959 974) (1178 1189 1179 1186 1158 1181 1173 1174 1158 1173) (993 988 978 1001 981 987 954 975 986 992) (1168 1195 1217 1164 1182 1195 1181 1197 1181 1178) (941 942 938 945 943 957 957 954 973 967) (1161 1154 1158 1168 1158 1143 1139 1158 1143 1156) (910 941 955 958 947 945 949 941 938 930) (1165 1178 1179 1148 1126 1163 1160 1128 1155 1167) (588 587 585 595 595 585 595 600 594 592) (804 802 799 811 828 801 804 814 793 773) (585 586 585 580 584 589 587 592 582 592) (766 791 789 790 785 795 786 797 801 789) (1081 1105 1117 1120 1113 1124 1084 1132 1110 1131) (1332 1319 1329 1335 1330 1322 1323 1336 1336 1327) (1150 1140 1153 1122 1110 1133 1097 1124 1113 1118) (1334 1292 1309 1326 1302 1321 1298 1308 1280 1232) (710 686 709 710 711 710 713 713 710 700 692 701 696 715 700 686 699 689 711 700 702 702 668 665 663 664 661 658 656 658 669) (881 875 879 864 853 884 854 835 859 861) (777 804 790 786 781 803 785 782 786 799) (1001 993 984 992 983 986 990 1005 1003 964) (1446 1472 1489 1469 1489 1461 1460 1464 1499 1505) (1666 1704 1689 1694 1722 1740 1698 1660 1735 1718) (1472 1476 1473 1501 1491 1504 1448 1469 1479 1475) (1698 1729 1728 1643 1707 1681 1688 1701 1670 1690) (1114 1126 1115 1107 1098 1095 1102 1104 1096 1101) (1291 1289 1302 1314 1269 1287 1284 1299 1308 1300) (1070 1100 1099 1096 1109 1120 1100 1079 1112 1103) (1303 1294 1303 1284 1260 1296 1297 1301 1288 1294) (1323 1300 1276 1318 1307 1305 1311 1290 1313 1278) (1519 1511 1513 1542 1525 1526 1494 1496 1500 1500) (1330 1329 1333 1312 1331 1330 1305 1306 1288 1307) (1507 1511 1516 1515 1530 1464 1461 1547 1508 1520) (952 952 979 933 958 935 964 978 965 969) (1167 1171 1158 1157 1179 1165 1171 1188 1132 1172) (950 926 896 896 913 907 935 887 910 915) (1066 1063 1075 1065 1074 1069 1074 1057 997 998 1003 1011 988 998 1008 1011 1030 1023 1053 1007 1018 1020 1039 1036 1008 993 1022 1022 1019 1012 1020) (642 648 653 644 652 648 650 645 648 639) (722 730 736 736 733 732 738 741 749 747) (616 616 612 607 606 610 617 609 614 611) (1210 1208 1194 1206 1173 1224 1232 1243 1230 1230) (608 603 609 598 586 592 595 600 610 573) (804 797 750 799 801 787 803 803 802 810 753 781 812 788 795 793 797 791 802 806 780 789 795 781 787 804 784 790 807 792 793) (598 583 568 598 574 599 594 569 584 581) (787 781 788 764 798 782 777 786 775 790) (1096 1095 1094 1082 1070 1100 1081 1085 1079 1090) (1351 1327 1331 1344 1332 1322 1330 1314 1319 1301) (1092 1094 1115 1127 1111 1082 1106 1118 1088 1126) (1334 1340 1322 1257 1341 1331 1307 1323 1347 1319) (778 781 774 772 773 761 772 774 762 769) (992 1033 1019 983 1029 1024 1012 1012 1002 1021) (798 791 782 790 787 793 801 785 799 784) (1004 1024 1040 1025 1005 993 1007 1010 1004 1024) (1451 1449 1467 1478 1471 1494 1469 1435 1449 1460) (1700 1690 1669 1709 1708 1641 1709 1688 1678 1615) (1492 1465 1483 1448 1411 1471 1466 1449 1456 1414) (1701 1660 1668 1645 1702 1686 1682 1618 1655 1655) (1103 1093 1121 1105 1101 1109 1104 1105 1100 1112) (1308 1320 1303 1292 1315 1269 1271 1297 1293 1295) (1114 1126 1070 1100 1104 1094 1092 1082 1071 1076) (1000 989 993 988 983 969 970 984 986 981) (1300 1227 1290 1275 1255 1247 1228 1237 1224 1241) (1489 1520 1513 1535 1528 1472 1482 1469 1471 1476) (1260 1313 1288 1258 1297 1291 1287 1285 1268 1267) (1485 1501 1504 1493 1498 1512 1529 1513 1511 1545) (970 953 963 979 971 951 959 975 990 979) (1168 1158 1183 1165 1154 1164 1190 1149 1168 1165) (980 976 971 972 1001 1005 961 986 986 993) (1154 1196 1193 1156 1176 1177 1158 1182 1178 1183) (968 948 952 947 974 936 943 973 968 954) (1170 1177 1134 1175 1188 1193 1190 1157 1154 1179) (950 944 938 954 967 953 944 919 949 965) (1165 1171 1170 1183 1194 1168 1114 1144 1171 1164) (587 589 599 585 572 589 582 590 587 587) (811 817 804 771 807 800 814 800 817 793) (581 584 556 579 587 573 576 575 574 577) (791 790 811 783 749 782 788 808 797 778) (1121 1123 1075 1119 1124 1125 1086 1125 1103 1113) (1312 1325 1324 1330 1308 1308 1342 1341 1316 1285) (1095 1122 1124 1141 1094 1117 1146 1135 1140 1106) (1313 1317 1322 1343 1352 1286 1325 1353 1361 1348) (734 724 728 742 736 708 736 726 732 732) (893 924 953 966 948 974 928 952 963 969) (702 738 757 751 741 749 763 740 726 731) (931 934 955 931 953 951 951 954 967 979) (1484 1474 1450 1438 1469 1415 1426 1449 1460 1456) (1688 1650 1656 1667 1637 1639 1666 1693 1700 1729) (1465 1443 1454 1426 1425 1427 1432 1465 1413 1438) (1698 1678 1640 1690 1665 1656 1659 1649 1678 1668) (1076 1064 1084 1029 1081 1072 1072 1047 1068 1066) (1279 1246 1277 1268 1290 1289 1262 1297 1278 1277) (1065 1086 1074 1061 1024 1062 1060 1062 1039 1057) (1269 1255 1240 1241 1216 1229 1250 1256 1229 1236) (1276 1289 1281 1285 1271 1275 1260 1303 1282 1286) (1487 1500 1485 1469 1489 1486 1472 1495 1489 1510) (1301 1293 1301 1264 1307 1301 1293 1307 1308 1295) (1500 1527 1528 1479 1499 1555 1527 1497 1512 1510) (963 943 918 946 955 939 964 938 949 952) (1177 1144 1137 1093 1160 1148 1157 1137 1139 1124) (949 967 949 944 940 943 953 943 947 935) (1146 1124 1107 1063 1116 1101 1105 1115 1110 1097) (701 696 709 686 702 703 695 682 709 706) (869 866 846 866 751 775 790 780 773 743) (945 948 943 957 949 960 949 946 950 950) (1163 1178 1167 1192 1182 1188 1187 1167 1187 1202) (572 564 572 551 545 569 566 571 569 557) (769 762 736 763 752 756 767 765 765 751) (549 566 551 561 543 534 543 527 554 551) (749 745 711 746 737 744 748 745 736 749 740 752 738 742 748 740 759 749 751 758 740 749 747 758 745 751 746 753 747 745 728) (1031 1014 1031 1032 1023 1033 1043 1064 1070 1016) (1290 1271 1270 1265 1277 1256 1262 1294 1282 1280) (1063 1078 1095 1052 1080 1088 1084 1097 1072 1072) (1339 1336 1307 1304 1317 1341 1281 1306 1317 1291) (730 735 747 742 740 755 758 772 744 733) (976 956 972 939 973 975 992 975 987 989) (730 765 744 747 721 764 754 729 742 755) (965 981 977 980 992 965 978 964 995 982) (1423 1470 1454 1441 1445 1404 1401 1410 1431 1422) (1681 1663 1665 1672 1621 1665 1670 1627 1657 1630) (1448 1476 1484 1416 1471 1399 1478 1431 1432 1434) (1686 1635 1677 1665 1661 1633 1717 1671 1669 1664) (1090 1063 1048 1112 1102 1105 1095 1092 1093 1071) (1268 1258 1286 1280 1299 1295 1317 1283 1294 1213) (1054 1045 1028 1058 1014 1059 1051 1026 1063 1059) (1230 1271 1266 1204 1228 1282 1281 1294 1265 1312) (1233 1259 1265 1242 1254 1257 1263 1264 1255 1258) (1491 1503 1458 1469 1459 1466 1430 1464 1475 1434) (1287 1291 1284 1288 1254 1270 1252 1259 1245 1257) (1501 1509 1510 1477 1474 1494 1453 1497 1498 1503) (956 963 971 966 967 961 959 953 931 963) (1195 1150 1147 1123 1151 1166 1177 1171 1162 1156) (955 975 979 962 959 951 956 965 971 968) (1164 1161 1172 1146 1191 1205 1169 1168 1167 1208) (943 937 932 940 933 923 939 946 957 940) (1182 1110 1136 1113 1153 1162 1168 1154 1156 1162) (945 942 950 950 955 933 937 950 950 934) (1152 1174 1176 1184 1166 1154 1164 1166 1154 1155) (580 580 576 575 578 578 589 579 582 587) (781 756 787 781 798 793 802 791 782 819) (577 574 576 563 546 582 576 550 567 578) (771 769 783 761 785 769 792 775 792 777) (1113 1097 1104 1121 1122 1113 1120 1133 1139 1120) (1344 1336 1336 1328 1315 1333 1329 1317 1337 1313) (1150 1145 1132 1141 1109 1142 1124 1127 1135 1132) (1322 1366 1339 1345 1349 1339 1302 1332 1312 1326) (724 718 753 748 697 751 752 742 753 705) (933 973 987 981 979 936 956 941 983 981) (796 778 766 793 768 780 772 796 792 783) (973 964 955 966 991 977 971 999 968 974) (1476 1458 1461 1463 1482 1430 1500 1509 1507 1511) (1688 1666 1697 1732 1666 1721 1718 1696 1713 1704) (1474 1463 1501 1534 1524 1461 1457 1492 1485 1487) (1743 1697 1637 1716 1689 1701 1682 1709 1684 1665) (1092 1116 1079 1087 1099 1081 1106 1089 1092 1083) (1280 1279 1283 1262 1244 1268 1267 1284 1268 1297) (1069 1098 1084 1081 1109 1082 1097 1063 1091 1097) (1277 1306 1298 1271 1262 1269 1279 1264 1286 1243) (1312 1311 1298 1320 1316 1308 1300 1310 1291 1266) (1457 1517 1546 1466 1488 1511 1506 1509 1509 1501) (1324 1321 1327 1324 1317 1309 1285 1304 1309 1292) (1518 1512 1500 1499 1524 1512 1522 1521 1517 1506) (956 954 955 948 945 946 952 962 958 959) (1146 1151 1150 1171 1146 1160 1183 1126 1150 1150) (834 756 757 756 746 740 723 760 754 750 754 756 750 752 755 731 737 739 737 737 744 742 742 739 729 737 737 737 738 740 738) (833 830 823 840 838 833 832 838 835 840) (647 632 638 648 639 608 606 608 606 609) (1122 1187 1134 1085 1138 1133 1137 1172 1192 1189) (1005 1002 971 960 919 992 983 984 989 970) (1171 1191 1167 1186 1171 1151 1152 1176 1183 1178) (574 571 584 576 555 585 560 576 576 580) (775 776 797 787 770 783 752 788 782 794) (570 567 570 565 556 578 575 563 573 557) (770 765 776 763 761 761 788 764 783 796) (1096 1117 1096 1090 1081 1071 1086 1088 1092 1066) (1304 1320 1327 1323 1330 1320 1283 1290 1320 1323) (1124 1120 1108 1081 1103 1103 1107 1099 1116 1090) (1315 1334 1306 1326 1340 1304 1306 1333 1308 1327) (753 760 761 745 759 724 761 767 745 762) (997 997 998 1021 1017 1001 993 985 1004 989) (769 771 762 794 780 778 740 773 774 761) (970 1014 1004 1001 996 991 1000 990 969 996) (1449 1480 1494 1469 1433 1466 1464 1458 1421 1445) (1629 1654 1658 1651 1652 1662 1663 1678 1704 1684) (1423 1448 1436 1446 1464 1457 1444 1486 1465 1466) (1660 1651 1659 1692 1682 1674 1675 1685 1695 1666) (1082 1105 1048 1119 1107 1123 1107 1094 1039 1100) (1251 1278 1285 1259 1281 1264 1242 1211 1243 1206) (1076 1057 1068 1094 1089 1081 1086 1079 1071 1048) (1277 1255 1263 1252 1262 1279 1295 1287 1292 1314) (1262 1256 1286 1258 1285 1274 1267 1268 1250 1274) (1514 1497 1487 1489 1492 1448 1462 1457 1500 1485) (1291 1309 1259 1272 1270 1277 1234 1284 1265 1262) (1534 1551 1525 1487 1496 1477 1482 1486 1431 1458) (951 958 969 980 949 949 931 952 949 947) (1173 1159 1163 1151 1141 1153 1171 1153 1162 1158) (985 978 976 966 928 984 984 995 970 965) (1157 1131 1161 1179 1163 1194 1176 1167 1178 1166) (932 938 956 952 952 947 956 947 962 949) (1142 1126 1142 1149 1180 1180 1166 1167 1183 1177) (936 916 958 948 955 961 948 963 949 951) (1152 1160 1158 1165 1190 1160 1173 1184 1186 1192) (575 570 576 565 583 578 580 594 570 575) (784 750 775 788 784 786 788 790 789 762 801 774 774 771 774 779 782 762 789 736 789 763 771 784 776 783 782 774 785 782 777) (570 566 576 567 552 571 569 550 567 566) (764 771 782 759 767 779 760 745 774 767) (1147 1142 1086 1106 1128 1112 1129 1082 1122 1112) (1330 1316 1272 1276 1292 1270 1244 1271 1297 1268) (806 813 813 813 811 778 803 803 812 802 803 810 807 798 772 806 803 806 813 795 805 809 804 803 802 800 808 802 796 788 804) (1266 1247 1278 1237 1161 1237 1271 1279 1282 1283) (693 667 662 697 689 695 678 692 702 694) (898 912 913 883 917 896 897 912 904 927) (690 700 695 701 688 670 701 698 701 721) (929 911 923 920 899 876 928 930 910 937) (1438 1402 1429 1418 1397 1419 1424 1434 1425 1404) (1658 1595 1615 1627 1614 1633 1592 1642 1650 1679) (1415 1411 1409 1413 1390 1394 1352 1116 1118 1080 1098 1118 1111 1113 1119 1130 1123 1122 1122 1109 1107 1110 1107 1110 1112 1109 1111 1111 1118 1117 1120) (1281 1279 1290 1263 1286 1285 1273 1271 1265 1269) (828 822 819 819 825 811 811 826 810 821) (969 964 971 967 968 974 969 959 966 968) (798 813 813 807 809 818 817 799 807 812) (957 947 943 945 948 960 943 947 951 953) (998 990 995 959 995 990 997 991 997 997 986 992 1004 998 992 995 987 989 950 994 994 999 998 996 990 993 979 985 988 995 968) (1145 1151 1149 1152 1142 1154 1149 1155 1153 1147) (1002 998 1010 994 997 984 990 1002 999 995) (1167 1170 1167 1148 1164 1165 1154 1160 1160 1154) (711 709 717 707 706 705 707 715 706 708) (867 864 861 851 863 874 866 871 872 865) (720 703 710 718 709 707 709 718 710 722) (830 856 854 846 855 852 849 853 852 850 844 847 844 815 842 841 829 824 820 821 789 818 815 822 816 819 817 818 807 808 817) (946 911 930 889 877 939 936 938 930 914) (1139 1114 1121 1116 1107 1113 1116 1101 1084 1122) (921 920 922 919 916 915 913 913 916 913) (1132 1091 1111 1100 1124 1090 1104 1082 1117 1099) (536 530 519 513 530 534 524 531 538 536) (724 728 709 725 729 714 733 720 684 734) (515 511 506 508 516 511 482 515 502 514) (711 707 697 713 697 688 692 699 687 715) )
false
3bcc9ff81c069def460cabd39c1b3d4de133fc9d
7485cf3e657a70f0e122eec01dd4b1e95d78ddd3
/racket/untyped/main.rkt
157af87e412804a5f1ee30d5fb372a82bf3cca92
[]
no_license
YellPika/CSC494
e00d45e396b199ef2cb3e6af69649936688b9969
e6804fc8d136dd0c62943e2ab54fa37df6affeb7
refs/heads/master
"2021-01-18T16:36:50.055864"
"2017-03-30T21:03:53"
"2017-03-30T21:03:53"
86,748,030
0
0
null
null
null
null
UTF-8
Racket
false
false
2,462
rkt
main.rkt
#lang racket/base (module reader syntax/module-reader untyped) (require racket/match racket/promise racket/set syntax/parse/define (for-syntax racket/base)) (provide #%module-begin #%top-interaction #%top (rename-out [un-λ λ] [un-app #%app] [un-let let] [un-datum #%datum])) (define (make-fresh id in-scope) (if (set-member? in-scope id) (make-fresh (string->symbol (format "~a′" id)) in-scope) id)) (define (reify expr [scope (set)]) (cond [(LAM? expr) (define id (make-fresh (LAM-id expr) scope)) (match (reify ((LAM-call expr) id) (set-add scope id)) [`(λ (,ids ...) ,body) `(λ ,(cons id ids) ,body)] [exp `(λ (,id) ,exp)])] [(APP? expr) (define expr₁ (reify (APP-expr₁ expr) scope)) (define expr₂ (reify (APP-expr₂ expr) scope)) (if (and (list? expr₁) (not (equal? (car expr₁) 'λ))) (append expr₁ (list expr₂)) (list expr₁ expr₂))] [else expr])) (define (write-reified expr port mode) (define recur (case mode [(#t) write] [(#f) display] [else (λ (p port) (print p port mode))])) (recur (reify expr) port)) (struct APP (expr₁ expr₂) #:methods gen:custom-write [(define write-proc write-reified)]) (struct LAM (id call) #:methods gen:custom-write [(define write-proc write-reified)]) (define-syntax-parser un-λ [(_ (id:id) expr) #'(LAM 'id (λ (id) (#%expression (force expr))))] [(_ (id:id ids:id ...) expr:expr) #'(un-λ (id) (un-λ (ids ...) expr))]) (define-syntax-parser un-app [(_ expr:expr) #'expr] [(_ expr₁:expr expr₂:expr exprs:expr ...) #'(un-app (let ([expr₁′ (force expr₁)] [expr₂′ (lazy expr₂)]) (if (LAM? expr₁′) ((LAM-call expr₁′) expr₂′) (APP expr₁′ (force expr₂′)))) exprs ...)]) (define-syntax-parser un-let [(_ id:id expr:expr) #:with expr′ (local-expand #'expr 'expression null) #'(define id expr′)]) (define-syntax-parser un-datum [(_ . nat:nat) #`(un-λ (s z) #,(let loop ([n (syntax->datum #'nat)]) (if (zero? n) #'z #`(un-app s #,(loop (sub1 n))))))])
true
0a4e4a960f6a71081542ba976a5dcbfef677c038
fc90b5a3938850c61bdd83719a1d90270752c0bb
/web-server-test/tests/web-server/e2e/read-write/server.rkt
0c06e8a66a56e3a5fa65abea4c28412e9609140f
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
racket/web-server
cccdf9b26d7b908701d7d05568dc6ed3ae9e705b
e321f8425e539d22412d4f7763532b3f3a65c95e
refs/heads/master
"2023-08-21T18:55:50.892735"
"2023-07-11T02:53:24"
"2023-07-11T02:53:24"
27,431,252
91
42
NOASSERTION
"2023-09-02T15:19:40"
"2014-12-02T12:20:26"
Racket
UTF-8
Racket
false
false
602
rkt
server.rkt
#lang racket/base (require racket/port web-server/servlet web-server/servlet-dispatch web-server/safety-limits web-server/web-server) (provide start) (define (read-write req) (response/output (lambda (out) (display (request-post-data/raw req) out)))) (define (start port) (parameterize ([current-error-port (open-output-nowhere)]) (serve #:port port #:dispatch (dispatch/servlet read-write) #:safety-limits (make-safety-limits #:request-read-timeout 1 #:response-send-timeout 1))))
false
28059fc20e918eba3b71908e6b58f6c5ad0a275c
bfdea13ca909b25a0a07c044ec456c00124b6053
/mischief/scribblings/dye-pack.scrbl
135438c1a0b03cd951ebb5191be5caba5b7bd423
[]
no_license
carl-eastlund/mischief
7598630e44e83dd477b7539b601d9e732a96ea81
ce58c3170240f12297e2f98475f53c9514225825
refs/heads/master
"2018-12-19T07:25:43.768476"
"2018-09-15T16:00:33"
"2018-09-15T16:00:33"
9,098,458
7
2
null
"2015-07-30T20:52:08"
"2013-03-29T13:02:31"
Racket
UTF-8
Racket
false
false
2,106
scrbl
dye-pack.scrbl
#lang scribble/manual @(require (for-label mischief)) @title[#:tag "dye-pack"]{@racketmodname[mischief/dye-pack]: Protecting Syntax Objects} @defmodule[mischief/dye-pack] @defparam[current-dye-packs stx syntax?]{ Stores the syntax object used for arming and disarming dye packs in the current syntax transformer. } @defproc[ (call-with-disarmed-dye-packs [stx syntax?] [proc (-> syntax? any)] [#:inspector inspector (or/c inspector? #false) #false]) any ]{ Calls @racket[proc] with a version of @racket[stx] whose dye packs are disarmed using @racket[insp]. Stores the original @racket[stx] in @racket[current-dye-packs] during the execution of @racket[proc]. Equivalent to: @racketblock[ (parameterize {[current-dye-packs stx]} (proc (syntax-disarm stx inspector))) ] } @defform[ (with-disarmed-dye-packs name-id stx-expr body ...+) ]{ Executes @racket[body] with @racket[name-id] bound to a disarmed version of @racket[stx-expr] using the declaration inspector for the enclosing module. Stores the value of the original @racket[stx-expr] in @racket[current-dye-packs] during the execution of @racket[proc]. Equivalent to: @racketblock[ (call-with-disarmed-dye-packs stx-expr #:inspector (module-code-inspector) (lambda {name-id} body ...)) ] } @defproc[ (rearm-dye-packs [stx syntax?] [#:dye-packs dye-packs syntax? (current-dye-packs)] [#:mode mode any/c #false]) syntax? ]{ Produces a version of @racket[stx] in which the dye packs on @racket[dye-packs] are rearmed. If @racket[mode] is @racket[#false], always rearms the dye packs for the whole syntax object. If @racket[mode] is a non-symbol true value, the dye packs are pushed to nested syntax objects in accordance with the @racket['taint-mode] syntax property. If @racket[mode] is a symbol, sets the @racket['taint-mode] property of @racket[stx] to @racket[mode] and then rearms according to it. } @defform[ (module-code-inspector) ]{ Produces the declaration inspector for the enclosing module. Equivalent to: @racketblock[ (variable-reference->module-declaration-inspector (#%variable-reference)) ] }
false
3d4631a7f29f37c92fcddb79fe79d2337c690262
82c76c05fc8ca096f2744a7423d411561b25d9bd
/typed-racket-test/succeed/units-no-sigs.rkt
00c3b8ee757f37a0e322db9ef6c3d3593ef7e303
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
racket/typed-racket
2cde60da289399d74e945b8f86fbda662520e1ef
f3e42b3aba6ef84b01fc25d0a9ef48cd9d16a554
refs/heads/master
"2023-09-01T23:26:03.765739"
"2023-08-09T01:22:36"
"2023-08-09T01:22:36"
27,412,259
571
131
NOASSERTION
"2023-08-09T01:22:41"
"2014-12-02T03:00:29"
Racket
UTF-8
Racket
false
false
935
rkt
units-no-sigs.rkt
#lang typed/racket (define-signature yz-sig ([y : Integer] [z : Integer])) (let ((y 1) (z 10)) (define u (unit (import) (export yz-sig) (define y 2) (define z 3))) (define u1 (unit (import) (export) y)) (define u2 (unit (import (only yz-sig z)) (export) y)) (define u3 (unit (import (except yz-sig y)) (export) y)) (define u4 (unit (import (prefix s: yz-sig)) (export) y)) (define u5 (unit (import (rename yz-sig (r y))) (export) y)) (define u6 (unit (import yz-sig) (export) y)) (: l (-> (Unit (import yz-sig) (export) Integer) Integer)) (define (l x) (invoke-unit (compound-unit (import) (export) (link (((YZ : yz-sig)) u) (() x YZ))))) (invoke-unit u1) (l u2) (l u3) (l u4) (l u5) (l u6))
false
55cc9e09c631deee1705e1dbefb83109ff84a9a6
ddae9f912790ca2fb5eb271ce54a156560ea526e
/cs275/lab1/1.10.rkt
0343541d3cc8f6a741f77ffec241e8b43b545a06
[]
no_license
cmccahil/Classwork
489658e06a4f88ac56297a980494a0ced7613184
1ed775acfd6e0a9d511ad3bb795e76039d2fbb5a
refs/heads/master
"2020-07-31T18:22:26.034292"
"2020-01-27T19:26:21"
"2020-01-27T19:26:21"
210,707,952
0
0
null
null
null
null
UTF-8
Racket
false
false
128
rkt
1.10.rkt
#lang racket (define duplicate (lambda(n exp) (cond [(= n 0) null] [else(cons exp (duplicate (- n 1) exp))])))
false
6aeb895dbed569fd38e287b13559113f126ddbf7
627680558b42ab91471b477467187c3f24b99082
/results/24-hr/rbtrees-1-search.rktd
fbd7d4347b395b83d9009f273f6ed2446d3b59fb
[]
no_license
bfetscher/dissertation
2a579aa919d6173a211560e20630b3920d108412
148d7f9bb21ce29b705522f7f4967d63bffc67cd
refs/heads/master
"2021-01-12T12:57:45.507113"
"2016-10-06T06:54:21"
"2016-10-06T06:54:21"
70,130,350
0
1
null
"2016-10-06T14:01:38"
"2016-10-06T06:58:19"
Racket
UTF-8
Racket
false
false
31,341
rktd
rbtrees-1-search.rktd
(start 2015-08-18T16:09:49 (#:model "rbtrees-1" #:type search)) (heartbeat 2015-08-18T16:09:49 (#:model "rbtrees-1" #:type search)) (gc-major 2015-08-18T16:09:49 (#:amount 10817280 #:time 269)) (counterexample 2015-08-18T16:09:50 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 23 #:time 1024)) (new-average 2015-08-18T16:09:50 (#:model "rbtrees-1" #:type search #:average 1023.0 #:stderr +nan.0)) (counterexample 2015-08-18T16:09:58 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 246 #:time 7688)) (new-average 2015-08-18T16:09:58 (#:model "rbtrees-1" #:type search #:average 4355.5 #:stderr 3332.4999999999995)) (heartbeat 2015-08-18T16:09:59 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:09:59 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 52 #:time 1443)) (new-average 2015-08-18T16:09:59 (#:model "rbtrees-1" #:type search #:average 3384.6666666666665 #:stderr 2155.079916022709)) (counterexample 2015-08-18T16:10:00 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 39 #:time 1125)) (new-average 2015-08-18T16:10:00 (#:model "rbtrees-1" #:type search #:average 2819.75 #:stderr 1625.2124668793308)) (counterexample 2015-08-18T16:10:02 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 42 #:time 1239)) (new-average 2015-08-18T16:10:02 (#:model "rbtrees-1" #:type search #:average 2503.6 #:stderr 1297.9754080875339)) (counterexample 2015-08-18T16:10:04 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 70 #:time 2099)) (new-average 2015-08-18T16:10:04 (#:model "rbtrees-1" #:type search #:average 2436.1666666666665 #:stderr 1061.9356671244786)) (counterexample 2015-08-18T16:10:05 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 31 #:time 866)) (new-average 2015-08-18T16:10:05 (#:model "rbtrees-1" #:type search #:average 2211.8571428571427 #:stderr 925.105410430705)) (counterexample 2015-08-18T16:10:05 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 12 #:time 389)) (new-average 2015-08-18T16:10:05 (#:model "rbtrees-1" #:type search #:average 1983.9999999999998 #:stderr 832.9369080891678)) (counterexample 2015-08-18T16:10:06 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 34 #:time 1082)) (new-average 2015-08-18T16:10:06 (#:model "rbtrees-1" #:type search #:average 1883.7777777777776 #:stderr 741.3866658307289)) (counterexample 2015-08-18T16:10:07 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 12 #:time 526)) (new-average 2015-08-18T16:10:07 (#:model "rbtrees-1" #:type search #:average 1747.9999999999998 #:stderr 676.8744016104874)) (counterexample 2015-08-18T16:10:07 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 25 #:time 667)) (new-average 2015-08-18T16:10:07 (#:model "rbtrees-1" #:type search #:average 1649.7272727272725 #:stderr 620.0926190484347)) (heartbeat 2015-08-18T16:10:09 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:10:11 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 136 #:time 3732)) (new-average 2015-08-18T16:10:11 (#:model "rbtrees-1" #:type search #:average 1823.2499999999998 #:stderr 592.0634963516338)) (counterexample 2015-08-18T16:10:14 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 89 #:time 2642)) (new-average 2015-08-18T16:10:14 (#:model "rbtrees-1" #:type search #:average 1886.230769230769 #:stderr 548.248717115271)) (gc-major 2015-08-18T16:10:15 (#:amount 78983752 #:time 248)) (heartbeat 2015-08-18T16:10:19 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:10:20 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 171 #:time 5857)) (new-average 2015-08-18T16:10:20 (#:model "rbtrees-1" #:type search #:average 2169.8571428571427 #:stderr 581.4473779932249)) (counterexample 2015-08-18T16:10:21 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 37 #:time 1537)) (new-average 2015-08-18T16:10:21 (#:model "rbtrees-1" #:type search #:average 2127.6666666666665 #:stderr 542.9397902834309)) (counterexample 2015-08-18T16:10:23 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 42 #:time 1821)) (new-average 2015-08-18T16:10:23 (#:model "rbtrees-1" #:type search #:average 2108.5 #:stderr 508.23520637594555)) (counterexample 2015-08-18T16:10:27 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 104 #:time 3837)) (new-average 2015-08-18T16:10:27 (#:model "rbtrees-1" #:type search #:average 2210.176470588235 #:stderr 488.1111948058656)) (counterexample 2015-08-18T16:10:29 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 69 #:time 1924)) (new-average 2015-08-18T16:10:29 (#:model "rbtrees-1" #:type search #:average 2194.277777777778 #:stderr 460.4701973534118)) (heartbeat 2015-08-18T16:10:29 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:10:30 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 56 #:time 1547)) (new-average 2015-08-18T16:10:30 (#:model "rbtrees-1" #:type search #:average 2160.2105263157896 #:stderr 436.8914486329311)) (counterexample 2015-08-18T16:10:35 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 136 #:time 4668)) (new-average 2015-08-18T16:10:35 (#:model "rbtrees-1" #:type search #:average 2285.6 #:stderr 433.0233760555269)) (counterexample 2015-08-18T16:10:37 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 53 #:time 2162)) (new-average 2015-08-18T16:10:37 (#:model "rbtrees-1" #:type search #:average 2279.714285714286 #:stderr 411.9294388424237)) (heartbeat 2015-08-18T16:10:39 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:10:40 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 96 #:time 3180)) (new-average 2015-08-18T16:10:40 (#:model "rbtrees-1" #:type search #:average 2320.6363636363635 #:stderr 394.8854157078535)) (counterexample 2015-08-18T16:10:43 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 104 #:time 3036)) (new-average 2015-08-18T16:10:43 (#:model "rbtrees-1" #:type search #:average 2351.7391304347825 #:stderr 378.6058011149728)) (counterexample 2015-08-18T16:10:47 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 90 #:time 3588)) (new-average 2015-08-18T16:10:47 (#:model "rbtrees-1" #:type search #:average 2403.25 #:stderr 366.1291114731468)) (heartbeat 2015-08-18T16:10:49 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:10:51 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 99 #:time 4153)) (new-average 2015-08-18T16:10:51 (#:model "rbtrees-1" #:type search #:average 2473.24 #:stderr 358.0853030587358)) (counterexample 2015-08-18T16:10:52 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 17 #:time 668)) (new-average 2015-08-18T16:10:52 (#:model "rbtrees-1" #:type search #:average 2403.807692307692 #:stderr 350.97359102592486)) (counterexample 2015-08-18T16:10:52 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 8 #:time 336)) (new-average 2015-08-18T16:10:52 (#:model "rbtrees-1" #:type search #:average 2327.2222222222217 #:stderr 346.2992478201991)) (counterexample 2015-08-18T16:10:53 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 23 #:time 934)) (new-average 2015-08-18T16:10:53 (#:model "rbtrees-1" #:type search #:average 2277.4642857142853 #:stderr 337.39158353549595)) (gc-major 2015-08-18T16:10:53 (#:amount 115158872 #:time 306)) (counterexample 2015-08-18T16:10:54 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 8 #:time 664)) (new-average 2015-08-18T16:10:54 (#:model "rbtrees-1" #:type search #:average 2221.8275862068963 #:stderr 330.26953490612357)) (heartbeat 2015-08-18T16:10:59 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:11:02 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 245 #:time 8390)) (new-average 2015-08-18T16:11:02 (#:model "rbtrees-1" #:type search #:average 2427.433333333333 #:stderr 379.5784827402456)) (counterexample 2015-08-18T16:11:03 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 27 #:time 755)) (new-average 2015-08-18T16:11:03 (#:model "rbtrees-1" #:type search #:average 2373.4838709677415 #:stderr 371.07262967875283)) (counterexample 2015-08-18T16:11:06 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 94 #:time 2878)) (new-average 2015-08-18T16:11:06 (#:model "rbtrees-1" #:type search #:average 2389.2499999999995 #:stderr 359.63528232130193)) (counterexample 2015-08-18T16:11:07 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 37 #:time 1137)) (new-average 2015-08-18T16:11:07 (#:model "rbtrees-1" #:type search #:average 2351.30303030303 #:stderr 350.62639694759923)) (counterexample 2015-08-18T16:11:07 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 15 #:time 439)) (new-average 2015-08-18T16:11:07 (#:model "rbtrees-1" #:type search #:average 2295.0588235294117 #:stderr 344.77613429999144)) (counterexample 2015-08-18T16:11:08 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 14 #:time 427)) (new-average 2015-08-18T16:11:08 (#:model "rbtrees-1" #:type search #:average 2241.6857142857143 #:stderr 339.0083580720939)) (heartbeat 2015-08-18T16:11:09 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:11:10 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 61 #:time 2244)) (new-average 2015-08-18T16:11:10 (#:model "rbtrees-1" #:type search #:average 2241.75 #:stderr 329.45691091672916)) (counterexample 2015-08-18T16:11:12 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 48 #:time 1997)) (new-average 2015-08-18T16:11:12 (#:model "rbtrees-1" #:type search #:average 2235.135135135135 #:stderr 320.49724683446453)) (heartbeat 2015-08-18T16:11:19 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:11:20 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 210 #:time 8480)) (new-average 2015-08-18T16:11:20 (#:model "rbtrees-1" #:type search #:average 2399.4736842105262 #:stderr 352.5895742588258)) (counterexample 2015-08-18T16:11:20 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 0 #:time 27)) (new-average 2015-08-18T16:11:20 (#:model "rbtrees-1" #:type search #:average 2338.6410256410254 #:stderr 348.7759538365584)) (counterexample 2015-08-18T16:11:21 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 17 #:time 675)) (new-average 2015-08-18T16:11:21 (#:model "rbtrees-1" #:type search #:average 2297.0499999999997 #:stderr 342.47955572521926)) (counterexample 2015-08-18T16:11:23 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 59 #:time 1721)) (new-average 2015-08-18T16:11:23 (#:model "rbtrees-1" #:type search #:average 2282.9999999999995 #:stderr 334.31732771388926)) (counterexample 2015-08-18T16:11:23 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 13 #:time 413)) (new-average 2015-08-18T16:11:23 (#:model "rbtrees-1" #:type search #:average 2238.47619047619 #:stderr 329.284308629364)) (gc-major 2015-08-18T16:11:27 (#:amount 85952392 #:time 295)) (heartbeat 2015-08-18T16:11:29 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:11:33 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 256 #:time 10264)) (new-average 2015-08-18T16:11:33 (#:model "rbtrees-1" #:type search #:average 2425.1162790697667 #:stderr 371.77884358504497)) (counterexample 2015-08-18T16:11:36 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 70 #:time 2827)) (new-average 2015-08-18T16:11:36 (#:model "rbtrees-1" #:type search #:average 2434.249999999999 #:stderr 363.3458799297785)) (counterexample 2015-08-18T16:11:37 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 24 #:time 1050)) (new-average 2015-08-18T16:11:37 (#:model "rbtrees-1" #:type search #:average 2403.488888888888 #:stderr 356.5093388809265)) (heartbeat 2015-08-18T16:11:39 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:11:39 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 42 #:time 1812)) (new-average 2015-08-18T16:11:39 (#:model "rbtrees-1" #:type search #:average 2390.630434782608 #:stderr 348.91003001091553)) (counterexample 2015-08-18T16:11:41 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 45 #:time 1866)) (new-average 2015-08-18T16:11:41 (#:model "rbtrees-1" #:type search #:average 2379.468085106382 #:stderr 341.588140560481)) (counterexample 2015-08-18T16:11:44 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 111 #:time 3089)) (new-average 2015-08-18T16:11:44 (#:model "rbtrees-1" #:type search #:average 2394.249999999999 #:stderr 334.72256228953813)) (counterexample 2015-08-18T16:11:46 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 68 #:time 1891)) (new-average 2015-08-18T16:11:46 (#:model "rbtrees-1" #:type search #:average 2383.979591836734 #:stderr 327.98116817127857)) (heartbeat 2015-08-18T16:11:49 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:11:49 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 120 #:time 3289)) (new-average 2015-08-18T16:11:49 (#:model "rbtrees-1" #:type search #:average 2402.0799999999995 #:stderr 321.86395508611)) (counterexample 2015-08-18T16:11:51 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 60 #:time 1692)) (new-average 2015-08-18T16:11:51 (#:model "rbtrees-1" #:type search #:average 2388.1568627450974 #:stderr 315.79685747986167)) (counterexample 2015-08-18T16:11:53 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 70 #:time 2018)) (new-average 2015-08-18T16:11:53 (#:model "rbtrees-1" #:type search #:average 2381.038461538461 #:stderr 309.74610212876877)) (counterexample 2015-08-18T16:11:55 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 72 #:time 1966)) (new-average 2015-08-18T16:11:55 (#:model "rbtrees-1" #:type search #:average 2373.207547169811 #:stderr 303.9465310362139)) (counterexample 2015-08-18T16:11:56 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 26 #:time 750)) (new-average 2015-08-18T16:11:56 (#:model "rbtrees-1" #:type search #:average 2343.148148148148 #:stderr 299.77566665698834)) (counterexample 2015-08-18T16:11:57 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 38 #:time 1083)) (new-average 2015-08-18T16:11:57 (#:model "rbtrees-1" #:type search #:average 2320.2363636363634 #:stderr 295.16531915534785)) (counterexample 2015-08-18T16:11:57 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) (R E (s (s (s O))) E)) (s (s (s (s O)))) (B E (s (s (s (s (s O))))) E)) #:iterations 1 #:time 92)) (new-average 2015-08-18T16:11:57 (#:model "rbtrees-1" #:type search #:average 2280.4464285714284 #:stderr 292.5650087816457)) (heartbeat 2015-08-18T16:11:59 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:11:59 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 60 #:time 2325)) (new-average 2015-08-18T16:11:59 (#:model "rbtrees-1" #:type search #:average 2281.2280701754385 #:stderr 287.387520786349)) (counterexample 2015-08-18T16:12:00 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 10 #:time 461)) (new-average 2015-08-18T16:12:00 (#:model "rbtrees-1" #:type search #:average 2249.844827586207 #:stderr 284.12762846464153)) (gc-major 2015-08-18T16:12:01 (#:amount 111799232 #:time 260)) (counterexample 2015-08-18T16:12:04 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 140 #:time 4321)) (new-average 2015-08-18T16:12:04 (#:model "rbtrees-1" #:type search #:average 2284.9491525423728 #:stderr 281.4680501437791)) (counterexample 2015-08-18T16:12:06 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 80 #:time 2204)) (new-average 2015-08-18T16:12:06 (#:model "rbtrees-1" #:type search #:average 2283.6 #:stderr 276.7404464281749)) (counterexample 2015-08-18T16:12:06 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 4 #:time 129)) (new-average 2015-08-18T16:12:06 (#:model "rbtrees-1" #:type search #:average 2248.2622950819673 #:stderr 274.4504244219285)) (counterexample 2015-08-18T16:12:07 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 28 #:time 825)) (new-average 2015-08-18T16:12:07 (#:model "rbtrees-1" #:type search #:average 2225.3064516129034 #:stderr 270.9616778755993)) (counterexample 2015-08-18T16:12:08 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) (R E (s (s (s O))) E)) (s (s (s (s O)))) (B E (s (s (s (s (s (s (s O))))))) E)) #:iterations 44 #:time 1193)) (new-average 2015-08-18T16:12:08 (#:model "rbtrees-1" #:type search #:average 2208.920634920635 #:stderr 267.12904163644464)) (heartbeat 2015-08-18T16:12:09 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:12:09 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 25 #:time 745)) (new-average 2015-08-18T16:12:09 (#:model "rbtrees-1" #:type search #:average 2186.0468750000005 #:stderr 263.915135272377)) (counterexample 2015-08-18T16:12:10 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 49 #:time 1388)) (new-average 2015-08-18T16:12:10 (#:model "rbtrees-1" #:type search #:average 2173.7692307692314 #:stderr 260.11310111146366)) (counterexample 2015-08-18T16:12:13 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 74 #:time 2800)) (new-average 2015-08-18T16:12:13 (#:model "rbtrees-1" #:type search #:average 2183.2575757575764 #:stderr 256.3173552941571)) (counterexample 2015-08-18T16:12:15 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 47 #:time 1888)) (new-average 2015-08-18T16:12:15 (#:model "rbtrees-1" #:type search #:average 2178.8507462686575 #:stderr 252.50119788148254)) (counterexample 2015-08-18T16:12:15 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 1 #:time 82)) (new-average 2015-08-18T16:12:15 (#:model "rbtrees-1" #:type search #:average 2148.0147058823536 #:stderr 250.66414722224346)) (counterexample 2015-08-18T16:12:16 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 20 #:time 797)) (new-average 2015-08-18T16:12:16 (#:model "rbtrees-1" #:type search #:average 2128.4347826086964 #:stderr 247.77944989008873)) (counterexample 2015-08-18T16:12:17 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) (R E (s (s (s O))) E)) (s (s (s (s O)))) (B E (s (s (s (s (s (s (s O))))))) E)) #:iterations 18 #:time 783)) (new-average 2015-08-18T16:12:17 (#:model "rbtrees-1" #:type search #:average 2109.2142857142867 #:stderr 244.9692843321249)) (heartbeat 2015-08-18T16:12:19 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:12:19 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 69 #:time 2286)) (new-average 2015-08-18T16:12:19 (#:model "rbtrees-1" #:type search #:average 2111.7042253521136 #:stderr 241.50720264897788)) (counterexample 2015-08-18T16:12:20 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 12 #:time 503)) (new-average 2015-08-18T16:12:20 (#:model "rbtrees-1" #:type search #:average 2089.3611111111118 #:stderr 239.17521725366825)) (counterexample 2015-08-18T16:12:20 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 10 #:time 422)) (new-average 2015-08-18T16:12:20 (#:model "rbtrees-1" #:type search #:average 2066.5068493150693 #:stderr 236.9806900559497)) (counterexample 2015-08-18T16:12:21 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 37 #:time 1394)) (new-average 2015-08-18T16:12:21 (#:model "rbtrees-1" #:type search #:average 2057.4189189189196 #:stderr 233.93290538776407)) (counterexample 2015-08-18T16:12:23 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 35 #:time 1194)) (new-average 2015-08-18T16:12:23 (#:model "rbtrees-1" #:type search #:average 2045.9066666666674 #:stderr 231.07966893648555)) (counterexample 2015-08-18T16:12:24 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 40 #:time 1104)) (new-average 2015-08-18T16:12:24 (#:model "rbtrees-1" #:type search #:average 2033.5131578947376 #:stderr 228.35543969828447)) (counterexample 2015-08-18T16:12:24 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 15 #:time 433)) (new-average 2015-08-18T16:12:24 (#:model "rbtrees-1" #:type search #:average 2012.7272727272734 #:stderr 226.32678350360575)) (counterexample 2015-08-18T16:12:25 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 45 #:time 1341)) (new-average 2015-08-18T16:12:25 (#:model "rbtrees-1" #:type search #:average 2004.1153846153852 #:stderr 223.57223988488056)) (counterexample 2015-08-18T16:12:26 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 11 #:time 392)) (new-average 2015-08-18T16:12:26 (#:model "rbtrees-1" #:type search #:average 1983.7088607594942 #:stderr 221.6653809402807)) (counterexample 2015-08-18T16:12:27 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 55 #:time 1592)) (new-average 2015-08-18T16:12:27 (#:model "rbtrees-1" #:type search #:average 1978.8125000000005 #:stderr 218.93178601656243)) (heartbeat 2015-08-18T16:12:29 (#:model "rbtrees-1" #:type search)) (gc-major 2015-08-18T16:12:32 (#:amount 85378232 #:time 295)) (counterexample 2015-08-18T16:12:34 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 162 #:time 6349)) (new-average 2015-08-18T16:12:34 (#:model "rbtrees-1" #:type search #:average 2032.7654320987658 #:stderr 222.8420094931379)) (counterexample 2015-08-18T16:12:35 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 30 #:time 1161)) (new-average 2015-08-18T16:12:35 (#:model "rbtrees-1" #:type search #:average 2022.1341463414637 #:stderr 220.36424622067076)) (counterexample 2015-08-18T16:12:36 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 17 #:time 697)) (new-average 2015-08-18T16:12:36 (#:model "rbtrees-1" #:type search #:average 2006.1686746987955 #:stderr 218.27772940064236)) (heartbeat 2015-08-18T16:12:39 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:12:40 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 104 #:time 4217)) (new-average 2015-08-18T16:12:40 (#:model "rbtrees-1" #:type search #:average 2032.4880952380956 #:stderr 217.26359637109744)) (counterexample 2015-08-18T16:12:44 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 138 #:time 4654)) (new-average 2015-08-18T16:12:44 (#:model "rbtrees-1" #:type search #:average 2063.3294117647065 #:stderr 216.89625912771135)) (counterexample 2015-08-18T16:12:46 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 27 #:time 1148)) (new-average 2015-08-18T16:12:46 (#:model "rbtrees-1" #:type search #:average 2052.6860465116283 #:stderr 214.62344287845983)) (heartbeat 2015-08-18T16:12:49 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:12:52 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 171 #:time 6899)) (new-average 2015-08-18T16:12:52 (#:model "rbtrees-1" #:type search #:average 2108.3908045977014 #:stderr 219.3338041830235)) (counterexample 2015-08-18T16:12:55 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s (s (s O)))))) E)) #:iterations 85 #:time 2668)) (new-average 2015-08-18T16:12:55 (#:model "rbtrees-1" #:type search #:average 2114.7500000000005 #:stderr 216.92028235041624)) (counterexample 2015-08-18T16:12:57 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E (s O) E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 50 #:time 1407)) (new-average 2015-08-18T16:12:57 (#:model "rbtrees-1" #:type search #:average 2106.797752808989 #:stderr 214.6165060830433)) (counterexample 2015-08-18T16:12:57 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 26 #:time 802)) (new-average 2015-08-18T16:12:57 (#:model "rbtrees-1" #:type search #:average 2092.3 #:stderr 212.7131131990725)) (heartbeat 2015-08-18T16:12:59 (#:model "rbtrees-1" #:type search)) (counterexample 2015-08-18T16:13:03 (#:model "rbtrees-1" #:type search #:counterexample (R (B (R E O E) (s (s O)) E) (s (s (s O))) (B E (s (s (s (s O)))) E)) #:iterations 141 #:time 5323)) (new-average 2015-08-18T16:13:03 (#:model "rbtrees-1" #:type search #:average 2127.802197802198 #:stderr 213.33738046743758)) (counterexample 2015-08-18T16:13:05 (#:model "rbtrees-1" #:type search #:counterexample (R (B E O (R E (s (s O)) E)) (s (s (s O))) (B E (s (s (s (s (s O))))) E)) #:iterations 63 #:time 2461)) (new-average 2015-08-18T16:13:05 (#:model "rbtrees-1" #:type search #:average 2131.4239130434785 #:stderr 211.03683376683222)) (finished 2015-08-18T16:13:05 (#:model "rbtrees-1" #:type search #:time-ms 196110 #:attempts 5710 #:num-counterexamples 92 #:rate-terms/s 29.11631227372393 #:attempts/cexp 62.06521739130435))
false
7fe810832c70a66fc44dc08ac7d12f607f78d783
e6f5012a6a49be22543c2d465762853c43beeaf5
/.emacs.d/lisp/lib/racket-mode/racket/fresh-line.rkt
e294be37fa518b862ee0ea6612b0bce930cab126
[]
no_license
eiselekd/dotfiles
244342cbb0821b24436fb686e2360d5698766352
50894f43d0f635cdfe813120c6c7fa7decddf35c
refs/heads/master
"2023-07-28T15:24:29.375967"
"2023-07-15T13:08:39"
"2023-07-15T13:09:33"
26,353,163
1
0
null
"2020-09-05T16:33:37"
"2014-11-08T07:23:31"
Emacs Lisp
UTF-8
Racket
false
false
1,246
rkt
fresh-line.rkt
#lang racket/base (provide fresh-line zero-column!) ;; Borrowed from xrepl (define last-output-port (make-parameter #f)) (define last-error-port (make-parameter #f)) (define (maybe-new-output-ports) (define (maybe last cur) (unless (eq? (last) (cur)) (when (and (last) (not (port-closed? (last)))) (flush-output (last))) ;just in case (last (cur)) (flush-output (last)) (port-count-lines! (last)))) (maybe last-output-port current-output-port) (maybe last-error-port current-error-port)) (define (fresh-line [stderr? #f]) (maybe-new-output-ports) (define port (if stderr? (last-error-port) (last-output-port))) (flush-output port) (define-values [line col pos] (port-next-location port)) (unless (eq? col 0) (newline))) (define (zero-column!) ;; there's a problem whenever there's some printout followed by a ;; read: the cursor will be at column zero, but the port counting ;; will think that it's still right after the printout; call this ;; function in such cases to adjust the column to 0. (maybe-new-output-ports) (define-values [line col pos] (port-next-location (last-output-port))) (set-port-next-location! (last-output-port) line 0 pos))
false
f9f6917053a681d11a4ff8cf329886c505c3c547
08fbdb00feb0191adc5db86507fdd79c2fb308e7
/objects/class.rkt
2459e486bd7757f39262a334d6de99bfff15f885
[]
no_license
mkohlhaas/mflatt-macro-dsl-tutorial
dad0e24cb47811c6ec9548e612757e7525ecd1ca
b8b2ffaffe2bde27c2ff3ad25917ca250a34795d
refs/heads/master
"2022-10-21T23:28:02.799348"
"2020-06-16T03:19:32"
"2020-06-16T03:19:32"
271,256,333
0
0
null
null
null
null
UTF-8
Racket
false
false
2,624
rkt
class.rkt
#lang racket/base (require (rename-in "with-method.rkt" [class raw:class]) syntax/parse/define racket/stxparam (for-syntax racket/base)) (provide class make-object send with-method) ;; >>> define `class` <<< ;; where the expansion uses `raw:class` #; (define point-class (class [x y] ; fields this ; name that refers back to self (define (get-x) x) (define (get-y) y) (define (set-x v) (set! x v)) (define (set-y v) (set! y v)) (define (rotate degrees) (define pt (make-rectangular x y)) (define new-pt (make-polar (magnitude pt) (+ (angle pt) (* pi (/ degrees 180))))) (set! x (real-part new-pt)) (set! y (imag-part new-pt))))) #; (define point-class (class (hash 'get-x (lambda (this) (get-field this 'x)) 'get-y (lambda (this) (get-field this 'y)) 'set-x (lambda (this v) (set-field! this 'x v)) 'set-y (lambda (this v) (set-field! this 'y v)) 'rotate (lambda (this degrees) (define pt (make-rectangular (get-field this 'x) (get-field this 'y))) (define new-pt (make-polar (magnitude pt) (+ (angle pt) (* pi (/ degrees 180))))) (set-field! this 'x (real-part new-pt)) (set-field! this 'y (imag-part new-pt)))) (hash 'x 0 'y 1))) (define-syntax-parser class #:literals (define) [(_ [fields ...] (define (function-names args ...) body ...) ...) #'(raw:class (for/hash ([fn-name (list 'function-names ...)] [fn-body (list (lambda(this args ...) (define-field fields this) ... body ...) ...)]) (values fn-name fn-body)) (for/hash ([name '(fields ...)] [pos (in-naturals)]) (values name pos)))]) ; shamelessly copied from solutions ; instead of 'field-name in expanded code I could use 'id ; eg. [id (get-field this-id 'id)] (define-syntax-rule (define-field field-name this-id) (define-syntax field-name (syntax-id-rules (set!) [(set! id v) (set-field! this-id 'field-name v)] [(id arg (... ...)) ((get-field this-id 'field-name) arg (... ...))] [id (get-field this-id 'field-name)])))
true
6d83519e991f9da795f7ce24bf218858bfad9a2f
b08b7e3160ae9947b6046123acad8f59152375c3
/Programming Language Detection/Experiment-2/Dataset/Train/Racket/rename-a-file.rkt
7fae0dfcd94cd91f0d7fa8d1ffda622ae03fc6d9
[]
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
428
rkt
rename-a-file.rkt
#lang racket (rename-file-or-directory "input.txt" "output.txt") (rename-file-or-directory "docs" "mydocs") ;; find the filesystem roots, and pick the first one (define root (first (filesystem-root-list))) (rename-file-or-directory (build-path root "input.txt") (build-path root "output.txt")) (rename-file-or-directory (build-path root "docs") (build-path root "mydocs"))
false
71cc19d6622853bbde2a386c5688298a435add93
82c76c05fc8ca096f2744a7423d411561b25d9bd
/typed-racket-lib/typed-racket/logic/ineq.rkt
eb5430c45c187c233d7b55ed366d1d5e04f37de7
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
racket/typed-racket
2cde60da289399d74e945b8f86fbda662520e1ef
f3e42b3aba6ef84b01fc25d0a9ef48cd9d16a554
refs/heads/master
"2023-09-01T23:26:03.765739"
"2023-08-09T01:22:36"
"2023-08-09T01:22:36"
27,412,259
571
131
NOASSERTION
"2023-08-09T01:22:41"
"2014-12-02T03:00:29"
Racket
UTF-8
Racket
false
false
32,231
rkt
ineq.rkt
#lang racket/base (require "../utils/utils.rkt" "../rep/object-rep.rkt" "../rep/prop-rep.rkt" "../rep/fme-utils.rkt" (contract-req) racket/format racket/list (for-syntax racket/base syntax/parse) racket/match) ;; public API for reasoning about LeqProps (provide/cond-contract [contradictory-Leqs? (-> LeqProp? LeqProp? boolean?)] [complementary-Leqs? (-> LeqProp? LeqProp? boolean?)] [Leq-implies-Leq? (-> LeqProp? LeqProp? boolean?)] [satisfiable-Leqs? (-> (listof LeqProp?) boolean?)] [Leqs-imply-Leq-or-not-Leq? (-> (listof LeqProp?) LeqProp? (or/c boolean? 'neither))] [Leqs-imply-Leq? (-> (listof LeqProp?) LeqProp? boolean?)] [Leqs-imply-not-Leq? (-> (listof LeqProp?) LeqProp? boolean?)] [Leqs-imply-Leqs? (-> (listof LeqProp?) (listof LeqProp?) boolean?)]) ;; some internal contracts (define-for-cond-contract lexp? (cons/c exact-integer? (and/c (hash/c any/c (and/c exact-integer? (not/c (=/c 0))) #:immutable #t) hash-eq?))) (define-for-cond-contract leq? (cons/c lexp? lexp?)) (define-for-cond-contract sli? (listof leq?)) ;; ***************************************************** ;; public API functions (define (contradictory-Leqs? l1 l2) (contradictory-leqs? (Leq->leq l1) (Leq->leq l2))) (define (complementary-Leqs? l1 l2) (contradictory-leqs? (leq-negate (Leq->leq l1)) (leq-negate (Leq->leq l2)))) (define (Leq-implies-Leq? l1 l2) (leq-imp-leq? (Leq->leq l1) (Leq->leq l2))) (define (satisfiable-Leqs? leqs) (fme-sat? (Leqs->sli leqs))) ;; Leqs-imply-Leq-or-not-Leq? ;; ;; Determins if the Leqs in 'ls' either prove ;; or disprove 'l' (define (Leqs-imply-Leq-or-not-Leq? ls l) (define leqs (Leqs->sli ls)) (define ineq (Leq->leq l)) (cond [(fme-imp-leq? leqs ineq) #t] [(fme-imp-leq? leqs (leq-negate ineq)) #f] [else 'neither])) (define (Leqs-imply-Leq? ls l) (fme-imp-leq? (Leqs->sli ls) (Leq->leq l))) (define (Leqs-imply-not-Leq? ls l) (fme-imp-leq? (Leqs->sli ls) (leq-negate (Leq->leq l)))) (define (Leqs-imply-Leqs? assumptions goals) (fme-imp? (Leqs->sli assumptions) (Leqs->sli goals))) ;; ***************************************************** ;; helper functions ;; turns a list of Leqs into a sli (system of linear equations) ;; which is just a list of leqs (the internal version) (define/cond-contract (Leqs->sli Leqs) (-> (listof LeqProp?) sli?) (map Leq->leq Leqs)) ;; Leq to the internal leq rep (define (Leq->leq l) (match l [(LeqProp: (LExp: c1 ts1) (LExp: c2 ts2)) (leq (lexp c1 ts1) (lexp c2 ts2))])) ;; ***************************************************************************** ;; Fourier-Motzkin elimination implementation ;; http://en.wikipedia.org/wiki/Fourier-Motzkin_elimination ;; ;; Uses non-matrix representations of data ;; ;; Decides satisfiability, implication, etc... of/between systems of linear inequalities ;; of the form ([(a_1x_1 + a_2x_2 + ... + a_c) <= (b_1x_1 + b_2x_2 + ... + b_c)] ...) ;; ***************************************************************************** (define-match-expander lexp: (lambda (stx) (syntax-case stx () [(_ const exp) #'(cons const exp)]))) (define-match-expander leq: (lambda (stx) (syntax-case stx () [(_ lhs rhs) #'(cons lhs rhs)]))) (define/cond-contract (lexp const terms) (-> exact-integer? (and/c (hash/c any/c (and/c exact-integer? (not/c (=/c 0))) #:immutable #t) hash-eq?) lexp?) (cons const terms)) (define lexp-const car) (define lexp-terms cdr) (define-syntax-rule (lexp* t ...) (list->lexp (list t ...))) (define/cond-contract (list->lexp terms) (-> (listof (or/c exact-integer? (list/c exact-integer? any/c))) lexp?) (let loop ([c 0] [h (make-terms)] [zxs terms]) (match zxs [(list) (lexp c h)] [(cons (list coeff var) zxs-rst) (loop c (terms-set h var (+ coeff (terms-ref h var))) zxs-rst)] [(cons constant zxs-rst) (loop (+ constant c) h zxs-rst)]))) ;; what is the coefficient of 'x' in 'l' (define/cond-contract (lexp-coeff l x) (-> lexp? any/c exact-integer?) (terms-ref (lexp-terms l) x)) (module+ test (define-syntax (check-true stx) (syntax-case stx () [(_ exp) (syntax/loc stx (unless (eq? #t exp) (error 'check-true "test failed!")))])) (define-syntax (check-false stx) (syntax-case stx () [(_ exp) (syntax/loc stx (when (not (eq? #f exp)) (error 'check-false "test failed!")))])) (define-syntax (check-not-false stx) (syntax-case stx () [(_ exp) (syntax/loc stx (unless exp (error 'check-not-false "test failed!")))])) (define-syntax (check-equal? stx) (syntax-case stx () [(_ val exp) (syntax/loc stx (unless (equal? val exp) (error 'check-equal? "not equal!")))])) (check-equal? (lexp* 1 '(1 x) '(42 y) 1) (lexp* '(42 y) 2 '(1 x))) (check-equal? (lexp* 0) (lexp* 0 '(0 x) '(0 y) '(0 z))) (check-equal? (lexp-coeff (lexp* 1 '(1 x) '(42 y)) 'y) 42) (check-equal? (lexp-const (lexp* 1 '(1 x) '(42 y))) 1) (check-equal? (lexp-coeff (lexp* '(1 x) '(42 y)) 'q) 0)) ;; what variables are in this lexp (define/cond-contract (lexp-vars exp) (-> lexp? list?) (terms-vars (lexp-terms exp))) ;; what scalars are in this lexp (define/cond-contract (lexp-scalars exp) (-> lexp? (listof exact-integer?)) (match exp [(lexp: c ts) (define coeffs (terms-coeffs ts)) (if (zero? c) coeffs (cons c coeffs))] [_ (error 'lexp-scalars "given invalid lexp ~a" exp)])) (module+ test (check-true (and (equal? (sort (lexp-vars (lexp* 17 '(42 x) '(2 z))) symbol<?) (sort '(x z) symbol<?)) (= 2 (length (lexp-vars (lexp* 17 '(42 x) '(2 z))))))) (check-true (and (equal? (sort (lexp-scalars (lexp* 17 '(42 x) '(2 z))) <) '(2 17 42)) (= 3 (length (lexp-scalars (lexp* 17 '(42 x) '(2 z)))))))) ; lexp-scale ;; if multiplying any scalar by a results ;; in a non integer, error is thrown if ;; contracts are active (define/cond-contract (lexp-scale exp a) (-> lexp? rational? lexp?) (cond [(eqv? a 0) (lexp 0 (make-terms))] [(= a 1) exp] [else (match exp [(lexp: c h) (lexp (* c a) (terms-scale h a))])])) (module+ test (check-equal? (lexp-set (lexp* 17 '(42 x)) 'x 0) (lexp* 17))) ; lexp-set ; excludes items set to 0 (define/cond-contract (lexp-set exp x i) (-> lexp? any/c exact-integer? lexp?) (match exp [(lexp: c h) (lexp c (terms-set h x i))])) ; lexp-set-const ; sets the constant in an lexp (define/cond-contract (lexp-set-const exp i) (-> lexp? exact-integer? lexp?) (lexp i (lexp-terms exp))) (module+ test (check-equal? (lexp-set (lexp* 17) 'x 42) (lexp* 17 '(42 x))) (check-equal? (lexp-set (lexp* 17 '(2 x)) 'x 42) (lexp* 17 '(42 x))) (check-equal? (lexp-set-const (lexp* 17 '(2 x)) 42) (lexp* 42 '(2 x)))) ; lexp-zero? ;; is this lexp equiv to 0? (define/cond-contract (lexp-zero? exp) (-> lexp? boolean?) (match exp [(lexp: c h) (and (= 0 c) (terms-empty? h))])) (module+ test (check-false (lexp-zero? (lexp* 17 '(42 x)))) (check-false (lexp-zero? (lexp* 17))) (check-not-false (lexp-zero? (lexp* 0)))) ; l1 - l2 (define/cond-contract (lexp-subtract l1 l2) (-> lexp? lexp? lexp?) (match* (l1 l2) [((lexp: c1 h1) (lexp: c2 h2)) (lexp (- c1 c2) (terms-subtract h1 h2))])) ;; l1 + l2 (define/cond-contract (lexp-plus l1 l2) (-> lexp? lexp? lexp?) (match* (l1 l2) [((lexp: c1 h1) (lexp: c2 h2)) (lexp (+ c1 c2) (terms-add h1 h2))])) (module+ test (check-equal? (lexp-subtract (lexp* -1 '(2 x) '(3 y)) (lexp* -1 '(2 x) '(42 z))) (lexp* 0 '(3 y) '(-42 z))) (check-equal? (lexp-subtract (lexp* 0) (lexp* -1 '(2 x) '(42 z))) (lexp* 1 '(-2 x) '(-42 z)))) ; lexp-has-var? ; is 'x' a non-zero term in 'l' (define/cond-contract (lexp-has-var? l x) (-> lexp? any/c boolean?) (not (zero? (lexp-coeff l x)))) (module+ test (check-false (lexp-has-var? (lexp* 17 '(42 x)) 'y)) (check-not-false (lexp-has-var? (lexp* 17 '(42 x)) 'x))) (define/cond-contract (lexp-add1 l) (-> lexp? lexp?) (match l [(lexp: c h) (lexp (add1 c) h)])) (module+ test (check-equal? (lexp-add1 (lexp* 0)) (lexp* 1)) (check-equal? (lexp-add1 (lexp* 1 '(5 x))) (lexp* 2 '(5 x)))) ;; is this lexp just a constant? (i.e. no terms) (define/cond-contract (constant-lexp? l) (-> lexp? (or/c exact-integer? #f)) (match l [(lexp: const terms) (and (terms-empty? terms) const)])) ;; if this lexp is 1*x, return x (define/cond-contract (simple-lexp? exp) (-> lexp? any/c) (match exp [(lexp: c terms) (and ;; ps is length 1? (i.e. only 1 variable) (and (zero? c) (= 1 (terms-count terms)) (let ([pair (car (terms->list terms))]) (and (= 1 (cdr pair)) (car pair)))))])) (define/cond-contract (lexp->string e [pp #f]) (-> lexp? (-> any/c any/c) string?) (define vars (terms-vars (lexp-vars e))) (define const (lexp-const e)) (define term->string (λ (x) (string-append (if (= 1 (lexp-coeff e x)) "" (number->string (lexp-coeff e x))) "(" (if pp (pp x) (~a x)) ")"))) (cond [(terms-empty? vars) (number->string const)] [(zero? const) (for/fold ([str (term->string (car vars))]) ([var (in-list (cdr vars))]) (string-append str " + " (term->string var)))] [else (for/fold ([str (number->string const)]) ([var (in-list vars)]) (string-append str " + " (term->string var)))])) ;; ********** ********** L E Q s ********* ********** (define/cond-contract (leq lhs rhs) (-> lexp? lexp? leq?) (cons lhs rhs)) (define leq-lhs car) (define leq-rhs cdr) (define/cond-contract (leq-lexps ineq) (-> leq? (values lexp? lexp?)) (match ineq [(leq: lhs rhs) (values lhs rhs)])) (define/cond-contract (leq-contains-var? ineq x) (-> leq? any/c boolean?) (match ineq [(leq: lhs rhs) (or (lexp-has-var? lhs x) (lexp-has-var? rhs x))])) (define/cond-contract (leq-vars ineq) (-> leq? list) (let-values ([(l r) (leq-lexps ineq)]) (remove-duplicates (append (lexp-vars l) (lexp-vars r))))) ; leq-negate ; ~ (l1 <= l2) -> ; l2 <= 1 + l1 ; (obviously this is valid for integers only) (define/cond-contract (leq-negate ineq) (-> leq? leq?) (match ineq [(leq: (lexp: c-l terms-l) (lexp: c-r terms-r)) (define c-r* (add1 c-r)) (cond [(eqv? c-l c-r*) (leq (lexp 0 terms-r) (lexp 0 terms-l))] [(< c-l c-r*) (leq (lexp (- c-r* c-l) terms-r) (lexp 0 terms-l))] [else (leq (lexp 0 terms-r) (lexp (- c-l c-r*) terms-l))])])) (module+ test (check-equal? (leq-negate (leq (lexp* 0 '(1 x)) (lexp* 0 '(1 y)))) (leq (lexp* 1 '(1 y)) (lexp* 0 '(1 x))))) ;; leq-isolate-var ;; converts leq with x into either: ;; 1) ax <= by + cz + ... ;; or ;; 2) by + cz + ... <= ax ;; where a is a positive integer and x is on at most ;; one side of the inequality (define/cond-contract (leq-isolate-var ineq x) (-> leq? any/c leq?) (match ineq [(leq: (lexp: lhs-c lhs-ts) (lexp: rhs-c rhs-ts)) (define x-lhs-coeff (terms-ref lhs-ts x)) (define x-rhs-coeff (terms-ref rhs-ts x)) (cond ;; ...1 + ax + ...2 <= ...3 + ax + ...4 ;; remove x ;; --> ;; ...1 + ...2 <= ...3 + ...4 [(eqv? x-lhs-coeff x-rhs-coeff) (define lhs* (lexp lhs-c (terms-remove lhs-ts x))) (define rhs* (lexp rhs-c (terms-remove rhs-ts x))) (leq lhs* rhs*)] ;; ...1 + ax + ...2 <= ...3 + bx + ...4 where a < b ;; isolate x so it is on the rhs ;; --> ...1 + ...2 - ...3 - ...4 <= (bx - ax) [(< x-lhs-coeff x-rhs-coeff) (define lhs* ;; lhs - rhs (w/ x removed from the result) (let ([lhs-c* (- lhs-c rhs-c)] [lhs-h* (terms-subtract lhs-ts rhs-ts)]) (lexp lhs-c* (terms-remove lhs-h* x)))) (define rhs* (lexp 0 (make-terms x (- x-rhs-coeff x-lhs-coeff)))) (leq lhs* rhs*)] ;; ...1 + ax + ...2 <= ...3 + bx + ...4 where a > b ;; isolate x so it is on the lhs ;; --> (ax - bx) <= ...3 + ...4 - ...1 - ...2 [else (define lhs* (lexp 0 (make-terms x (- x-lhs-coeff x-rhs-coeff)))) (define rhs* (let ([rhs-c* (- rhs-c lhs-c)] [rhs-h* (terms-subtract rhs-ts lhs-ts)]) (lexp rhs-c* (terms-remove rhs-h* x)))) (leq lhs* rhs*)])])) ; x lhs (module+ test (check-equal? (leq-isolate-var (leq (lexp* '(3 x) '(2 z) '(5 y)) (lexp* '(1 x) '(1 z))) 'x) (leq (lexp* '(2 x)) (lexp* '(-5 y) '(-1 z)))) ;; x rhs (check-equal? (leq-isolate-var (leq (lexp* '(3 x) '(2 z) '(5 y)) (lexp* '(1 z) '(33 x))) 'x) (leq (lexp* '(1 z) '(5 y)) (lexp* '(30 x)))) ;; x eq (check-equal? (leq-isolate-var (leq (lexp* '(42 x) '(2 z) '(5 y)) (lexp* '(42 x) '(1 z))) 'x) (leq (lexp* '(2 z) '(5 y)) (lexp* '(1 z)))) ;; no x (check-equal? (leq-isolate-var (leq (lexp* '(2 z) '(5 y)) (lexp* '(1 z))) 'x) (leq (lexp* '(2 z) '(5 y)) (lexp* '(1 z)))) ; x mix (check-equal? (leq-isolate-var (leq (lexp* '(2 x) '(4 y) 1) (lexp* '(2 y))) 'x) (leq (lexp* '(2 x)) (lexp* '-1 '(-2 y))))) ;; leq-join ;; takes a pair a1x <= l1 and l2 <= a2x ;; and returns a2l1 <= a1l2 (define/cond-contract (leq-join leq1 leq2 x) (-> leq? leq? any/c leq?) ;; leq1: ... + ax + .... <= ... + bx + ... ;; leq2: ... + cx + .... <= ... + dx + ... (let-values ([(l1 r1) (leq-lexps leq1)] [(l2 r2) (leq-lexps leq2)]) (let ([a (lexp-coeff l1 x)] [b (lexp-coeff r1 x)] [c (lexp-coeff l2 x)] [d (lexp-coeff r2 x)]) (cond ;; leq1: ax <= lexp1 ;; leq2: lexp2 <= dx [(and (eqv? 0 b) (eqv? 0 c)) (leq (lexp-scale l2 a) (lexp-scale r1 d))] ;; leq1: lexp1 <= bx ;; leq2: cx <= lexp2 [(and (eqv? 0 a) (eqv? 0 d)) (leq (lexp-scale l1 c) (lexp-scale r2 b))] [else (error 'leq-join "cannot join ~a and ~a by ~a" leq1 leq2 x)])))) (module+ test (check-equal? (leq-join (leq (lexp* '(2 x)) (lexp* '(4 y) 10)) (leq (lexp* '(4 z) 2) (lexp* '(4 x))) 'x) (leq (lexp* '(8 z) 4) (lexp* '(16 y) 40)))) (define/cond-contract (leq-trivially-valid? ineq) (-> leq? boolean?) (let-values ([(l r) (leq-lexps ineq)]) (or (and (constant-lexp? l) (constant-lexp? r) (<= (lexp-const l) (lexp-const r))) (equal? l r)))) (define/cond-contract (leq-trivially-invalid? ineq) (-> leq? boolean?) (let-values ([(l r) (leq-lexps ineq)]) (and (constant-lexp? l) (constant-lexp? r) (< (lexp-const r) (lexp-const l))))) (define/cond-contract (leq->string ineq [pp #f]) (-> leq? (-> any/c any/c) string?) (define-values (lhs rhs) (leq-lexps ineq)) (string-append (lexp->string lhs pp) " ≤ " (lexp->string rhs pp))) ;; ******** ******** SLIs ******** ******** ;; (i.e. system of linear inequalities) (define/cond-contract (sli->string sli) (-> sli? string?) (string-append (cond [(null? sli) "("] [else (for/fold ([str (leq->string (car sli))]) ([ineq (cdr sli)]) (string-append str " ∧ "(leq->string ineq)))]) ")")) (define/cond-contract (sli-trivially-valid? s) (-> sli? boolean?) (for/and ([ineq (in-list s)]) (leq-trivially-valid? ineq))) (define/cond-contract (sli-vars sli) (-> sli? list?) (remove-duplicates (append-map leq-vars sli))) (module+ test (check-equal? (sort (sli-vars (list (leq (lexp* '(1 x)) (lexp* '(1 y))) (leq (lexp* '(1 x) '(1 z)) (lexp* '(1 q))) (leq (lexp* '(1 r) '(3 z)) (lexp* '(1 x))))) symbol<?) (sort (list 'r 'q 'z 'y 'x) symbol<?)) (check-equal? (length (sli-vars (list (leq (lexp* '(1 x)) (lexp* '(1 y))) (leq (lexp* '(1 x) '(1 z)) (lexp* '(1 q))) (leq (lexp* '(1 r) '(3 z)) (lexp* '(1 x)))))) 5)) ;; sli-partition ;; partitions leq expressions into ;; 3 lists of x-normalized inequalities: ;; value 1) set of (ax <= by + cz + ...) leqs ;; value 2) set of form (by + cz + ... <= ax) leqs ;; value 3) leqs w/o x (define/cond-contract (sli-partition leqs x) (-> sli? any/c (values (listof leq?) (listof leq?) (listof leq?))) (for/fold ([xlhs '()] [xrhs '()] [nox '()]) ([ineq (in-list leqs)]) (let ([ineq (leq-isolate-var ineq x)]) (cond [(lexp-has-var? (leq-lhs ineq) x) (values (cons ineq xlhs) xrhs nox)] [(lexp-has-var? (leq-rhs ineq) x) (values xlhs (cons ineq xrhs) nox)] [else (values xlhs xrhs (cons ineq nox))])))) (module+ test (check-equal? (let-values ([(lt gt no) (sli-partition (list (leq (lexp* '(2 x) '(4 y) 1) (lexp* '(2 y)))) 'x)]) (list lt gt no)) (list (list (leq (lexp* '(2 x)) (lexp* '(-2 y) -1))) (list) (list))) (check-equal? (let-values ([(lt gt no) (sli-partition (list (leq (lexp* '(2 x) '(4 y) 1) (lexp* '(2 y))) (leq (lexp* '(2 x) '(4 y)) (lexp* '(2 y) '(42 x)))) 'x)]) (list lt gt no)) (list (list (leq (lexp* '(2 x)) (lexp* '(-2 y) -1))) (list (leq (lexp* '(2 y)) (lexp* '(40 x)))) (list))) (check-equal? (let-values ([(lt gt no) (sli-partition (list (leq (lexp* '(2 x) '(4 y) -1) (lexp* '(2 y))) (leq (lexp* '(2 x) '(4 y)) (lexp* '(2 y) '(42 x))) (leq (lexp* '(2 z) '(4 y)) (lexp* '(2 y) '(42 q)))) 'x)]) (list lt gt no)) (list (list (leq (lexp* '(2 x)) (lexp* '(-2 y) 1))) (list (leq (lexp* '(2 y)) (lexp* '(40 x)))) (list (leq (lexp* '(2 z) '(4 y)) (lexp* '(2 y) '(42 q))))))) ;; fme-elim ;; reduces the system of linear inequalties, eliminating x ;; (does so while preventing duplicate leqs) (define/cond-contract (fme-elim sli x) (-> sli? any/c sli?) (define-values (xltleqs xgtleqs noxleqs) (sli-partition sli x)) (define leqs (make-hash)) (for ([l (in-list noxleqs)]) (hash-set! leqs l #t)) (for* ([l1 (in-list xltleqs)] [l2 (in-list xgtleqs)]) (hash-set! leqs (leq-join l1 l2 x) #t)) (hash-keys leqs)) ;; sli-satisfiable? (define/cond-contract (fme-sat? sli) (-> sli? boolean?) (let* ([vars (sli-vars sli)] [simple-system (for/fold ([s sli]) ([x (in-list vars)]) (fme-elim s x))]) (for/and ([ineq (in-list simple-system)]) (leq-trivially-valid? ineq)))) (module+ test ; 3x + 2y <= 7; 6x + 4y <= 15; -x <= 1; 0 <= 2y has integer solutions (check-true (fme-sat? (list (leq (lexp* '(3 x) '(2 y)) (lexp* 7)) (leq (lexp* '(6 x) '(4 y)) (lexp* 15)) (leq (lexp* '(-1 x)) (lexp* 1)) (leq (lexp* 0) (lexp* '(2 y)))))) ; 3x + 2y <= 4; 1 <= x; 1 <= y no solutions (check-false (fme-sat? (list (leq (lexp* '(3 x) '(2 y)) (lexp* 4)) (leq (lexp* 1) (lexp* '(1 x))) (leq (lexp* 1) (lexp* '(1 y))))))) ;;********************************************************************** ;; Logical Implication for Integer Linear Inequalities ;; using Fourier-Motzkin elimination ;;********************************************************************** (define/cond-contract (fme-imp-leq? s ineq) (-> sli? leq? boolean?) (or (and (member ineq s) #t) (not (fme-sat? (cons (leq-negate ineq) s))))) (module+ test ; transitivity! x <= y /\ y <= z --> x <= z (check-true (fme-imp-leq? (list (leq (lexp* '(1 x)) (lexp* '(1 y))) (leq (lexp* '(1 y)) (lexp* '(1 z)))) (leq (lexp* '(1 x)) (lexp* '(1 z))))) ; x <= x; (check-true (fme-imp-leq? (list) (leq (lexp* '(1 x)) (lexp* '(1 x))))) ; x - 1 <= x + 1; (check-true (fme-imp-leq? (list) (leq (lexp* '(1 x) -1) (lexp* '(1 x) 1)))) ; x + y <= z; 1 <= y; 0 <= x --> x + 1 <= z (check-true (fme-imp-leq? (list (leq (lexp* '(1 x) '(1 y)) (lexp* '(1 z))) (leq (lexp* 1) (lexp* '(1 y))) (leq (lexp*) (lexp* '(1 x)))) (leq (lexp* '(1 x) 1) (lexp* '(1 z)))))) ;;********************************************************************** ;; Simple Inequality Implication (does P imply Q) ;;********************************************************************** (define/cond-contract (leq-imp-leq? P Q) (-> leq? leq? boolean?) (or (equal? P Q) ;; (P -> Q) == (~P or Q) == ~(P and ~Q) (not (fme-sat? (list P (leq-negate Q)))))) (module+ test (check-true (leq-imp-leq? (leq (lexp* '(1 x)) (lexp* '(1 y))) (leq (lexp* '(1 x)) (lexp* '(1 y))))) (check-true (leq-imp-leq? (leq (lexp* '(1 x)) (lexp* 14)) (leq (lexp* '(1 x)) (lexp* 15)))) (check-true (leq-imp-leq? (leq (lexp* '(1 x) '(1 y)) (lexp* 14)) (leq (lexp* '(1 x) '(1 y)) (lexp* 20)))) (check-false (leq-imp-leq? (leq (lexp* '(1 x) '(1 y)) (lexp* 14)) (leq (lexp* '(1 x)) (lexp* 14))))) ;;********************************************************************** ;; Contradictory leqs? ~(P and Q) ;;********************************************************************** (define/cond-contract (contradictory-leqs? P Q) (-> leq? leq? boolean?) ;; (P -> Q) == (~P or Q) == ~(P and ~Q) (not (fme-sat? (list P Q)))) (module+ test (check-true (contradictory-leqs? (leq (lexp* 2) (lexp* 1)) (leq (lexp* '(1 y)) (lexp* '(1 x))))) (check-true (contradictory-leqs? (leq (lexp* '(1 x)) (lexp* '(1 y))) (leq (lexp* 1 '(1 y)) (lexp* '(1 x))))) (check-false (contradictory-leqs? (leq (lexp* '(1 x)) (lexp* '(1 y))) (leq (lexp* '(1 x)) (lexp* '(1 y))))) (check-false (contradictory-leqs? (leq (lexp* 1) (lexp* 2)) (leq (lexp* 2) (lexp* 3))))) ;;********************************************************************** ;; Logical Implication for Systems of Integer Linear Inequalities ;; using Fourier-Motzkin elimination ;;********************************************************************** (define/cond-contract (fme-imp? axioms goals) (-> sli? sli? boolean?) (for/and ([ineq (in-list goals)]) (fme-imp-leq? axioms ineq))) (module+ test ;; 4 <= 3 is false (check-false (fme-imp? (list) (list (leq (lexp* 4) (lexp* 3))))) ;; P and ~P --> false (check-true (fme-imp? (list (leq (lexp*) (lexp* '(1 y))) (leq-negate (leq (lexp*) (lexp* '(1 y))))) (list (leq (lexp* 4) (lexp* 3))))) ;; x + y <= z; 0 <= y; 0 <= x --> x <= z /\ y <= z (check-true (fme-imp? (list (leq (lexp* '(1 x) '(1 y)) (lexp* '(1 z))) (leq (lexp*) (lexp* '(1 y))) (leq (lexp*) (lexp* '(1 x)))) (list (leq (lexp* '(1 x)) (lexp* '(1 z))) (leq (lexp* '(1 y)) (lexp* '(1 z)))))) ;; x + y <= z; 0 <= y; 0 <= x -/-> x <= z /\ y <= q (check-false (fme-imp? (list (leq (lexp* '(1 x) '(1 y)) (lexp* '(1 z))) (leq (lexp*) (lexp* '(1 y))) (leq (lexp*) (lexp* '(1 x)))) (list (leq (lexp* '(1 x)) (lexp* '(1 z))) (leq (lexp* '(1 y)) (lexp* '(1 q)))))) ;; 7x <= 29 --> x <= 4 (check-true (fme-imp? (list (leq (lexp* '(7 x)) (lexp* 29))) (list (leq (lexp* '(1 x)) (lexp* 4))))) ;; 7x <= 28 --> x <= 4 (check-true (fme-imp? (list (leq (lexp* '(7 x)) (lexp* 28))) (list (leq (lexp* '(1 x)) (lexp* 4))))) ;; 7x <= 28 does not --> x <= 3 (check-false (fme-imp? (list (leq (lexp* '(7 x)) (lexp* 28))) (list (leq (lexp* '(1 x)) (lexp* 3))))) ;; 7x <= 27 --> x <= 3 (check-true (fme-imp? (list (leq (lexp* '(7 x)) (lexp* 27))) (list (leq (lexp* '(1 x)) (lexp* 3))))) ;; 4x+3y+9z+20q-100r + 42 <= 4x+3y+9z+20q+100r; ;; x <= y + z; ;; 29r <= x + y + z + q; ;; 0 <= x; ;; 0 <= x + y + z; ;; 0 <= x + z; ;; x <= z ;; z + 1 <= t ;; 0 <= x + y; ;; 0 <= x + r; ;; 0 <= x + r + q; ;; --> ;; 0 <= t (check-true (fme-imp? (list (leq (lexp* '(4 x) '(3 y) '(9 z) '(20 q) '(-100 r) 42) (lexp* '(4 x) '(3 y) '(9 z) '(20 q) '(100 r))) (leq (lexp* '(1 x)) (lexp* '(1 y) '(1 z))) (leq (lexp* '(29 r)) (lexp* '(1 x) '(1 y) '(1 z) '(1 q))) (leq (lexp*) (lexp* '(1 x))) (leq (lexp*) (lexp* '(1 x) '(1 y) '(1 z))) (leq (lexp*) (lexp* '(1 x) '(1 z))) (leq (lexp* '(1 x)) (lexp* '(1 z))) (leq (lexp* '(1 z) 1) (lexp* '(1 t))) (leq (lexp*) (lexp* '(1 x) '(1 y))) (leq (lexp*) (lexp* '(1 x) '(1 r))) (leq (lexp*) (lexp* '(1 x) '(1 r) '(1 q)))) (list (leq (lexp*) (lexp* '(1 t)))))) ;; 4x+3y+9z+20q-100r + 42 <= 4x+3y+9z+20q+100r; ;; x <= y + z; ;; 29r <= x + y + z + q; ;; 0 <= x; ;; 0 <= x + y + z; ;; 0 <= x + z; ;; x <= z ;; z + 1 <= t ;; 0 <= x + y; ;; 0 <= x + r; ;; 0 <= x + r + q; ;; -/-> ;; t <= 0 (check-false (fme-imp? (list (leq (lexp* '(4 x) '(3 y) '(9 z) '(20 q) '(-100 r) 42) (lexp* '(4 x) '(3 y) '(9 z) '(20 q) '(100 r))) (leq (lexp* '(1 x)) (lexp* '(1 y) '(1 z))) (leq (lexp* '(29 r)) (lexp* '(1 x) '(1 y) '(1 z) '(1 q))) (leq (lexp*) (lexp* '(1 x))) (leq (lexp*) (lexp* '(1 x) '(1 y) '(1 z))) (leq (lexp*) (lexp* '(1 x) '(1 z))) (leq (lexp* '(1 x)) (lexp* '(1 z))) (leq (lexp* '(1 z) 1) (lexp* '(1 t))) (leq (lexp*) (lexp* '(1 x) '(1 y))) (leq (lexp*) (lexp* '(1 x) '(1 r))) (leq (lexp*) (lexp* '(1 x) '(1 r) '(1 q)))) (list (leq (lexp* '(1 t)) (lexp*))))))
true
14ee34ac1bfd42966a9e4be5eb3deb632f24b367
416e7d2651195905c2d8370744b248c8ebefa3b5
/dkanren-benchmarks/benchmarks.rkt
c185bdd1903fb78dfd265c9f25d4c765478dec16
[ "MIT" ]
permissive
gregr/dKanren
0758f640d3ba1b8669257264bdac0f952a809b1b
2f05275b00dfba5c2f0ca196a514c377b3b60798
refs/heads/master
"2021-04-03T04:12:46.775763"
"2020-03-28T13:08:04"
"2020-03-28T13:08:04"
83,606,045
16
3
null
"2017-04-08T01:05:17"
"2017-03-01T22:00:02"
Racket
UTF-8
Racket
false
false
11,909
rkt
benchmarks.rkt
#lang racket/base (require (rename-in "lifted-closure-encoding.rkt" (term? term-lifted-closure?) (eval-term eval-term-lifted-closure) (initial-env initial-env-lifted-closure)) (rename-in "closure-encoding.rkt" (term? term-closure-encoded?) (eval-term eval-term-closure-encoded) (initial-env initial-env-closure-encoded)) (rename-in "raw.rkt" (term? term-raw?) (eval-term eval-term-raw) (initial-env initial-env-raw)) racket/list racket/match ) (define problem-iterations 100) (define problem-size 10) ;; Use this size to differentiate immediate and runtime scheme eval, but ;; remember to turn off the slow evaluators! ;(define problem-size 10000) (define (run/scheme-eval term) (eval term)) (define (run/raw-eval term) (eval-term-raw term initial-env-raw)) (define (run/closure-eval term) (eval-term-closure-encoded term initial-env-closure-encoded)) (define (run/lifted-closure-eval term) (let-values (((st v) ((eval-term-lifted-closure term initial-env-lifted-closure) #t))) v)) (define (run/scheme-eval-eval term) (run/eval-eval run/scheme-eval term)) (define (run/raw-eval-eval term) (run/eval-eval run/raw-eval term)) (define (run/closure-eval-eval term) (run/eval-eval run/closure-eval term)) (define (run/lifted-closure-eval-eval term) (run/eval-eval run/lifted-closure-eval term)) (define (run/eval-eval run/eval term) (run/eval `(let ((closure-tag ',(gensym "#%closure")) (prim-tag ',(gensym "#%primitive")) (empty-env '())) (let ((initial-env `((cons . (val . (,prim-tag . cons))) (car . (val . (,prim-tag . car))) (cdr . (val . (,prim-tag . cdr))) (null? . (val . (,prim-tag . null?))) (pair? . (val . (,prim-tag . pair?))) (symbol? . (val . (,prim-tag . symbol?))) (not . (val . (,prim-tag . not))) (equal? . (val . (,prim-tag . equal?))) (list . (val . (,closure-tag (lambda x x) ,empty-env))) . ,empty-env)) (closure-tag? (lambda (v) (equal? v closure-tag))) (prim-tag? (lambda (v) (equal? v prim-tag)))) (letrec ((applicable-tag? (lambda (v) (or (closure-tag? v) (prim-tag? v)))) (quotable? (lambda (v) (match v ((? symbol?) (not (applicable-tag? v))) (`(,a . ,d) (and (quotable? a) (quotable? d))) (_ #t)))) (not-in-params? (lambda (ps sym) (match ps ('() #t) (`(,a . ,d) (and (not (equal? a sym)) (not-in-params? d sym)))))) (param-list? (lambda (x) (match x ('() #t) (`(,(? symbol? a) . ,d) (and (param-list? d) (not-in-params? d a))) (_ #f)))) (params? (lambda (x) (match x ((? param-list?) #t) (x (symbol? x))))) (in-env? (lambda (env sym) (match env ('() #f) (`((,a . ,_). ,d) (or (equal? a sym) (in-env? d sym)))))) (extend-env* (lambda (params args env) (match `(,params . ,args) (`(() . ()) env) (`((,x . ,dx*) . (,a . ,da*)) (extend-env* dx* da* `((,x . (val . ,a)) . ,env)))))) (lookup (lambda (env sym) (match env (`((,y . ,b) . ,rest) (if (equal? sym y) (match b (`(val . ,v) v) (`(rec . ,lam-expr) `(,closure-tag ,lam-expr ,env))) (lookup rest sym)))))) (term? (lambda (term env) (letrec ((term1? (lambda (v) (term? v env))) (terms? (lambda (ts env) (match ts ('() #t) (`(,t . ,ts) (and (term? t env) (terms? ts env))))))) (match term (#t #t) (#f #t) ((? number?) #t) ((and (? symbol? sym)) (in-env? env sym)) (`(,(? term1?) . ,rands) (terms? rands env)) (`(quote ,datum) (quotable? datum)) (`(if ,c ,t ,f) (and (term1? c) (term1? t) (term1? f))) (`(lambda ,params ,body) (and (params? params) (let ((res (match params ((and (not (? symbol?)) params) (extend-env* params params env)) (sym `((,sym . (val . ,sym)) . ,env))))) (term? body res)))) (`(letrec ((,p-name ,(and `(lambda ,params ,body) lam-expr))) ,letrec-body) (and (params? params) (let ((res `((,p-name . (rec . (lambda ,params ,body))) . ,env))) (and (term? lam-expr res) (term? letrec-body res))))) (_ #f))))) (eval-prim (lambda (prim-id args) (match `(,prim-id . ,args) (`(cons ,a ,d) `(,a . ,d)) (`(car (,(and (not (? applicable-tag?)) a) . ,d)) a) (`(cdr (,(and (not (? applicable-tag?)) a) . ,d)) d) (`(null? ,v) (match v ('() #t) (_ #f))) (`(pair? ,v) (match v (`(,(not (? applicable-tag?)) . ,_) #t) (_ #f))) (`(symbol? ,v) (symbol? v)) (`(number? ,v) (number? v)) (`(not ,v) (match v (#f #t) (_ #f))) (`(equal? ,v1 ,v2) (equal? v1 v2))))) (eval-term-list (lambda (terms env) (match terms ('() '()) (`(,term . ,terms) `(,(eval-term term env) . ,(eval-term-list terms env)))))) (eval-term (lambda (term env) (let ((bound? (lambda (sym) (in-env? env sym))) (term1? (lambda (v) (term? v env)))) (match term (#t #t) (#f #f) ((? number? num) num) (`(,(and 'quote (not (? bound?))) ,(? quotable? datum)) datum) ((? symbol? sym) (lookup env sym)) ((and `(,op . ,_) operation) (match operation (`(,(or (? bound?) (not (? symbol?))) . ,rands) (let ((op (eval-term op env)) (a* (eval-term-list rands env))) (match op (`(,(? prim-tag?) . ,prim-id) (eval-prim prim-id a*)) (`(,(? closure-tag?) (lambda ,x ,body) ,env^) (let ((res (match x ((and (not (? symbol?)) params) (extend-env* params a* env^)) (sym `((,sym . (val . ,a*)) . ,env^))))) (eval-term body res)))))) (`(if ,condition ,alt-true ,alt-false) (if (eval-term condition env) (eval-term alt-true env) (eval-term alt-false env))) (`(lambda ,params ,body) `(,closure-tag (lambda ,params ,body) ,env)) (`(letrec ((,p-name (lambda ,params ,body))) ,letrec-body) (eval-term letrec-body `((,p-name . (rec . (lambda ,params ,body))) . ,env)))))))))) (let ((program ',term)) (eval-term program initial-env))))))) (define ex-append `(letrec ((append (lambda (xs ys) (if (null? xs) ys (cons (car xs) (append (cdr xs) ys)))))) (list . ,(make-list problem-iterations `(append ',(range problem-size) '()))))) (define ex-reverse-quadratic `(letrec ((append (lambda (xs ys) (if (null? xs) ys (cons (car xs) (append (cdr xs) ys)))))) (letrec ((reverse (lambda (xs) (if (null? xs) '() (append (reverse (cdr xs)) (list (car xs))))))) (list . ,(make-list problem-iterations `(reverse ',(range problem-size))))))) (define (benchmark) (let loop-prog ((programs `((append ,ex-append) (reverse-quadratic ,ex-reverse-quadratic) ))) (when (pair? programs) (let ((program (car programs)) (programs (cdr programs))) (newline) (displayln `(program: ,(car program))) (let loop-eval ((runners `((scheme-eval-static ,(eval `(lambda (,(gensym "unused")) ,(cadr program)))) (scheme-eval-runtime ,run/scheme-eval) (closure-eval ,run/closure-eval) (lifted-closure-eval ,run/lifted-closure-eval) (raw-eval ,run/raw-eval) ;; TODO: this needs to require racket/match ;(scheme-eval-eval ,run/scheme-eval-eval) (closure-eval-eval ,run/closure-eval-eval) (lifted-closure-eval-eval ,run/lifted-closure-eval-eval) (raw-eval-eval ,run/raw-eval-eval) ))) (if (null? runners) (loop-prog programs) (let ((runner (car runners)) (runners (cdr runners))) (collect-garbage 'major) (displayln `(evaluator: ,(car runner))) (time (void ((cadr runner) (cadr program)))) ;(time (displayln ((cadr runner) (cadr program)))) (loop-eval runners)))))))) (benchmark) ; TODO: port these to Chez Scheme ; deterministic evaluation benchmark ideas to measure sources of overhead ; across programs: append, reverse, map, fold, mini interpreter, remove-foo, etc. ; across program implementations: tailcall, w/ fold, etc. ; across runtimes: ; scheme, mk-only, mixed ; across interpreter architectures: ; static (scheme only) ; eval at runtime (scheme only) ; ahead-of-time compiled (dkanren only) ; closure encoding (mk would need to support procedure values) ; de bruin encoding (with and without integer support) ; raw interpretation ; original relational interpreter(s) (mk only)
false
3087b78d6d99ef0375de557f7c1c81a1f39de761
260f6f881a0964c3981186bb290b014882710a10
/2021/racket/day3.rkt
bceac036e97f30eeeb185d80d453a56023592075
[]
no_license
brprice/advent-of-code
3a03e780fe18fb6eb58a83c5c13d5b1e1558b9e7
e2e83e035edb0a1de2cd3de31aabde79f6aa8585
refs/heads/master
"2023-04-28T22:34:37.414670"
"2021-12-25T17:24:06"
"2021-12-25T17:27:17"
228,043,018
0
0
null
null
null
null
UTF-8
Racket
false
false
2,269
rkt
day3.rkt
#lang racket (define (with-data f) (call-with-input-file "../data/day3" (lambda (p) (f (sequence->stream (sequence-map string->bits (in-lines p))))))) (define (with-test-data f) (f (map string->bits (list "00100" "11110" "10110" "10111" "10101" "01111" "00111" "11100" "10000" "11001" "00010" "01010")))) (define (string->bits s) (sequence-map (lambda (c) (string->number (string c))) s)) ; takes the pointwise sum of two sequences, ignoring any excess elements ; when one is longer than the other (define (pointwise-sum xs ys) (sequence-map + (in-parallel xs ys))) (define-syntax-rule (fold-parallel ([f i] ...) s) (sequence-fold (lambda (accs x) (map (lambda (g acc) (g acc x)) (list f ...) accs)) (list i ...) s)) (define (majority-bits s #:eq [def 0]) (match (fold-parallel ([pointwise-sum (in-cycle (in-value 0))] [(lambda (l _) (+ l 1)) 0]) s) [(list count-1s lines) (sequence-map (lambda (c1) (let ([c0 (- lines c1)]) (cond [(> c1 c0) 1] [(< c1 c0) 0] [else def]))) count-1s)])) (define (bits->number bs) (sequence-fold (lambda (acc b) (+ (* 2 acc) b)) 0 bs)) (define (part1 s) (let* ([maj (majority-bits s)] [gamma (bits->number maj)] [delta (bits->number (sequence-map (lambda (b) (- 1 b)) maj))]) (* gamma delta))) (printf "part 1: ~a\n" (with-data part1)) (define (o2 s) (bits->number (letrec ([go (lambda (i s) (let* ([maj (majority-bits s #:eq 1)] [sf (sequence-filter (lambda (n) (eq? (sequence-ref maj i) (sequence-ref n i))) s)]) (if (stream-empty? (stream-rest sf)) (stream-first sf) (go (+ 1 i) sf))))]) (go 0 s)))) (define (co2 s) (bits->number (letrec ([go (lambda (i s) (let* ([maj (majority-bits s #:eq 1)] [sf (sequence-filter (lambda (n) (eq? (- 1 (sequence-ref maj i)) (sequence-ref n i))) s)]) (if (stream-empty? (stream-rest sf)) (stream-first sf) (go (+ 1 i) sf))))]) (go 0 s)))) ; part 2: we don't worry about being efficient at all (define (part2 s) (* (o2 s) (co2 s))) (printf "part 2: ~a\n" (with-data part2))
true
18cac263aeefc413a56889f904efd96c5441e852
f5b99d59741af88067a78383cf2df94c06fe3710
/sicp/chap2/2.87.rkt
183e36fa5abefa58faf9fe8cf294ea01fa50c516
[ "MIT" ]
permissive
shouya/thinking-dumps
53921a23ff62dd6aa0580cec6da26b11b83dd818
6191a940f3fca4661a6f01663ef38b8ce57c9018
refs/heads/master
"2023-06-08T17:53:34.143893"
"2023-06-04T15:41:18"
"2023-06-04T15:41:18"
22,285,392
24
3
MIT
"2022-06-11T12:23:49"
"2014-07-26T11:40:12"
Coq
UTF-8
Racket
false
false
60
rkt
2.87.rkt
(require "alg.rkt") (install-=zero?-package) ;; from 2.80
false
eea6b80ef646706c9c56ec39122dc1c59107d3da
0e6d3bf1f7f37f06d4dbadf7a7917213c1729258
/base/top-level.rkt
898a634b6547e7a67206de29db8aacb3d1b46e48
[]
no_license
lewisbrown/Caper
9c042425be47e08a22f34b5f675ed5156d80c34d
be05f13f3189c7717cd14a223b0cb3b188fe5bb1
refs/heads/master
"2020-05-29T11:04:53.628197"
"2012-08-28T15:43:13"
"2012-08-28T15:43:13"
null
0
0
null
null
null
null
UTF-8
Racket
false
false
331
rkt
top-level.rkt
#lang racket/base (require caper/core/top-level caper/base/macros caper/base/atomic-ref) (provide ; from core prelude postlude begin-reagent computed bind-values define-reagent define-reagent-syntax react reagent pmacro (all-from-out caper/base/macros) (all-from-out caper/base/atomic-ref) )
false
6c27557f21d030b36261d5a53f5c87164aa8ee4a
25a6efe766d07c52c1994585af7d7f347553bf54
/gui-lib/mred/private/wxme/editor-data.rkt
1d07db510c79a2d8a9ee4f2cea548d52c5758dea
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
racket/gui
520ff8f4ae5704210822204aa7cd4b74dd4f3eef
d01d166149787e2d94176d3046764b35c7c0a876
refs/heads/master
"2023-08-25T15:24:17.693905"
"2023-08-10T16:45:35"
"2023-08-10T16:45:35"
27,413,435
72
96
NOASSERTION
"2023-09-14T17:09:52"
"2014-12-02T03:35:22"
Racket
UTF-8
Racket
false
false
5,318
rkt
editor-data.rkt
#lang racket/base (require racket/class racket/file file/convertible "../syntax.rkt" "private.rkt" racket/snip/private/snip-flags racket/snip/private/private racket/snip/private/style racket/snip/private/load-one (only-in "cycle.rkt" editor-stream-in% editor-stream-out% get-editor-data-class set-get-editor-data-class!) "../wx/common/event.rkt" racket/draw) (provide get-the-editor-data-class-list editor-data% editor-data-class% location-editor-data% editor-data-class-list<%> the-editor-data-class-list ;; parameter make-the-editor-data-class-list (struct-out editor-data-class-link)) ;; ------------------------------------------------------------ (defclass editor-data% object% (properties [[(make-or-false editor-data-class%) dataclass] #f] [[(make-or-false editor-data%) next] #f]) (super-new) (def/public (write [editor-stream-out% f]) (error 'write "should have overridden")) (define/public (get-s-dataclass) dataclass) (define/public (get-s-next) next) (define/public (set-s-next v) (set! next v))) (defclass location-editor-data% editor-data% (inherit set-dataclass) (init-field x y) (super-new) (set-dataclass the-location-editor-data-class) (define/public (get-x) x) (define/public (get-y) y) (def/override (write [editor-stream-out% f]) (send f put x) (send f put y) #t)) ;; ------------------------------------------------------------ (defclass editor-data-class% object% (define classname "wxbad") (def/public (set-classname [string? s]) (set! classname (string->immutable-string s))) (def/public (get-classname) classname) (properties [[bool? required?] #f]) (define/public (get-s-required?) required?) (def/public (read [editor-stream-in% f]) (void)) (super-new)) (defclass location-editor-data-class% editor-data-class% (inherit set-classname set-required?) (super-new) (set-classname "wxloc") (set-required? #t) (def/override (read [editor-stream-in% f]) (let ([x (send f get-inexact)] [y (send f get-inexact)]) (new location-editor-data% [x x][y y])))) (define the-location-editor-data-class (new location-editor-data-class%)) ;; ------------------------------------------------------------ (define-struct editor-data-class-link ([c #:mutable] [name #:mutable] map-position)) (defclass editor-data-class-list% object% (define ht (make-hash)) (define pos-ht (make-hash)) (define rev-pos-ht (make-hash)) (super-new) (add the-location-editor-data-class) (def/public (find [string? name]) (let ([c (hash-ref ht name #f)]) (or c (let ([c (get-editor-data-class name)]) (when c (add c)) c)))) (def/public (find-position [editor-data-class% c]) (hash-ref pos-ht c 0)) (def/public (add [editor-data-class% c]) (let ([name (send c get-classname)]) (hash-set! ht name c) (let ([n (add1 (hash-count pos-ht))]) (hash-set! pos-ht c n) (hash-set! rev-pos-ht n c)))) (def/public (number) (hash-count ht)) (def/public (nth [exact-nonnegative-integer? n]) (hash-ref rev-pos-ht n #f)) (def/public (write [editor-stream-out% f]) (let ([n (number)]) (send f put n) (for ([i (in-range 1 (add1 n))]) (let ([c (nth i)]) (send f put (string->bytes/utf-8 (send c get-classname))) (send f add-dl (make-editor-data-class-link c #f i))))) #t) (def/public (read [editor-stream-in% f]) (let-boxes ([count 0]) (send f get count) (for/and ([i (in-range count)]) (let ([s (send f get-bytes)]) (and (send f ok?) (send f add-dl (make-editor-data-class-link #f (bytes->string/utf-8 s #\?) (add1 i))) #t))))) (define/public (find-by-map-position f n) (ormap (lambda (s) (and (= n (editor-data-class-link-map-position s)) (begin (when (editor-data-class-link-name s) (let ([c (find (editor-data-class-link-name s))]) (when (not c) ;; unknown class/version (log-error (format "unknown editor data class: ~e" (editor-data-class-link-name s)))) (set-editor-data-class-link-name! s #f) (set-editor-data-class-link-c! s c))) (editor-data-class-link-c s)))) (send f get-dl)))) (define editor-data-class-list<%> (class->interface editor-data-class-list%)) (define (make-the-editor-data-class-list) (new editor-data-class-list%)) (define the-editor-data-class-list (make-parameter (make-the-editor-data-class-list))) (define (get-the-editor-data-class-list) (the-editor-data-class-list)) (set-get-editor-data-class! (lambda (name) (load-one name 'editor-data-class editor-data-class%)))
false
91540028b918a788fab9ebb5f6c838a11f6a3608
5a19631a10bab15dafa5353bfb2faa454e5be6b9
/Brasilia_2013/notes.scrbl
e52d4a6f046419d5798d28e6d61f5026b90df9d7
[]
no_license
amkhlv/talks
3d14256dbf58c9c5534fdca585bad0055cf31371
04ab693beffb4c132fd83577b28c6472fd27bd34
refs/heads/master
"2021-09-08T07:40:54.579550"
"2021-09-04T17:50:50"
"2021-09-04T17:50:50"
14,686,398
0
0
null
null
null
null
UTF-8
Racket
false
false
31,694
scrbl
notes.scrbl
#lang scribble/base @(require racket scribble/core scribble/base scribble/html-properties) @(require "defs_for-syntax.rkt" (for-syntax (planet amkhlv/bystroTeX/slides_for-syntax))) @(require "defs.rkt" (planet amkhlv/bystroTeX/common) (planet amkhlv/bystroTeX/slides)) @(require (only-in db/base disconnect)) @; --------------------------------------------------------------------------------------------------- @; User definitions: @(define bystro-conf (bystro (find-executable-path "amkhlv-java-formula.sh") "notes/formulas.sqlite" ; name for the database "notes" ; directory where to store .png files of formulas 25 ; formula size (list 255 255 255) ; formula background color (list 0 0 0) ; formula foreground color 2 ; automatic alignment adjustment 0 ; manual alignment adjustment )) @; This controls the single page mode: @(define singlepage-mode #t) @; --------------------------------------------------------------------------------------------------- (define (start-formula-database) (configure-bystroTeX-using bystro-conf) (bystro-initialize-formula-collection bystro-conf)) (define formula-database (start-formula-database)) (unless (bystro-formula-processor bystro-conf) (error "*** could not find executable for formula processing ***")) @(bystro-def-formula "formula-enormula-humongula!") (bystro-titlepage-init #:singlepage-mode singlepage-mode)) @; --------------------------------------------------------------------------------------------------- @; AND HOPEFULLY SOME CONTENT: @(define amkhlv/css-dir (string->path "./")) @elem[#:style (make-style #f (list (make-css-addition (build-path amkhlv/css-dir "no-margin.css"))))]{} @elem[#:style (make-style #f (list (make-css-addition (build-path amkhlv/css-dir "misc.css"))))]{} @title{Notes on my talk in Brasilia} @table-of-contents[] @section{Pure spinor superstring} @subsection{Fundamental principle: Existence of the BRST operator} There are different approaches to string theory, which all start from slightly different (although similar) postulates. @spn[attn]{Pure spinor string} postulates (among other things) that the classical backgrounds of the Type IIB SUGRA are in one-to-one correspondence with the classical 2d sigma-models satisfying certain additional requirements. The requirements are: @itemlist[#:style 'ordered @item{The @f{\sigma}-model should be classically conformally invariant} @item{The @f{\sigma}-model should be classically invariant under a fermionic symmetry @f{Q} which is nilpotent: @f{Q^2 = 0}; it is usually called ``BRST symmetry''. Moreover: @itemlist[#:style 'ordered @item{The @f{\sigma}-model should be classically invariant under two @f{U(1)} symmetries called ``left and right ghost number''} @item{The BRST operator splits into two parts: @f{Q = Q_L + Q_R} where @f{Q_L} has left ghost number +1 and right ghost number 0, and @f{Q_R} has left ghost number 0 and right ghost number +1. The @f{Q_L} and @f{Q_R} should be separately nilpotent.} ]}] @subsection{Unintegrated vertices} @bold{Definition @th-num{SpaceOfOperators}:} ``@spn[attn]{Operators}'' are reasonably nice expressions built on the sigma-model fields and their derivatives, modulo the @f{\sigma}-model classical equations of motion. The sigma-model fields are typically matter fields @f{x,\theta} and ghosts @f{\lambda_L,\lambda_R,w_+,w_-}. The ghosts @f{\lambda_L,\lambda_R} satisfy the @spn[attn]{pure spinor constraints}: @equation[#:label "PureSpinorConstraints"]{ \lambda_L^{\alpha}\,\Gamma_{\alpha\beta}\,\lambda_L^{\beta} \; = \; \lambda_R^{\dot{\alpha}}\,\Gamma_{\dot{\alpha}\dot{\beta}}\,\lambda_R^{\dot{\beta}} = 0 } @bold{Definition @th-num{ConformalDimension}:} The @spn[attn]{conformal dimension} of an operator is defined as the total number of derivatives, plus the number of @f{w_{\pm}}. The BRST operator @f{Q}, being a symmetry of the theory, acts on such expressions. @bold{Definition @th-num{Ghost number}:} The @spn[attn]{ghost number} of an operator is the total number of @f{\lambda}'s minus the total number of @f{w's}. @bold{Definition @th-num{UnintegratedVertices}:} @spn[attn]{Unintegrated vertex} is an operator @f{V(x,\theta,\lambda)} of the conformal dimension zero annihilated by @f{Q}. The @spn[attn]{gauge transformation} of the vertex operator is: @equation[#:label "GaugeTransformationOfUnintegratedVertices"]{ V \mapsto V + Qu } @div[redbox]{Unintegrated operators form the cohomology of the BRST operator @f{Q} at the ghost number two. This is, essentially, the Hilbert space of states in the worldsheet sigma-model} It is a fundamental principle of the string theory, that every state corresponds to some deformation of the worldsheet theory. This leads to the concept of @bold{integrated vertex}, which we will now describe. @subsection{Integrated vertices} @bold{Definition @th-num{IntegratedVertex}:} @spn[attn]{Integrated vertices are deformations} of the string worldsheet theory, preserving the existence of the BRST structure: @equation[#:label "DeformationOfTheAction"]{ S \mapsto S + \int \;d\tau^+ d\tau^- \; U } --- this @f{U} is the integrated vertex. As we already said, there is the correspondence between physical states of the worldsheet theory and its deformations. This means that @bold{for every unintegrated vertex there exists a corresponding integrated vertex}. The correspondence is described by the @spn[attn]{descent procedure}, which goes as follows. Given some unintegrated vertex @f{V}, do the following: @align[r.l.n @list[ @v+[3 @f{dV \;=\;}] @f{QW} @label{DefW} ]@list[ @v+[3 @f{dW \;=\;}] @f{QU} @label{DefU} ]] @bold{Theorem @th-num{Descent}}: @spn[attn]{Exist} operators @f{W} and @f{U} defined in (@ref{DefW}) and (@ref{DefU}) exist. @div[redbox]{The main result in this talk is the proof of this theorem for the superstring in @f{AdS_5\times S^5}.} @subsection{Plan of the talk} In order to prove the descent procedure, we will need two ingredients: @itemlist[#:style 'ordered @item{Relation between the cohomology of @f{Q} and the @bold{Lie algebra cohomology}. @smaller{Lie algebra cohomology is the cohomology of the operator which is well-known to physicists:} @equation{Q_{\rm Lie} = c^a t_a - {1\over 2} f^a_{bc}\;c^bc^c{\partial\over\partial c^a}} @smaller{This is what is usually called ``BRST operator'' @italic{e.g.} in Yang-Mills theory. But mathematicians call such things ``Lie algebra cohomology''. It turns out that the BRST cohomology can be cast in this form.} } @item{Some observation about the @bold{integrable structure} of the worldsheet theory} ] @section{Simplest example of the pure spinor formalism} Here I will give the simplest nontrivial example of the pure spinor formalism. Consider the following @spn[attn]{pure spinor BRST operator} acting on functions of @f{x,\theta,\lambda} as follows: @equation[#:label "SimplestBRSTComplex"]{ Qf(x,\theta,\lambda) \; = \; \lambda^{\alpha}\left( {\partial\over\partial\theta^{\alpha}} + \theta^{\beta}\Gamma^m_{\beta\alpha}\; {\partial\over\partial x^m} \right)\;f(x,\theta,\lambda) } We assume that @f{f} are polynomials in @f{\lambda}. The @spn[attn]{simplest example of the pure spinor formalism} is given by the following @bold{Theorem @th-num{CohomologyOfSimplestBRSTComplex}:} The cohomology is nonzero only at the ghost number 1, and counts the solutions of SUSY Maxwell equations. @section{Algebras formed by covariant derivatives} We will start by relating the cohomology of (@ref{SimplestBRSTComplex}) with some Lie algebra cohomology. @itemlist[@item{ Pure spinor cohomology is related to the Lie algebra cohomology of some infinite-dimensional Lie superalgebra }] So, we have to first @bold{define} that infinite-dimensional Lie superalgebra. The definition is motivated by the super-Yang-Mills theory, and the resulting algebra is called SYM. Let us proceed to its definition. @subsection{The SYM algebra} Classical equations of motion of the ten-dimensional super-Yang-Mills algebra are @bold{encoded in the constraints}: @equation[#:label "QuadraticConstraint"]{\Gamma_{[m_1\ldots m_5]}^{\alpha\beta}\;\;\;\;\;\;\nabla_{\alpha}\nabla_{\beta} = 0} As a consequence of these constraints, there exist operators @f{\nabla_m} such that: @equation[#:label "SYMConstraints"]{ \{\nabla_{\alpha},\nabla_{\beta}\} = \Gamma_{\alpha\beta}{}^m \nabla_m } The actual definition of the operators @f{\nabla_{\alpha}} and @f{\nabla_m} in the super-Yang-Mill theory is: @align[r.l.n @list[ @f{\nabla_{\alpha} \;=\;} @f{{\partial\over\partial\theta^{\alpha}} + \theta^{\beta}\Gamma^m_{\beta\alpha}\;{\partial\over\partial x^m} + A_{\alpha}(x,\theta)} @label{InternalStructureOfNablaAlpha} ]@list[ @f{\nabla_m \;=\;} @f{{\partial\over\partial x^m} + A_m(x,\theta)} @label{InternalStructureOfNablaM} ]] @(fsize+ (- 3)) @div[comment]{ I am sorry for the abuse of notations; notice that @f{A_{\alpha}} and @f{A_m} are completely different fields; but in my notations the only difference between them is greek subindex @f{\alpha} @italic{vs.} latin subindex @f{m}. }@(fsize=) @div[redbox]{ Now let us forget about the ``internal structure'' of @f{\nabla_{\alpha}} and @f{\nabla_m} given by (@ref{InternalStructureOfNablaAlpha}) and (@ref{InternalStructureOfNablaM}) and think of Eq. (@ref{QuadraticConstraint}) as defining relations in an @(begin (bystro-fg 255 0 0) "") @spn[attn]{abstract algebra formed by the letters} @f{\nabla_{\alpha}}. @(begin (bystro-fg 0 0 0) "") } This is an infinite-dimensional algebra. Moreover, this is actually a @bold{quadratic algebra}, because the constraint (@ref{QuadraticConstraint}) is quadratic in generators. @subsubsection{Relation between the SYM algebra and the susy algebra} The Lie superalgebra @f{\rm susy} is formed by the operators @f{S_{\alpha}} and @f{T_m} with the following commutation relations: @align[r.l.n @list[ @f{\{S_{\alpha},S_{\beta}\} \;=\;} @f{\Gamma_{\alpha\beta}^m\; T_m} @label{AnticommutatorOfSAlpha} ]@list[ @f{\{S_{\alpha},T_m\} \;=\;} @f{0} "" ]] The algebra @f{\rm susy} (unlike SYM algebra) is finite-dimensional. There is a homomorphism from the SYM algebra to @f{\rm susy}: @align[r.l.n @list[ @f{\nabla_{\alpha} \;\to\;} @f{S_{\alpha}} @label{HomomorphismFromSYMToSUSY} ]] The kernel of this homomorphism is an ideal in SYM, which we will call @f{I_{\rm susy}}. We have: @equation[#:label "RelationBetweenSYMAndSUSY"]{ {\rm susy} = {\rm SYM}/I_{\rm susy} } @subsubsection{Cohomology of SYM algebra and pure spinor cohomology} Now we want to relate the cohomology of the operator (@ref{SimplestBRSTComplex}) to the cohomology of the Lie superalgebra SYM. It is convenient to start with a generalization of (@ref{SimplestBRSTComplex}). Remember that in (@ref{SimplestBRSTComplex}) the BRST operator is: @equation[#:label "SimpleQ"]{ Q \; = \; \lambda^{\alpha}\left( {\partial\over\partial\theta^{\alpha}} + \theta^{\beta}\Gamma^m_{\beta\alpha}\; {\partial\over\partial x^m} \right)} We observe that the components of pure spinor @f{\lambda^{\alpha}} get contracted with the differential operators @f-3{{\partial\over\partial\theta^{\alpha}} + \theta^{\beta}\Gamma^m_{\beta\alpha}\; {\partial\over\partial x^m}} which @bold{form a representation} of the algebra @f{\rm susy} (@ref{AnticommutatorOfSAlpha}). Let us therefore consider @bold{any} representation @f{V\;} of @f{\rm susy}. To every such representation corresponds a pure spinor BRST complex, which is constructed as follows. Let @f{{\cal P\,}^n} be the space of polynomials of the pure spinor variables @f{\lambda^{\alpha}} of degree @f{n}. It is assumed that @f-3{\lambda^{\alpha}\Gamma_{\alpha\beta}^m\;\lambda^{\beta}= 0}; in other words @f{{\cal P\,}^n} is the commutative algebra of polynomials of the degree @f{n} of the variables @f{\lambda^{\alpha}} modulo the ideal of polynomials divisible by the expression @f-3{\lambda^{\alpha}\Gamma^m_{\alpha\beta}\;\lambda^{\beta}}. @equation[#:label "PureSpinorBRSTComplexWithV"]{ \ldots\longrightarrow {\cal P\,}^n\otimes V \xrightarrow{Q} {\cal P\,}^{n+1}\otimes V \longrightarrow \ldots } where the BRST operator acts as follows (compare to (@ref{SimpleQ})): @equation[#:label "BRSTOperatorOfSYM"]{Q = \lambda^{\alpha} S_{\alpha}} @div[redbox]{The cohomology of this complex is related to the Lie algebra cohomology of the SYM algebra.} In order to explain how, we have to notice that @f{V\;}, being a representation of @f{\rm susy}, is also a representation of @f{SYM} (because of the homomorphism (@ref{HomomorphismFromSYMToSUSY})). Then we have: @(fsize+ 10) @equation[#:label "BRSTForSYMvsLie"]{H^n(Q,V\;) = H^n({\rm SYM}, V\;)} @(fsize=) This is a very nontrivial theorem. Our goal is to establish a similar theorem in the SUGRA context. But before, let us consider some consequences. First of all, an important special case is when @f{V\;} is the dual space of the universal enveloping algebra of the @f{\rm susy} algebra: @equation{V = (U{\rm susy})'} This is the representation in the space of Taylor series of @bold{functions on the super-space-time}. In this case the cohomology of the BRST complex computes the @bold{solutions of the Maxwell equations}. @subsection{What we are going to do} We want some analogue of (@ref{BRSTForSYMvsLie}) for SUGRA. Let us first understand the LHS. The LHS should give the @spn[attn]{space of vertex operators} in a given background. Equivalently: this is the same as the space of solutions of the linearized SUGRA equations. (Linearized around a given background solution.) We will only discuss the case when the background solution is @f{AdS_5\times S^5} (or flat space as a limit of AdS). (Generalization of these methods to arbitrary backgrounds is work in progress.) @subsection{Superconformal algebra} @subsubsection{General definition and generators} It is important to remember that the classical SUGRA background @f{AdS_5\times S^5} has a large algebra of symmetries, the @bold{superconformal algebra} a.k.a. @f{{\bf psu}(2,2|4)}. We will denote it @f{{\bf g}}: @equation{{\bf g} = {\bf psu}(2,2|4)} It has the subalgebra @f{{\bf g}_{\bar{0}}\subset {\bf g}} which consists of those generators which preserve a fixed point: @equation{{\bf g}_{\bar{0}} = so(1,4)\oplus so(5)} Indeed, @f{AdS_5\times S^5} is a coset space: @equation{{AdS_5\times S^5} = G_{\bar{0}}\backslash G} Let us use a calligraphic index to parametrize the generators of @f{{\bf g}_{\bar{0}}}: @equation{[t^0_{\cal A}\;,\;t^0_{\cal B}] = f_{\cal AB}{}^{\cal C} t^0_{\cal C}} The rest of the generators of @f{{\bf psu}(2,2|4)} are denoted: @equation{t_{\hat{\alpha}}^1\;,\; t_m^2 \;,\; t_{\alpha}^3} The superindex @f{0,1,2,3} corresponds to some @f{{\bf Z}_4}-grading which we do not need now, we just have to remember that the generators @f{t^0_{\cal A}} generate @f{{\bf g}_{\bar{0}}}, and @f{t_{\hat{\alpha}}^1\;,\; t_m^2 \;,\; t_{\alpha}^3} generate the rest of @f{{\bf g}}. @subsubsection{Structure of commutation relations} The commutation relations are parametrized by the @bold{structure constants}. For our present purpose, we have to know the following facts: @itemlist[#:style 'ordered @item{First of all, @f{{\bf g}_{\bar{0}}} acts by the adjoint representation: @align[r.l.n @list[ @f{[t^0_{\cal A}\;,\,t^1_{\hat{\alpha}}\,] \;=\;} @v-[8 @f{f_{{\cal A}\hat{\alpha}}{}^{\hat{\beta}} t^1_{\hat{\beta}}}] "" ]@list[ @f{[t^0_{\cal A}\;,\,t^2_m\,] \;=\;} @f{f_{{\cal A}m}{}^n t^2_n} "" ]@list[ @f{[t^0_{\cal A}\;,\,t^3_{\alpha}\,] \;=\;} @v-[8 @f{f_{{\cal A}\alpha}{}^{\beta} t^1_{\beta}}] "" ]]} @item{We need to know that the commutator of @f{t^3_{\alpha}} and @f{t^1_{\hat{\beta}}} falls into @f{{\bf g}_{\bar{0}}}: @equation{\{t^3_{\alpha}\;,\,t^1_{\dot{\beta}}\} = f_{\alpha\dot{\beta}}{}^{\cal A} t^0_{\cal A}} } @item{The commutator @f{\{t_{\alpha}^3\;,\,t_{\beta}^3\}} is proportional to @f{t^2_m}, and moreover there is a basis where the structure constants are proportional to the gamma-matrices: @align[r.l.n @list[ @f{\{t^3_{\alpha}\;,\,t^3_{\beta}\} \;=\; } @f{\Gamma^m_{\alpha\beta}\; t^2_m} "" ]@list[ @f{\{t^1_{\hat{\alpha}}\;,\,t^1_{\hat{\beta}}\} \;=\; } @f{\Gamma^m_{\hat{\alpha}\hat{\beta}}\; t^2_m} "" ]] } ] We see that @bold{the superconformal algebra is somewhat similar to the @f{\rm susy} algebra (@ref{AnticommutatorOfSAlpha})}, or maybe we should say ``to a sum of two copies of it''. @subsection{Algebra @f{{\cal L}_{\rm tot}} and its relation to vertex operators} We will now extend the superconformal algebra to some infinite-dimensional algebra, just like @f{\rm susy} was extended to SYM. @subsubsection{Definition} We will take @bold{two copies} @f{{\cal L}_L} and @f{{\cal L}_R} of the SYM algebra (@ref{QuadraticConstraint}), add a copy of @f{{\bf g}_{\bar{0}}}, and @bold{glue them all together}: @align[r.l.n @list[ @f{\{\nabla^L_{\alpha},\nabla^R_{\dot{\beta}}\} =\;}@f{f_{\alpha\dot{\beta}}{}^{\cal A}t^0_{\cal A}\;\;\;}@label{NablaLNablaR} ]@list[ @f{[t^0_{\cal A}\;,\;\nabla^L_{\alpha}] = \;}@f{f_{{\cal A}\alpha}{}^{\beta}\nabla^L_{\beta}}@label{T0NablaL} ]@list[ @f{[t^0_{\cal A}\;,\;\nabla^R_{\dot{\alpha}}] = \;}@f{f_{{\cal A}\dot{\alpha}}{}^{\dot{\beta}}\nabla^R_{\dot{\beta}}}@label{T0NablaR} ]@list[ @f{\Gamma_{m_1\ldots m_5}^{\alpha\beta} \;\;\;\;\; \{\nabla^L_{\alpha}\;,\;\nabla^L_{\beta}\} = \;}@v+[6 @f{0}]@label{NablaLNablaL} ]@list[ @f{\Gamma_{m_1\ldots m_5}^{\dot{\alpha}\dot{\beta}} \;\;\;\;\; \{\nabla^R_{\dot{\alpha}}\;,\;\nabla^R_{\dot{\beta}}\} = \;}@v+[6 @f{0}]@label{NablaRNablaR} ]] In other words: @equation[#:label "Ltot"]{ {\cal L}_{\rm tot} = {\cal L}_L + {\cal L}_R + {\bf g}_{\bar{0}} } @subsubsection{BRST cohomology and relative cohomology} The analogue of (@ref{BRSTForSYMvsLie}) is: @equation[#:label "BRSTVsRelative"]{ H^n(Q,V\,) = H^n({\cal L}_{\rm tot}\;,\;{\bf g}_{\bar{0}}\;,\;V\,) } It involves @bold{relative Lie algebra cohomology}. The cochain complex consists of @f{{\bf g}_{\bar{0}}}-invariant linear functions: @equation{ C^n = \mbox{Hom}_{{\bf g}_{\bar{0}}}\left( \Lambda^n\left( {{\cal L}_{\rm tot}\over {\bf g}_{\bar{0}}} \right)\;,\;V \right) } @subsubsection{Algebraic interpretation of SUGRA operators} There is a relation analogous to (@ref{RelationBetweenSYMAndSUSY}), namely exists an ideal @f{I\subset {\cal L}_{\rm tot}} such that: @equation{ {\bf psu}(2,2|4) = {\cal L}_{\rm tot}/I } This has an interesting consequence in the case when @f{V = (U{\bf g})'}: @equation{ H^n\left({\cal L}_{\rm tot}\;,\;{\bf g}_{\bar{0}}\;,\;\,(U{\bf g})'\right) \;=\; H^n(I) } In particular, the linear space dual to @f{H^2(I)}: @align[r.l.n @list[ @v+[7 @f{H_2(I) \;=\;} ] @f{\left\{ \sum_i x_i\wedge y_i\;|\; \sum_i [x_i,y_i] = 0 \right\}} @label{H2} ]@list[ "" @elem{modulo @f{\sum_i \left([x_i,y_i]\wedge z_i + \mbox{cycl}(x,y,z)\right)}} "" ]] describes @bold{gauge invariant local operators}. The analysis of (@ref{H2}) is nontrivial, the only operator in AdS which I can identify is the @bold{dilaton} @f{C^{\alpha\dot{\alpha}} \nabla^L_{\alpha}\wedge\nabla^R_{\dot{\beta}}} where @f{C^{\alpha\dot{\alpha}}} is some @f{{\bf g}_{\bar{0}}}-invariant tensor. In the @bold{flat space limit}, the analysis simplifies: @align[r.l.n @list[ @f{[\nabla_k^L,\nabla_l^L]\wedge [\nabla_m^R,\nabla_n^R] + [\nabla_m^L\;,\nabla_n^L]\wedge [\nabla_k^R,\nabla_l^R] \;}@f{= {\cal R}_{klmn}}"" ]@list[ @f{(\nabla_{[k}^L-\nabla_{[k}^R)\wedge [\nabla^L_l,\nabla^L_{m]}\;] \;}@f{= H_{klm} =\partial_{[k}B_{lm]}}"" ]@list[ @v+[7 @f{A_m^{\pm}\;}]@f{= A_m^L \pm A_m^R}@label{DefApm} ]] We get the following equations of motion: @align[r.l @list[ @v+[7 @f{g^{lm}{\cal R}_{klmn} \;}]@f{= {3\over 4} \nabla_{(k}A^-_{n)}} ]@list[ @v+[7 @f{0 \;}]@f{= \nabla_{[k}A^-_{n]}} ]@list[ @v+[7 @f{\nabla^k H_{klm} \;}]@f{= \nabla_{[l} A^+_{m]}} ]@list[ @v+[7 @f{0 \;}]@f{= \nabla_{(l}A^+_{m)}} ]] The gradient of the dilaton corresponds to @f{A^-_n}, while @f{A_n^+} @bold{does not have a clear interpretation} in the Type IIB supergravity. @div[greenbox]{This rizes a question: do we correctly understand the low momentum sector of the Type IIB SUGRA? The pure spinor formalism suggests a different low momentum spectrum from what we all know from the textbooks. Is it possible that the textbooks miss some discrete degrees of freedom?} But we will now turn to a different subject. Let us look at what we can learn from the @spn[attn]{classical integrability} of the worldsheet theory. @section{Generalized Lax operator} The algebra @f{{\cal L}_{\rm tot}} was essentially guessed. But it turns out that it has a natural interpretation in the string worldsheet theory. @subsection{Usual definition of the Lax operator} For the pure spinor superstring in @f{AdS_5\times S^5} the Lax pair was constructed by @hyperlink["http://arxiv.org/abs/hep-th/0307018"]{B.C.Vallilo}: @align[r.l.n @list[ @f{L_+ =\;}@f{{\partial\over\partial\tau^+} + \left( J^{{\cal A}}_{0+} - N^{{\cal A}}_+ \right)t^0_{{\cal A}} \;\;\;+}"" ]@list[ @f{}@f{\phantom{\partial\over\partial\tau^+} + {1\over z} J^{\alpha}_{3+}\;\;t^3_{\alpha} + {1\over z^2} J^m_{2+}\;t^2_m + {1\over z^3} J^{\dot{\alpha}}_{1+}\; t^1_{\dot{\alpha}} + {1\over z^4} N^{{\cal A}}_+t^0_{{\cal A}}\;\;\;}@label{OrigLPlus} ]@list[ @f{L_- = \;}@f{{\partial\over\partial\tau^-} + \left( J^{{\cal A}}_{0-} - N^{{\cal A}}_- \right)t^0_{{\cal A}} \;\;\; +}"" ]@list[ @f{}@f{\phantom{\partial\over\partial\tau^-} + zJ^{\dot{\alpha}}_{1-}\;\;t^1_{\dot{\alpha}} + z^2 J^m_{2-}\;t^2_m + z^3J^{\alpha}_{3-}\;\;t^3_{\alpha} + z^4N^{{\cal A}}_- t^0_{{\cal A}}\;\;\;}@label{OrigLMinus} ]] where @f-2{t^0_{{\cal A}}\;\;\;, t^1_{\dot{\alpha}}\;, t^2_m\;, t^3_{\alpha}} are generators of @f{{\bf g} = {\bf psl}(4|4)}: @equation[#:label "SuperCommutationRelations"]{ [t^{\bar{a}}_A \;, t^{\bar{b}}_B\; ] = f_{AB}{}^C t^{\bar{a} + \bar{b}\mbox{ \tiny mod } 4}_C } @f{J} are @bold{currents}: @equation[#:label "Jvsg"]{ J_{\bar{k}} = -(dg g^{-1})_{\bar{k}} } and @f{z} is a complex number which is called @bold{spectral parameter}. It follows from the equations of motion that @f{[L_+,L_-] = 0}. This observation can be taken as a starting point of the classical integrability theory. @larger{We will now discuss @bold{generalizations} of this construction.} @subsection{Lax operator and the loop algebra} One can interpret @f-3{{1\over z}t_{\alpha}^3\;}, @f-3{{1\over z^2} t^2_m\;}, @f-3{{1\over z^3} t^1_{\dot{\alpha}}\;}, @f{\ldots} as generators of the twisted loop superalgebra @f{L{\bf g} = L{\bf psl}(4|4)}. @div[comment]{The word ``twisted'' means that the power of the spectral parameter mod 4 should correlate with the @f{{\bf Z}_4}-grading of the generators} This observation allows us to rewrite (@ref{OrigLPlus}) and (@ref{OrigLMinus}) as follows: @align[r.l.n @list[ @f{L_+ =\;}@f{{\partial\over\partial\tau^+} + \left( J^{\cal A}_{0+} - N^{\cal A}_+ \right)T^0_{\cal A}\;\;\;+}"" ]@list[ @f{}@f{\phantom{\partial\over\partial\tau^+} + J^{\alpha}_{3+}\;\;T^{-1}_{\alpha} + J^m_{2+}\;T^{-2}_m + J^{\dot{\alpha}}_{1+}\; T^{-3}_{\dot{\alpha}} + N^{\cal A}_+T^{-4}_{\cal A}\;\;}@label{LoopLPlus} ]@list[ @f{L_- = \;}@f{{\partial\over\partial\tau^-} + \left( J^{\cal A}_{0-} - N^{\cal A}_- \right)T^0_{\cal A} \;\;\;+}"" ]@list[ @f{}@f{\phantom{\partial\over\partial\tau^-} + J^{\dot{\alpha}}_{1-}\;T^1_{\dot{\alpha}} + J^m_{2-}\;T^2_m + J^{\alpha}_{3-}\;T^3_{\alpha} + N^{\cal A}_- T^4_{\cal A}\;\;\;}@label{LoopLMinus} ]] where @f{T_{\alpha}^{-1}} replaces @f{ z^{-1}t^3_{\alpha}} @italic{etc.}; operators @f{T^{n}_A} are generators of the twisted loop superalgebra. Withe these new notations, the spectral parameter is not present in @f{L_{\pm}}. Instead of entering explicitly in @f{L_{\pm}}, it now @bold{parametrizes a representation} of the generators @f{T_A^n}. @subsection{Further generalization} The basic relations (@ref{NablaLNablaL}) imply: @align[r.l.n @list[ @f{\{\nabla_{\alpha}^L, \nabla_{\beta}^L\} = \;}@f{f_{\alpha\beta}{}^m A_m^L} @label{DefAm} ]@list[ @f{[\nabla_{\alpha}^L, A_m^L\,] = \;}@f{f_{\alpha m}{}^{\dot{\beta}} W_{L\dot{\beta}}}@label{DefW} ]] and similar equations for the commutators of @f{\nabla^R_{\dot{\alpha}}}. @(fsize+ (- 3)) @div[comment]{ Eq. (@ref{DefAm}) we already discussed; it encodes the SUGRA constraints and at the same time @bold{defines} @f{A_m^L}. Eq. (@ref{DefW}) is a @italic{theorem-definition}: the @italic{theorem} says that the left hand side is proportional to @f{f_{\alpha m}{}^{\dot{\beta}}}, and the @italic{definition} is of @f{W_{L\dot{\beta}}} } @(fsize=) It turns out, that there is the following generalization of the Lax pair: @align[r.l.n @list[ @f{L_+ = \;}@f{\left( {\partial\over \partial \tau^+} + J_{0+}^{\cal A}\; t^0_{\cal A} \;\;\; \right) + J_{3+}^{\alpha}\; \nabla^L_{\alpha} + J_{2+}^m\; A^L_m + J_{1+}^{\dot{\alpha}} \; W^L_{\dot{\alpha}} +}"" ]@list[ @f{}@f{+ \; \lambda_L^{\alpha} w_{L+}^{\dot{\beta}}\;\, \left( \{ \nabla^L_{\alpha} \,,\, W^L_{\dot{\beta}}\} - f_{\alpha\dot{\beta}}{}^{\cal A} t^0_{\cal A}\;\;\;\,\right)}@label{LPlus} ]@list[ @f{L_- = \;}@f{\left( {\partial\over\partial\tau^-} + J_{0-}^{\cal A}\; t^0_{\cal A}\;\;\; \right) + J_{1-}^{\dot{\alpha}}\; \nabla^R_{\dot{\alpha}} + J_{2-}^m \,A^R_m + J_{3-}^{\alpha}\; W^R_{\alpha} +}"" ]@list[ @f{}@f{+ \; \lambda_R^{\dot{\alpha}} w_{R-}^{\beta}\;\,\left( \{ \nabla^R_{\dot{\alpha}} \;,\; W^R_{\beta} \} - f_{\dot{\alpha}\beta}{}^{\cal A} t^0_{\cal A}\;\;\;\, \right)}@label{LMinus} ]] The generalized Lax operator has the following properties: @itemlist[ @item{ @bold{The @f{{\bf g}_{\bar{0}}} gauge covariance.} For @f{\xi_0(\tau^+,\tau^-) \in {\bf g}_{\bar{0}}}, consider the transformation @f{\delta_{\xi_{\bar{0}}}} acting on the currents (@ref{Jvsg}) and ghosts @f{w_{\pm}}, @f{\lambda_L,\lambda_R} as follows: @align[r.l @list[ @f{\delta_{\xi_{\bar{0}}} g =\;}@f{\xi_{\bar{0}} g} ]@list[ @f{\delta_{\xi_{\bar{0}}} \lambda_{L|R} =\;}@f{[\xi_{\bar{0}},\;\lambda_{L|R}]} ]@list[ @f{\delta_{\xi_{\bar{0}}} w_{\pm} =\;}@f{[\xi_{\bar{0}},\;w_{\pm}]} ]] Then @f{L_{\pm}} transforms in a covariant way: @equation{ \delta_{\xi_0}L_{\pm} = [\xi_0,\;L_{\pm}] } } @item{@bold{Zero curvature}: @equation[#:label "ZeroCurvatureForGeneralizedLax"]{[L_+,L_-]=0}} @item{@bold{Covariance under the BRST transformations.} When we act on the currents (@ref{Jvsg}) and ghosts @f{w_{\pm}}, @f{\lambda_L,\lambda_R} by the BRST transformation: @align[r.l @list[ @v+[6 @f{Q_{\rm BRST}\; g \;=\;}] @f{(\lambda_L^{\alpha}t^3_{\alpha} + \lambda_R^{\hat{\alpha}}t^1_{\hat{\alpha}})g} ]@list[ @f{Q_{\rm BRST}\; w_{1+} \;=\;}@f{J_{1+}} ]@list[ @f{Q_{\rm BRST}\; w_{3-} \;=\;}@f{J_{3-}} ]@list[ @f{Q_{\rm BRST}\; \lambda_{L|R} \;=\;}@v+[2 @f{0}] ]] then @f{L_{\pm}} transforms in a covariant way: @equation[#:label "BRSTCovariance"]{ Q_{BRST}L_{\pm} \;=\; \left[ L_{\pm}\;,\;\left( \lambda_L^{\alpha}\nabla^L_{\alpha} + \lambda_R^{\dot{\alpha}} \nabla^R_{\dot{\alpha}} \right) \right] } }] @section{Integrated vertex} Finally, we are now ready to discuss our construction of the integrated vertex. Suppose that we are given an unintegrated vertex, and we want to construct the corresponding integrated vertex. Unintegrated vertices correspond to the elements of @f{H^2({\cal L}_{\rm tot},{\bf g}_{\bar{0}}, \; (U{\bf g})')}. The 2-cocycle representing such an element is a bilinear function of two elements of @f{{\cal L}_{\rm tot}}, which we will denote @f{\xi} and @f{\eta}. We have to remember that the 2-cocycle takes values in @f{(U{\bf g})'} which is identified with the space of Taylor series at the unit of the group manifold. Let @f{g\in PSU(2,2|4)} denote the group element. Therefore, the element @f{\psi\in H^2({\cal L}_{\rm tot},{\bf g}_{\bar{0}}, \; (U{\bf g})')} is a function of two elements of @f{{\cal L}_{\rm tot}}, which we will call @f{\xi} and @f{\eta}, taking values in the functions of @f{g}: @equation[#:label "PsiCocycle"]{ \psi(\xi,\eta)(g) } Remember that our generalized Lax operators (@ref{LPlus}), (@ref{LMinus}) have the form: @equation{ L_{\pm} = {\partial\over\partial \tau^{\pm}} + {\cal J}_{\pm} } where @f{{\cal J}_{\pm}} are operators of the conformal dimension 1 taking values in @f{{\cal L}_{\rm tot}}. @bold{Theorem @th-num{IntegratedFromCocycle}:} The integrated vertex operator is obtained from (@ref{PsiCocycle}) by replacing @f{\xi} and @f{\eta} with @f{{\cal J}_{\pm}}: @equation{ U = \psi({\cal J}_+,{\cal J}_-)(g) } @bold{Proof.} We have to verify the descent procedure (@ref{DefU}), (@ref{DefW}). The proof is a variation of the famous differential geometry formula @f{{\cal L}_v = \iota_v d + d \iota_v}. Consider @f{{\cal J} = {\cal J}_+ d\tau^+ + {\cal J}_- d\tau^-}. This is a @f{{\cal L}_{\rm tot}}-valued differential 1-form on the worldsheet. Substitution of @f{{\cal J}} into @f{\psi} intertwines the @f{Q_{\rm Lie}} with the de Rham differential @f{d}. (The verification of this statement uses the fact that @f{{\cal J}_{\pm}} satisfies the zero-curvature equations (@ref{ZeroCurvatureForGeneralizedLax}).) It is useful to introduce the free Grassmann parameters @f{\epsilon} and @f{\epsilon'}. Let us formally introduce the operator @f{I_{\epsilon}} as follows: @equation{ I_{\epsilon} = \epsilon(\lambda_L^{\alpha} \nabla^L_{\alpha} + \lambda_R^{\hat{\alpha}}\nabla^R_{\hat{\alpha}}) {\partial\over\partial {\cal J}} } This operator simply replaces @f{{\cal J}} with @f-3{\epsilon(\lambda_L^{\alpha} \nabla^L_{\alpha} + \lambda_R^{\hat{\alpha}}\nabla^R_{\hat{\alpha}})}. Eq. (@ref{BRSTCovariance}) implies that the BRST differential acts as follows: @equation{ \epsilon Q = dI_{\epsilon} + I_{\epsilon}d } But @f{d\psi = 0}, therefore: @align[r.c.l @list[ @v-[2 @f{\epsilon Q\psi = dw\;\;}] " where " @v-[2 @f{\;\;w = I_{\epsilon}\psi}] ]] This was the first step (@ref{DefU}) of the descent procedure. To make the second step (@ref{DefW}), we have to remember that @f{\psi} is a @bold{relative} cocycle, which means that it always vanishes whenever one of the ghosts falls into @f{{\bf g}_{\bar{0}}}. This implies: @equation{ [dI_{\epsilon'} + I_{\epsilon'}d\;\;,\;\; I_{\epsilon}]\;\psi = 0 } and further: @align[r.c.l @list[ @v-[8 @f{\epsilon'Q\;w = {1\over 2}dv\;\;}] " where " @v-[4 @f{\;\;v = I_{\epsilon'}I_{\epsilon}\psi}]]] Notice that the unintegrated vertex @f{v} is obtained from the cocycle @f{\psi} by replacing the ghost fields with @f{\lambda_L + \lambda_R}. @section{Instead of conclusion} In my opinion, it is a drawback of the string theory that it is too geometric: @centered{ @image[#:scale 0.5]{graphics/genusExpansion.png} } Theory being geometric indicates that the classical limit has somehow been already taken. I think that the @bold{quantum} theory should use @bold{algebraic} description, instead of geometric. Here we attempt to interpret some constructions of the pure spinor formalism in terms of abstract algebra. We observe that at least some aspects of the formalism get simplified, notably the relation between integrated and unintegrated vertices. At this point, however, this is not entirely convincing, at least for the following reasons: @itemlist[ @item{Our results are only valid for the simplest nondegenerate background, @f{AdS_5\times S^5}. The correct description should, of course, be background-independent.} @item{We only studied SUGRA, we did not attempt to say anything about the massive states} ] We think that this circle of ideas should be further developed. @; --------------------------------------------------------------------------------------------------- @disconnect[formula-database]
false
ad49bfdc656e53b084b2c5afe152a584d3789209
7755804e53cd2660ee6658ca4da366f9664dcf61
/error-prop.rkt
ecf616ca721202946273b1759a453bb06ca5e0cd
[]
no_license
iitalics/Physics-Macros
fd43d571b45d2a2b9167d8881db74e5d00cfc71d
40864ce3c71e13135940b3eb84afab00b8094610
refs/heads/master
"2021-01-23T03:33:53.800722"
"2017-03-24T13:03:30"
"2017-03-24T13:03:30"
86,091,626
0
0
null
null
null
null
UTF-8
Racket
false
false
1,898
rkt
error-prop.rkt
#lang racket (require (for-syntax syntax/parse)) (provide error-prop) (define-syntax error-prop (syntax-parser #:literals (+ - * / expt log sqr) ; d(a +- b) = sqrt(a^2 + b^2) [(_ (+ a b)) #'(match* ((error-prop a) (error-prop b)) [((list av da) (list bv db)) (list (+ av bv) (sqrt (+ (sqr da) (sqr db))))])] [(_ (- a b)) #'(match* ((error-prop a) (error-prop b)) [((list av da) (list bv db)) (list (- av bv) (sqrt (+ (sqr da) (sqr db))))])] ; d(a?b) = (a?b) * sqrt((da/a)^2 + (db/b)^2) [(_ (* a b)) #'(match* ((error-prop a) (error-prop b)) [((list av da) (list bv db)) (list (* av bv) (* (sqrt (+ (sqr (/ da av)) (sqr (/ db bv)))) av bv))])] [(_ (/ a b)) #'(match* ((error-prop a) (error-prop b)) [((list av da) (list bv db)) (list (/ av bv) (* (sqrt (+ (sqr (/ da av)) (sqr (/ db bv)))) (/ av bv)))])] ; d(x^n) = x^n * |n| * dx/x [(_ (expt a n)) #'(let ([nv n]) (match (error-prop a) [(list av da) (list (expt av nv) (* (expt av (sub1 nv)) (abs nv) da))]))] ; d(ln(x)) = dx/x [(_ (log a)) #'(match (error-prop a) [(list av da) (list (log av) (/ da av))])] [(_ (- a b c ...)) #'(error-prop (- a (+ b c ...)))] [(_ (+ a b c ...)) #'(error-prop (+ a (+ b c ...)))] [(_ (* a b c ...)) #'(error-prop (* a (* b c ...)))] [(_ (/ a b c ...)) #'(error-prop (/ a (* b c ...)))] [(_ (sqr a)) #'(error-prop (* a a))] [(_ x:id) #'x] [(_ n:number) #'(list n 0)]))
true
eb6603d879cd212fb3d33b2a4fc1aa07200461b1
2cfd2e7dbfec688de9d738a7ff047e3227678b8f
/clicker-lib/assets.rkt
dc6941a916620cb057785a870ea6c54b566f3e63
[]
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
1,242
rkt
assets.rkt
#lang racket (provide freeze slow light question-icon (rename-out [pointer-sprite pointer] [cage-sprite cage] [glovecursor-sprite glove] [magicwandcursor-sprite magic-wand] [whitehandcursor-sprite white-hand])) (require clicker-assets game-engine) (define freeze (new-sprite (make-rounded-icon freeze-icon 'cyan))) (define slow (new-sprite (make-rounded-icon turtle-icon 'cyan))) (define light (new-sprite (make-rounded-icon sun-icon 'yellow))) (define pointer-sprite (new-sprite POINTER-IMG)) (define cage-sprite (new-sprite (change-img-alpha -100 (apply beside (map (λ (x) (rectangle 20 80 'outline (pen 'gray 4 'solid 'butt 'bevel))) (range 5)))))) (define glovecursor-sprite (sprite->cursor-sprite (new-sprite (change-img-alpha -100 glove)) 8 2)) (define magicwandcursor-sprite (sprite->cursor-sprite (sheet->sprite magic-wand-sheet #:columns 6 #:delay 5) 6 5)) (define whitehandcursor-sprite (sprite->cursor-sprite (new-sprite white-hand) 8 0))
false
fe860ec6ac55a32b8bcea5353883bdce6a7502e5
9d1701a88644663277342f3a12d9795cd55a259c
/CSC324/Exercises/EX8/streams.rkt
d0f53629320554ea28c3a7e928e161346e67768c
[]
no_license
xxcocoymlxx/Study-Notes
cb05c0e438b0c47b069d6a4c30dd13ab97e4ee6d
c7437d387dc2b9a8039c60d8786373899c2e28bd
refs/heads/master
"2023-01-13T06:09:11.005038"
"2020-05-19T19:37:45"
"2020-05-19T19:37:45"
252,774,764
2
0
null
"2022-12-22T15:29:26"
"2020-04-03T15:44:44"
Jupyter Notebook
UTF-8
Racket
false
false
1,316
rkt
streams.rkt
#lang racket (provide s-null s-null? s-cons s-first s-rest make-stream stream->list) ; Empty stream value, and check for empty stream. (define s-null 's-null) (define (s-null? stream) (equal? stream s-null)) #| (s-cons <first> <rest>) <first>: A Racket expression. <rest>: A stream (e.g., s-null or another s-cons expression). Returns a new stream whose first value is <first>, and whose other items are the ones in <rest>. Unlike a regular list, both <first> and <rest> are wrapped in a thunk, so aren't evaluated until called. |# (define-syntax s-cons (syntax-rules () [(s-cons <first> <rest>) (cons (thunk <first>) (thunk <rest>))])) ; These two define the stream-equivalents of "first" and "rest". ; We need to use `car` and `cdr` (similar to `first` and `rest`) ; for a technical reason that isn't important for this course. ; Note that s-rest both accesses the "rest thunk" and calls it, ; so that it does indeed return a stream. (define (s-first stream) ((car stream))) (define (s-rest stream) ((cdr stream))) ; Make a stream. We use macros to so that the elements of the stream ; are not evaluated until they are used. (define-syntax make-stream (syntax-rules () [(make-stream) s-null] [(make-stream <first> <rest> ...) (s-cons <first> (make-stream <rest> ...))]))
true
5dd74fe72f70d2562bab0890ad4fbd9bd9f061f2
799b5de27cebaa6eaa49ff982110d59bbd6c6693
/soft-contract/test/programs/unsafe/issues/sub-exn.rkt
0731eae718c08e4f4b4dceed2bb2f28597c730d5
[ "MIT" ]
permissive
philnguyen/soft-contract
263efdbc9ca2f35234b03f0d99233a66accda78b
13e7d99e061509f0a45605508dd1a27a51f4648e
refs/heads/master
"2021-07-11T03:45:31.435966"
"2021-04-07T06:06:25"
"2021-04-07T06:08:24"
17,326,137
33
7
MIT
"2021-02-19T08:15:35"
"2014-03-01T22:48:46"
Racket
UTF-8
Racket
false
false
53
rkt
sub-exn.rkt
#lang racket (struct exn:gregor exn:fail ()) (/ 1 0)
false
a422c16c941d5a4fa6cf2b70b022fa66f1ee9872
7cfaf223b67065a849adb73962956b488809e3a4
/SyntacticPatchingV2/test-patch.rkt
852dd2289f478fb53bf55ccaab3b8be8aa2d53ac
[ "MIT" ]
permissive
ProgramAnalysisISU/Helium
bd628934190dcbd4891bee7bccad071702e5b6f7
43921e135362dd9c9663f5e2de260e65f2454b13
refs/heads/master
"2020-03-16T16:54:49.317308"
"2018-05-09T20:36:17"
"2018-05-09T20:36:17"
132,809,477
0
0
null
null
null
null
UTF-8
Racket
false
false
2,342
rkt
test-patch.rkt
#lang racket (require "./ast.rkt") (require "./patch.rkt") (require "./visual.rkt") (require "./gen.rkt") (module+ test (patch-parent (mark-continue-lines (third (tu-get-funcs (read-scm "./test/expr.c.scm"))))) (visualize-ast (mark-lines (first (tu-get-funcs (read-scm "./test/stmt.c.scm"))) '(25 28 41 43))) (visualize-ast (patch-min (patch-lca (patch-parent (mark-lines (first (tu-get-funcs (read-scm "./test/stmt.c.scm"))) ;; '(25 41 43) '(25 14 17 21 22 20) ))))) (visualize-ast (syntactic-patch (mark-lines (first (tu-get-funcs (read-scm "./test/stmt.c.scm"))) ;; '(25 41 43) '(25 14 17 21 22 20) )))) (module+ test "Test gen-code-select" (displayln (gen-code-select (syntactic-patch (mark-lines (first (tu-get-funcs (read-scm "./test/stmt.c.scm"))) ;; '(25 41 43) '(25 13) ))))) (module+ test (display (gen-code (read-scm "./test/expr.c.scm"))) (visualize-ast (third (tu-get-funcs (read-scm "./test/expr.c.scm")))) (filter (lambda (c) (eq? c 'select)) (map-ast get-color (mark-continue-lines (third (tu-get-funcs (read-scm "./test/expr.c.scm")))))) (visualize-ast (mark-random-lines (third (tu-get-funcs (read-scm "./test/expr.c.scm"))))) (visualize-ast (mark-continue-lines (third (tu-get-funcs (read-scm "./test/expr.c.scm"))))) (patch-parent (mark-continue-lines (third (tu-get-funcs (read-scm "./test/expr.c.scm"))))) (visualize-ast (mark-continue-lines (first (tu-get-funcs (read-scm "./test/stmt.c.scm"))))) (filter identity (map-ast is-leaf? (third (tu-get-funcs (read-scm "./test/expr.c.scm"))))) (void (update-node (λ (n) ;; (displayln n) ;; (displayln ".") n) (third (tu-get-funcs (read-scm "./test/expr.c.scm")))))) (module+ test (visualize-ast (mark-continue-lines (first (tu-get-funcs (read-scm "./test/stmt.c.scm"))))) (visualize-ast (mark-lines (first (tu-get-funcs (read-scm "./test/stmt.c.scm"))) '(25 28 41 43))) (visualize-ast (read-scm "./test/stmt.c.scm")) (map visualize-ast (map read-scm (get-scms "./test/"))) (visualize-ast (read-scm "./test/expr.c.scm")))
false
51b0d9936f32197f0b9886bd21eabf302c4eeb2d
91dc09382f6cc58925f46622212d36ab37e7e4ae
/pages/blog/post-2020-08-28.rkt
8c0a0bd2faca41199b9c2b7f3bb0140a3b59abea
[]
no_license
srfoster/codespells.org
53b4e62afb2131ed7198f76d02e023e977547bdc
fe6c14a70bf3a88579bfc675403e6a4605d6473c
refs/heads/master
"2023-08-16T20:40:03.931174"
"2021-05-24T21:29:26"
"2021-05-24T21:29:26"
285,627,595
3
1
null
"2021-09-11T23:53:09"
"2020-08-06T17:10:42"
Racket
UTF-8
Racket
false
false
697
rkt
post-2020-08-28.rkt
#lang at-exp racket (require "../../lang.rkt") (require "./lang.rkt") (require website-js/components/accordion-cards website-js (prefix-in html: (only-in website script)) (prefix-in h: 2htdp/image)) (define-post 2020-08-28 "Evaluating Runes in the 3D World" @div{ End of week update! } @div{ @p{Although there are a million little things I want to change, I accomplished my main goal this week: to get a working Rune editor inside of the 3D world of CodeSpells. Here's a video demo!} @(video 'controls: #t (source width: "100%" src: "/videos/end-of-week-update1.mkv" )) @p{- Stephen R. Foster} @(logo 200) })
false
f85e3184b7e333a1b6f35619dec83b228369d3aa
5dca9480215968ecd1acaf56cdae9b6873f752d7
/GPT4-synthesis/7-transfer-learning.rkt
86c79974cf77e161fbcdc21b08f72117721b55e1
[]
no_license
namin/biohacker
7a8921f60998bdd08d79a7d9daabf1cdc69b1fda
986f171f605b7679eab23d3c505df9867b64871f
refs/heads/master
"2023-08-14T13:05:54.809784"
"2023-04-17T03:27:28"
"2023-04-17T03:27:28"
40,253,006
41
7
null
"2020-08-07T16:29:24"
"2015-08-05T15:22:39"
Common Lisp
UTF-8
Racket
false
false
1,297
rkt
7-transfer-learning.rkt
#lang racket (define knowledge-base '()) (define (learn-strategy context strategy) (set! knowledge-base (cons (cons context strategy) knowledge-base))) (define (evaluate problem template positive-feedback context) (let ((transfer-score (or (cdr (assoc context knowledge-base)) 0))) (cond [(equal? problem "Write a program that adds two numbers.") (if (equal? template (cadr (assoc 'addition templates))) (+ 1 positive-feedback (if (member context (cadddr (assoc 'addition templates))) 1 0) transfer-score) 0)] [(equal? problem "Write a program that subtracts two numbers.") (if (equal? template (cadr (assoc 'subtraction templates))) (+ 1 positive-feedback (if (member context (cadddr (assoc 'subtraction templates))) 1 0) transfer-score) 0)] [else 0]))) ; (learn-strategy 'arithmetic 2) (define problem "Write a program that adds two numbers.") (define context "math") (define intermediate-template 'add-intermediate) (define generated-program (run 1 (template) (fresh (score) (synthesize-program template problem score context intermediate-template) (== score 3)))) ; Choose the template with the highest score (display "Generated program: ") (display generated-program) (newline)
false
11461f3728abeee52471d4bb3cc8832b8be9ebe8
631764b5f40576a6857e7d31d207a5ece7ccba43
/Scheme/Lists-And-Multiple-Arguments/number-list.rkt
49d1798e7154659eff41ae8436539988e9646519
[]
no_license
Ralitsa-Vuntsova/fp
ea37a40aaf3c42a70a1abc5fdb6736b875393543
7cca3819079de98108c70aed4d79f42c1fc294cc
refs/heads/main
"2023-06-07T03:24:18.405190"
"2021-06-28T15:59:34"
"2021-06-28T15:59:34"
381,085,860
0
0
null
null
null
null
UTF-8
Racket
false
false
748
rkt
number-list.rkt
; Да се напише процедура, която преобразува число в списък ;(number->list 12345) -> '(1 2 3 4 5) (define (count-digits n) (if (< n 10) 1 (+ 1 (count-digits (quotient n 10))))) (define (number->list n) (define (helper i) (if (= (count-digits i) 1) (list i) (cons (remainder i 10) (helper (quotient i 10))))) (reverse (helper n))) ; Да се напише процедура, която преобразува списък в число ;(list->number '(1 2 3 4 5)) -> 12345 (define (list->number lst) (define (helper l len) (if (= len 0) 0 (+ (* (car l) (expt 10 (- len 1))) (helper (cdr l) (- len 1))) )) (helper lst (length lst)))
false
e32927424b59273276b1201e2154d11e143501da
ce499a0e03cd8a4e36a7f9378f5a5d7b3dff9827
/play/parsers.rkt
8523e284160cb59edbb77deae8db12251334889d
[]
no_license
pleiad/play
652c406a5a0fcc4de10e73a71f82df1b4ce87a26
34a145ffb815110bec33a48004e8897e48d11f51
refs/heads/master
"2021-01-18T20:35:23.703893"
"2019-06-18T16:42:53"
"2019-06-18T16:42:53"
12,071,753
2
1
null
"2016-10-26T20:11:55"
"2013-08-13T02:53:22"
Racket
UTF-8
Racket
false
false
1,051
rkt
parsers.rkt
#lang racket (require parser-tools/lex) (require parser-tools/lex-sre) (require parser-tools/yacc) (require "./defmac.rkt") (provide (all-from-out parser-tools/lex) (prefix-out @ (all-from-out parser-tools/lex-sre)) define-lexer consume-lexer (all-from-out parser-tools/yacc) define-parser parse ) (define-syntax define-lexer (syntax-rules () [(define-lexer lexer-name (pattern action) ...) (define lexer-name (lexer (pattern action) ...))])) ;; lexer x input-port -> list[lexer-values] (define (consume-lexer l input) (match (l input) ['eof '()] [lexer-value (cons lexer-value (consume-lexer l input))])) (define-syntax define-parser (syntax-rules () [(define-parser parser-name clause ...) (define parser-name (parser clause ...))])) (define-syntax parse (syntax-rules (with-parser and-lexer) [(parse program with-parser parser and-lexer lexer) (let ((input-program (open-input-string program))) (parser (lambda () (lexer input-program))))]))
true
96013f2fcf2e5fa1415ae1ffd908520a0f8b2182
cca967d31130f30e3d964cd68699835a421186db
/info.rkt
381848806db8b97d2b696430d43dbc3638707a7b
[ "Apache-2.0" ]
permissive
jackfirth/racket-retry
9e91dd03e914960fcba7cdc99bb9c4965f627ca1
2a6ba58ab5f14707305e75063c3ee4519fc6dc7d
refs/heads/master
"2021-01-12T09:29:13.789280"
"2017-12-05T05:52:37"
"2017-12-05T05:52:37"
76,159,612
5
2
null
"2017-02-01T07:00:23"
"2016-12-11T07:05:53"
Racket
UTF-8
Racket
false
false
614
rkt
info.rkt
#lang info (define collection "retry") (define scribblings '(("scribblings/main.scrbl" (multi-page) (library) "retry"))) (define compile-omit-paths '("private")) (define deps '("compose-app" "fancy-app" "gregor-lib" "reprovide-lang" ("base" #:version "6.5") ("mock" #:version "2.1"))) (define build-deps '("at-exp-lib" "gregor-doc" "scribble-text-lib" "racket-doc" "scribble-lib" "rackunit-lib" "mock-rackunit"))
false
01980e82fa8969407bc56e8cc07e43ab39aeba47
a3673e4bb7fa887791beabec6fd193cf278a2f1a
/lib/racket-docs/types/macrotypes/typecheck.rkt
eb11e1b48c12ab10e8db0c36d5957471daf7ab6c
[]
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
4,679
rkt
typecheck.rkt
#lang racket ;; This file contains functions for type checking. (require syntax/parse syntax/stx racket/syntax "stx-utils.rkt") ;; Stx is a syntax object, as defined by Racket ;; An Id is Stx that is an identifier ;; - see http://docs.racket-lang.org/guide/stx-obj.html ;; A Term is Stx that has 'type stx prop that is a Type ;; - NOTE: ;; A Term must be expanded Stx since the 'type prop ;; is only attached after expansion. ;; We continue to use Stx as the data def of unexpanded Terms, e.g. ;; see assign-type or type-of. ;; A Datum is an S-expr (provide ; i.e., my wish list ; assign-type : Stx Type -> Term ; Creates a Term from a Stx by attaching the given Type. assign-type ; type-of : Stx -> [List Term Type] ; Computes a Type and Term from the given Stx. type-of ; type-of/ctx : Stx TyEnv -> [List Ids Term Type] ; Like `type-of`, but accepts an extra type environment context. ; Computes a Type and Term from the given Stx and TyEnv. ; Also returns a list of binders for var refs in the returned Term. type-of/ctx ; type=? : Type Type -> Bool ; Returns true if two types are equal. type=? ; tyerr-msg : Type Type -> String ; prints type err msg with given "expected" and "actual" types tyerr-msg ;; type of types ---------------------------------------- ; mk-type : Stx -> Type ; Creates a Type from a Stx mk-type ; type? : Stx -> Bool ; Returns true if the argument is a Type. type? ; types? : Stx -> Bool ; Returns true if input is stxobj whose elemenets are all Types. types? ; syntax class forms of the above predicates type types ) (define TYPE-TAG 'type) ; key for type stx prop ;; assign-type : Stx Type -> Term ;; Creates a Term from a Stx by attaching the given Type. (define (assign-type e t) (syntax-property e TYPE-TAG t)) ;; get-type : Term -> Type ;; Returns the TYPE-TAG property from the given Term. (define (get-type e) (ca*r (syntax-property e TYPE-TAG))) ; type-of : Stx -> [List Term Type] ; Computes a Type and Term from a given Stx. (define (type-of e) (define e+ (local-expand e 'expression null)) (list e+ (get-type e+))) ; type=? : Type Type -> Boolean ; Returns true if the two given types are equivalent. (define (type=? t1 t2) ;; type may be id (or (and (identifier? t1) (identifier? t2) (free-identifier=? t1 t2)) ;; or compound type (ie, type constructor) (and (stx-pair? t1) (stx-pair? t2) (all type=? t1 t2)))) ; type->datum : Type -> s-expr ; Converts a Type into a more printable representation. (define (type->datum t) (syntax->datum t)) ;; Type Type -> String ;; Returns an appropriate type error message when the given ;; `expected` and `actual` types differ. (define (tyerr-msg expected actual) (format "type mismatch, expected ~a, got ~a" (type->datum expected) (type->datum actual))) ;; ---------------------------------------------------------------------------- ;; types for types ;; #%type = the type of types, i.e., a "kind" (define (#%type) (error '#%type "can't use at runtime")) (define (mk-type t) (assign-type t #'#%type)) (define (type? t) (define tt (type-of t)) (and tt (type=? (second tt) #'#%type))) (define (types? ts) (all type? ts)) (define-syntax-class type (pattern (~and τ (~fail #:unless (type? #'τ) "expected type")))) (define-syntax-class types (pattern (τ:type ...) #:attr len (length (syntax->list #'(τ ...))))) ;; ---------------------------------------------------------------------------- ;; expanding with contexts ;; A TyEnv is Stx with shape ([Id Type] ...) ;; An ExpandCtx is a definition context, as recognized by local-expand ; type-of/ctx : Stx TyEnv -> [List Ids Term Type] (define (type-of/ctx e Γ) (match-define (list xs+ CTX) (tyenv->expandctx Γ)) (define e+ (local-expand e 'expression null CTX)) (list xs+ e+ (get-type e+))) ;; TyEnv -> [List Ids ExpandCtx] ;; intuition: ;; for each x : τ in TyEnv: ;; define x as macro that expands into (assign-type #'y #'τ) ;; where y is a new, untyped var ;; Returns the ExpandCtx and the new y's (define (tyenv->expandctx Γ) (syntax-parse Γ [([x τ] ...) (define ctx (syntax-local-make-definition-context)) (define (fresh/ctx s) (internal-definition-context-introduce ctx (generate-temporary s))) (define xs+ (stx-map fresh/ctx #'(x ...))) (syntax-local-bind-syntaxes xs+ #f ctx) (syntax-local-bind-syntaxes (syntax->list #'(x ...)) (with-syntax ([(x+ ...) xs+]) #`(values (mk-applied-id-macro (assign-type #'x+ #'τ)) ...)) ctx) (list xs+ ctx)]))
true
77785568c253bfd3e02c8afbf8ae9f2cdec3e3fb
ed2cfb6bbed32ff5dfe376d0b1036aeb116ad9f7
/tests/planet2/tests-install.rkt
a18bd6c453713e6f6c2dcc396f87b79eee12efbd
[]
no_license
jeapostrophe/galaxy
c1474fecd23b6a24d26039088eeda109691595d5
6bfa46d01ece8645d1752472c589748dad0c5bd8
refs/heads/master
"2016-09-05T17:47:16.658215"
"2013-10-31T01:32:39"
"2013-10-31T01:32:39"
3,250,570
1
0
null
null
null
null
UTF-8
Racket
false
false
3,762
rkt
tests-install.rkt
#lang racket/base (require rackunit racket/system unstable/debug racket/match (for-syntax racket/base syntax/parse) racket/file racket/runtime-path racket/path racket/list planet2/util "shelly.rkt" "util.rkt") (pkg-tests (shelly-begin (initialize-indexes) (shelly-case "raco pkg install tests" (shelly-install "local package (tgz)" "test-pkgs/planet2-test1.tgz") (shelly-install "local package (zip)" "test-pkgs/planet2-test1.zip") (shelly-install "local package (plt)" "test-pkgs/planet2-test1.plt") (shelly-case "invalid package format is an error" $ "raco pkg install test-pkgs/planet2-test1.zip.CHECKSUM" =exit> 1) (shelly-install "remote/URL/http package (file, tgz)" "http://localhost:9999/planet2-test1.tgz") (shelly-install "remote/URL/http package (directory)" "http://localhost:9999/planet2-test1/") (shelly-case "remote/URL/http directory, non-existant file" $ "raco pkg install http://localhost:9999/planet2-test1.rar" =exit> 1) (shelly-case "remote/URL/http directory, no manifest fail" $ "raco pkg install http://localhost:9999/planet2-test1/planet2-test1" =exit> 1 =stderr> #rx"Invalid package format") (shelly-case "remote/URL/http directory, bad manifest" ;; XXX why does this error now? $ "raco pkg install http://localhost:9999/planet2-test1-manifest-error" =exit> 1) (shelly-case "local directory fails when not there (because interpreted as package name that isn't there)" $ "raco pkg install test-pkgs/planet2-test1-not-there" =exit> 1) (shelly-install "local package (directory)" "test-pkgs/planet2-test1") (shelly-install "local package (directory with slash)" "test-pkgs/planet2-test1/") (with-fake-root (shelly-case "linking local directory" (shelly-wind $ "cp -r test-pkgs/planet2-test1 test-pkgs/planet2-test1-linking" $ "racket -e '(require planet2-test1)'" =exit> 1 $ "raco pkg install --link test-pkgs/planet2-test1-linking" $ "racket -e '(require planet2-test1)'" $ "racket -e '(require planet2-test1/a)'" =exit> 1 $ "cp test-pkgs/planet2-test1-staging/a.rkt test-pkgs/planet2-test1-linking/planet2-test1/a.rkt" $ "racket -e '(require planet2-test1/a)'" $ "rm -f test-pkgs/planet2-test1-linking/planet2-test1/a.rkt" $ "racket -e '(require planet2-test1/a)'" =exit> 1 $ "raco pkg remove planet2-test1-linking" $ "racket -e '(require planet2-test1)'" =exit> 1 (finally $ "rm -r test-pkgs/planet2-test1-linking")))) (with-fake-root (shelly-case "remote/name package, doesn't work when no package there" $ "raco pkg config --set indexes http://localhost:9990" $ "raco pkg install planet2-test1-not-there" =exit> 1)) (with-fake-root (shelly-case "remote/name package" $ "raco pkg config --set indexes http://localhost:9990" $ "racket -e '(require planet2-test1)'" =exit> 1 $ "raco pkg install planet2-test1" $ "racket -e '(require planet2-test1)'" $ "raco pkg remove planet2-test1" $ "racket -e '(require planet2-test1)'" =exit> 1)) (with-fake-root (shelly-case "remote/name package (multi)" $ "raco pkg config --set indexes http://localhost:9990 http://localhost:9991" $ "racket -e '(require planet2-test1)'" =exit> 1 $ "raco pkg install --deps search-auto planet2-test2-snd" $ "racket -e '(require planet2-test1)'" $ "racket -e '(require planet2-test2)'" $ "raco pkg remove planet2-test2-snd planet2-test1" $ "racket -e '(require planet2-test1)'" =exit> 1)))))
false
ea563b865af64b42e4484d89c9cb078862b52a05
b08b7e3160ae9947b6046123acad8f59152375c3
/Programming Language Detection/Experiment-2/Dataset/Train/Racket/zero-to-the-zero-power.rkt
8d6d083e46ddac349638a59219a96c8c2dd136ad
[]
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
466
rkt
zero-to-the-zero-power.rkt
#lang racket ;; as many zeros as I can think of... (define zeros (list 0 ; unspecified number type 0. ; hinted as float #e0 ; explicitly exact #i0 ; explicitly inexact 0+0i ; exact complex 0.+0.i ; float inexact )) (for*((z zeros) (p zeros)) (printf "(~a)^(~a) = ~s~%" z p (with-handlers [(exn:fail:contract:divide-by-zero? exn-message)] (expt z p))))
false
531e3f8414c7469455cc3cda73ea81d69edd88c2
3c8f0893f3f123a77442eba85e3712f945e9fd49
/Macros/task-5.rkt
f6e621d3b4412de2b0a8c178f2d172be84092502
[ "Apache-2.0", "MIT" ]
permissive
mfelleisen/7GUI
b3ba683841476588beb658450bc7d07043ff6296
ef86aeb1bfac0c098322242116a053fcd280c110
refs/heads/master
"2022-02-04T08:06:39.903030"
"2022-01-20T17:04:46"
"2022-01-20T17:40:39"
189,009,701
60
11
null
"2022-01-20T17:40:40"
"2019-05-28T10:49:37"
Racket
UTF-8
Racket
false
false
2,431
rkt
task-5.rkt
#! /usr/bin/env gracket #lang at-exp racket/gui ;; a create-read-update-deleted MVC implementation ;; --------------------------------------------------------------------------------------------------- (require 7GUI/Macros/7guis 7GUI/Macros/7state) ;; --------------------------------------------------------------------------------------------------- (define (selector! nu) (set! *prefix nu)) (define (select s) (string-prefix? s *prefix)) (define (data->selected! _) (set! *selected (if (string=? "" *prefix) *data (filter select *data)))) (define-state *data '("Emil, Hans" "Mustermann, Max" "Tisch, Roman") data->selected!) (define-state *prefix "" data->selected!) (define-state *selected *data (λ (s) (send lbox set s))) ;; selected = (filter select data) (define (Create *data) (append *data (list (get-name)))) (define (Update i) (if i (operate-on i (curry cons (get-name))) none)) (define (Delete i) (if i (operate-on i values) none)) #; {N [[Listof X] -> [Listof X]] -> [Listof X]} ;; traverse list to the i-th position of selected in data, then apply operator to rest (efficiency) ;; ASSUME selected = (filter selector data) ;; ASSUME i <= (length selected) (define (operate-on i operator) (let sync ((i i) (data *data) (selected *selected)) (if (select (first data)) (if (zero? i) (operator (rest data)) (cons (first data) (sync (sub1 i) (rest data) (rest selected)))) (cons (first data) (sync i (rest data) selected))))) (define (get-name) (string-append (send surname get-value) ", " (send name get-value))) ;; --------------------------------------------------------------------------------------------------- (define (mk-changer p) (with i #:post p #:widget lbox #:method get-selection i)) (define (name-field% n) (class text-field% (super-new (label n) (init-value "") (min-width 200)))) (define-gui frame "CRUD" (#:horizontal (#:vertical (text-field% #:change *prefix (with p p) [label "Filter prefix: "][init-value ""]) (#:id lbox list-box% [label #f][choices '()][min-width 100][min-height 100])) (#:vertical (#:id name (name-field% "Name: ")) (#:id surname (name-field% "Surname: ")))) (#:horizontal (button% #:change *data (just Create) [label "Create"]) (button% #:change *data (mk-changer Update) [label "Update"]) (button% #:change *data (mk-changer Delete) [label "Delete"]))) (selector! "") (send frame show #t)
false
0bc3d322be151390a13366207c331f88cf74f217
d2fc383d46303bc47223f4e4d59ed925e9b446ce
/courses/2012/fall/330/notes/2-7.rkt
3f8b9272a1d51c0341d601b4c6834d4cfe6457a2
[]
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,408
rkt
2-7.rkt
#lang plai (print-only-errors #t) (define-type AE [num (n number?)] [add (lhs AE?) (rhs AE?)] [sub (lhs AE?) (rhs AE?)] [id (sym symbol?)] [with (new-name symbol?) (named-thing AE?) (body AE?)] [app (fun symbol?) (arg AE?)]) ;; <AE> := <real Racket number> ;; | (+ <AE> <AE>) ;; | (- <AE> <AE>) ;; | <id> ;; | (with [<id> <AE>] <AE>) ;; | (<id> <AE>) ;; where <id> is any Racket symbol, except +, -, and with ;; parse :: s-expression -> AE (define (parse se) (cond [(and (list? se) (= 2 (length se)) (symbol? (first se)) (not (member (first se) '(+ - with)))) (app (first se) (parse (second se)))] [(and (list? se) (= 3 (length se)) (equal? 'with (first se)) (list? (second se)) (= 2 (length (second se))) (symbol? (first (second se)))) (with (first (second se)) (parse (second (second se))) (parse (third se)))] [(symbol? se) (id se)] [(number? se) (num se)] [(and (list? se) (= 3 (length se)) (equal? '+ (first se))) (add (parse (second se)) (parse (third se)))] [(and (list? se) (= 3 (length se)) (equal? '- (first se))) (sub (parse (second se)) (parse (third se)))] [else (error 'parse "Invalid syntax, dude")])) (test (parse '1) (num 1)) (test (parse '(+ 1 1)) (add (num 1) (num 1))) (test (parse '(- 1 1)) (sub (num 1) (num 1))) (test (parse 'x) (id 'x)) (test (parse '(with [x 27] x)) (with 'x (num 27) (id 'x))) (test (parse '(double 5)) (app 'double (num 5))) (test/exn (parse "1") "Invalid syntax") ;; subst : symbol AE AE -> AE (define (subst name named-thing body) (type-case AE body [app (fun arg) (app fun (subst name named-thing arg))] [id (sym) (if (equal? name sym) named-thing body)] [with (inner-name inner-named-thing inner-body) (if (equal? inner-name name) (with inner-name (subst name named-thing inner-named-thing) inner-body) (with inner-name (subst name named-thing inner-named-thing) (subst name named-thing inner-body)))] [add (lhs rhs) (add (subst name named-thing lhs) (subst name named-thing rhs))] [sub (lhs rhs) (sub (subst name named-thing lhs) (subst name named-thing rhs))] [num (n) body])) ;; C perspective... linker ;; First-order function (language doens't define functions, just uses ;; them) (define-type FunDef [a-FunDef (name symbol?) (param symbol?) (body AE?)]) (define double-def (a-FunDef 'double 'x (parse '(+ x x)))) (define triple (a-FunDef 'triple 'x (parse '(+ x (double x))))) ;; lookup-fun : symbol lofds -> FunDef (define (lookup-fun fun fs) (cond [(empty? fs) (error 'calc "SIGSEGV")] [(equal? fun (a-FunDef-name (first fs))) (first fs)] [else (lookup-fun fun (rest fs))])) ;; calc/funs : AE? lofds -> number? ;; compute the meaning of the AE (define (calc/funs ae fs) (type-case AE ae [app (fun arg) (type-case FunDef (lookup-fun fun fs) [a-FunDef (fun-name param body) ;; (calc/funs (subst param (num (calc/funs arg fs)) body) fs) (calc/funs (with param arg body) fs)])] [id (sym) (error 'calc "You has a bad identifier, bro: ~e" sym)] [with (name named-thing body) ;; Inefficient -- Lazy' semantics ;; (calc (subst name named-thing body)) ;; Efficient -- Eager semantics (calc/funs (subst name (num (calc/funs named-thing fs)) body) fs)] [num (n) n] [add (lhs rhs) (+ (calc/funs lhs fs) (calc/funs rhs fs))] [sub (lhs rhs) (- (calc/funs lhs fs) (calc/funs rhs fs))])) ;; calc* : sexpr -> number? (define (calc* se) (calc/funs (parse se) empty)) ;; calc*/funs : sexpr lofds -> number? (define (calc*/funs se fs) (calc/funs (parse se) fs)) (test (calc* '1) 1) (test (calc* '(+ 1 1)) 2) (test (calc* '(- 0 1)) -1) (test (calc* '(with [x (+ 5 5)] (+ x x))) 20) (test (calc* '(with [y 7] (with [x y] (+ x x)))) 14) (test (calc* '(with [x (+ 5 5)] (with [x 7] (+ x x)))) 14) (test (calc* '(with [x (+ 5 5)] (+ x (with [x 7] (+ x x))))) 24) (test (calc* '(with [x 7] (with [y (+ 2 x)] (+ y 3)))) 12) (test (calc* '(with [y 7] (with [y (+ y 2)] (+ y 3)))) 12) (test (calc* '(with [x (+ 5 5)] 7)) 7) (test (calc* '(with [x (+ 5 5)] (+ x x))) 20) (test (calc* '(with [x 6] (+ x x))) 12) (test (calc*/funs '(double (+ 5 5)) (list double-def)) 20) (test (calc*/funs '(double 6) (list double-def)) 12) (test (calc*/funs '(with [x 5] (double x)) (list double-def)) 10) (test (calc*/funs '(triple (+ 5 5)) (list double-def triple)) 30) (test (calc*/funs '(triple 6) (list double-def triple)) 18) (test (calc*/funs '(with [x 5] (triple x)) (list double-def triple)) 15) ;;(test (calc*/funs '(f 1) ;; (list (a-FunDef 'f 'x (parse '(f x))))) ;; 42) (test (calc*/funs '(with [double 5] (double (triple double))) (list double-def triple)) 30) ;; Two "namespaces" --- one for functions and one for identifiers ;; 2-Lisps (have two) [original, Common Lisp, Javascript] ;; and 1-Lisps (have one) [C, Clojure, Scheme, Racket] ;; Java... a 2-lisp ;; class Stupid { ;; int x (float f) { return 0; } ;; int main () { ;; float x = 3.0; ;; x(x); ;; } ;; } (test/exn (calc*/funs '(with [x 5] (f 17)) (list (a-FunDef 'f 'n (parse '(+ n x))))) "bro")
false
864e4c34dc8b5149d0f147c4f660a048e57e8e81
8baf076b379734f6e1af698c74d37c75fe6f13a5
/data.rkt
e0344de5b74c581847c55d4515e64c2ffe4105be
[]
no_license
lexi-lambda/racket-pipe-game-clone
239035bc6892f2b124df04e0dc651be6c845c40a
356eaa0e7d4be4e295b3e83a037877b8a101957f
refs/heads/master
"2016-09-06T20:12:33.798292"
"2015-03-17T17:13:26"
"2015-03-17T17:13:26"
32,307,557
2
0
null
null
null
null
UTF-8
Racket
false
false
6,112
rkt
data.rkt
#lang typed/racket/base (require racket/vector racket/function racket/match typed/pict "constants.rkt" "utils.rkt" "shapes.rkt") (provide (struct-out tile) Tile-Grid Tile-Offsets tile->pict starting-tile-grid accumulate-tile-offsets tile-grid-pivot tile-grid->pict) ;; tile data ;; --------------------------------------------------------------------------------------------------- (struct tile ([type : (U 'l 'i)] [rotation : Integer] [color : (U 'grey 'red 'green 'yellow)]) #:transparent) ; cache the bitmaps to prevent recalculating them every frame (define tile-cache : (HashTable tile pict) (make-hash '())) ; Converting a tile type to a pict is easy—just look up the appropriate shape. (define (tile-type->pict [t : (U 'l 'i)]) (case t [(l) pipe-l] [(i) pipe-i])) ; Each integral "rotation" is equivalent to a 90º spin. (define (tile-rotation->radians [t : Float]) (revolutions->radians (* 1/4 t))) ; Tile color lookups are similarly straightforward. (define (tile-color->color [t : (U 'grey 'red 'yellow 'green)]) (case t [(grey) pipe-color-grey] [(red) pipe-color-red] [(yellow) pipe-color-yellow] [(green) pipe-color-green])) ; Converting a tile to a pict simply grabs the appropriate graphic, colors it, rotates it, and ; overlays it atop the generic tile base. Tile graphics are cached to avoid recalculation. (define (tile->pict [t : tile]) (hash-ref! tile-cache t (λ () (match-define (tile type rotation color) t) (freeze (clip (pin-over tile-base 0 0 (colorize (rotate (tile-type->pict type) (tile-rotation->radians (exact->inexact rotation))) (tile-color->color color)))))))) ;; tile grid ;; --------------------------------------------------------------------------------------------------- ; A Tile-Grid is simply a vector of length 36 containing tile data. (define-type Tile-Grid (Vectorof tile)) ; A Tile-Offsets map contains information about how tile move around the grid. This data needs to be ; exposed by the data layer so that the rendering layer can perform animation. (define-type Tile-Offsets (HashTable tile (List Float Float))) ; The initial tile grid is hardcoded. It could be procedurally generated, but for now, it's easier ; to just hardcode things to avoid needing to tune the algorithm. (define starting-tile-grid : Tile-Grid (vector-immutable (tile 'l 0 'green) (tile 'l 1 'grey) (tile 'l 3 'red) (tile 'i 0 'yellow) (tile 'i 1 'grey) (tile 'l 3 'red) (tile 'i 1 'grey) (tile 'l 1 'red) (tile 'l 3 'grey) (tile 'l 0 'red) (tile 'i 0 'red) (tile 'l 3 'yellow) (tile 'i 1 'grey) (tile 'l 0 'yellow) (tile 'l 1 'green) (tile 'l 2 'yellow) (tile 'l 1 'green) (tile 'l 2 'grey) (tile 'l 2 'green) (tile 'i 0 'green) (tile 'i 0 'red) (tile 'i 1 'green) (tile 'i 0 'yellow) (tile 'l 0 'grey) (tile 'l 1 'yellow) (tile 'l 3 'red) (tile 'l 0 'grey) (tile 'i 0 'green) (tile 'i 1 'grey) (tile 'i 0 'green) (tile 'l 3 'green) (tile 'i 1 'yellow) (tile 'i 1 'red) (tile 'i 0 'red) (tile 'i 0 'yellow) (tile 'l 0 'yellow))) ; Simply converts (x, y) coordinates to linear coordinates. This is easy since the grid is a fixed ; size. (: tile-grid-point->index (Integer Integer -> Integer)) (define (tile-grid-point->index x y) (+ x (* y 6))) ; This adds two sets of tile offsets together via simple addition. (: accumulate-tile-offsets (Tile-Offsets Tile-Offsets -> Tile-Offsets)) (define (accumulate-tile-offsets offsets new-offsets) (for/fold ([offsets offsets]) ([(tile new-offset) new-offsets]) (match-let* ([(list new-x new-y) new-offset] [(list old-x old-y) (hash-ref offsets tile (thunk '(0 0)))]) (hash-set offsets tile (list (+ old-x new-x) (+ old-y new-y)))))) ; Pivots tiles around in a clockwise motion. The pivot location is the lower right corner of the tile ; at the provided x and y coordinates. ; It returns the new tile grid as well as hash table of the tiles and their old positions in ; pixel offsets relative to their new positions (this is used for animation). (: tile-grid-pivot (Tile-Grid Integer Integer -> (Values Tile-Grid Tile-Offsets))) (define (tile-grid-pivot tg px py) (define new-grid (vector-copy tg)) ; first get the indicies... (let ([ai (tile-grid-point->index px py)] [bi (tile-grid-point->index (add1 px) py)] [ci (tile-grid-point->index (add1 px) (add1 py))] [di (tile-grid-point->index px (add1 py))]) ; then get the values... (let ([a (vector-ref tg ai)] [b (vector-ref tg bi)] [c (vector-ref tg ci)] [d (vector-ref tg di)]) ; then rotate them... (vector-set! new-grid ai d) (vector-set! new-grid bi a) (vector-set! new-grid ci b) (vector-set! new-grid di c) ; and finally, make the result immutable and return the offset information (values (vector->immutable-vector new-grid) (make-immutable-hasheq `((,a . (-64. 0.)) (,b . ( 0. -64.)) (,c . ( 64. 0.)) (,d . ( 0. 64.)))))))) ; Converts a tile grid and a table of tile offsets to a renderable pict. (: tile-grid->pict (Tile-Grid Tile-Offsets -> pict)) (define (tile-grid->pict tg offsets) ; we start with a completely blank board and overlay tiles on top (for/fold ([board (blank (* 64 6) (* 64 6))]) ([tile (in-vector tg)] [i (in-naturals)]) ; the actual x and y coordinates can be derived from the linear index (match-let-values ([(y x) (quotient/remainder i 6)] [((list o-x o-y)) (hash-ref offsets tile (thunk '(0 0)))]) ; the result is the tile composited onto the board with offsets taken into account (pin-over board (+ (* x 64) o-x) (+ (* y 64) o-y) (tile->pict tile)))))
false
dc804604e7dcccf51daf1ba7c0c8be518da548fe
ecfd9ed1908bdc4b099f034b121f6e1fff7d7e22
/old1/eopl/1/28.rkt
9f5e07555ce12edd9211ee0561c4dac4c84b1cbb
[ "MIT" ]
permissive
sKabYY/palestra
36d36fc3a03e69b411cba0bc2336c43b3550841c
06587df3c4d51961d928bd8dd64810c9da56abf4
refs/heads/master
"2021-12-14T04:45:20.661697"
"2021-11-25T08:29:30"
"2021-11-25T08:29:30"
12,856,067
6
3
null
null
null
null
UTF-8
Racket
false
false
445
rkt
28.rkt
#lang eopl (#%require "lib.rkt") (define (merge loi1 loi2) (cond ((null? loi1) loi2) ((null? loi2) loi1) (else (let ((i1 (car loi1)) (i2 (car loi2))) (cond ((< i1 i2) (cons i1 (merge (cdr loi1) loi2))) (else (cons i2 (merge loi1 (cdr loi2))))))))) (run-disp (merge '(1 4) '(1 2 8)) (merge '(35 62 81 90 91) '(3 83 85 90)))
false
09fb49f4e4aad8720fa10d25f5d10da23f2a0008
7291089892216ed5ceb99d9402318464f68c8204
/io/file.rkt
f0df2393cc75087fe6342fd6f05e9842655c1b0e
[ "MIT" ]
permissive
samth/io.rkt
7a1c582750affa39d053e39d58282d5f256bca18
db8413c802782bfc3de706cc1cb8dab6fe4f941e
refs/heads/master
"2020-12-25T12:40:26.084784"
"2017-11-10T23:08:12"
"2017-11-10T23:08:12"
9,921,397
0
0
null
null
null
null
UTF-8
Racket
false
false
6,568
rkt
file.rkt
#lang racket/base (require racket/contract racket/path (except-in srfi/1/list any)) ;; ============================================================================= ;; CONTRACTS ;; ============================================================================= ;; TODO: expanded-path?, simple-path? ;; A relative-path is a path for which relative-path? is #t. A ;; relative-file-path or relative-directory-path is a relative-path for ;. which file-exists? or directory-exists? is #t, respectively. ;; relative-path/c : contract (define relative-path/c (and/c (or/c path? string?) relative-path?)) ;; relative-file-path/c : contract (define relative-file-path/c (and/c relative-path/c file-exists?)) ;; relative-directory-path/c : contract (define relative-directory-path/c (and/c relative-path/c directory-exists?)) ;; A complete-path is a path for which complete-path? is #t. A ;; complete-file-path or complete-directory-path is a complete-path for ;. which file-exists? or directory-exists? is #t, respectively. ;; complete-path/c : contract (define complete-path/c (and/c (or/c path? string?) complete-path?)) ;; complete-file-path/c : contract (define complete-file-path/c (and/c complete-path/c file-exists?)) ;; complete-directory-path/c : contract (define complete-directory-path/c (and/c complete-path/c directory-exists?)) ;; ============================================================================= ;; PROCEDURES ;; ============================================================================= ;; path->relative-path : (or string path) [(or string path)] -> relative-path ;; converts a path to a relative path (define (path->relative-path path [relative-to (current-directory)]) (let-values ([(base name must-be-dir?) (split-path path)]) (let loop ([base base] [name name] [rest (list name)]) (if (path=? base relative-to) (apply build-path rest) (let-values ([(base name must-be-dir?) (split-path base)]) (loop base name (cons name rest))))))) ;; explode-relative-path : relative-path -> (listof path) ;; computes the list of directories in a relative path (define (explode-relative-path path) (let loop ([path path] [rest '()]) (let-values ([(base name dir?) (split-path path)]) (cond [(eq? base 'relative) (cons name rest)] [(or (not (path? name)) (not path)) (raise-type-error 'explode-relative-path "relative-path in normal form" path)] [else (loop base (cons name rest))])))) ;; telescope-exploded-path : (listof path) -> (listof path) (define (telescope-exploded-path alop) (fold (lambda (this rest) (cons (if (null? rest) this (build-path (car rest) this)) rest)) null alop)) ;; telescope-path : complete-path -> (listof complete-path) (define (telescope-path path) (telescope-exploded-path (explode-path path))) ;; telescope-relative-path : relative-path -> (listof relative-path) (define (telescope-relative-path path) (telescope-exploded-path (explode-relative-path path))) ;; path=?/2 : (or path #f 'relative) (or path #f 'relative) -> boolean (define (path=?/2 path1 path2) (or (and (not path1) (not path2)) (and (eq? path1 'relative) (eq? path2 'relative)) (and (path? path1) (path? path2) (let-values ([(base1 name1 dir1?) (split-path path1)] [(base2 name2 dir2?) (split-path path2)]) (and (or (and (symbol? name1) (symbol? name2) (eq? name1 name2)) (and (path? name1) (path? name2) (bytes=? (path->bytes name1) (path->bytes name2)))) (path=?/2 base1 base2)))))) ;; path=? : path path ... -> boolean ;; determines whether two paths contain exactly the same elements (define (path=? path1 path2 . paths) (andmap (lambda (path2) (path=?/2 path1 path2)) (cons path2 paths))) ;; path-normalized=? : path path ... -> boolean ;; determines whether two paths refer to the same normalized path (define (path-normalized=? path1 path2 . paths) (apply bytes=? (map (compose path->bytes normalize-path) (cons path1 (cons path2 paths))))) ;; directory-list/all : [(or string path)] -> (listof relative-path) ;; returns the list of all files and subdirectories, relative to base-dir (define (directory-list/all [base-dir (current-directory)]) (let all-from ([dir base-dir] [prefix #f]) (append-map (lambda (p) (let ([p* (if prefix (build-path prefix p) p)] [entry (build-path dir p)]) (if (directory-exists? entry) (cons p* (all-from entry p*)) (list p*)))) (directory-list dir)))) ;; empty-directory? : (or string path) -> boolean (define (empty-directory? p) (and (directory-exists? p) (null? (directory-list p)))) ;; dirname : path -> path (define (dirname p) (let-values ([(parent name must-be-dir?) (split-path p)]) (cond [(not parent) (build-path p)] [(eq? parent 'relative) (build-path 'same)] [else parent]))) ;; basename : path -> relative-path (define (basename p) (let-values ([(parent name must-be-dir?) (split-path p)]) (if (symbol? name) (build-path name) name))) (provide/contract [relative-path/c contract?] [relative-file-path/c contract?] [relative-directory-path/c contract?] [complete-path/c contract?] [complete-file-path/c contract?] [complete-directory-path/c contract?]) ;; TODO: can we make these contracts a little more precise? -- namely, the ;; relative-paths must be simplified and expanded (provide/contract [dirname ((or/c string? path?) . -> . path?)] [basename ((or/c string? path?) . -> . path?)] [empty-directory? ((or/c string? path?) . -> . boolean?)] [directory-list/all (() ((or/c string? path?)) . ->* . (listof relative-path/c))] [path->relative-path (((or/c string? path?)) ((or/c string? path?)) . ->* . relative-path/c)] [explode-relative-path (relative-path/c . -> . (listof path?))] [telescope-path (complete-path/c . -> . (listof complete-path/c))] [telescope-relative-path (relative-path/c . -> . (listof relative-path/c))] [path=? ((path? path?) (listof path?) . ->* . boolean?)] [path-normalized=? ((path? path?) (listof path?) . ->* . boolean?)] )
false
60a8ebbd4e21a92fb4bcea90ecf9e35fa6682a52
4e39c242da63607de30191e5eff94a68c498bccb
/Scheme/week04/04. Last/last.rkt
c676b50e03cc0875ab5f143afd958b5e69e0e07c
[]
no_license
KristiyanGergov/FunctionalProgramming
09747a8bd30f44e62deddcd6b19dedccacf86f70
2f1a0f941f9d9e43f684808776d998db72a07013
refs/heads/master
"2020-04-01T11:39:30.632117"
"2019-02-12T21:23:14"
"2019-02-12T21:23:14"
153,171,801
1
0
null
null
null
null
UTF-8
Racket
false
false
134
rkt
last.rkt
#lang racket (define l '(0 1 2 3 4)) (define (last l) (if (null? (cdr l)) (car l) (last (cdr l)) ) ) (last l)
false
76ed5a35ea31cda68bfe168ca8e8e63fdf6e3fd8
12bfbb764384f9fd847f6e5bdfce24ebcb39f072
/src/graph/solver/model-O0/graph-searcher.rkt
c877c41142d4e8fd90036838ad8b38ac7363493b
[ "WTFPL" ]
permissive
Techatrix/RGE
aab6d9004c57bc9e76924016a93c50c33520ed08
cff1d7fea06544ee0e3fed78099e2abd758b204a
refs/heads/master
"2023-02-06T05:36:03.186144"
"2020-12-28T17:21:25"
"2020-12-28T17:21:25"
293,315,003
0
0
WTFPL
"2020-12-23T20:08:31"
"2020-09-06T16:18:58"
Racket
UTF-8
Racket
false
false
1,538
rkt
graph-searcher.rkt
#lang racket (require "../../base/base-structures.rkt") (require "../util/graph-searcher.rkt") (require "../util/graph-state.rkt") (provide searcher-graph-O0 searcher-state-O0) (define (get-comp proc) (lambda (v1 v2) (eq? (proc v1) (proc v2)))) (define (list-search-comp lst v [proc eq?]) (cond [(empty? lst) #f] [(proc v (car lst)) (car lst)] [else (list-search-comp (rest lst) v proc)])) (define (list-replace-comp lst old-value new-value [proc eq?]) (cond [(empty? lst) '()] [else (cons (if (proc old-value (car lst)) new-value (car lst)) (list-replace-comp (rest lst) old-value new-value proc))])) (define (list-remove-comp lst v [proc eq?]) (cond [(empty? lst) '()] [(proc v (car lst)) (list-remove-comp (rest lst) v proc)] [else (cons (car lst) (list-remove-comp (rest lst) v proc))])) (define (searcher-builder-O0 proc-get-value) (searcher (lambda (data value [proc proc-get-value]) (list-search-comp data value (get-comp proc))) (lambda (data old-value new-value [proc proc-get-value]) (list-replace-comp data old-value new-value (get-comp proc))) (lambda (data value [proc proc-get-value]) (cons value data)) (lambda (data value [proc proc-get-value]) (list-remove-comp data value (get-comp proc))) (lambda (data proc) (map (lambda (node) (proc node)) data)) (lambda (data) data))) (define searcher-graph-O0 (searcher-builder-O0 node-id)) (define searcher-state-O0 (searcher-builder-O0 node-state-id))
false
79bb008ebcef9da187a5dcf733af9b84cd6e3281
681f5c7c0ff0ba9d671556db409622595c935a68
/demos/factorial/fact.rkt
ce046a25ed35dbe7871229f6d49aa8d65e9a10e8
[]
no_license
lixiangqi/medic
60f7ad8ee9fc9437b1e569f12e3f90752c9805a6
0920090d3c77d6873b8481841622a5f2d13a732c
refs/heads/master
"2021-01-04T14:07:20.607887"
"2015-11-08T23:26:25"
"2015-11-08T23:26:25"
29,596,045
14
4
null
"2015-09-11T16:03:40"
"2015-01-21T15:27:17"
Racket
UTF-8
Racket
false
false
93
rkt
fact.rkt
#lang racket (define (fact x) (if (zero? x) 1 (* x (fact (- x 1))))) (fact 3)
false
69bf2d293ecaf0d92a89b4f79a32ea1afda10b38
4c643ce89fb0afc078882a52c7a372e6341cd650
/js-assembler/fracture.rkt
7de7173ce425d715de4b262f214ea8bc0a560604
[]
no_license
gwdean/whalesong
9cf7d5a5245e1f3d69fbd8ed9601c26a22eecd2d
d117f5687dbea34c1c86bd623c97c9fdbc42a6f5
refs/heads/master
"2020-07-22T01:02:56.312388"
"2011-10-17T20:15:11"
"2011-10-17T20:15:11"
2,131,242
0
0
null
null
null
null
UTF-8
Racket
false
false
3,475
rkt
fracture.rkt
#lang typed/racket/base (require "assemble-structs.rkt" "assemble-helpers.rkt" "assemble-open-coded.rkt" "assemble-expression.rkt" "assemble-perform-statement.rkt" "collect-jump-targets.rkt" "../compiler/il-structs.rkt" "../compiler/lexical-structs.rkt" "../compiler/expression-structs.rkt" "../helpers.rkt" racket/string racket/list) (provide fracture) ;; fracture: (listof stmt) -> (listof basic-block) (: fracture ((Listof Statement) -> (Listof BasicBlock))) (define (fracture stmts) (let*: ([first-block-label : Symbol (if (and (not (empty? stmts)) (symbol? (first stmts))) (first stmts) (make-label 'start))] [stmts : (Listof Statement) (if (and (not (empty? stmts)) (symbol? (first stmts))) (rest stmts) stmts)] [jump-targets : (Listof Symbol) (cons first-block-label (collect-general-jump-targets stmts))]) (let: loop : (Listof BasicBlock) ([name : Symbol first-block-label] [acc : (Listof UnlabeledStatement) '()] [basic-blocks : (Listof BasicBlock) '()] [stmts : (Listof Statement) stmts] [last-stmt-goto? : Boolean #f]) (cond [(null? stmts) (reverse (cons (make-BasicBlock name (reverse acc)) basic-blocks))] [else (let: ([first-stmt : Statement (car stmts)]) (: do-on-label (Symbol -> (Listof BasicBlock))) (define (do-on-label label-name) (cond [(member label-name jump-targets) (loop label-name '() (cons (make-BasicBlock name (if last-stmt-goto? (reverse acc) (reverse (append `(,(make-GotoStatement (make-Label label-name))) acc)))) basic-blocks) (cdr stmts) last-stmt-goto?)] [else (loop name acc basic-blocks (cdr stmts) last-stmt-goto?)])) (cond [(symbol? first-stmt) (do-on-label first-stmt)] [(LinkedLabel? first-stmt) (do-on-label (LinkedLabel-label first-stmt))] [else (loop name (cons first-stmt acc) basic-blocks (cdr stmts) (GotoStatement? (car stmts)))]))]))))
false
ee3157598334e7b5f514a5908471263a37af3177
d755de283154ca271ef6b3b130909c6463f3f553
/htdp-lib/2htdp/planetcute/character-princess-girl.rkt
953dbdf1a59801d3d4167026f051380aebabb9ad
[ "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
249
rkt
character-princess-girl.rkt
#lang racket/base (provide character-princess-girl) (require racket/draw racket/runtime-path) (define-runtime-path character-princess-girl-img "character-princess-girl.png") (define character-princess-girl (read-bitmap character-princess-girl-img))
false
fc6e5397a1059aa8d0c93d1554e417cd65e5949f
00e9233f3c51474561c07a8fbb756f80068deb40
/passes/assign-homes.rkt
54a1d5b3606db1f159d65de17ec7097333cd3727
[ "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
3,190
rkt
assign-homes.rkt
#lang racket (require "../utilities.rkt") (require "../runtime-config.rkt") (provide assign-homes) ;; ;; Assign Homes ;; ;; assign-homes : x86' + (var -> reg) -> x86' ;; ;; Pass takes a ;; (define (assign-homes p) (match p [`(program (,vars ,reg-map) (defines ,defs ...) ,instrs ...) (begin (color->reg reg-map) `(program (,vars) (defines ,@(map (lambda (d) (match d [`(define (,f) ,num-locals (,vars ,max-stack) ,instrs ...) `(define (,f) ,num-locals (,vars ,max-stack) ,@(assign-reg instrs reg-map))])) defs)) ,@(assign-reg instrs reg-map)))])) (define (assign-reg instrs reg-map) (map (lambda (i) (assign-helper i reg-map)) instrs)) (define (assign-helper instr reg-map) (match instr [`(,op (,typex ,x) (offset (,typey ,y) ,i)) (let ([x^ (hash-ref reg-map x #f)] [y^ (hash-ref reg-map y #f)]) (cond ;; [(and (equal? x^ #f) (equal? y^ #f)) `((,op (,typex ,x)) (offset (,typey ,y) ,i))] ;; [(equal? x^ #f) `(,op (,typex ,x) (offset ,y^ ,i))] [(equal? y^ #f) `(,op ,x^ (,typey ,y))] [else `(,op ,x^ (offset ,y^ ,i))]))] [`(,op (offset (,typex ,x) ,i) (,typey ,y)) (let ([x^ (hash-ref reg-map x #f)] [y^ (hash-ref reg-map y #f)]) (cond [(and (equal? x^ #f) (equal? y^ #f)) `(,op (offset (,typex ,x) i) (,typey ,y))] [(equal? x^ #f) `(,op (offset (,typex ,x), i) ,y^)] [(equal? y^ #f) `(,op (offset ,x^ ,i) (,typey ,y))] [else `(,op (offset ,x^ ,i) ,y^)]))] [`(,op (offset (,typex ,x) ,i) (offset (,typey ,y) ,j)) (let ([x^ (hash-ref reg-map x #f)] [y^ (hash-ref reg-map y #f)]) (cond [(and (equal? x^ #f) (equal? y^ #f)) `(,op (offset (,typex ,x) i) (offset (,typey ,y) ,i))] [(equal? x^ #f) `(,op (offset (,typex ,x), i) (offset ,y^ ,i) )] [(equal? y^ #f) `(,op (offset ,x^ ,i) (offset (,typey ,y) ,i))] [else `(,op (offset ,x^ ,i) (offset ,y^ ,i))]))] [`(,op (,typex ,x) (,typey ,y)) (let ([x^ (hash-ref reg-map x #f)] [y^ (hash-ref reg-map y #f)]) (cond [(and (equal? x^ #f) (equal? y^ #f)) `(,op (,typex ,x) (,typey ,y))] [(equal? x^ #f) `(,op (,typex ,x) ,y^)] [(equal? y^ #f) `(,op ,x^ (,typey ,y))] [else `(,op ,x^ ,y^)]))] [`(negq (var ,x)) `(negq ,(hash-ref reg-map x))] [`(sete ,x) `(sete ,x)] [`(setl ,x) `(setl ,x)] [`(if (eq? ,t ,cnd) ,thn ,els) (let ([cnd^ (if (eq? (car cnd) 'var) (hash-ref reg-map (cadr cnd)) cnd)] [thn^ (assign-reg thn reg-map)] [els^ (assign-reg els reg-map)]) `(if (eq? ,t ,cnd^) ,thn^ ,els^))] [`(callq ,x) `(callq ,x)] [`(indirect-callq (var ,x)) `(indirect-callq ,(hash-ref reg-map x))] [`(leaq ,_ ,_) instr] )) (define (color->reg color-hash) (hash-map color-hash (lambda (x y) (if (> y (register-num)) ;; this is where we choose number of registers (hash-set! color-hash x `(stack ,(- (* 8 (- y (register-num)))))) (hash-set! color-hash x `(reg ,(vector-ref general-registers y)))))))
false
1e2f104647fdc0def3c363ff87bce94bd8868442
93fd61180e3ad2db364085053b1ea1bdec19f7bf
/compiler/primops.rkt
1690a8f483c70c6e5ee01cd8e0d7bdfd8ca17bf5
[ "BSD-3-Clause" ]
permissive
nilern/complement
c14de84c1ac08c12b8b1f07038ae3961e423d9d9
7bbf2ed0eafaa0b881926f2c432e3091a522bef5
refs/heads/master
"2021-01-21T09:28:33.600811"
"2018-04-21T11:13:33"
"2018-04-21T11:13:33"
101,971,610
0
0
null
null
null
null
UTF-8
Racket
false
false
2,845
rkt
primops.rkt
#lang racket/base (provide primapply portable-ops vm-ops) (require racket/match racket/undefined) ;;;; Internal utilities ;; Reified primop/instruction. (struct $op (call ; function that performs the operation foldable?)) ; can the operation be constant-folded (if no type, range etc. error would occur)? ;; Prefix a symbol with "__". (define (prefix-underscores sym) (string->symbol (string-append "__" (symbol->string sym)))) (define portable-ops (make-hash)) (define ops (make-parameter portable-ops)) ;; Syntax sugar for creating a new $op and adding it into the registry. (define-syntax define-op (syntax-rules (-> !) [(_ (name . args) -> ! body ...) (hash-set! (ops) (prefix-underscores (quote name)) ($op (lambda args body ...) #f))] [(_ (name . args) body ...) (hash-set! (ops) (prefix-underscores (quote name)) ($op (lambda args body ...) #t))])) ;;;; Portable ops (define-op (iEq a b) (= a b)) (define-op (iAdd a b) (+ a b)) (define-op (iSub a b) (- a b)) (define-op (iMul a b) (* a b)) (define-op (tupleNew . vals) (list->vector vals)) (define-op (tupleLength tup) (vector-length tup)) (define-op (tupleGet tup i) (vector-ref tup i)) (define-op (boxNew) (box undefined)) (define-op (boxSet box v) -> ! (set-box! box v)) (define-op (boxGet box) (unbox box)) (define-op (denvNew) (hash)) (define-op (denvPush denv . kvs) (let loop ([denv denv] [kvs kvs]) (match kvs [(list-rest k v kvs) (loop (hash-set denv k v) kvs)] ['() denv]))) (define-op (denvGet denv name) (hash-ref denv name)) (struct $fn ([code #:mutable] env) #:transparent) (define-op (fnNew f . freevars) ($fn f (list->vector freevars))) (define-op (fnCode f) ($fn-code f)) (define-op (fnGet f i) (vector-ref ($fn-env f) i)) (struct $cont ([code #:mutable] env) #:transparent) (define-op (contNew cont . freevars) ($cont cont (list->vector freevars))) (define-op (contCode k) ($cont-code k)) (define-op (contGet k i) (vector-ref ($cont-env k) i)) ;;;; VM ops (define vm-ops (hash-copy portable-ops)) (parameterize ([ops vm-ops]) (define-op (tupleNew len) (make-vector len undefined)) (define-op (tupleInit tup i v) -> ! (vector-set! tup i v)) (define-op (denvPush . args) (error "unimplemented")) (define-op (fnNew len) ($fn undefined (make-vector len undefined))) (define-op (fnInitCode f code) -> ! (set-$fn-code! f code)) (define-op (fnInit f i v) -> ! (vector-set! ($fn-env f) i v)) (define-op (contNew len) ($cont undefined (make-vector len undefined))) (define-op (contInitCode k code) -> ! (set-$cont-code! k code)) (define-op (contInit k i v) -> ! (vector-set! ($cont-env k) i v))) ;;;; API ;; Apply a primop to arguments. (define ((primapply ops) op args) (apply ($op-call (hash-ref ops op)) args))
true
b621d54f354df4550656fbb0384a2b8ca331a5ce
50508fbb3a659c1168cb61f06a38a27a1745de15
/turnstile-lib/turnstile/eval.rkt
85831fda6d1b726a6f38118f3617f055c933aeb7
[ "BSD-2-Clause" ]
permissive
phlummox/macrotypes
e76a8a4bfe94a2862de965a4fefd03cae7f2559f
ea3bf603290fd9d769f4f95e87efe817430bed7b
refs/heads/master
"2022-12-30T17:59:15.489797"
"2020-08-11T16:03:02"
"2020-08-11T16:03:02"
307,035,363
1
0
null
null
null
null
UTF-8
Racket
false
false
3,963
rkt
eval.rkt
#lang turnstile ;; turnstile library for specifying type-level reduction rules (require "more-utils.rkt") (provide define-red define-typerule/red reflect/m (for-syntax reflect mk-reflected)) ;; macro version of reflect; enables cleaner rules in some cases ;; - doesnt need to be template metafn; waiting until expansion to reflect is ok (define-syntax reflect/m (syntax-parser [(_ e) (reflect #'e)])) (begin-for-syntax ;; reflects expanded stx to surface, so evaluation may continue (define (reflect stx) (syntax-parse stx [:id stx] [(m . rst) #:do[(define new-m (syntax-property #'m 'reflect))] (transfer-props stx (datum->syntax stx ; this datum->stx ensures correct #%app inserted (cons (or new-m (reflect #'m)) (stx-map reflect #'rst)) stx) #:except null)] [_ stx])) (define (mk-reflected reflected-name placeholder [display-as #f]) (syntax-property (syntax-property placeholder 'reflect reflected-name) 'display-as display-as)) ) (define-syntax define-red (syntax-parser [(_ red-name redex (~datum ~>) contractum) ; single redex case #'(define-red red-name [redex ~> contractum])] ;; NOTE: be careful about "pattern passing" for this macro-defining macro: ;; Specifically, if `head-pat` is an id expander and `rst-pat` is null, ;; then `head-pat` wont expand to its paren-wrapped nullary-constructor call ;; (as defined by define-type in turnstile/eval), ;; bc it will already have parens in the stx-parse clauses below, ;; so the match will fail ;; eg, see `zero?` in stdlib/nat [(_ red-name (~optional (~seq #:display-as orig) #:defaults ([orig #'#f])) [(placeholder:id . pats) (~datum ~>) contractum] ...) #:with placeholder1 (if (stx-null? #'(placeholder ...)) #'#%plain-app (stx-car #'(placeholder ...))) #:with name- (mk-- #'red-name) #'(begin (define-core-id name-) (define-syntax red-name (λ (stx) (transfer-type stx (syntax-parse (stx-map expand/df (stx-cdr stx)) ; drop macro name [pats ;; #:do[(displayln 'red-name) ;; (pretty-print (stx->datum this-syntax)) ;; (displayln '~>) ;; (pretty-print (stx->datum #`contractum))] (reflect (quasitemplate contractum))] ... [es ;; #:do[(display "no match: ") (displayln 'red-name) ;; (pretty-print (stx->datum #'es)) ;; (displayln 'expected) ;; (stx-map ;; (λ (ps) (pretty-print (stx->datum ps))) ;; #'(pats ...))] (quasisyntax/loc stx (#,(mk-reflected #'red-name #'placeholder1 #'orig) . es))])))))])) ;; use #%plain-app for now (define-syntax define-core-id (syntax-parser [(_ name:id) #'(define-core-id name #%plain-app)] ; plain-app is the default [(_ name x:id) #'(define-syntax name (make-rename-transformer #'x))])) ;; combination of define-typerule and define-red (define-syntax define-typerule/red (syntax-parser [(_ (name:id . in-pat) (~and rule (~not #:where)) ... #:where red-name (~optional (~seq #:display-as orig) #:defaults ([orig #'#f])) (~and (~not #:display-as) reds) ...) #:with name- (mk-- #'name) #`(begin- #,(quasisyntax/loc this-syntax (define-typerule (name . in-pat) rule ...)) (define-core-id name-) ; a placeholder to use in the red rule (define-red red-name #:display-as orig reds ...))]))
true
0049300ff1328f8852da6b3bd5d9fdab49c15832
2bc995f30a2b738e593bd67df4ba719d8e584187
/sql.scrbl
abe9c18093fcf2fd3975bbe076ca3c1afd14066a
[]
no_license
rmculpepper/sql
cea83029802e7391a28b59797c7d8c5056d79dac
f8722d186a5b2ebcbdd58b19a900ebb805bbf33e
refs/heads/master
"2022-05-20T15:34:37.265926"
"2022-03-22T22:06:58"
"2022-03-24T14:35:43"
32,065,057
31
5
null
"2022-03-24T14:35:44"
"2015-03-12T08:13:32"
Racket
UTF-8
Racket
false
false
35,871
scrbl
sql.scrbl
#lang scribble/manual @(require scribble/manual scribble/basic scribble/example racket/runtime-path racket/sandbox (for-label racket racket/contract db/base sql)) @title{SQL: A Structured Notation for SQL Statements} @author[@author+email["Ryan Culpepper" "ryanc@racket-lang.org"]] @(define (lit str) (racketfont str)) @(begin (define-syntax-rule (interaction e ...) (examples #:label #f e ...)) (define-runtime-path log-file "private/log-for-sql-docs.rktd") (define log-mode 'replay) (define (make-pg-eval log-file) (let ([ev (make-log-based-eval log-file log-mode)]) (ev '(require racket/class db sql db/util/postgresql db/util/datetime)) ev)) (define db-eval (make-pg-eval log-file))) @(define the-eval (make-base-eval)) @(the-eval '(require sql racket/match)) @defmodule[sql] This library provides an S-expression notation for a subset of SQL. It provides forms that produce statements (as opaque values rather than strings) that can be used directly with Racket's @racketmodname[db] library. It also provides macros and functions for creating and manipulating SQL ASTs. @; ============================================================ @section[#:tag "sql-intro"]{Using the SQL Library} This library complements the @racketmodname[db] library. The database library manages connecting to databases and executing queries; this library helps construction of the queries to execute. We'll start by going through the examples @secref["intro-basic" #:doc '(lib "db/scribblings/db.scrbl")] using this library's SQL notation instead. @interaction[#:eval db-eval (require sql db) (eval:alts (define pgc ....) (define pgc (dsn-connect 'db-scribble-env))) ] First we create a temporary table to play around with: @interaction[#:eval db-eval (query-exec pgc (create-table #:temporary the_numbers #:columns [n integer #:not-null] [d varchar])) (query-exec pgc (insert #:into the_numbers #:set [n 0] [d "nothing"])) ] Let's take a look at the statements that just went by: @interaction[#:eval db-eval (create-table #:temporary the_numbers #:columns [n integer #:not-null] [d varchar]) (insert #:into the_numbers #:set [n 0] [d "nothing"]) ] Now let's add another row, using ``computed'' values rather than literals. We can use @racket[unquote] (or @litchar{,}) in a scalar expression position to insert a Racket value: @interaction[#:eval db-eval (define n1 1) (define d1 "the loneliest number") (query-exec pgc (insert #:into the_numbers #:set [n ,n1] [d ,d1])) ] Let's look at that last statement: @interaction[#:eval db-eval (insert #:into the_numbers #:set [n ,n1] [d ,d1]) ] The @racket[unquote]d expressions turned into parameter placeholders, and the statement stores their values separately. Strangely, the placeholders appear as @tt{?}, and PostgreSQL doesn't understand @tt{?} placeholders; they should have been @tt{$1} and @tt{$2}. But the statement seems to have worked. What's going on? We need to set the interactive printing dialect to PostgreSQL. This has no effect on the query operations; they set the dialect independently based on the database connection. @interaction[#:eval db-eval (parameterize ((current-sql-dialect 'postgresql)) (print (insert #:into the_numbers #:set [n ,n1] [d ,d1]))) ] And now we see @tt{$1} and @tt{$2} as expected. We can introduce placeholders explicitly (although @racket[unquote] is usually more convenient). An explicit placeholder is written @racket[?], regardless of the dialect. The parameters are given in the query call as usual: @interaction[#:eval db-eval (query-exec pgc (insert #:into the_numbers #:set [n ?] [d ?]) (+ 1 1) "company") ] It is not currently possible to mix explicit placeholders and @racket[unquote] parameters: @interaction[#:eval the-eval (eval:error (query-exec pgc (insert #:into the_numbers #:set [n ,3] [d ?]) "a crowd")) ] You can, of course, mix constant literals and @racket[unquote]s (or placeholders). @interaction[#:eval db-eval (query-exec pgc (insert #:into the_numbers #:set [n 3] [d ,"a crowd"])) ] @tt{SELECT} statements are constructed similarly, and they follow the same rules regarding parameters. The statements work the same with all of the query operations. @interaction[#:eval db-eval (query pgc (select n d #:from the_numbers #:where (= (% n 2) 0))) (query-rows pgc (select n d #:from the_numbers #:where (= (+ n n) (* n n)))) (query-row pgc (select n d #:from the_numbers #:where (< n 1))) (query-list pgc (select d #:from the_numbers #:where (= 0 (% n 2)))) (query-value pgc (select (string_agg d ", ") #:from the_numbers #:where (= 0 (% n 2)))) ] There are S-expression notations for many common SQL operators and expression forms. See @secref["scalar-exprs"] for details. The rest of this manual uses the default SQL1992 dialect for printing results: @interaction[#:eval db-eval (current-sql-dialect #f) ] @; ============================================================ @section[#:tag "statement-forms"]{Statement Forms} The macros in this section create statement values suitable for passing to the query functions of the @racketmodname[db] library. These statement values satisfy the @racketmodname[db] library's @racket[statement?] predicate. They are different from the @svar[statement] ASTs produced by @racket[statement-qq]. The printing of a statement value is controlled by @racket[(current-sql-dialect)], but the code it generates when passed to a query function is determined by the dialect of the connection the query is performed on. @defform*[[(sql statement) (sql ddl-statement)]]{ Produces a statement value that can be passed to a @racketmodname[db] query function. The syntax corresponds to the syntax of the @svar[statement] or @svar[ddl-statement] nonterminals from @secref["sql-syntax"]. @examples[#:eval the-eval (sql (select a b c #:from mytable #:where (> a 10))) (sql (insert #:into mytable #:set [a 1] [b 2] [c 3])) (sql (create-table numbers #:columns [n integer #:not-null] [t text] #:constraints (primary-key n))) ]} @deftogether[[ @defform*[[(select select-item ... select-clause ...) (select select-clause ...)]] @defform*[[(insert #:into table-name assign-clause maybe-conflict) (insert #:into table-name maybe-columns #:from table-expr maybe-conflict)]] @defform[(update table-name assign-clause maybe-where)] @defform[(delete #:from table-name maybe-where)] ]]{ Like @racket[sql], but specialized to the syntax of the @svar[select-statement], @svar[insert-statement], @svar[update-statement], and @svar[delete-statement] nonterminals from @secref["sql-syntax"], respectively. @examples[#:eval the-eval (select a b c #:from mytable #:where (> a 10)) (insert #:into mytable #:set [a 1] [b 2] [c 3]) (insert #:into mytable #:from (select a b c #:from other_table #:where (is-not-null d))) ] Equivalent to @racketblock[ (sql (@#,lit{select} select-item ... select-clause ...)) (sql (@#,lit{insert} #:into table-name assign-clause)) ] and so forth. @history[#:changed "1.1" @elem{Added @racket[#:or-ignore] for @racket[insert].}] } @deftogether[[ @defform*[[(create-table maybe-temp maybe-ifnotexists table-name #:columns column-def ... maybe-constraints) (create-table maybe-temp maybe-ifnotexists table-name #:as statement)]] @defform[(create-view maybe-temp view-name statement)] ]]{ Like @racket[sql], but specialized to the syntax of the DDL @svar[create-table-statement] and @svar[create-view-statement], respectively. @examples[#:eval the-eval (create-table numbers #:columns [n integer #:not-null] [t text] #:constraints (primary-key n)) ] Equivalent to @racketblock[ (sql (@#,lit{create-table} maybe-temp table-name #:columns column-def ... maybe-constraints)) ] and so forth. @history[#:changed "1.1" @elem{Added @racket[#:if-not-exists] option.}] } @defproc[(sql-statement? [v any/c]) boolean?]{ Returns @racket[#t] if @racket[v] is a statement value returned by one of the forms in this section such as @racket[select], @racket[#f] otherwise. } @defproc[(sql-statement->string [statement sql-statement?] [dialect (or/c symbol? #f) (current-sql-dialect)]) string?]{ Produces SQL code as a string for the given @racket[statement] according to the rules of @racket[dialect]. } @; ============================================================ @section[#:tag "sql-syntax"]{S-expression Syntax for SQL} This section describes this library's S-expression syntax for a subset of SQL. The SQL support is organized by nonterminals (eg @svar[statement], @svar[table-ref], and @svar[scalar-expr]); the grammar handled by this library is adapted from @emph{A Guide to the SQL Standard, 4th ed@._} by C@._ J@._ Date and Hugh Darwen. Each non-terminal has the following: @itemlist[ @item{an S-expression syntax,} @item{an AST type predicate, and} @item{a quasiquotation macro to produce AST values from the S-expression syntax.} ] All literals are recognized symbolically, rather than by identifier binding, to avoid cluttering the namespace. The AST type representations are not considered public; they are likely to change in future versions of this library. @defproc[(sql-ast->string [ast (or/c name-ast? scalar-expr-ast? table-expr-ast? table-ref-ast? statement-ast? ddl-ast?)] [dialect (or/c symbol? #f) (current-sql-dialect)]) string?]{ Produces SQL code as a string for the given AST to a string according to the rules of @racket[dialect]. Examples are given throughout the following sections. } @; ---------------------------------------- @subsection[#:tag "names"]{SQL Names and Identifiers} A name is either an unqualified identifier or an identifier qualified with another name, which depending on its usage might represent a catalog, schema, table, range variable, etc. Concrete SQL has both unquoted and quoted identifiers. Different SQL environments (eg, database backends) have different restrictions on unquoted identifiers, regarding illegal characters and reserved words. Most (but not all) systems also apply some case-folding rule to unquoted identifiers (eg, PostgreSQL converts to lowercase, some others convert to uppercase). Similarly, this library has both ``tagged'' and ``untagged'' notations for identifiers and names. Untagged identifiers are written as raw symbols; they are short and convenient, but they run the risk of confusion with operators and special symbols used by this library. Examples of special symbols include @lit{select}, @lit{as}, and @lit{from}. Examples of identifiers containing operator characters include @tt{hello-goodbye} and @tt{first/last}. These identifiers must be written in tagged form. @racketgrammar*[ [ident symbol (@#,lit{Ident:} string) (@#,lit{Ident:} symbol)] [name symbol ident (@#,lit{Name:} name ...+)] ] @specsubform[(@#,lit{Ident:} symbol)]{ Unquoted if possible; case-folded and quoted according the SQL dialect's rules if @racket[symbol] is a reserved word or contains illegal characters. @racketblock[ (Ident: MyTable) (code:comment "MyTable") (Ident: Select) (code:comment "\"SELECT\"") (Ident: a+b.c) (code:comment "\"a+b.c\"") ]} @specsubform[(@#,lit{Ident:} string)]{ Always quoted without case-folding. @racketblock[ (Ident: "MyTable") (code:comment "\"MyTable\"") (Ident: "Select") (code:comment "\"Select\"") (Ident: "x1.$!!") (code:comment "\"x1.$!!\"") ]} @specsubform[(@#,lit{Name:} name ...+)]{ Qualified name; each name except the last qualifies the name to its right. @racketblock[ (Name: x y z) (code:comment "x.y.z") (Name: x y.z) (code:comment "x.y.z") (Name: x (Ident: y.z)) (code:comment "x.\"y.z\"") ]} @specsubform[symbol]{ Must not be a special symbol; otherwise an error is raised. Equivalent to @racket[(@#,lit{Ident:} symbol)] if @racket[symbol] contains no dot (@litchar{.}) characters and matches the pattern @racket[#px"^(?:\\p{L}|_)(?:\\p{L}|\\p{N}|[_$])*$"]---that is, a letter or underscore followed by zero or more letters, numbers, underscores, and dollar signs. If @racket[symbol] consists of dot-separated @racket[_part]s satisfying the rule above, it is equivalent to @racket[(Name: _part ...)]. @racketblock[ MyTable (code:comment "MyTable") x.y.z (code:comment "x.y.z") x.select.as (code:comment "x.\"SELECT\".\"AS\"") ]} Because case-folding behavior is system-dependent, it is wisest to either always quote a given name or never quote it. @deftogether[[ @defform[(ident-qq ident)] @defproc[(ident-ast? [v any/c]) boolean?] ]]{ Quasiquotation macro and predicate, respectively, for @svar[ident]. @examples[#:eval the-eval (sql-ast->string (ident-qq MyTable)) (sql-ast->string (ident-qq (Ident: MyTable))) (sql-ast->string (ident-qq (Ident: "MyTable"))) (sql-ast->string (ident-qq Select)) (sql-ast->string (ident-qq (Ident: Select))) (sql-ast->string (ident-qq (Ident: "Select"))) (sql-ast->string (ident-qq (Ident: a+b.c))) (eval:error (sql-ast->string (ident-qq select))) (eval:error (sql-ast->string (ident-qq a+b.c))) ]} @deftogether[[ @defform[(name-qq name)] @defproc[(name-ast? [v any/c]) boolean?] ]]{ Quasiquotation macro and predicate, respectively, for @svar[name]. @examples[#:eval the-eval (sql-ast->string (name-qq (Name: x y z))) (sql-ast->string (name-qq (Name: x.y z))) (sql-ast->string (name-qq x.y.z)) (sql-ast->string (name-qq x.select.as)) ]} @; ---------------------------------------- @subsection[#:tag "scalar-exprs"]{SQL Scalar Expressions} A scalar expression is either a name, a literal integer or string value, or an application of some function or operator. Note: not every kind of expression is supported in every SQL dialect. @racketgrammar*[ [scalar-expr name exact-integer string (@#,lit{exists} table-expr) (@#,lit{in} scalar-expr #:from table-expr) (@#,lit{in} scalar-expr #:values scalar-expr ...) (@#,lit{case} [scalar-expr scalar-expr] ... maybe-else) (@#,lit{case} #:of scalar-expr [scalar-expr scalar-expr] ... maybe-else) (compare-operator scalar-expr #:some table-expr) (compare-operator scalar-expr #:all table-expr) (name scalar-expr ...) table-expr (operator/special scalar-expr ...) ? (@#,lit{unquote} racket-expr)] ] @specsubform[(@#,lit{exists} table-expr)]{ Produces an @tt{EXISTS} expression: @racketblock[ (exists (select 1 #:from t)) (code:comment "EXISTS (SELECT 1 FROM t)") ]} @specsubform[(code:line (@#,lit{in} scalar-expr #:from table-expr) (@#,lit{in} scalar-expr #:values scalar-expr ...))]{ There are two forms of @tt{IN} expression, one for table expressions and one for lists of scalar expressions: @racketblock[ (in x #:from (select y #:from ys)) (code:comment "x IN (SELECT y FROM ys)") (in x #:values 1 2 3) (code:comment "x IN (1, 2, 3)") ]} @specsubform[(code:line (@#,lit{case} [scalar-expr scalar-expr] ... maybe-else) (@#,lit{case} #:of scalar-expr [scalar-expr scalar-expr] ... maybe-else))]{ There are two forms of @tt{CASE} expression, one like Racket's @racket[cond] and the other like Racket's @racket[case]: @racketblock[ (case [(= x 0) "zero"] [else "no"]) (code:comment "CASE WHEN x = 0 THEN 'zero' ELSE 'no' END") (case #:of x [0 "zero"] [else "no"]) (code:comment "CASE x WHEN 0 THEN 'zero' ELSE 'no' END") ]} @specsubform[(code:line (compare-operator scalar-expr #:some table-expr) (compare-operator scalar-expr #:all table-expr))]{ Produces an ``all-or-any'' comparison between a scalar (or row) expression and a table expression. @racketblock[ (= x #:some (select y #:from ys)) (code:comment "x = SOME (SELECT y FROM ys)") (< x #:all (select y #:from ys)) (code:comment "x < ALL (select y FROM ys)") ]} @specsubform[(name scalar-expr ...)]{ Represents an ordinary function call; no arity checking is done. @racketblock[ (coalesce x y z) (code:comment "coalesce(x, y, z)") ]} @specsubform[table-expr]{ Represents a subquery; the query must return at most one row. @racketblock[ (select y #:from ys #:where (x = 0)) (code:comment "(SELECT y FROM ys WHERE x = 0)") ]} @deftogether[[ @defform[(scalar-expr-qq scalar-expr)] @defproc[(scalar-expr-ast? [v any/c]) boolean?] ]]{ Quasiquotation macro and predicate, respectively, for @svar[scalar-expr]. @examples[#:eval the-eval (sql-ast->string (scalar-expr-qq mytable.mycolumn)) (sql-ast->string (scalar-expr-qq 42)) (sql-ast->string (scalar-expr-qq "Salutations")) (sql-ast->string (scalar-expr-qq "a 'tricky' string")) (sql-ast->string (scalar-expr-qq (log (- 1 p)))) (sql-ast->string (scalar-expr-qq (and (> x 10) (< x 55)))) (sql-ast->string (scalar-expr-qq (coalesce x y z))) (sql-ast->string (scalar-expr-qq (cast "2015-03-15" DATE))) (sql-ast->string (scalar-expr-qq (extract YEAR dob))) (sql-ast->string (scalar-expr-qq (is-null mytable.mycolumn))) (sql-ast->string (scalar-expr-qq (like ph_num "555-____"))) (sql-ast->string (scalar-expr-qq (|| lname ", " fname))) ]} @; ---------------------------------------- @subsubsection[#:tag "special-operators"]{Special Scalar Expressions} @specsubform[(operator/special scalar-expr ...)]{ This function-like syntax is used to represent uses of SQL operators, standard SQL functions that don't use ordinary function-call notation, and a few other special cases, listed below. } @itemlist[ @item{The @tt{CAST} and @tt{EXTRACT} special functions: @racketblock[ (cast "2015-03-15" DATE) (code:comment "CAST('2015-03-15' AS DATE)") (cast "123" (NUMERIC 5 0)) (code:comment "CAST('123' AS NUMERIC(5, 0))") (extract YEAR dob) (code:comment "EXTRACT(YEAR FROM dob)") ] Note that as above, types and fields are written as ``scalar expressions'', in a mild abuse of syntax. } @item{The @tt{OVERLAY}, @tt{POSITION}, and @tt{SUBSTRING} functions: @racketblock[ (overlay "abc" "z" 2 1) (code:comment "OVERLAY('abc' PLACING 'z' FROM 2 FOR 1)") (position "c" "abc") (code:comment "POSITION('c' IN 'abc)") (substring "abc" 2 1) (code:comment "SUBSTRING('abc' FROM 2 FOR 1)") ]} @item{The @tt{TRIM} function is written using one of the following variants: @racketblock[ (trim-leading "z" "zzabc") (code:comment "TRIM(LEADING 'z' FROM 'zzabc')") (trim-trailing "z" "abczz") (code:comment "TRIM(TRAILING 'z' FROM 'abczz')") (trim-both "z" "zzabczz") (code:comment "TRIM(BOTH 'z' FROM 'zzabczz')") ]} @item{The syntax @tt{COUNT(*)} can be written as follows: @racketblock[ (count-all) (code:comment "COUNT(*)") ]} @item{The chaining arithmetic operators @tt{+}, @tt{-}, @tt{*}, and @tt{/}: @racketblock[ (+ 1 2 3 4) (code:comment "1 + 2 + 3 + 4") ]} @item{The chaining infix logical operators @tt{AND} and @tt{OR}: @racketblock[ (and x y z) (code:comment "x AND y AND z") (or x y z) (code:comment "x OR y OR z") ]} @item{The chaining infix binary operator @tt{||} can be written as @racket[\|\|] or as @racket[||]; the latter reads as the empty symbol. @racketblock[ (|| lname ", " fname) (code:comment "lname || ', ' || fname") (\|\| lname ", " fname) (code:comment "lname || ', ' || fname") ]} @item{Any identifier consisting of only characters in @litchar["~!@#%^&*-_=+|<>?/"] is considered a non-chaining infix binary operator: @racketblock[ (< x y) (code:comment "x < y") (%&! 1 2) (code:comment "1 %&! 2") ]} @item{The following operators: @racketblock[ (not x) (code:comment "NOT x") (is-null x) (code:comment "x IS NULL") (is-not-null x) (code:comment "x IS NOT NULL") (is-true x) (code:comment "x IS TRUE") (is-not-true x) (code:comment "x IS NOT TRUE") (is-false x) (code:comment "x IS FALSE") (is-not-false x) (code:comment "x IS NOT FALSE") (is-unknown x) (code:comment "x IS UNKNOWN") (is-not-unknown x) (code:comment "x IS NOT UNKNOWN") (collate x utf8) (code:comment "x COLLATE utf8") (between-and 5 1 10) (code:comment "5 BETWEEN 1 AND 10") (distinct-from x y) (code:comment "x DISTINCT FROM y") (like "abc" "a%") (code:comment "'abc' LIKE 'a%'") (ilike "aBC" "ab_") (code:comment "'aBC' ILIKE 'ab_'") (similar-to "abc" "(a|z)%") (code:comment "'abc' SIMILAR TO '(a|z)%'") ]} @item{Field selection is written as a regular identifier (or @tt{*}) prefixed by a dot. @racketblock[ (.city state) (code:comment "(state).city") (.* table1) (code:comment "(table1).*") (.*) (code:comment "*") ]} @item{Row constructors (the @tt{ROW} syntax is a PostgreSQL extension): @racketblock[ (%row 1 2 3) (code:comment "(1, 2, 3)") (row 1 2 3) (code:comment "ROW(1, 2, 3)") ]} @item{Arrays and array indexing (PostgreSQL extension): @racketblock[ (%array 1 2 3) (code:comment "ARRAY[1, 2, 3]") (%ref x 1) (code:comment "(x)[1]") (%ref x 1 2 3) (code:comment "(x)[1,2,3]") ]} ] @; ---------------------------------------- @subsubsection[#:tag "unquote"]{Placeholders and Unquoted Parameters} There are two variants of @svar[scalar-expr] that enable the construction of parameterized queries. The first is the placeholder, written @lit{?} (regardless of the notation used by the database the query is to be sent to). The second is the @lit{unquote} form, which is equivalent to inserting a placeholder and also providing the expression as a query parameter. @racketgrammar*[ [scalar-expr .... ? (@#,lit{unquote} racket-expr)] ] Note: Due to limitations in the @racketmodname[db] library, @lit{unquote} parameters and ordinary placeholders cannot be mixed in the same statement. @examples[#:eval the-eval (select a #:from mytable #:where (= b ?)) ] The resulting statement can be used with parameters thus: @racketblock[ (query-value c (select a #:from mytable #:where (= b ?)) 10) ] Using the @lit{unquote} form eliminates the need to keep track of positional parameters; instead, the parameter value is written as a Racket expression within the statement. It is automatically translated to SQL code containing placeholders. @examples[#:eval the-eval (define b-param 10) (select a #:from mytable #:where (= b ,b-param)) ] The resulting statement must be called without additional parameters: @racketblock[ (query-value c (select a #:from mytable #:where (= b ,b-param))) ] Note that placeholder syntax varies between SQL dialects. We can see the code a statement produces for a specific dialect by setting the @racket[current-sql-dialect] parameter: @interaction[#:eval the-eval (parameterize ((current-sql-dialect 'postgresql)) (sql-statement->string (select a #:from mytable #:where (= b ,b-param)))) ] @; ---------------------------------------- @subsection[#:tag "table-exprs"]{SQL Table References and Expressions} A table reference is either a reference to a defined table (or view) or a computed table with a name or named components. A table expression can be formed using join and set operations. @racketgrammar*[ [table-ref table-name (@#,lit{as} table-name range-var-ident) (@#,lit{as} table-expr range-var-ident) table-expr] ] Note: in the final variant of @svar[table-ref], the @svar[table-expr] must be a join table expression, specifically. @racketgrammar*[ [table-expr (@#,lit{cross-join} table-ref table-ref) (join-op table-ref table-ref join-condition) (set-op table-ref table-ref maybe-all correspond-clause) (@#,lit{values} scalar-expr ...) (@#,lit{values*} (scalar-expr ...) ...) select-statement] [join-op @#,lit{inner-join} @#,lit{left-join} @#,lit{right-join} @#,lit{full-join} @#,lit{union-join}] [join-condition (code:line #:natural) (code:line #:using column-ident ...) (code:line #:on scalar-expr)] [set-op @#,lit{union} @#,lit{except} @#,lit{intersect}] [maybe-all (code:line) (code:line #:all)] [correspond-clause (code:line) (code:line #:corresponding) (code:line #:corresponding-by column-ident ...)] ] @deftogether[[ @defform[(table-ref-qq table-ref)] @defproc[(table-ref-ast? [v any/c]) boolean?] ]]{ Quasiquotation macro and predicate, respectively, for @svar[table-ref]. @examples[#:eval the-eval (sql-ast->string (table-ref-qq supplier)) (sql-ast->string (table-ref-qq (as supplier s))) (sql-ast->string (table-ref-qq (inner-join supplier part #:using supply_id))) ] } @deftogether[[ @defform[(table-expr-qq table-expr)] @defproc[(table-expr-ast? [v any/c]) boolean?] ]]{ Quasiquotation macro and predicate, respectively, for @svar[table-expr]. } @; ---------------------------------------- @subsection[#:tag "statements"]{SQL Statements} A statement is one of the four standard DML statements or a @tt{WITH} statement that combines them with one or more common table expressions. @racketgrammar*[ [statement select-statement insert-statement update-statement delete-statement with-statement] ] @bold{Select} @racketgrammar*[ [select-statement (@#,lit{select} distinct-clause select-item ... select-clause ...) (@#,lit{select} distinct-clause select-clause ...)] [select-clause (code:line #:values select-item ...) (code:line #:from table-ref ...) (code:line #:where condition-scalar-expr ...) (code:line #:group-by column-ident ...) (code:line #:having condition-scalar-expr ...) (code:line #:order-by order-item ...) (code:line #:limit scalar-expr) (code:line #:offset scalar-expr)] [select-item scalar-expr (@#,lit{as} scalar-expr ident)] [distinct-clause (code:line) (code:line #:all) (code:line #:distinct)] [order-item (code:line scalar-expr #:asc) (code:line scalar-expr #:desc) (code:line scalar-expr)] ] A @svar[select-statement] can contain each kind of @svar[select-clause] at most once. The clauses can occur in any order. If the first form of @svar[select-statement] is used (that is, with the initial @svar[select-item]s), then the @racket[#:values] clause may not also be used. @history[#:changed "1.2" @elem{Added @svar[distinct-clause]}] @bold{Insert} @racketgrammar*[ [insert-statement (@#,lit{insert} #:into table-name assign-clause maybe-conflict) (@#,lit{insert} #:into table-name maybe-columns #:from table-expr maybe-conflict)] [assign-clause (code:line #:set [column-ident scalar-expr] ...)] [maybe-columns (code:line) (code:line #:columns column-ident ...)] [maybe-conflict (code:line) (code:line #:or-ignore) (code:line #:or-fail)] ] @history[#:changed "1.1" @elem{Added @racket[#:or-ignore].}] @bold{Update} @racketgrammar*[ [update-statement (@#,lit{update} table-name assign-clause maybe-where)] [assign-clause (code:line #:set [column-ident scalar-expr] ...)] [maybe-where (code:line) (code:line #:where condition-scalar-expr ...)] ] @bold{Delete} @racketgrammar*[ [delete-statement (@#,lit{delete} #:from table-name maybe-where)] [maybe-where (code:line) (code:line #:where condition-scalar-expr ...)] ] @bold{With} @racketgrammar*[ [with-statement (@#,lit{with} maybe-rec ([table-ident/columns cte]) statement)] [maybe-rec (code:line) #:recursive] [table-ident/columns table-ident (table-ident column-ident ...)] [cte statement table-expr] ] Different database systems place different restrictions on what kinds of statements and table expressions they allow within @tt{WITH} statements. @history[#:changed "1.6" @elem{Allowed @svar[table-expr] for right-hand side.}] @deftogether[[ @defform[(statement-qq statement)] @defproc[(statement-ast? [v any/c]) boolean?] ]]{ Quasiquotation macro and predicate, respectively, for @svar[statement]. @examples[#:eval the-eval (sql-ast->string (statement-qq (select a b c #:from mytable #:where (> a 10)))) (sql-ast->string (statement-qq (insert #:into mytable #:set [a 1] [b 2] [c 3]))) ] } @deftogether[[ @defform[(select-item-qq select-item)] @defproc[(select-item-ast? [v any/c]) boolean?] ]]{ Quasiquotation macro and predicate, respectively, for @svar[select-item]. Note that a @svar[select-item] AST cannot be used with @racket[sql-ast->string] unless it is just @svar[scalar-expr]. A @svar[select-item] AST can be a list of @svar[select-item] ASTs, representing multiple items to be spliced into the @tt{SELECT} statement. @history[#:added "1.6"]} @; ---------------------------------------- @subsection[#:tag "ddl-statements"]{SQL DDL Statements} @racketgrammar*[ [ddl-statement create-table-statement create-view-statement] [create-table-statement (@#,lit{create-table} maybe-temp maybe-ifnotexists table-name #:columns column-def ... maybe-constraints) (@#,lit{create-table} maybe-temp maybe-ifnotexists table-name #:as statement)] [maybe-temp (code:line) (code:line #:temporary)] [maybe-ifnotexists (code:line) (code:line #:if-not-exists)] [column-def [column-ident type column-option ...]] [column-option #:not-null (code:line #:default scalar-expr)] [maybe-constraints (code:line) (code:line #:constraints constraint-decl ...)] [constraint-decl (@#,lit{constraint} constraint-ident constraint) constraint] [constraint (@#,lit{primary-key} column-ident ...) (@#,lit{unique} column-ident ...) (@#,lit{check} scalar-expr) (@#,lit{foreign-key} column-ident ... #:references table-ident/columns action-decl ...)] [action-decl (code:line #:on-delete action) (code:line #:on-update action)] [action #:set-null #:set-default #:cascade #:restrict #:no-action] [create-view (@#,lit{create-view} maybe-temp view-name statement)] ] @history[#:changed "1.1" @elem{Added @racket[#:if-not-exists] option for @lit{create-table}.} #:changed "1.4" @elem{Added @svar[action-decl] for @lit{foreign-key} and the @racket[#:default] @svar[column-option] for @svar[column-def]. }] @deftogether[[ @defform[(ddl-qq ddl-statement)] @defproc[(ddl-ast? [v any/c]) boolean?] ]]{ Quasiquotation macro and predicate, respectively, for @svar[ddl-statement]. } @; ---------------------------------------- @subsection[#:tag "dialect"]{SQL Dialect} @defparam[current-sql-dialect dialect (or/c symbol? #f)]{ Controls the default dialect used when converting SQL ASTs to strings using functions such as @racket[sql-ast->string]. This parameter @bold{does not} affect statement (@racket[sql-statement?]) values used with connection query methods; generation of SQL code for a query method automatically uses the dialect associated with the connection the query is performed on. } @; ============================================================ @subsection[#:tag "escapes"]{Dynamic Statement Composition and SQL Injection} This library allows the dynamic composition of statements and the injection of SQL text using the following extensions to the SQL grammar. @bold{Warning:} Never use the @lit{INJECT} forms to include SQL computed from an untrusted source. Use placeholders or @racket[unquote] parameters instead; see @secref["unquote"]. @racketgrammar*[ [ident .... (@#,lit{Ident:AST} (@#,lit{unquote} ast-racket-expr))] [name .... (@#,lit{Name:AST} (@#,lit{unquote} ast-racket-expr))] [select-item .... (@#,lit{SelectItem:AST} (@#,lit{unquote} ast-racket-expr))] [scalar-expr .... (@#,lit{ScalarExpr:AST} (@#,lit{unquote} ast-racket-expr)) (@#,lit{ScalarExpr:INJECT} (@#,lit{unquote} string-racket-expr))] [table-expr .... (@#,lit{TableExpr:AST} (@#,lit{unquote} ast-racket-expr)) (@#,lit{TableExpr:INJECT} (@#,lit{unquote} string-racket-expr))] [table-ref .... (@#,lit{TableRef:AST} (@#,lit{unquote} ast-racket-expr)) (@#,lit{TableRef:INJECT} (@#,lit{unquote} string-racket-expr))] ] @history[#:changed "1.2" @elem{Added @lit{Ident:AST} and @lit{Name:AST}.} #:changed "1.6" @elem{Added @lit{SelectItem:AST}. See note under @racket[select-item-ast?] about lists.}] @defproc[(make-ident-ast [s (or/c symbol? string?)]) ident-ast?]{ Produces an identifier AST from @racket[s] by applying the rules in @secref["names"] to the term @racket[`(Ident: ,s)]. @history[#:added "1.2"] @examples[#:eval the-eval (sql-ast->string (make-ident-ast 'MyTable)) (sql-ast->string (make-ident-ast "MyTable")) (sql-ast->string (make-ident-ast 'Select)) (sql-ast->string (make-ident-ast 'a+b.c)) ] } @defproc[(make-name-ast [s (flat-rec-contract C symbol? name-ast? (listof C))]) name-ast?]{ Produces a name AST from @racket[s] according to the following rules: @itemlist[ @item{If @racket[s] is a symbol, it is parsed according to the @svar[symbol] case of the @svar[name] nonterminal (see @secref["names"]).} @item{If @racket[s] is a @racket[name-ast?], it is returned unchanged.} @item{If @racket[s] is a list, each component is parsed a @racket[name-ast?] and the components are joined.} ] @history[#:added "1.2"] @examples[#:eval the-eval (sql-ast->string (make-name-ast 'x)) (sql-ast->string (make-name-ast 'x.y.z)) (sql-ast->string (make-name-ast (list 'x.y (make-name-ast 'a.b)))) ] } @defproc[(value->scalar-expr-ast [v any/c]) scalar-expr-ast?]{ Produces a scalar expression AST representing the Racket value @racket[value]. Equivalent to @racket[(scalar-expr-qq (unquote value))]. @history[#:added "1.2"] } @defproc[(make-values*-table-expr-ast [l-rows (listof (listof scalar-expr-ast?))]) table-expr-ast?]{ Produces a table expression AST of the same kind as the @racket[(values* (@#,svar[scalar-expr] ...) ...)] case of the @svar[table-expr] nonterminal, but where the number of rows and columns may be determined dynamically. Note that all of the rows (i.e. the inner lists) must be of the same length. @history[#:added "1.3"] @examples[ #:eval the-eval (struct produce-item (name num type) #:transparent) (define (insert-produce items) (insert #:into produce #:columns name num type #:from (TableExpr:AST ,(make-values*-table-expr-ast (for/list ([item (in-list items)]) (match-define (produce-item name num type) item) (map value->scalar-expr-ast (list name num type))))))) (sql-statement->string (insert-produce (list (produce-item "apples" 1 "standard") (produce-item "bananas" 5 "organic") (produce-item "cranberries" 50 "canned")))) ] } @(close-eval db-eval)
true
e71be8d7b6b71bd4c3dcbdc4fc0737e265ffe715
0ac2d343bad7e25df1a2f2be951854d86b3ad173
/pycket/test/dot-jit.rkt
0a26da61fb68228c9df8f65d8db5b8937744b3de
[ "MIT" ]
permissive
pycket/pycket
8c28888af4967b0f85c54f83f4ccd536fc8ac907
05ebd9885efa3a0ae54e77c1a1f07ea441b445c6
refs/heads/master
"2021-12-01T16:26:09.149864"
"2021-08-08T17:01:12"
"2021-08-08T17:01:12"
14,119,907
158
14
MIT
"2021-08-08T17:01:12"
"2013-11-04T18:39:34"
Python
UTF-8
Racket
false
false
3,537
rkt
dot-jit.rkt
#lang pycket ;(require racket/contract racket/flonum racket/unsafe/ops) (require racket/private/for) (define N 100) (define (dot1 v1 v2) (for/sum ([e1 v1] [e2 v2]) (* e1 e2))) ;; (define (dot2 v1 v2) ;; (for/sum ([e1 (in-vector v1)] [e2 (in-vector v2)]) (fl* e1 e2))) ;; (define (dot-fast v1 v2) ;; (for/fold ([sum 0.0]) ([i (in-range (vector-length v1))]) ;; (unsafe-fl+ sum (unsafe-fl* (unsafe-vector-ref v1 i) (unsafe-vector-ref v2 i))))) ;; (define (dot-fastest v1 v2) ;; (define len (vector-length v1)) ;; (unless (= len (vector-length v2)) ;; (error 'fail)) ;; (let loop ([n 0] [sum 0.0]) ;; (if (unsafe-fx= len n) sum ;; (loop (unsafe-fx+ 1 n) (unsafe-fl+ sum (unsafe-fl* (unsafe-vector-ref v1 n) ;; (unsafe-vector-ref v1 n))))))) ;; (define (dot-flfastest v1 v2) ;; (define len (flvector-length v1)) ;; (unless (= len (flvector-length v2)) ;; (error 'fail)) ;; (let loop ([n 0] [sum 0.0]) ;; (if (unsafe-fx= len n) sum ;; (loop (unsafe-fx+ n 1) (unsafe-fl+ sum (unsafe-fl* (unsafe-flvector-ref v1 n) ;; (unsafe-flvector-ref v1 n))))))) ;; (define/contract (dot1c v1 v2) ;; ((vectorof flonum?) (vectorof flonum?) . -> . flonum?) ;; (for/sum ([e1 v1] [e2 v2]) (* e1 e2))) ;; (define/contract (dot2c v1 v2) ;; ((vectorof flonum?) (vectorof flonum?) . -> . flonum?) ;; (for/sum ([e1 (in-vector v1)] [e2 (in-vector v2)]) (fl* e1 e2))) ;; (define (dot3 v1 v2) ;; (for/sum ([e1 (in-flvector v1)] [e2 (in-flvector v2)]) (fl* e1 e2))) ;; (define/contract (dot3c v1 v2) ;; (flvector? flvector? . -> . flonum?) ;; (for/sum ([e1 (in-flvector v1)] [e2 (in-flvector v2)]) (fl* e1 e2))) (define v1 (for/vector #:length N #:fill 0.0 ([i (in-range N)]) (random))) (define v2 (for/vector #:length N #:fill 0.0 ([i (in-range N)]) (random))) ;; (define fv1 (for/flvector #:length N ([i (in-range N)]) (vector-ref v1 i))) ;; (define fv2 (for/flvector #:length N ([i (in-range N)]) (vector-ref v2 i))) (collect-garbage) (collect-garbage) 'dot1 (time (dot1 v1 v2)) ;; (collect-garbage) (collect-garbage) ;; 'dot-fast ;; (time (dot-fast v1 v2)) ;; (collect-garbage) (collect-garbage) ;; 'dot-fastest ;; (time (dot-fastest v1 v2)) ;; (collect-garbage) (collect-garbage) ;; 'dot2 ;; (time (dot2 v1 v2)) ;; (collect-garbage) (collect-garbage) ;; 'dot1c ;; (time (dot1c v1 v2)) ;; (collect-garbage) (collect-garbage) ;; 'dot2c ;; (time (dot2c v1 v2)) ;; (collect-garbage) (collect-garbage) ;; 'dot3 ;; (time (dot3 fv1 fv2)) ;; 'dot3c ;; (collect-garbage) (collect-garbage) ;; ;; this one involves no chaperones, so we skip it ;; (time (dot3c fv1 fv2)) ;; (collect-garbage) (collect-garbage) ;; 'dot-flfastest ;; (time (dot-flfastest fv1 fv2)) #| Timing results: [samth@huor:~/sw/pycket (master) plt] ~/sw/pycket/pycket-c ~/tmp/dot.rkt cpu time: 38 real time: 38 gc time: 0 2498917.90318 cpu time: 35 real time: 35 gc time: 0 2498917.90318 cpu time: 510 real time: 510 gc time: 0 2498917.90318 cpu time: 470 real time: 470 gc time: 0 2498917.90318 cpu time: 14 real time: 14 gc time: 0 2498917.90318 [samth@huor:~/sw/pycket (master) plt] r ~/tmp/dot.rkt cpu time: 517 real time: 518 gc time: 13 2502935.368641578 cpu time: 105 real time: 105 gc time: 15 2502935.368641578 cpu time: 1132 real time: 1131 gc time: 41 2502935.368641578 cpu time: 675 real time: 674 gc time: 43 2502935.368641578 cpu time: 77 real time: 77 gc time: 14 2502935.368641578 |#
false
67ad647593d8facc6571bb54707a54f51579f4f6
05acd32769e873a795433169209a6a4f9ba53c6e
/vestige-doc/vestige/info.rkt
97fe89b945468ee792bdaeecd30c92a7db7d4ca8
[]
no_license
haakonhr/vestige
67479e394203d3c46079f7b8693c59102ba1b349
ee7f0b35ba5e5d1a3e5ec90976c658bce24d0ba4
refs/heads/master
"2023-03-04T23:51:34.753447"
"2021-02-16T16:17:35"
"2021-02-16T16:17:35"
null
0
0
null
null
null
null
UTF-8
Racket
false
false
67
rkt
info.rkt
#lang info (define scribblings '(("vestige.scrbl" (multi-page))))
false
e2661ca47ed9cd552d654d883545057e9916c188
d755de283154ca271ef6b3b130909c6463f3f553
/htdp-test/tests/htdp-lang/intmlam-adv.rktl
9e077c8fef5c9218a954a76c081a85908ff08422
[ "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
609
rktl
intmlam-adv.rktl
(syntax-test #'(lambda (z z) 10)) (define f7 (lambda (y) (lambda (z) z))) (test #t procedure? f7) (test 778 (lambda (x) 778) 'ignored) (test values (lambda (f) (f f)) values) (define (f11 y) ((lambda (x) x) y)) (test 'id f11 'id) (err/rt-test (1 2 3)) (htdp-syntax-test #'(recur empty-f () 10) "recur: expected a function name after recur, but nothing's there" (htdp-syntax-test #'(local [(lambda (x) x)] 1) "local: expected a definition, but found a part") (htdp-syntax-test #'((unquote-splicing (list 10))) "unquote-splicing: misuse of ,@ or unquote-splicing, not under a quasiquoting backquote")
false
2366232523f74142b36d4009013230a6dd33f301
6ed02f3ebc64478e266db7c07d96a88d4979bed7
/gnal-lambda/require.rkt
dd20e17391cab71d304c5c30ae491a37630cbde5
[ "MIT" ]
permissive
AlexKnauth/gnal-lambda
2dd09c8515857fc0d1c1a1a0c5addf47a0013039
366160d5752f338e69e11d99fd1b3e5c09363d31
refs/heads/master
"2022-01-22T16:01:26.495995"
"2022-01-07T14:57:10"
"2022-01-07T14:57:10"
64,271,526
1
0
null
null
null
null
UTF-8
Racket
false
false
181
rkt
require.rkt
#lang racket/base (provide require) (require syntax/parse/define (only-in racket/base [require -require])) (define-simple-macro (require s:str ...) (-require s ...))
false
f3accbae7e7596f3d0a1aaa22cf4f78b52e7a281
8c492ce2dfcb1e047c28de8753c173842fdaeb21
/model/api.rkt
8f4181543e4f13a10e567b621653f16fff11b3ae
[]
no_license
carl-eastlund/refined-acl2
f8775e2f899e71778a1909d74066e6063b60d645
2e344ad7bcbc5b5a758296a8158dcf9a7f3880bd
refs/heads/master
"2021-01-21T21:47:42.946847"
"2016-03-19T18:32:50"
"2016-03-19T18:32:50"
12,603,459
2
1
null
"2016-03-19T18:32:50"
"2013-09-04T22:22:07"
Racket
UTF-8
Racket
false
false
3,709
rkt
api.rkt
#lang mischief (provide check-program!/residual lookup-proof-obligation all-proof-obligations all-modules-with-proofs minimal-modules-with-proofs proof-dependencies) (require refined-acl2/model/data refined-acl2/model/parse refined-acl2/model/quote refined-acl2/model/verify refined-acl2/model/acl2 refined-acl2/expansion/simplify mischief/preserve-expensive-metadata) (define (all-proof-obligations) (for/hash {[{mod ob} (in-hash module~>obligations)]} (values mod (proof->acl2 ob)))) (define (all-modules-with-proofs) (remove-duplicates (queue->list module-queue))) (define (minimal-modules-with-proofs) (minimize-dependencies (all-modules-with-proofs))) (define (lookup-proof-obligation mod) (proof->acl2 (lookup mod module~>obligations))) (define (check-program!/residual stxs) (define deps (all-modules-with-proofs)) (define-values {prelude-obs} (prelude-obligations deps)) (define-values {env0 shapes0 prelude-csqs} (prelude-consequences deps)) (define-values {env shapes obligations consequences} (verify-program env0 shapes0 (parse-program (map simplify-local-expansion stxs)))) (define proof (append prelude-obs prelude-csqs obligations)) #`(begin (define ref (#%variable-reference)) (define rmp (variable-reference->resolved-module-path ref)) (define mod (resolved-module-path-name rmp)) (define var (quote-syntax/preserve-expensive-metadata var)) (define dep #,(quote-dependencies deps)) (define shs #,(quote-shape-map (shape-map-subtract shapes shapes0))) (define env #,(quote-environment (environment-subtract env env0))) (define obs #,(quote-proof proof)) (define csq #,(quote-proof consequences)) (enqueue! module-queue mod) (dict-set! module~>identifier mod var) (dict-set! module~>dependencies mod dep) (dict-set! module~>shape-map mod shs) (dict-set! module~>environment mod env) (dict-set! module~>obligations mod obs) (dict-set! module~>consequences mod csq))) (define (quote-dependencies deps) #`(list #,@(map quote-dependency deps))) (define (quote-dependency dep) (define/syntax-parse var (lookup dep module~>identifier)) #'(resolved-module-path-name (variable-reference->resolved-module-path (#%variable-reference var)))) (define (prelude-obligations mods) (append-map verify-dependency (minimize-dependencies mods))) (define (minimize-dependencies mods) (define redundant (for*/set {[mod (in-list mods)] [dep (in-list (lookup mod module~>dependencies))]} dep)) (for/list {[mod (in-list mods)] #:unless (set-member? redundant mod)} mod)) (define (prelude-consequences mods) (define/for/fold/append-lists {[env0 (empty-environment)] [shape0 (empty-shape-map)]} {all-csqs} {[mod (in-list mods)]} (define env (lookup mod module~>environment)) (define shapes (lookup mod module~>shape-map)) (define csqs (lookup mod module~>consequences)) (values (environment-union env0 env) (shape-map-union shape0 shapes) csqs)) (values env0 shape0 all-csqs)) (define (proof-dependencies) (for/hash {[{mod deps} (in-hash module~>dependencies)]} (values mod deps))) (define (lookup mod dict) (dict-ref dict mod (lambda {} (error 'Dracula "no record for module ~a" mod)))) (define module~>identifier (make-hash)) (define module~>dependencies (make-hash)) (define module~>shape-map (make-hash)) (define module~>environment (make-hash)) (define module~>obligations (make-hash)) (define module~>consequences (make-hash)) (define module-queue (make-queue))
false
03e6e5b0e7d09e9a18d2dfec5309498be0b01a4a
2648ed01abe9e761560bf1cd79d5da122ac8266f
/tool/syntax-color.rkt
0a463b5a32ab825f6c2adab049043094a16d785c
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
racket/datalog
74a783a54a79e86a8d040848e8476fe6bd68d2f9
3a30258c7a11f6f1836f52590e26542c11865714
refs/heads/master
"2023-08-18T02:06:23.735559"
"2022-03-31T08:01:51"
"2022-03-31T13:15:17"
27,412,704
40
17
NOASSERTION
"2022-03-31T13:15:18"
"2014-12-02T03:13:48"
Racket
UTF-8
Racket
false
false
1,866
rkt
syntax-color.rkt
#lang racket/base (require racket/contract/base syntax-color/lexer-contract parser-tools/lex (prefix-in : parser-tools/lex-sre) "../private/lex.rkt") (provide (contract-out [get-syntax-token lexer/c])) (define (syn-val lex a b c d) (values lex a b (position-offset c) (position-offset d))) (define (colorize-string my-start-pos) (define lxr (lexer [(eof) (syn-val "" 'error #f my-start-pos end-pos)] [(:~ #\" #\\ #\newline) (lxr input-port)] [(:: #\\ #\\) (lxr input-port)] [(:: #\\ #\newline) (lxr input-port)] [(:: #\\ #\") (lxr input-port)] [#\" (syn-val "" 'string #f my-start-pos end-pos)] [any-char (syn-val "" 'error #f my-start-pos end-pos)])) lxr) (define get-syntax-token (lexer [(:+ whitespace) (syn-val lexeme 'whitespace #f start-pos end-pos)] [comment-re (syn-val lexeme 'comment #f start-pos end-pos)] [variable-re (syn-val lexeme 'symbol #f start-pos end-pos)] [identifier-re (syn-val lexeme 'identifier #f start-pos end-pos)] [(:or #\) #\() (syn-val lexeme 'parenthesis #f start-pos end-pos)] [(:or "!=" #\= #\? #\~ #\. #\, ":-") (syn-val lexeme 'parenthesis #f start-pos end-pos)] [(eof) (syn-val lexeme 'eof #f start-pos end-pos)] [#\" ((colorize-string start-pos) input-port)] [any-char (syn-val lexeme 'error #f start-pos end-pos)] [(special) (syn-val lexeme 'error #f start-pos end-pos)] [(special-comment) (syn-val lexeme 'error #f start-pos end-pos)])) (module+ test (define p (open-input-string "\"\\}\n{}\"û@F\n`ª\"\"~\e\u009A\u0081Ä)| ||\"\"|\"}ô|ü\"û\u0081±\"@u|ΣZ}\"\u00955í;/@ýG\u0001λþ\u0082)Pbù\"\"\u0018Σþ\u008CÁ\"\"h*)W|!")) (let loop () (define-values (lex sym b c d) (get-syntax-token p)) (unless (eq? 'eof sym) (printf "~a(~v)\n" sym lex) (loop))))
false
ac1cadc6cf73f1779de1141d6cb77f45a71d1e93
00f61893609b0ec26859a77f82c5b6408ad668e7
/input-reader.rkt
59cc94fa3333fd6d1b2d52b10e3a0279bab53400
[]
no_license
pineapplevendor/crappy-spy-game
879a22804126e2bad795561d1181433d88b8e109
64815820a7c5c313fd4e03d46fa4f00edc7bb1e9
refs/heads/master
"2020-06-03T18:54:24.985402"
"2019-06-13T04:28:23"
"2019-06-13T04:28:23"
191,691,039
0
0
null
null
null
null
UTF-8
Racket
false
false
1,727
rkt
input-reader.rkt
#lang racket (require "rooms.rkt") (require "messages.rkt") (provide read-syntax) (define (read-syntax src in) (read-command in)) (define (read-command input) (select-command (string-split input))) (define-syntax-rule (select-command command-args) (let ([command-name (first command-args)]) (cond [(equal? command-name "help") (handle-help)] [(equal? command-name "list-rooms") (handle-list-rooms)] [(equal? command-name "display-room") (handle-display-room (second command-args))] [(equal? command-name "solve-room") (handle-solve-room (second command-args) (third command-args))] [(equal? command-name "check-messages") (handle-check-messages (second command-args))] [(equal? command-name "add-message") (handle-add-message (second command-args) (string-join (cdr (cdr command-args)) " "))] [else (handle-help)]))) (define (handle-help) (writeln "The allowed commands are:") (writeln "help") (writeln "list-rooms") (writeln "display-room example-room") (writeln "solve-room example-room example-answer") (writeln "check-messages example-room") (writeln "add-message example-room example-message")) (define (handle-list-rooms) (list-rooms (get-rooms))) (define (handle-display-room room) (display-selected-room room)) (define (handle-solve-room room answer) (solve-selected-room room answer)) (define (handle-check-messages room) (display-messages room)) (define (handle-add-message room message) (update-messages room message))
true
d6859cfa51d1318bb8030dbe277fa101800e4a23
4d6d3bc9bc33bcf83f3bad1cca510adceaa7ba42
/Plan/pre-thu-aft.scrbl
89a4fc8acb8924a64ba9b7f6d09676d8823cc724
[]
no_license
mfelleisen/RacketSchool
fafaf20d50e1a34976d4514e4e4e6fa1f80c8cae
ada599f31d548a538a37d998b32d80aa881d699a
refs/heads/master
"2020-04-05T11:47:42.700262"
"2019-04-19T12:51:27"
"2019-04-19T12:51:27"
81,274,050
14
1
null
null
null
null
UTF-8
Racket
false
false
25,178
scrbl
pre-thu-aft.scrbl
#lang scribble/manual @(require "shared.rkt") @; --------------------------------------------------------------------------------------------------- @title[#:tag "thu-aft"]{@bold{Matthew F.} Building Languages} @author{Matthew Flatt} @goals[ @item{@racket[#%module-begin]} @item{@racket[#%top-interaction]} @item{conventional syntax} ] On the one hand, we've looked at modeling languages in Redex. On the other hand, we've started looking at implementing compile-time functions as a way of defining new pieces of a language. As we'll see, you can use comple-time functions to define a whole new language within Racket. So, what's the relationship between Redex models and compile-time functions? Redex and compile-time functions reflect the two main, different ways to implement a language in the realm of Racket. A Redex model gives you an @deftech{interpreter}---a function that maps programs to results. Compile-time functions can define a @deftech{compiler}---a function that maps programs to other programs; to run the resulting program, you will rely on the existing Racket "interpreter". @margin-note*{The Racket interpreter itself composes a compiler to machine code with interpretation of that machine code.} Whether an interepreter or a compiler is better depends on your goal. You may well want both; you want to take a model as an interpreter and compile programs to a call to your interpreter, which gives you some of the benefits of both, and we'll see how to do that tomorrow morning. @; ---------------------------------------- @section{Extending or Defining a Language with Macros} Up to this point, we've written @defterm{compile-time function}, but we refine the terminology now to @defterm{macro} to reflect that we mean a particular kind of compile-time function. Racket macros implement @defterm{syntactic extensions}, by which we mean that you have to learn specific rules for each macro that you might use in a way that's qualitiatively different from having to learn the specific behavior of each library function that you might call. When you use a run-time function, you can know that the rest of the program will run independent of the function as long as you don't reach the call. More importantly, you know how argument expressons in the function call will behave. With a macro, you don't know whether your program will even compile if you don't know anything about the macro (i.e., you may not have the option of running the rest of the program), and there are no subexpressions within the macro use that have a meaning independent of the macro. We've seen examples all week of how you have to learn special rules for the syntactic forms provided by Redex. Hopefully, it has also been clear why learning and using those special rules is worthwhile to more succinctly express program models. If you're @emph{defining} a language, then the concern of having to specify a form's interaction with the rest of the language is the point, anyway. While both macros and the implementation of a conventional compiler use @defterm{compile-time functions} (i.e., the compiler, obviously runs at compile time), macros have the additional feature of being able to plug into different contexts and to cooperate with other, unknown language extensions. Along those lines, Racket macros offer a smooth path from simple syntactic abstractions to language extensions to whole language implementations. To get a sense of why it's possible to implement whole new languages with Racket macros, try running this program @racketmod[ racket (require (for-syntax syntax/parse)) (define-syntax (lambda stx) (syntax-parse stx [(_ (x:id) e:expr) #'(cons 'x e)])) (lambda (x) 10) ] This example illustrates that there are no identifiers in Racket that are special as keywords that cannot be redefined. Instead, seemingly core parts of the language, including @racket[lambda], can be defined as macros. @bold{Stop}! What happens if you add @racket[(define (f x) 11)] and @racket[(f 10)] to the program? @exercise["ex:lambda-via-define"]{Racket's @racket[define] forms can appear in @racket[(let () ....)] to make the definition local to the @racket[let] form. Given that fact, define @racket[lambda] without referring to the built-in @racket[lambda] form.} @; ---------------------------------------- @section{Macros and Identifiers} When we define @racket[lambda] as above, then the original @racket[lambda] becomes inaccessible. Sometimes that's fine, but if the intent of a new @racket[lambda] is to extend the existing one---perhaps to add logging on each entry to the function---then we'd like to define a new @racket[lambda] in terms of the original. One approach is to define @racket[lambda] as the new form, but import the original @racket[lambda] under a different name so that we can still refer to it: @racketmod[ racket (require (for-syntax syntax/parse) (only-in racket [lambda original-lambda])) (define-syntax (lambda stx) (syntax-parse stx [(_ (x:id) e:expr) #'(original-lambda (x) (printf "arg: ~s\n" x) e)])) (define f (lambda (x) 10)) (f 2) ] Importing the original @racket[lambda] as @racket[original-lambda] allows the new implementation of @racket[lambda] to use it, but it also allows the rest of the module to use @racket[original-lambda]. If we want to write programs that only have access to the new @racket[lambda], the best organization is to put the implementation of @racket[lambda] in a module separate from the program that uses it. @racketmod[#:file "noisy-lambda.rkt" racket (require (for-syntax syntax/parse) (only-in racket [lambda original-lambda])) (provide lambda) (define-syntax (lambda stx) (syntax-parse stx [(_ (x:id) e:expr) #'(original-lambda (x) (printf "arg: ~s\n" x) e)])) ] @racketmod[#:file "program.rkt" racket (require "noisy-lambda.rkt") (define f (lambda (x) 10)) (f 2) (code:comment @#,elem{@racket[original-lambda] isn't bound here}) ] Since we may want to use the original @racket[lambda] in many ways to implement a langauge, and since that language implementaton typically doesn't doesn't want to use the new form directly, we usually rename on @racket[provide] instead of on @racket[require]: @racketmod[#:file "noisy-lambda.rkt" racket (require (for-syntax syntax/parse)) (provide (rename-out [new-lambda lambda])) (define-syntax (new-lambda stx) (syntax-parse stx [(_ (x:id) e:expr) #'(lambda (x) (printf "arg: ~s\n" x) e)])) ] @exercise["ex:more-lambda"]{Add a match clause (or several) to the @racket[new-lambda] macro so that @racket[lambda] shapes (trees) other than @;% @(begin #reader scribble/comment-reader (racketblock (lambda (x:id) e:expr) )) @;% behave as before. @bold{Note} If you know more than basic Racket but not the whole language, just get some shapes to work---not all of @racket[lambda].} @exercise["ex:noisy-define"]{Adjust @racket["noisy-lambda.rkt"] to make @racket[define] create noisy functions, too, when it's used in function-shorthand mode---like @racket[(define (f x) 11)], as opposed to @racket[(define x 8)] or @racket[(define f (lambda (x) 11))].} @; ---------------------------------------- @section[#:tag "whole"]{Controlling the Whole Language} Although @racket["noisy-lambda.rkt"] provides a @racket[lambda] to shadow the one initially provided by the @racketmodname[racket] language, we rely on a client program to @racket[require] it within a @code{#lang racket} without renaming the new @racket[lambda] to something else and without requiring any other modules that provide a variant of @racket[lambda]. To take control more reliably, we'd like a plain @hash-lang[] line that gives the program the new @racket[lambda] directly. The language name listed after @hash-lang[] is almost the same as a module name listed in @racket[require]. To extra features of @hash-lang[] prevent us from using @racket["noisy-lambda.rkt"] after @hash-lang[] in place of @racketmodname[racket]: @itemlist[ @item{A language name after @hash-lang[] is responsible not only for providing a set of identifier bindings, but also for declaring how to parse the rest of the characters after @hash-lang[], and @racket["noisy-lambda.rkt"] does not yet do that.} @item{A language name after @hash-lang[] has to be just alphanumeric characters plus @litchar{_} and @litchar{-}. It cannot hash quote marks, like @racket["noisy-lambda.rkt"].} ] We can defer both of these constraints to an existing language @racketmodname[s-exp], which declares that the module content is parsed using parentheses, and that looks for a module name to provide initial bindings (using normal Racket string syntax) right after @racketmodname[s-exp]---but our first attempt will not work: @racketmod[#:file "program.rkt" s-exp "noisy-lambda.rkt" (define f (lambda (x) 10)) (f 2) ] The error is @centerline{@racketerror{module: no #%module-begin binding in the module's language}} We'll need to tell you a little more to say why the error complains about @racket[#%module-begin], but the overall problem is that the module after @racketmodname[s-exp] is responsible for providing @emph{all} bindings to be used in the module body, and not just things that differ from @racketmodname[racket]. Our example program needs, in addition to @racket[lambda], the @racket[define] form, number constants, function application, and module-body sequencing. Let's define @racket["noisy-racket.rkt"] to provide our new @racket[lambda] plus all the non-@racket[lambda] bindings of @racketmodname[racket]. @racketmod[#:file "noisy-racket.rkt" racket (require (for-syntax syntax/parse)) (provide (rename-out [new-lambda lambda]) (except-out (all-from-out racket) lambda)) (define-syntax (new-lambda stx) (syntax-parse stx [(_ (x:id) e:expr) #'(lambda (x) (printf "arg: ~s\n" x) e)])) ] Then we can use it as @racketmod[#:file "program.rkt" s-exp "noisy-racket.rkt" (define f (lambda (x) 10)) (f 2) ] @exercise["ex:no-divide"]{To avoid the possibility of divide-by-zero errors, adjust @racket["noisy-racket.rkt"] to not export @racket[/], @racket[modulo], or @racket[remainder].} @exercise["ex:dbz-to-inf"]{To allow division without the possibility of divide-by-zero errors, adjust @racket["noisy-racket.rkt"] export variants of @racket[/], @racket[modulo], or @racket[remainder] that return @racket[+inf.0] when the second argument is @racket[0].} @; ---------------------------------------- @section{Implicit Syntactic Forms} Triggering syntactic extensions by name allows different extensions to be composed in a natural way, since each has its own trigger. Still, Racket has several forms where you don't use a name. For example, @racket[5] by itself normally treated as a literal number, instead of requiring the programmer to write @racket[(@#,racket[quote] 5)]. Similarly, assuming that @racket[f] has a variable binding, @racket[(f 1 2)] is a function call without something before the @racket[f] to say ``this is a function call.'' In many of these places, you might want to extend or customize a language, even though there's no apparent identifier to bind. To support extension and replacement. Racket macro expander treats several kinds of forms as having an implicit use of a particular identifier: @tabular[ #:column-properties '(top top top) #:sep (hspace 2) (list (list @racket[5] "=" @racket[(#%datum 5)]) '(nbsp nbsp nbsp) (list @racket[(f 1 2)] "=" @racket[(#%app f 1 2)]) '(nbsp nbsp nbsp) (list @racketblock0[@#,hash-lang[] racket/base (define (f x) x) (f 5)] "=" @racketblock0[(module name racket/base (#%module-begin (define (f x) x) (f 5)))])) ] Why does @hash-lang[] correspond to @emph{two} implicit names? Because the @racket[module] one can't be configured. The second one, @racket[#%module-begin], applies after the first one has imported the @racket[#%module-begin] binding, so its meaning can be configured. We couldn't use @racket["noisy-lambda.rkt"] as a module-language module, because it doesn't export @racket[#%module-begin]. By exporting everything from @racketmodname[racket] except @racket[lambda], @racket["noisy-racket.rkt"] provides @racket[#%module-begin], @racket[#%app], and @racket[#%datum], all of which are used implicitly in @racket["program.rkt"]. @exercise["ex:right-to-left"]{Racket's @racket[#%app] implements left-to-right evaluation of function-call arguments. Change @racket["noise-racket.rkt"] so that it implements right-to-left evaluation of arguments to a function call. You'll need to use Racket's @racket[#%app] to implement your new @racket[#%app].} @; ---------------------------------------- @section{Macro-Definition Shorthands} The pattern @racketblock[ (define-syntax (_macro-id stx) (syntax-parse stx [(_ _pattern ....) #'_template])) ] is common enough that it would be nice to have a shorter way of writing it. Fortunately, we're in a language that's easy to extend with a shorthand like @racket[define-syntax-rule], which lets you write the above form equivalently as @racketblock[ (define-syntax-rule (_macro-id _pattern ....) _template) ] For historical reasons, the allowed @racket[_pattern] forms are restricted in that they cannot include identifiers that have @litchar{:} followed by a syntax-class name, as in @racket[x:id]. Also, the error messages are worse, so @racket[define-syntax-rule] is normally used only for temporary or internal extensions. There's also an intermediate point, which avoids writing an explicit @racket[lambda] but allows multiple patterns: @racketblock[ (define-syntax _macro-id (syntax-rules () [(_ _pattern ....) _template])) ] Finally, you may see @racket[syntax-case], which is almost the same as @racket[syntax-parse], but it has the pattern-language restrictions of @racket[define-syntax-rule] and @racket[syntax-rules]. There's little reason to use @racket[syntax-case] over @racket[syntax-parse], other than the minor convenience of having it included in @racketmodname[racket] (again, for historical reasons). @; ---------------------------------------- @section{Aside: Scope and Macro Expansion} In Redex, @racket[define-language] lets you specify binding structure. The @racket[define-syntax-rule] form doesn't include any such specification. And yet... @racketmod[ racket (define-syntax-rule (noisy-begin e ... last-e) (begin (printf "~s\n" e) ... (let ([result last-e]) (printf "~s\n" result) result))) (let ([result 1]) (noisy-begin result 2)) ] Racket's macro system can infer binding structure for macros based on the way that macros ultimately expand. Specifically, the example macro above expands to @racket[let], and the expander knows the binding structure of @racket[let], so it can effectively infer a binding rule for @racket[example]. But you know that the @racket[define-syntax-rule] form is just a shorthand for a compile-time functions, which can do arbitrary things... mumble mumble halting problem mumble... so this inference is not as straightforward as, say, type inference. In fact, the inference works dynamically (at compile time). The details are beyond the scope (pun intended) of this summer school, but see @hyperlink["http://www.cs.utah.edu/~mflatt/scope-sets/"]{these notes} if you're interested. @;{ SKIPPED @; ---------------------------------------- @section{Aside: Phases} When you write Racket libraries, you shouldn't use @racket[@#,hash-lang[] racket], because @racketmodname[racket] pulls in more than you're likely to need. Use@racket[@#,hash-lang[] racket/base], instead, and then @racket[require] other modules that you need. If you follow that advice when writing macros, then you may immediately run into a problem: @racketmod[ racket/base (require (for-syntax syntax/parse)) (define-syntax (lambda stx) (syntax-parse stx [(_ (x:id) e:expr) #'(cons 'x e)])) (lambda (x) 10) ] The error is @centerline{@racketerror{syntax: unbound identifier in the transformer environment; also, no #%app syntax transformer is bound}} Although @racketmodname[racket/base] provides @racket[syntax] (as abbreviated with @litchar{#'}) and @racket[#%app] (as implicitly used for in function calls), it only provides then to @emph{run-time} expressions in the module body. The @racket[syntax-parse] form is explicitly imported for compile-time positions by @racket[(require (for-syntax syntax/parse))]. You can similarly import @racketmodname[racket/base] for use at compile time: @racketmod[ racket/base (require (for-syntax racket/base syntax/parse)) (define-syntax (lambda stx) (syntax-parse stx [(_ (x:id) e:expr) #'(cons 'x e)])) (lambda (x) 10) ] } @;{ SKIPPED @; ---------------------------------------- @section{Context-Sensitive Expansion} Macro expansion is context-sensitive in the sense that macro transformations are triggered by lexical binding. The process of matching a pattern and substituting into a template is context-insensitive (modulo bindings for literals). To perform context-sensitive transformations, a macro can use @racket[syntax-local-value] to inspect its environment, and it can use @racket[local-expand] to force the expression of a subform. } @; ---------------------------------------- @section{Interactive Evaluation} When you run a program in DrRacket, you get to interact with the program after it runs. The interactive prompt is sometimes called the @defterm{top level}, because you have access to all the bindings that are at the outer scope of your module, while nested bindings are inaccessible. Interactive evaluation is similar to adding additional definitions and expression to the end of your program---but it's not exactly the same, because interactive evaluation cannot generally reflect the same constraints and behaviors of in-module forms; the top level is hopeless. Since making interactive evaluation sensible with respect to a module's content depends on the module's language, a @racket[#%top-interaction] form is implicitly used for each interaction. A replacement @racket[#%top-interaction] might disallow definitions, or it might combine an expression's processing with information (such as types) that is recorded from the module body. The @racket[#%top-interaction] form is unusual in that it's paired with its argument form using @litchar{.}, as opposed to putting @racket[#%top-interaction] and its argument form in a syntactic list: @racketmod[ racket (define-syntax-rule (#%top-interaction . e) '("So, you want to evaluate..." e "?")) ] @exercise["ex:time-lang"]{Make a language module (to be used after @racket[@#,hash-lang[] s-exp]) that is like @racketmodname[racket] but adjusts @racket[#%top-interaction] to wrap @racket[time] around each form to show how long it takes to evaluate.} @; ---------------------------------------- @section{@hash-lang[] and Installed Languages} We mentioned in @secref["whole"] that the language named after @hash-lang[] must have two properties: it must take responsibility for parsing the rest of the characters in the module, and it must be accessible by a name that doesn't involve quote marks. To make the module accessible without quote marks, then it needs to reside in a directory that is registered with Racket as a @defterm{collection}. More specifically, we normally register the directory as a @defterm{package}, and the default treatment of a package (unless the package says otherwise) is to use its directory as a collection. @margin-note{You can also use a command line by @exec{cd}ing to the parent of the @filepath{noisy} directory and running @commandline{raco pkg install noisy/} Don't omit the final @litchar{/}, which makes it a directory reference instead of a request to consult the package server.} Create a directory named @filepath{noisy} somewhere on your filesystem. (Make the name @filepath{noisy} so that it matches our examples.) Then choose @onscreen{Package Manager...} from DrRacket's @onscreen{File} menu, click @onscreen{Browse...} near the top left of the resulting window, answer @onscreen{Directory}, and pick your @filepath{noisy} directory. Finally, click @onscreen{Install}. Now, create a @filepath{main.rkt} file in your @filepath{noisy}. (The name @filepath{main.rkt} is special.) Put the content of @filepath{noisy-racket.rkt} in @filepath{main.rkt}. It still won't work if you now try @racketmod[ @#,racket[noisy] ] because we've only addressed one of the problems---accessing the module by a name without quotes. We're now ready to supply the parsing half. Change your @filepath{main.rkt} file to add the nested module @racketblock[ (module reader syntax/module-reader noisy) ] This declaration creates a @racket[reader] @defterm{submodule} in the @filepath{main.rkt} module, and @racket[@#,hash-lang[] noisy] looks for a submodule by that name in the @filepath{main.rkt} module of the @filepath{noisy} collection. This @racket[reader] submodule is implemented using the language @racketmodname[syntax/module-reader], which is a language specifically for making module parsers. The @racket[#%module-begin] form of the @racketmodname[syntax/module-reader] module looks for a single identifier to be injected as the language of the parsed module; in this case, we use @racket[noisy] to refer back to the @filepath{main.rkt} module of the @filepath{noisy} collection, which is back to the enclosing module. Since the @racketmodname[syntax/module-reader] language implements a default reader that is the same as the @racketmodname[s-exp] parser, then @racketmod[ @#,racket[noisy] (+ 2 3) ] will run and print 5. It happens that @racketmod[ s-exp noisy (+ 2 3) ] would run and print the same way, just using the parser via @racketmodname[s-exp] instead of the @racket[reader] submodule. @; ---------------------------------------- @section{@hash-lang[] and Parsing} If the point of creating and installing @filepath{noisy/main.rkt} is that we can use the short reference @racket[@#,hash-lang[] noisy], then we're done. If the point is to change parsing, then we need to override the default parser provided by @racketmodname[syntax/module-reader]. A parser comes in two flavors: @racket[read-syntax] and @racket[read]. The @racket[read] flavor is essentially legacy, but a @racket[parser] submodule must provide it, anyway, even if just by using @racket[read-syntax] and stripping away ``syntax'' information to get a ``datum.'' The @racket[read] flavor takes an input stream, while the @racket[read-syntax] flavor takes a source-file description (usually a path) plus an input stream. Instead of writing a parser from scratch, which can be tedious, lets use the built-in @racket[read-syntax] and just configure it to read decimal numbers as exact rationals instead of inexact floating-point numbers: @racketblock[ (module reader syntax/module-reader noisy #:read-syntax my-read-syntax #:read (lambda (in) (syntax->datum (my-read-syntax #f in))) (define (my-read-syntax src in) (parameterize ([read-decimal-as-inexact #f]) (read-syntax src in)))) ] With that change, then @racketmod[ s-exp noisy (+ 2 3.1) ] will show an exact result instead of a floating-point approximation. @exercise["ex:REM"]{Some users of @racket[@#,hash-lang[] noisy] may miss DOS-style comments using @tt{REM}. Adjust the reader so that it detects and discards an @tt{REM} result, discarding the rest of the line as well, and then tries reading again. Use @racket[syntax?] to detect a non-EOF result from @racket[read-syntax], and use @racket[read-line] to consume (the rest of) a line from an input stream.} @; ---------------------------------------- @section{Extended Example} See @resource["ql.zip"]{QL}. @; ----------------------------------------------------------------------------- @section{Resources} @(define beautiful "http://beautifulracket.com/") If you want to construct languages, take a look at Matthew Butterick's book on building @link[beautiful]{Beautiful Racket}. @(define debug "https://github.com/AlexKnauth/debug") Matthew Butterick and Alex Knauth constructed a "meta-language"---like s-exp and at-exp---for @link[debug]{debugging}. @(define lwc "lwc-languages-the-racket-way.pdf") @(define linde "icfp-2017-lindemayer.pdf") @(define video "icfp-2017-video.pdf") If you would like to read some paper on constructing DSLs, consider @itemlist[ @item{@link[lwc]{Dan Feltey et al.} describe how to re-create a mini version of Java, including an IDE in the Racket world} @item{@link[linde]{Vincent St-Amour et al.} invent and implement a language for describing Lindemayer fractals, a paper with lots of amazing pictures, some code, and even less text} @item{@link[video]{Leif Andersen et al.} illustrate the language-oriented programming idea with a small, yet reasonably complex example involving eight embedded DSLs} ]
true
6da4dc7a5d8d35c1aa73f427ae3f44248e1fd770
898dceae75025bb8eebb83f6139fa16e3590eb70
/pl1/asg2/osx-dist/lib/plt/assignment2-osx/collects/racket/gui/dynamic.rkt
11564e64b55f53212db1846f5cd9ee0656fae93d
[]
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
1,196
rkt
dynamic.rkt
#lang racket/base (require ffi/unsafe) (provide gui-available? gui-dynamic-require) (define scheme_register_process_global (get-ffi-obj 'scheme_register_process_global #f (_fun _string _pointer -> _pointer))) (define (gui-available?) (and ;; Never available in non-0 phases: (zero? (variable-reference->phase (#%variable-reference))) ;; Must be instantiated: (scheme_register_process_global "GRacket-support-initialized" #f) (with-handlers ([exn:fail? (lambda (exn) #f)]) ;; Fails if `mred/private/dynamic' is not declared ;; (without loading it if not): (module->language-info 'mred/private/dynamic #f) ;; Fails if `mred/private/dynamic' is not instantiated: (namespace-attach-module (current-namespace) 'mred/private/dynamic) ;; Double check that it seems to have started ok: (eq? (dynamic-require 'mred/private/dynamic 'kernel-initialized) 'done)))) (define-namespace-anchor anchor) (define (gui-dynamic-require sym) (parameterize ([current-namespace (namespace-anchor->empty-namespace anchor)]) (if (gui-available?) (dynamic-require 'mred sym) (error "racket/gui/base is not available"))))
false
e8e5055931f3b028dc6c886cd1339187942cff03
fc6465100ab657aa1e31af6a4ab77a3284c28ff0
/results/all/poly-stlc-6-ordered-brutally-unfair.rktd
bf3630993a278e57731cd2ebd29044855b95d847
[]
no_license
maxsnew/Redex-Enum-Paper
f5ba64a34904beb6ed9be39ff9a5e1e5413c059b
d77ec860d138cb023628cc41f532dd4eb142f15b
refs/heads/master
"2020-05-21T20:07:31.382540"
"2017-09-04T14:42:13"
"2017-09-04T14:42:13"
17,602,325
0
0
null
null
null
null
UTF-8
Racket
false
false
287
rktd
poly-stlc-6-ordered-brutally-unfair.rktd
(start 2015-06-19T12:40:49 (#:model "poly-stlc-6" #:type ordered-brutally-unfair)) (finished 2015-06-20T12:40:01 (#:model "poly-stlc-6" #:type ordered-brutally-unfair #:time-ms 86400001 #:attempts 314707093 #:num-counterexamples 0 #:rate-terms/s 3642.4431638606115 #:attempts/cexp N/A))
false
77cfeab36f55aab9ecd6331492f1084b83761a9b
d17943098180a308ae17ad96208402e49364708f
/externals/js-sicp-5-5/typed-parse.rkt
6619c5324aa25d53ebc23522f797ef1e025a815d
[]
no_license
dyoo/benchmark
b3f4f39714cc51e1f0bc176bc2fa973240cd09c0
5576fda204529e5754f6e1cc8ec8eee073e2952c
refs/heads/master
"2020-12-24T14:54:11.354541"
"2012-03-02T19:40:48"
"2012-03-02T19:40:48"
1,483,546
1
0
null
null
null
null
UTF-8
Racket
false
false
146
rkt
typed-parse.rkt
#lang typed/racket/base (require "expression-structs.rkt") (require/typed "parse.rkt" [parse (Any -> Expression)]) (provide parse)
false
88b4df6d6f0acc36ef9f11c4868ec3cb80acec64
d00dcbbbfb48b4d9d016d2835413f1637dcd151b
/project/FP1/web.rkt
2abf9da398d446ad947a6ba75ef99672d8c1ad86
[]
no_license
Sokthai/OPL
c4aa253ac43c6c7e30ea36349b52fca23aca49d9
c87df824e320b3c6449e857be02fd3e91f1d352f
refs/heads/master
"2021-03-27T10:08:03.932698"
"2017-04-23T20:19:06"
"2017-04-23T20:19:06"
79,664,628
0
0
null
null
null
null
UTF-8
Racket
false
false
3,486
rkt
web.rkt
;Sokthai Tang 3/12/2017 #lang web-server/insta (require web-server/servlet web-server/servlet-env) (require json srfi/13 net/url) (define (start request) (response/xexpr '(html (head (title "Web Page") (link ((rel "stylesheet") (href "/style.css") (type "text/css")))) (body (h1 "Dictionary") (label "Search : ") (input ((name "search"))) (br)(br) (label "Word : ") (input ((name "word"))) (br)(br) (label "Definition : ") (input ((name "definition"))) (br)(br) (label "Examples : ") (input ((name "example"))) (br) (input ((type "submit"))) ) ) ) (send/suspend (lambda (k-url) (response/xexpr `(html (head (title "Enter a number")) (body (form ([action ,"http://localhost:8000/servlets/standalone.rkt"]) "Enter a number: " (input ([name "number"])) (input ([type "submit"])) (label (search "boy")) ) ))))) ) (static-files-path "htdocs") (serve/servlet start) ;--------- ;------connection------------------- (define word "") (define app_id "app_id:da0194c3") (define app_key "app_key:761ad80847bb97ee40842f7ecc43fade") (define open_api "https://od-api.oxforddictionaries.com:443/api/v1/entries/en/") (define myrespond "") (define (search w) (define con-url (string->url (string-append open_api w))) (define dict-port (get-pure-port con-url (list app_id app_key))) (define respond (port->string dict-port)) (begin (set! myrespond respond)) (close-input-port dict-port) (cond ((number? (string-contains respond "404 Not Found")) (printf "Not Found")) (else (getAnswer (readjson-from-input respond) '|word| "word : ") (getAnswer (readjson-from-input respond) '|definitions| "definitions : ") (getAnswer (readjson-from-input respond) '|examples| "examples : "))) ) (define (readjson-from-file file) (with-input-from-string (call-with-input-file file (lambda (in) (port->string in))) (lambda () (read-json))) ) (define (readjson-from-input var) (with-input-from-string var (lambda () (read-json))) ) (define (getAnswer hash k des) (cond ((list? hash) (getAnswer (car hash) k des)) ((and (hash? hash) (not (empty? (hash-ref hash k (lambda () empty))))) (display hash k des)) (else (cond ((hash? hash) (for (((key val) (in-hash hash))) (getAnswer (hash-ref hash key) k des))) (else hash))))) ;-------------- (define (display hash k des) (cond ((list? (hash-ref hash k)) (cond ((string? (car (hash-ref hash k))) (printf "~a~a\n" des (car (hash-ref hash k)))) (else (show (hash-ref hash k) k des)))) (else (printf "~a~a\n" des (hash-ref hash k (lambda () "")))) )) ;------------- (define (show lst k des) (cond ((null? lst) lst) (else (for (((key val) (in-hash (car lst )))) (printf "~a~a\n" des val )) (show (cdr lst) k des) ))) ;--------------
false
aa3bba184fa8cfd5bde069b6cd24686f62f3c06b
3424ab96c3265f69191dd3a219b2b66a1e61b57d
/zenspider/ch15.rkt
a0dcf4b9f7138fe8bbd04012cdf95e20f70c20a4
[]
no_license
SeaRbSg/little-schemer
9130db9720470c70ccddfc4803b0c14c214493c4
2864c2c46a546decb6e68cca92862c2d77fc6b65
refs/heads/master
"2016-09-10T02:09:03.708360"
"2015-12-29T20:56:16"
"2015-12-29T20:56:16"
26,874,199
10
4
null
null
null
null
UTF-8
Racket
false
false
140
rkt
ch15.rkt
#lang racket/base ;; meh... I understand all of this (module+ test (require rackunit)) ; make it run like other files in tests
false
cfe996cf7ca359261fd98cb80ebd30b673ec65f4
82c76c05fc8ca096f2744a7423d411561b25d9bd
/typed-racket-test/succeed/pr12644.rkt
dc113c250541b39a190939e2b23fdcf3921364d9
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
racket/typed-racket
2cde60da289399d74e945b8f86fbda662520e1ef
f3e42b3aba6ef84b01fc25d0a9ef48cd9d16a554
refs/heads/master
"2023-09-01T23:26:03.765739"
"2023-08-09T01:22:36"
"2023-08-09T01:22:36"
27,412,259
571
131
NOASSERTION
"2023-08-09T01:22:41"
"2014-12-02T03:00:29"
Racket
UTF-8
Racket
false
false
398
rkt
pr12644.rkt
#lang typed/racket (define-type inf (Rec inf (Any -> inf))) (: f inf) (define (f x) f) (: g (All (x) (x -> x))) (define (g x) x) (: v (Listof (U inf Number))) (define v (list (with-handlers ((number? add1)) 3) (with-handlers ((void f)) 4))) (list (with-handlers ((void values)) 6) (with-handlers ((number? add1)) 7) (with-handlers ((void f)) 8) (with-handlers ((void g)) 9))
false
42aaa80581ad83f0412416c9fdc3dea6ca6c230a
38bc0fc604c69927021ce4b619e42d8219e1214f
/default-recommendations/contract-shortcuts-test.rkt
21c47c29a965d635ad02bb9a5c31921ae611074a
[ "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
1,925
rkt
contract-shortcuts-test.rkt
#lang resyntax/testing/refactoring-test require: resyntax/default-recommendations contract-shortcuts header: ------------------------------ #lang racket/base (require racket/contract/base) ------------------------------ test: "nested or/c contracts can be flattened" - (void (or/c 1 2 (or/c 3 4))) - (void (or/c 1 2 3 4)) test: "flat or/c contracts can't be flattened" - (or/c 1 2 3) test: "multiple nested or/c contracts can be flattened at once" - (void (or/c (or/c 1 2) (or/c 3 4) (or/c 5 6))) - (void (or/c 1 2 3 4 5 6)) test: "deeply nested or/c contracts can be flattened in one pass" - (void (or/c 1 (or/c 2 (or/c 3 (or/c 4 5 6))))) - (void (or/c 1 2 3 4 5 6)) test: "multiline nested or/c contracts can't be flattened" ------------------------------ (or/c 1 (or/c 2 3)) ------------------------------ test: "nested and/c contracts can be flattened" - (void (and/c 1 2 (and/c 3 4))) - (void (and/c 1 2 3 4)) test: "flat and/c contracts can't be flattened" - (and/c 1 2 3) test: "multiple nested and/c contracts can be flattened at once" - (void (and/c (and/c 1 2) (and/c 3 4) (and/c 5 6))) - (void (and/c 1 2 3 4 5 6)) test: "deeply nested and/c contracts can be flattened in one pass" - (void (and/c 1 (and/c 2 (and/c 3 (and/c 4 5 6))))) - (void (and/c 1 2 3 4 5 6)) test: "multiline nested and/c contracts can't be flattened" ------------------------------ (and/c 1 (and/c 2 3)) ------------------------------ test: "nested or/c contracts interspersed with and/c contracts can be flattened" - (void (or/c (or/c 1 2) (and/c 3 4) (or/c 5 6))) - (void (or/c 1 2 (and/c 3 4) 5 6)) test: "nested and/c contracts interspersed with or/c contracts can be flattened" - (void (and/c (and/c 1 2) (or/c 3 4) (and/c 5 6))) - (void (and/c 1 2 (or/c 3 4) 5 6)) test: "contracts equivalent to predicate/c can be refactored to predicate/c" - (void (-> any/c boolean?)) - (void predicate/c)
false
fc95d41344dd881e9658949659f72eae97c79ec0
12c294500c7b5c37eeb588af94572bb9dc2419fa
/schemavalidate.rkt
7b2fe34d247b5ba73e8aa58ff5afedc197d4ac97
[]
no_license
kodaimura/muraql
bf97be5bac8808f580b9314c9b6e59def8e536c9
05a0848185892558006533385ff13aba9740ef57
refs/heads/main
"2023-03-03T14:10:56.935101"
"2021-02-14T11:35:34"
"2021-02-14T11:35:34"
329,822,851
0
0
null
null
null
null
UTF-8
Racket
false
false
10,516
rkt
schemavalidate.rkt
#lang racket (require "utilities.rkt") (provide validate-schema validate-resolvers) (define is-input-type? (lambda (type alltypes) (cond ((member? (hash-ref type 'kind) (list 'NON_NULL 'LIST)) (is-input-type? (hash-ref type 'type) alltypes)) (else (let ([name (hash-ref type 'name)]) (or (scalar? name) (member? (hash-ref (hash-ref alltypes name) 'kind) (list 'ENUM 'INPUT_OBJECT)))))))) (define is-output-type? (lambda (type alltypes) (cond ((member? (hash-ref type 'kind) (list 'NON_NULL 'LIST)) (is-output-type? (hash-ref type 'type) alltypes)) (else (let ([name (hash-ref type 'name)]) (or (scalar? name) (member? (hash-ref (hash-ref alltypes name) 'kind) (list 'OBJECT 'UNION 'ENUM 'INTERFACE)))))))) (define validate-schema (lambda (typesAst) (define schemaobj (filter (lambda (x) (eq? (hash-ref x 'kind) 'schema)) typesAst)) (define typedefs (filter-not (lambda (x) (eq? (hash-ref x 'kind) 'schema)) typesAst)) (define typesmap (for/hash ([type typedefs]) (values (hash-ref type 'name) type))) (define count-schemaobj (length schemaobj)) (when (= 1 count-schemaobj) (validate-schemaobj (car schemaobj) typesmap)) (when (< 1 count-schemaobj) (error 'schema-error "Must provide only one schema definition.")) (when (and (= 0 count-schemaobj) (not (hash-has-key? typesmap 'Query))) (error 'schema-error "Query root type must be provided.")) (validate-typedefs typedefs typesmap))) (define validate-schemaobj (lambda (schema alltypes) (define verified (make-hash)) (for ([field (hash-ref schema 'fields)]) (validate-schemafield field alltypes verified) (hash-set! verified (hash-ref field 'operation) void)) (unless (hash-has-key? verified 'query) (error 'schema-error "Query root type must be provided.")))) (define validate-schemafield (lambda (field alltypes verified) (define operation (hash-ref field 'operation)) (define typename (hash-ref field 'typename)) (when (hash-has-key? verified operation) (error 'schema-error (format "There can be only one ~a type in schema." operation))) (when (scalar? typename) (error 'schema-error (format "Root type must be Object type, it cannot be ~a." typename))) (unless (hash-has-key? alltypes typename) (error 'schema-error (format "Unknown type '~a'." typename))))) (define validate-typedefs (lambda (typedefs alltypes) (define verified (make-hash)) (for ([typedef typedefs]) (validate-typedef typedef alltypes verified) (hash-set! verified (hash-ref typedef 'name) void)))) (define validate-name (lambda (name) (define name* (symbol->string name)) (cond ((= (string-length name*) 1)) ((string=? "__" (substring name* 0 2)) (error 'schema-error "Name '~a' must not begin with '__'." name*)) (else void)))) (define validate-typedef (lambda (typedef alltypes verified) (define name (hash-ref typedef 'name)) (define kind (hash-ref typedef 'kind)) (when (hash-has-key? verified name) (error 'schema-error (format "There can be only one type named '~a'." name))) (validate-name name) (cond ((eq? kind 'OBJECT) (validate-objecttype typedef alltypes)) ((eq? kind 'ENUM) (validate-enumtype typedef alltypes)) ((eq? kind 'UNION) (validate-uniontype typedef alltypes)) ((eq? kind 'INPUT) (validate-inputtype typedef alltypes)) (else 'validate-typedef)))) (define validate-objecttype (lambda (typedef alltypes) (define name (hash-ref typedef 'name)) (define fields (hash-ref typedef 'fields)) (validate-name name) (validate-object-fields fields typedef alltypes))) (define validate-object-fields (lambda (fields typedef alltypes) (define verified (make-hash)) (when (null? fields) (error 'schema-error (format "Object type must define one or more fields. :~a" (hash-ref typedef 'name)))) (for ([field fields]) (validate-object-field field typedef alltypes verified) (hash-set! verified (hash-ref field 'name) void)))) (define validate-object-field (lambda (field typedef alltypes verified) (define name (hash-ref field 'name)) (when (hash-has-key? verified name) (error 'schema-error (format "Field '~a.~a' can only be defined once." (hash-ref typedef 'name) name))) (validate-name name) (validate-object-fieldtype field typedef alltypes) (validate-args (hash-ref field 'args) field alltypes))) (define validate-object-fieldtype (lambda (field typedef alltypes) (define fieldtype (hash-ref field 'type)) (define fieldtypename (get-fieldtype-name fieldtype)) (unless (or (hash-has-key? alltypes fieldtypename) (scalar? fieldtypename)) (error 'schema-error (format "Unknown type '~a'." fieldtypename))) (unless (is-output-type? fieldtype alltypes) (error 'schema-error (format "Field-Type must be either Object, Scalar, Union, Enum, or Interface.: ~a.~a" (hash-ref typedef 'name) (hash-ref field 'name)))))) (define validate-args (lambda (args field alltypes) (define verified (make-hash)) (for ([arg args]) (validate-arg arg alltypes verified) (hash-set! verified (hash-ref arg 'name) void)))) (define validate-arg (lambda (arg alltypes verified) (define name (hash-ref arg 'name)) (when (hash-has-key? verified name) (error 'schema-error "Arg '~a' can only be defined once in same field." name)) (validate-name name) (validate-argtype arg alltypes))) (define validate-argtype (lambda (arg alltypes [x "Argument-Type"]) (define argtype (hash-ref arg 'type)) (define argtypename (get-fieldtype-name argtype)) (unless (or (hash-has-key? alltypes argtypename) (scalar? argtypename)) (error 'schema-error (format "Unknown type '~a'." argtypename))) (unless (is-input-type? argtype alltypes) (error 'schema-error (format "~a must be either Scalar, Enum or Input.:~a" x (hash-ref arg 'name)))))) (define validate-uniontype (lambda (typedef alltypes) (validate-name (hash-ref typedef 'name)) (define types (hash-ref typedef 'types)) (when (null? types) (error 'schema-error (format "Union type must define one or more types. :~a" (hash-ref typedef 'name)))) (for ([type types]) (validate-uniontype-each-type type typedef alltypes)))) (define validate-uniontype-each-type (lambda (type typedef alltypes) (when (or (scalar? type) (member? (hash-ref (hash-ref alltypes type) 'kind) (list 'UNION 'INTERFACE))) (error 'schema-error (format "Union type ~a can only include Object types, it cannot include ~a." (hash-ref typedef 'name) type))) (unless (hash-has-key? alltypes type) (error 'schema-error "Unknown type '~a'." type)))) (define validate-enumtype (lambda (typedef alltypes) (validate-name (hash-ref typedef 'name)) (when (null? (hash-ref typedef 'values)) (error 'schema-error (format "Enum type must define one or more values. :~a" (hash-ref typedef 'name)))))) (define validate-inputtype (lambda (typedef alltypes) (define verified (make-hash)) (validate-name (hash-ref typedef 'name)) (define fields (hash-ref typedef 'fields)) (when (null? fields) (error 'schema-error (format "Input type must define one or more fields. :~a" (hash-ref typedef 'name)))) (for ([field fields]) (validate-inputtype-field field typedef alltypes verified) (hash-set! verified (hash-ref field 'name) void)))) (define validate-inputtype-field (lambda (field typedef alltypes verified) (define name (hash-ref field 'name)) (when (hash-has-key? verified name) (error 'schema-error (format "Field '~a.~a' can only be defined once." (hash-ref typedef 'name) name))) (validate-name name) (validate-argtype field alltypes "Input-Type"))) (define validate-resolvers (lambda (typesAst resolvers) (define typedefs (filter-not (lambda (x) (eq? (hash-ref x 'kind) 'schema)) typesAst)) (define unions (filter (lambda (def) (eq? 'UNION (hash-ref def 'kind))) typedefs)) (validate-resolvers-types typedefs resolvers) (validate-resolvers-unions unions resolvers))) (define validate-resolvers-types (lambda (typedefs resolvers) (define typesmap (for/hash ([type typedefs]) (values (hash-ref type 'name) type))) (for ([type (hash-keys resolvers)]) (if (not (hash-has-key? typesmap type)) (error 'resolver-error "Unknown type '~a'." type) (when (eq? (hash-ref (hash-ref typesmap type) 'kind) 'OBJECT) (validate-resolvers-fields (hash-ref (hash-ref typesmap type) 'fields) (hash-ref resolvers type) type)))))) (define validate-resolvers-fields (lambda (fields resolvers typename) (define fieldsmap (for/hash ([field fields]) (values (hash-ref field 'name) field))) (for ([fname (hash-keys resolvers)]) (unless (hash-has-key? fieldsmap fname) (error 'resolver-error "~a.~a defined in resolvers, but not in schema" typename fname))))) (define validate-resolvers-unions (lambda (unions resolvers) (for ([union unions]) (let ([name (hash-ref union 'name)]) (when (or (not (hash-has-key? resolvers name)) (not (hash-has-key? (hash-ref resolvers name) '__resolveType))) (error 'resolver-error "Type '~a' is missing a '__resolveType' resolver." name))))))
false