blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
171
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
8
| license_type
stringclasses 2
values | repo_name
stringlengths 6
82
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 13
values | visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 1.59k
594M
⌀ | star_events_count
int64 0
77.1k
| fork_events_count
int64 0
33.7k
| gha_license_id
stringclasses 12
values | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_language
stringclasses 46
values | src_encoding
stringclasses 14
values | language
stringclasses 2
values | is_vendor
bool 2
classes | is_generated
bool 1
class | length_bytes
int64 4
7.87M
| extension
stringclasses 101
values | filename
stringlengths 2
149
| content
stringlengths 4
7.87M
| has_macro_def
bool 2
classes |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
528b8750d46370d01b88a804284aa5577a0c524d
|
64cf06d15572f4319482bd286ef1b7b3edc22d78
|
/tests/run2.scm
|
d3a9a0e704b69e1c502b64dbed755fc350e745b6
|
[
"BSD-3-Clause"
] |
permissive
|
bjbarcla/ini-file
|
a1797f0fa60fdefc7e3d90b77a35e1841a847a4a
|
a69e04d725deda3d1c737efb976f553da89b5951
|
refs/heads/master
| 2020-05-29T11:05:06.810556 | 2015-11-21T06:36:07 | 2015-11-21T06:36:07 | 44,282,820 | 0 | 0 | null | 2015-10-14T23:53:45 | 2015-10-14T23:53:45 | null |
UTF-8
|
Scheme
| false | false | 178 |
scm
|
run2.scm
|
(use srfi-78 ports extras test yaml)
; test using ini-file in workspace
(include "../ini-file.scm")
(import ini-file)
(let ((data (read-ini "example2.ini")))
(print data))
| false |
8da7a89231bf715e04f65f579a816c167d49512d
|
ac2a3544b88444eabf12b68a9bce08941cd62581
|
/lib/_match/_match#.scm
|
c9894939e336c854abfdda5134f3d170aded6e89
|
[
"Apache-2.0",
"LGPL-2.1-only"
] |
permissive
|
tomelam/gambit
|
2fd664cf6ea68859d4549fdda62d31a25b2d6c6f
|
d60fdeb136b2ed89b75da5bfa8011aa334b29020
|
refs/heads/master
| 2020-11-27T06:39:26.718179 | 2019-12-15T16:56:31 | 2019-12-15T16:56:31 | 229,341,552 | 1 | 0 |
Apache-2.0
| 2019-12-20T21:52:26 | 2019-12-20T21:52:26 | null |
UTF-8
|
Scheme
| false | false | 667 |
scm
|
_match#.scm
|
;;;============================================================================
;;; File: "_match#.scm"
;;; Copyright (c) 2008-2019 by Marc Feeley, All Rights Reserved.
;;;============================================================================
;; Pattern-matching 'match' special form.
(##namespace ("_match#"
match
))
(##define-syntax match
(lambda (src)
(##import _match/match-expand)
(match-expand src
#f ;; use-question-mark-prefix-pattern-variables?
#t ;; use-exhaustive-cases?
#f))) ;; use-else?
;;;============================================================================
| true |
fda414c1963165c08e2d17d93526b776ef36b2b5
|
424b80e2c2a1829f8815378dd08ed6b6021310f7
|
/exercises/05/map-deep.scm
|
15ebcd1f0ca89144bbd2207fb943d37241ad7136
|
[
"MIT"
] |
permissive
|
fmi-lab/fp-elective-2017
|
b8238b413f346f6e74a02af043293d27822c9ce2
|
e88d5c0319b6d03c0ecd8a12a2856fb1bf5dcbf3
|
refs/heads/master
| 2021-09-06T22:01:16.421169 | 2018-02-12T09:53:52 | 2018-02-12T09:53:52 | 106,176,573 | 7 | 3 |
MIT
| 2018-01-15T15:00:40 | 2017-10-08T13:02:09 |
Scheme
|
UTF-8
|
Scheme
| false | false | 480 |
scm
|
map-deep.scm
|
(require rackunit rackunit/text-ui)
(define (square x) (* x x))
(define (cube x) (* x x x))
(define map-deep-tests
(test-suite
"Tests for map-deep"
(check-equal? (map-deep cube '() '()))
(check-equal? (map-deep square '((1 2 (3 4)) 5)) '((1 4 (9 16)) 25))
(check-equal? (map-deep square '((((2)) 1 ((4) 3)) (9)))
'((((4)) 1 ((16) 9)) (81)))
(check-equal? (map-deep square '(3 2 ((3) 4))) '(27 8 ((27) 64)))))
(run-tests map-deep-tests)
| false |
c1f8fd4c8cd5e90a0ef140e8d01b9d5e0d36cd93
|
7cc14e6ab8e064fa967251e3249863e2cfbcc920
|
/chapter-3/deadlock.scm
|
06fa53043631637f63a91858dded2c1162a16204
|
[] |
no_license
|
xueeinstein/sicp-code
|
0bec79419286705f58175067d474169afd6ba5fe
|
49602b0b13cb9c338b6af089f989c17890ba6085
|
refs/heads/master
| 2021-01-10T01:20:03.089038 | 2015-11-24T03:25:54 | 2015-11-24T03:25:54 | 43,536,317 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 96 |
scm
|
deadlock.scm
|
;;; Bill Xue
;;; 2015-11-03
;;; Deadlock
;; Exercise 3.48
;; TODO
;;
;; Exercise 3.49
;; TODO
| false |
cec21554ddb6f49038fda47ff4db64f4ab131be3
|
0768e217ef0b48b149e5c9b87f41d772cd9917f1
|
/stdlib/core/conditions.scm
|
5fa3a33a47942b25e86e6ccfd9761af415185245
|
[
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] |
permissive
|
fujita-y/ypsilon
|
e45c897436e333cf1a1009e13bfef72c3fb3cbe9
|
62e73643a4fe87458ae100e170bf4721d7a6dd16
|
refs/heads/master
| 2023-09-05T00:06:06.525714 | 2023-01-25T03:56:13 | 2023-01-25T04:02:59 | 41,003,666 | 45 | 7 |
BSD-2-Clause
| 2022-06-25T05:44:49 | 2015-08-19T00:05:35 |
Scheme
|
UTF-8
|
Scheme
| false | false | 2,159 |
scm
|
conditions.scm
|
#!core
;;; Copyright (c) 2004-2022 Yoshikatsu Fujita / LittleWing Company Limited.
;;; See LICENSE file for terms and conditions of use.
(library (core conditions)
(export define-condition-type
condition simple-conditions condition?
condition-predicate condition-accessor
&condition
&message make-message-condition message-condition? condition-message
&warning make-warning warning?
&serious make-serious-condition serious-condition?
&error make-error error?
&violation make-violation violation?
&assertion make-assertion-violation assertion-violation?
&irritants make-irritants-condition irritants-condition? condition-irritants
&who make-who-condition who-condition? condition-who
&non-continuable make-non-continuable-violation non-continuable-violation?
&implementation-restriction make-implementation-restriction-violation implementation-restriction-violation?
&lexical make-lexical-violation lexical-violation?
&syntax make-syntax-violation syntax-violation? syntax-violation-form syntax-violation-subform
&undefined make-undefined-violation undefined-violation?)
(import (core primitives)
(core syntax-case)
(core records))
(define-syntax define-condition-type
(lambda (x)
(syntax-case x ()
((_ condition-type supertype
constructor predicate
(cond-fields cond-accessors) ...)
(with-syntax (((rec-accessors ...) (generate-temporaries (syntax (cond-fields ...)))))
(syntax (begin
(define-record-type (condition-type constructor temp)
(parent supertype)
(nongenerative)
(fields (immutable cond-fields rec-accessors) ...))
(define predicate
(condition-predicate (record-type-descriptor condition-type)))
(define cond-accessors
(condition-accessor (record-type-descriptor condition-type) rec-accessors)) ...)))))))
) ;[end]
| true |
7f8f1b0121f83e6f10a0304eeaebec0c77570636
|
db0567d04297eb710cd4ffb7af094d82b2f66662
|
/scheme/ikarus.strings.ss
|
b8ad30bc08d057407702e2ab2aff8698e159448d
|
[] |
no_license
|
xieyuheng/ikarus-linux
|
3899e99991fd192de53c485cf429bfd208e7506a
|
941b627e64f30af60a25530a943323ed5c78fe1b
|
refs/heads/master
| 2021-01-10T01:19:05.250392 | 2016-02-13T22:21:24 | 2016-02-13T22:21:24 | 51,668,773 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 16,450 |
ss
|
ikarus.strings.ss
|
(library (ikarus strings)
(export string-length string-ref string-set! make-string string->list
string-append substring string list->string uuid
string-copy string-for-each string-fill!
string=? string<? string<=? string>? string>=?
string-copy!)
(import
(ikarus system $strings)
(ikarus system $fx)
(ikarus system $chars)
(ikarus system $bytevectors)
(ikarus system $pairs)
(except (ikarus) string-length string-ref string-set! make-string
string->list string-append substring string
list->string uuid string-copy string-for-each
string=? string<? string<=? string>? string>=?
string-fill! string-copy!))
(define string-length
(lambda (x)
(unless (string? x)
(die 'string-length "not a string" x))
($string-length x)))
(define (string-ref s i)
(unless (string? s)
(die 'string-ref "not a string" s))
(unless (fixnum? i)
(die 'string-ref "not a valid index" i))
(unless (and ($fx< i ($string-length s))
($fx<= 0 i))
(die 'string-ref "index is out of range" i s))
(let ([c ($string-ref s i)])
(unless (char? c)
(die 'string-ref "BUG: got a non-char"))
c))
(define string-set!
(lambda (s i c)
(unless (string? s)
(die 'string-set! "not a string" s))
(unless (fixnum? i)
(die 'string-set! "not a valid index" i))
(unless (and ($fx< i ($string-length s))
($fx>= i 0))
(die 'string-set! "index is out of range" i s))
(unless (char? c)
(die 'string-set! "not a character" c))
($string-set! s i c)))
(define make-string
(let ()
(define fill!
(lambda (s i n c)
(cond
[($fx= i n) s]
[else
($string-set! s i c)
(fill! s ($fx+ i 1) n c)])))
(define (make-string* n c)
(unless (fixnum? n)
(die 'make-string "length is not a fixnum" n))
(unless (eqv? 0 (fxsra n (fx- (fixnum-width) 2)))
(die 'make-string "length is out of range" n))
(fill! ($make-string n) 0 n c))
(define make-string
(case-lambda
[(n) (make-string* n (integer->char 0))]
[(n c)
(if (char? c)
(make-string* n c)
(die 'make-string "not a character" c))]))
make-string))
(define string
;;; FIXME: add case-lambda
(letrec ([length
(lambda (ls n)
(cond
[(null? ls) n]
[(char? ($car ls)) (length ($cdr ls) ($fx+ n 1))]
[else (die 'string "not a character" ($car ls))]))]
[loop
(lambda (s ls i n)
(cond
[($fx= i n) s]
[else
($string-set! s i ($car ls))
(loop s ($cdr ls) ($fx+ i 1) n)]))])
(lambda ls
(let ([n (length ls 0)])
(let ([s (make-string n)])
(loop s ls 0 n))))))
(module (substring)
(define fill
(lambda (s d si sj di)
(cond
[($fx= si sj) d]
[else
($string-set! d di ($string-ref s si))
(fill s d ($fxadd1 si) sj ($fxadd1 di))])))
(define substring
(lambda (s n m)
(unless (string? s)
(die 'substring "not a string" s))
(let ([len ($string-length s)])
(unless (and (fixnum? n)
($fx>= n 0)
($fx<= n len))
(die 'substring "not a valid start index" n s))
(unless (and (fixnum? m)
($fx>= m 0)
($fx<= m len))
(die 'substring "not a valid end index" m s))
(unless ($fx<= n m)
(die 'substring "indices are in decreasing order" n m))
(let ([len ($fx- m n)])
(if ($fx> len 0)
(fill s ($make-string len) n m 0)
""))))))
(define string-copy
(lambda (s)
(if (string? s)
(substring s 0 (string-length s))
(die 'string-copy "not a string" s))))
(module (string=?)
(define bstring=?
(lambda (s1 s2 i j)
(or ($fx= i j)
(and ($char= ($string-ref s1 i) ($string-ref s2 i))
(bstring=? s1 s2 ($fxadd1 i) j)))))
(define check-strings-and-return-false
(lambda (s*)
(cond
[(null? s*) #f]
[(string? ($car s*))
(check-strings-and-return-false ($cdr s*))]
[else (err ($car s*))])))
(define strings=?
(lambda (s s* n)
(or (null? s*)
(let ([a ($car s*)])
(unless (string? a)
(die 'string=? "not a string" a))
(if ($fx= n ($string-length a))
(and (strings=? s ($cdr s*) n)
(bstring=? s a 0 n))
(check-strings-and-return-false ($cdr s*)))))))
(define (err x)
(die 'string=? "not a string" x))
(define string=?
(case-lambda
[(s s1)
(if (string? s)
(if (string? s1)
(let ([n ($string-length s)])
(and ($fx= n ($string-length s1))
(bstring=? s s1 0 n)))
(err s1))
(err s))]
[(s . s*)
(if (string? s)
(strings=? s s* ($string-length s))
(err s))])))
(define string-cmp
(lambda (who cmp s1 s*)
(if (string? s1)
(let f ([s1 s1] [s* s*])
(cond
[(null? s*) #t]
[else
(let ([s2 (car s*)])
(if (string? s2)
(if (cmp s1 s2)
(f s2 (cdr s*))
(let f ([s* (cdr s*)])
(cond
[(null? s*) #f]
[(string? (car s*))
(f (cdr s*))]
[else
(die who "not a string"
(car s*))])))
(die who "not a string" s2)))]))
(die who "not a string" s1))))
(define ($string<? s1 s2)
(let ([n1 ($string-length s1)]
[n2 ($string-length s2)])
(if ($fx< n1 n2)
(let f ([i 0] [n n1] [s1 s1] [s2 s2])
(if ($fx= i n)
#t
(let ([c1 ($string-ref s1 i)]
[c2 ($string-ref s2 i)])
(if ($char< c1 c2)
#t
(if ($char= c1 c2)
(f ($fxadd1 i) n s1 s2)
#f)))))
(let f ([i 0] [n n2] [s1 s1] [s2 s2])
(if ($fx= i n)
#f
(let ([c1 ($string-ref s1 i)]
[c2 ($string-ref s2 i)])
(if ($char< c1 c2)
#t
(if ($char= c1 c2)
(f ($fxadd1 i) n s1 s2)
#f))))))))
(define ($string<=? s1 s2)
(let ([n1 ($string-length s1)]
[n2 ($string-length s2)])
(if ($fx<= n1 n2)
(let f ([i 0] [n n1] [s1 s1] [s2 s2])
(if ($fx= i n)
#t
(let ([c1 ($string-ref s1 i)]
[c2 ($string-ref s2 i)])
(if ($char< c1 c2)
#t
(if ($char= c1 c2)
(f ($fxadd1 i) n s1 s2)
#f)))))
(let f ([i 0] [n n2] [s1 s1] [s2 s2])
(if ($fx= i n)
#f
(let ([c1 ($string-ref s1 i)]
[c2 ($string-ref s2 i)])
(if ($char< c1 c2)
#t
(if ($char= c1 c2)
(f ($fxadd1 i) n s1 s2)
#f))))))))
(define ($string>? s1 s2)
($string<? s2 s1))
(define ($string>=? s1 s2)
($string<=? s2 s1))
(define string<?
(case-lambda
[(s1 s2)
(if (string? s1)
(if (string? s2)
($string<? s1 s2)
(die 'string<? "not a string" s2))
(die 'string<? "not a string" s2))]
[(s . s*)
(string-cmp 'string<? $string<? s s*)]))
(define string<=?
(case-lambda
[(s1 s2)
(if (string? s1)
(if (string? s2)
($string<=? s1 s2)
(die 'string<=? "not a string" s2))
(die 'string<=? "not a string" s2))]
[(s . s*)
(string-cmp 'string<=? $string<=? s s*)]))
(define string>?
(case-lambda
[(s1 s2)
(if (string? s1)
(if (string? s2)
($string>? s1 s2)
(die 'string>? "not a string" s2))
(die 'string>? "not a string" s2))]
[(s . s*)
(string-cmp 'string>? $string>? s s*)]))
(define string>=?
(case-lambda
[(s1 s2)
(if (string? s1)
(if (string? s2)
($string>=? s1 s2)
(die 'string>=? "not a string" s2))
(die 'string>=? "not a string" s2))]
[(s . s*)
(string-cmp 'string>=? $string>=? s s*)]))
(define string->list
(lambda (x)
(unless (string? x)
(die 'string->list "not a string" x))
(let f ([x x] [i ($string-length x)] [ac '()])
(cond
[($fxzero? i) ac]
[else
(let ([i ($fxsub1 i)])
(f x i (cons ($string-ref x i) ac)))]))))
(define list->string
(letrec ([race
(lambda (h t ls n)
(if (pair? h)
(let ([h ($cdr h)])
(if (pair? h)
(if (not (eq? h t))
(race ($cdr h) ($cdr t) ls ($fx+ n 2))
(die 'reverse "circular list" ls))
(if (null? h)
($fx+ n 1)
(die 'reverse "not a proper list" ls))))
(if (null? h)
n
(die 'reverse "not a proper list" ls))))]
[fill
(lambda (s i ls)
(cond
[(null? ls) s]
[else
(let ([c ($car ls)])
(unless (char? c)
(die 'list->string "not a character" c))
($string-set! s i c)
(fill s ($fxadd1 i) (cdr ls)))]))])
(lambda (ls)
(let ([n (race ls ls ls 0)])
(let ([s ($make-string n)])
(fill s 0 ls))))))
(module (string-append)
;; FIXME: make nonconsing on 0,1,2, and 3 args
(define length*
(lambda (s* n)
(cond
[(null? s*) n]
[else
(let ([a ($car s*)])
(unless (string? a)
(die 'string-append "not a string" a))
(length* ($cdr s*) ($fx+ n ($string-length a))))])))
(define fill-string
(lambda (s a si sj ai)
(unless ($fx= si sj)
($string-set! s si ($string-ref a ai))
(fill-string s a ($fxadd1 si) sj ($fxadd1 ai)))))
(define fill-strings
(lambda (s s* i)
(cond
[(null? s*) s]
[else
(let ([a ($car s*)])
(let ([n ($string-length a)])
(let ([j ($fx+ i n)])
(fill-string s a i j 0)
(fill-strings s ($cdr s*) j))))])))
(define string-append
(lambda s*
(let ([n (length* s* 0)])
(let ([s ($make-string n)])
(fill-strings s s* 0))))))
(module (string-for-each)
(define who 'string-for-each)
(define string-for-each
(case-lambda
[(p v)
(unless (procedure? p)
(die who "not a procedure" p))
(unless (string? v)
(die who "not a string" v))
(let f ([p p] [v v] [i 0] [n (string-length v)])
(cond
[($fx= i n) (void)]
[else
(p (string-ref v i))
(f p v ($fxadd1 i) n)]))]
[(p v0 v1)
(unless (procedure? p)
(die who "not a procedure" p))
(unless (string? v0)
(die who "not a string" v0))
(unless (string? v1)
(die who "not a string" v1))
(let ([n (string-length v0)])
(unless ($fx= n ($string-length v1))
(die who "length mismatch" v0 v1))
(let f ([p p] [v0 v0] [v1 v1] [i 0] [n n])
(cond
[($fx= i n) (void)]
[else
(p ($string-ref v0 i) ($string-ref v1 i))
(f p v0 v1 ($fxadd1 i) n)])))]
[(p v0 v1 . v*)
(unless (procedure? p)
(die who "not a procedure" p))
(unless (string? v0)
(die who "not a string" v0))
(unless (string? v1)
(die who "not a string" v1))
(let ([n (string-length v0)])
(unless ($fx= n ($string-length v1))
(die who "length mismatch" v0 v1))
(let f ([v* v*] [n n])
(unless (null? v*)
(let ([a ($car v*)])
(unless (string? a)
(die who "not a string" a))
(unless ($fx= ($string-length a) n)
(die who "length mismatch")))
(f ($cdr v*) n)))
(let f ([p p] [v0 v0] [v1 v1] [v* v*] [i 0] [n n])
(cond
[($fx= i n) (void)]
[else
(apply p ($string-ref v0 i) ($string-ref v1 i)
(let f ([i i] [v* v*])
(if (null? v*)
'()
(cons ($string-ref ($car v*) i)
(f i ($cdr v*))))))
(f p v0 v1 v* ($fxadd1 i) n)])))])))
(define (string-fill! v fill)
(unless (string? v)
(die 'string-fill! "not a vector" v))
(unless (char? fill)
(die 'string-fill! "not a character" fill))
(let f ([v v] [i 0] [n ($string-length v)] [fill fill])
(unless ($fx= i n)
($string-set! v i fill)
(f v ($fxadd1 i) n fill))))
(define string-copy!
(lambda (src src-start dst dst-start k)
(cond
[(or (not (fixnum? src-start)) ($fx< src-start 0))
(die 'string-copy! "not a valid starting index" src-start)]
[(or (not (fixnum? dst-start)) ($fx< dst-start 0))
(die 'string-copy! "not a valid starting index" dst-start)]
[(or (not (fixnum? k)) ($fx< k 0))
(die 'string-copy! "not a valid length" k)]
[(not (string? src))
(die 'string-copy! "not a string" src)]
[(not (string? dst))
(die 'string-copy! "not a string" dst)]
[(let ([n ($fx+ src-start k)])
(or ($fx< n 0) ($fx> n ($string-length src))))
(die 'string-copy! "out of range" src-start k)]
[(let ([n ($fx+ dst-start k)])
(or ($fx< n 0) ($fx> n ($string-length dst))))
(die 'string-copy! "out of range" dst-start k)]
[(eq? src dst)
(cond
[($fx< dst-start src-start)
(let f ([src src] [si src-start] [di dst-start] [sj ($fx+ src-start k)])
(unless ($fx= si sj)
($string-set! src di ($string-ref src si))
(f src ($fxadd1 si) ($fxadd1 di) sj)))]
[($fx< src-start dst-start)
(let f ([src src] [si ($fx+ src-start k)] [di ($fx+ dst-start k)] [sj src-start])
(unless ($fx= si sj)
(let ([si ($fxsub1 si)] [di ($fxsub1 di)])
($string-set! src di ($string-ref src si))
(f src si di sj))))]
[else (void)])]
[else
(let f ([src src] [si src-start] [dst dst] [di dst-start] [sj ($fx+ src-start k)])
(unless ($fx= si sj)
($string-set! dst di ($string-ref src si))
(f src ($fxadd1 si) dst ($fxadd1 di) sj)))])))
(define uuid
(lambda ()
(let ([s ($make-bytevector 16)])
(let ([r (foreign-call "ik_uuid" s)])
(if (bytevector? r)
(utf8->string r)
(error 'uuid "cannot obtain unique id"))))))
)
| false |
8ae47a80090c382227f61097be61b2ea2f27dcc6
|
b9eb119317d72a6742dce6db5be8c1f78c7275ad
|
/guile/unicode.scm
|
eff57f578496cb4280f147d0a6d66b68335eb4f7
|
[] |
no_license
|
offby1/doodles
|
be811b1004b262f69365d645a9ae837d87d7f707
|
316c4a0dedb8e4fde2da351a8de98a5725367901
|
refs/heads/master
| 2023-02-21T05:07:52.295903 | 2022-05-15T18:08:58 | 2022-05-15T18:08:58 | 512,608 | 2 | 1 | null | 2023-02-14T22:19:40 | 2010-02-11T04:24:52 |
Scheme
|
UTF-8
|
Scheme
| false | false | 543 |
scm
|
unicode.scm
|
(let ()
;; Redundant on Unix, but what the heck.
(define (with-output-to-binary-file fn proc)
(let* ((op (open-file fn "wb"))
(return (proc op)))
(close-port op)
return))
(with-output-to-binary-file
"/tmp/all-unicode-characters.txt"
(lambda (port)
(let loop ((chars 0))
(if (< chars 65536)
(begin
(display (integer->char (quotient chars 256)) port)
(display (integer->char (remainder chars 256)) port)
(loop (+ 1 chars))
))))))
| false |
e759aa4b81d40d90819798102700668d5c2a7443
|
c2603f0d6c6e523342deaa1e284b7855a450a6f7
|
/autoload/vgen/util.scm
|
de13d8d9cfca163137a36fd37d9e9b016a593b3d
|
[] |
no_license
|
aharisu/vise
|
5d35a085e6b1070920e9a4e035339050091b2be0
|
6d0f54b0fe28e7d2c3b2b91cb3ef5ff847a11484
|
refs/heads/master
| 2020-06-02T10:48:42.822204 | 2013-02-21T09:42:59 | 2013-02-21T09:42:59 | 7,975,231 | 1 | 1 | null | 2013-02-20T12:26:45 | 2013-02-02T11:53:18 | null |
UTF-8
|
Scheme
| false | false | 1,750 |
scm
|
util.scm
|
(define-module vgen.util
(use srfi-13)
(export-all)
)
(select-module vgen.util)
;;
;; util
(define (slot-ref-conv tokens)
(fold
(lambda (token acc)
`(slot-ref
,acc
(quote ,(string->symbol token))))
(string->symbol (car tokens))
(cdr tokens)))
(define-macro (@ expr)
(slot-ref-conv (string-split (symbol->string expr) ".")))
(define-macro (@! expr obj)
(let* ([tokens (reverse (string-split (symbol->string expr) "."))]
[last (car tokens)]
[head (reverse (cdr tokens))])
`(slot-set!
,(slot-ref-conv head)
(quote ,(string->symbol last))
,obj)))
(define-macro (@inc! expr :optional delta)
(if (undefined? delta)
`(inc! ,(slot-ref-conv (string-split (symbol->string expr) ".")))
`(inc! ,(slot-ref-conv (string-split (symbol->string expr) ".")) ,delta)))
(define-macro (@dec! expr :optional delta)
(if (undefined? delta)
`(dec! ,(slot-ref-conv (string-split (symbol->string expr) ".")))
`(dec! ,(slot-ref-conv (string-split (symbol->string expr) ".")) ,delta)))
(define-macro (@push! expr data)
`(push! ,(slot-ref-conv (string-split (symbol->string expr) ".")) ,data))
(define-macro (@op= expr op obj)
`(@! ,expr (,op (@ ,expr) ,obj)))
(define-macro (or* test x . any)
(let1 x-sym (gensym)
`(let1 ,x-sym ,x
(or ,@(map (lambda (y) `(,test ,x-sym ,y)) any)))))
(define (substring* str start end)
(let1 len (string-length str)
(substring str start (if (< len end) len end))))
(define (filter-obj obj pred list)
(let loop ([l list]
[acc '()])
(if (null? l)
(reverse! acc)
(let1 ret (pred (car l))
(loop (cdr l)
(if (equal? obj ret) acc (cons ret acc)))))))
| false |
3718505af67b98181b813e6d2aa9292d8a262811
|
ac2a3544b88444eabf12b68a9bce08941cd62581
|
/tests/unit-tests/04-list/member.scm
|
b1afd6fc4387e51a31638186bc1c4b1f639608a0
|
[
"Apache-2.0",
"LGPL-2.1-only"
] |
permissive
|
tomelam/gambit
|
2fd664cf6ea68859d4549fdda62d31a25b2d6c6f
|
d60fdeb136b2ed89b75da5bfa8011aa334b29020
|
refs/heads/master
| 2020-11-27T06:39:26.718179 | 2019-12-15T16:56:31 | 2019-12-15T16:56:31 | 229,341,552 | 1 | 0 |
Apache-2.0
| 2019-12-20T21:52:26 | 2019-12-20T21:52:26 | null |
UTF-8
|
Scheme
| false | false | 2,656 |
scm
|
member.scm
|
(include "#.scm")
(check-equal? (memq '() '()) #f)
(check-equal? (memq '() '(1 2)) #f)
(check-equal? (memq '() '(1 ())) '(()))
(check-equal? (memq '() '(1 () ())) '(() ()))
(check-equal? (memq 100000000000000000000 '(1 100000000000000000000 3)) #f)
(check-equal? (memq (cons 1 2) '(1 (1 . 2) ())) #f)
(check-tail-exn type-exception? (lambda () (memq '() #f)))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (memq)))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (memq '())))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (memq '() '() =)))
(check-equal? (memv '() '()) #f)
(check-equal? (memv '() '(1 2)) #f)
(check-equal? (memv '() '(1 ())) '(()))
(check-equal? (memv '() '(1 () ())) '(() ()))
(check-equal? (memv 100000000000000000000 '(1 100000000000000000000 3)) '(100000000000000000000 3))
(check-equal? (memv (cons 1 2) '(1 (1 . 2) ())) #f)
(check-tail-exn type-exception? (lambda () (memv '() #f)))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (memv)))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (memv '())))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (memv '() '() =)))
(check-equal? (member '() '()) #f)
(check-equal? (member '() '(1 2)) #f)
(check-equal? (member '() '(1 ())) '(()))
(check-equal? (member '() '(1 () ())) '(() ()))
(check-equal? (member 100000000000000000000 '(1 100000000000000000000 3)) '(100000000000000000000 3))
(check-equal? (member (cons 1 2) '(1 (1 . 2) ())) '((1 . 2) ()))
(check-tail-exn type-exception? (lambda () (member '() #f)))
(check-tail-exn type-exception? (lambda () (member '() '() #f)))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (member)))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (member '())))
(check-tail-exn wrong-number-of-arguments-exception? (lambda () (member '() '() = #f)))
(check-equal? (member '() '() eq?) #f)
(check-equal? (member '() '(1 2) eq?) #f)
(check-equal? (member '() '(1 ()) eq?) '(()))
(check-equal? (member '() '(1 () ()) eq?) '(() ()))
(check-equal? (member 100000000000000000000 '(1 100000000000000000000 3) eq?) #f)
(check-equal? (member (cons 1 2) '(1 (1 . 2) ()) eq?) #f)
(check-equal? (member '() '() eqv?) #f)
(check-equal? (member '() '(1 2) eqv?) #f)
(check-equal? (member '() '(1 ()) eqv?) '(()))
(check-equal? (member '() '(1 () ()) eqv?) '(() ()))
(check-equal? (member 100000000000000000000 '(1 100000000000000000000 3) eqv?) '(100000000000000000000 3))
(check-equal? (member (cons 1 2) '(1 (1 . 2) ()) eqv?) #f)
(check-equal? (member 2.0 '(1 2 3)) #f)
(check-equal? (member 2.0 '(1 2 3) =) '(2 3))
| false |
bfbfdcd2fe7863b9fe14b9651708f53eeec3ce66
|
59d5121573c9397e5da52d630558f4187f80b25e
|
/A01btestcode.ss
|
294315208dc0f071ed4671790bd8c4c5ae0c5ee3
|
[
"MIT"
] |
permissive
|
haskellstudio/CSSE304
|
dc900af2102b6e8bffca38f7be7d5236007c1a5d
|
698ceabf026cb847754fc2bc01c16641b2f2c2af
|
refs/heads/master
| 2021-04-03T05:16:05.177891 | 2018-02-13T21:35:01 | 2018-02-13T21:35:01 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,998 |
ss
|
A01btestcode.ss
|
(define (test-countdown)
(let ([correct '((5 4 3 2 1 0))]
[answers
(list
(countdown 5)
)])
(display-results correct answers equal?)))
(define (test-range)
(let ([correct '(() (0 1 2 3 4) (5 6 7 8) (25 26 27 28 29) (31) ())]
[answers
(list (range 0 0)
(range 0 5)
(range 5 9)
(range 25 30)
(range 31 32)
(range 7 4))])
(display-results correct answers equal?)))
(define (test-sum-of-squares)
(let ([correct '(84 0)]
[answers
(list
(sum-of-squares '(1 3 5 7))
(sum-of-squares '()))])
(display-results correct answers equal?)))
(define (test-map)
(let ([correct '((2 3 4 5)
((1 . 1) (2 . 2) (3 . 3) (4 . 4)))]
[answers
(list
(map add1 '(1 2 3 4))
(map (lambda (a) (cons a a)) '(1 2 3 4))
)])
(display-results correct answers equal?)))
(define (test-minus)
(let ([correct '(2 50)]
[answers
(list
(minus 5 3)
(minus 100 50)
)])
(display-results correct answers equal?)))
(define (test-div)
(let ([correct '(5 6)]
[answers
(list
(div 25 5)
(div 36 6)
)])
(display-results correct answers equal?)))
(define (test-filter)
(let ([correct '((2 4 6) (cat fish))]
[answers
(list
(filter even? '(1 2 3 4 5 6))
(filter symbol? '(1 2 cat 4 5 fish 6))
)])
(display-results correct answers equal?)))
(define (test-le->natural)
(let ([correct '(0 4 12 15 21 8191)]
[answers
(list
(le->natural '())
(le->natural '(0 0 1))
(le->natural '(0 0 1 1))
(le->natural '(1 1 1 1))
(le->natural '(1 0 1 0 1))
(le->natural '(1 1 1 1 1 1 1 1 1 1 1 1 1))
)])
(display-results correct answers equal?)))
;;-----------------------------------------------
(define display-results
(lambda (correct results test-procedure?)
(display ": ")
(pretty-print
(if (andmap test-procedure? correct results)
'All-correct
`(correct: ,correct yours: ,results)))))
(define set-equals? ; are these list-of-symbols equal when
(lambda (s1 s2) ; treated as sets?
(if (or (not (list? s1)) (not (list? s2)))
#f
(not (not (and (is-a-subset? s1 s2) (is-a-subset? s2 s1)))))))
(define is-a-subset?
(lambda (s1 s2)
(andmap (lambda (x) (member x s2))
s1)))
;; You can run the tests individually, or run them all
;; by loading this file (and your solution) and typing (r)
(define (run-all)
(display 'test-countdown)
(test-countdown)
(display 'test-range)
(test-range)
(display 'test-sum-of-squares)
(test-sum-of-squares)
(display 'test-map)
(test-map)
(display 'test-minus)
(test-minus)
(display 'test-div)
(test-div)
(display 'test-filter)
(test-filter)
(display 'test-le->natural)
(test-le->natural)
)
(define r run-all)
| false |
291baa7428d23f4aa8298904ebaa26a43c265cda
|
ac6ca831a64544efd82dd1e6c8fc44c35a9538a2
|
/test/test.ss
|
a46a0e8ead9f8a3f7b1263e6d57d43dab577de49
|
[
"MIT"
] |
permissive
|
ypyf/fscm
|
4bce4622cccccbfce8a5a1b4f482880ed14fa7c7
|
8be570e1c85a7ad6e1b888a2e3069ddcf4319569
|
refs/heads/master
| 2023-09-04T04:47:07.247132 | 2023-08-29T13:38:22 | 2023-08-29T13:59:56 | 5,802,289 | 5 | 1 | null | 2015-05-17T01:10:29 | 2012-09-13T23:10:28 |
Scheme
|
UTF-8
|
Scheme
| false | false | 736 |
ss
|
test.ss
|
(define expt (lambda (b n)
(define expt-iter (lambda (b counter product)
(if (= counter 0)
product
(expt-iter b
(- counter 1)
(* b product)))))
(expt-iter b n 1)))
;(define fib (trace-lambda (n)
; (if (< n 2)
; n
; (+ (fib (- n 1))
; (fib (- n 2))))))
(define fib (lambda (n)
(if (< n 2)
n
(+ (fib (- n 1))
(fib (- n 2))))))
;(letrec ((repl (lambda ()
; (write (eval (read)))
; (repl))))
; (repl))
| false |
fc430d578b6fd7a89749ea96636ea29d09c3fc8b
|
165a4ff581651cdad1bc512ec1c82cebc0ac575a
|
/src/SICP/4/4.1/ex4.23.ss
|
0f1f220690f0a97057f642b131bc9ddf2b4c07e3
|
[] |
no_license
|
haruyama/yami
|
5028e416a2caa40a0193d46018fe4be81d7820dc
|
32997caecc18d9d82a28b88fabe5b414a55e0e18
|
refs/heads/master
| 2020-12-25T09:47:04.240216 | 2018-06-16T08:28:41 | 2018-06-16T08:28:41 | 898,824 | 1 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,467 |
ss
|
ex4.23.ss
|
(load "./4.1_3.ss")
;ex4.22
(define (make-lambda parameters body)
(cons 'lambda (cons parameters body)))
(define (let? exp) (tagged-list? exp 'let))
(define (let-clauses exp) (cdr exp))
(define (let-bindings clauses) (car clauses))
(define (let-body clauses) (cdr clauses))
(define (let->combination exp)
(expand-let-clauses (let-clauses exp)))
(define (expand-let-clauses clauses)
(cons (make-lambda (map car (let-bindings clauses)) (let-body clauses))
(map cadr (let-bindings clauses))))
;ex4.23
;http://d.hatena.ne.jp/tmurata/20100423/1272021704
;http://www.serendip.ws/archives/2122
(define (analyze exp)
(cond ((self-evaluating? exp)
(analyze-self-evaluating exp))
((quoted? exp) (analyze-quoted exp))
((variable? exp) (analyze-variable exp))
((assignment? exp) (analyze-assignment exp))
((definition? exp) (analyze-definition exp))
((if? exp) (analyze-if exp))
((lambda? exp) (analyze-lambda exp))
((let? exp)
(analyze (let->combination exp)))
((begin? exp)
(analyze-sequence (begin-actions exp)))
((cond? exp) (analyze (cond->if exp)))
((application? exp) (analyze-application exp))
(else
(error "Unknown expression type -- ANALYZE" exp))))
(define (analyze-sequence exps)
(define (sequentially proc1 proc2)
(lambda (env) (proc1 env) (proc2 env)))
(define (loop first-proc rest-procs)
(if (null? rest-procs)
first-proc
(loop (sequentially first-proc (car rest-procs))
(cdr rest-procs))))
(let ((procs (map analyze exps)))
(if (null? procs)
(error "Empty sequence -- ANALYZE"))
(loop (car procs) (cdr procs))))
(analyze-sequence '((+ 1 1)))
(analyze-sequence '((+ 1 1)(+ 2 2)))
(analyze-sequence '((+ 1 1)(+ 2 2)(+ 3 3)))
(driver-loop)
(begin
(+ 1 1))
(begin
(+ 1 1)
(+ 2 2))
end
(define (analyze-sequence exps)
(define (execute-sequence procs env)
(cond ((null? (cdr procs)) ((car procs) env))
(else ((car procs) env)
(execute-sequence (cdr procs) env))))
(let ((procs (map analyze exps)))
(if (null? procs)
(error "Empty sequence -- ANALYZE"))
(lambda (env) (execute-sequence procs env))))
(analyze-sequence '((+ 1 1)))
(analyze-sequence '((+ 1 1)(+ 2 2)))
(analyze-sequence '((+ 1 1)(+ 2 2)(+ 3 3)))
(driver-loop)
(begin
(+ 1 1))
(begin
(+ 1 1)
(+ 2 2))
end
| false |
158e02c01bb39b1be270988e00ed033db7e3202d
|
6cf2e78840970768168f583716e8826b1902dafa
|
/learning-functional/work-in-university/home-practice/scheme-practice/part-2-recursion/solutions/perfect.scm
|
ac724e088f3db96dd97380278bd80de27f3f1a17
|
[] |
no_license
|
dianvaltodorov/learning-code
|
e4b3e5034c68cdf9d1e38f8b6a12af1d51d2e167
|
a92605345829e051c0b2420de6f3dfc1fe5eb65a
|
refs/heads/master
| 2021-01-17T12:24:58.618311 | 2016-02-02T17:48:55 | 2018-06-21T06:53:16 | 49,488,021 | 2 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 106 |
scm
|
perfect.scm
|
(load "../../lib/unit.scm")
(load "sum_divisors.scm")
(define (is-perfect? x)
(= x (sum-divisors x)))
| false |
dfd27e9e1157237784ef8c1593f10c9ad7709273
|
bbf024156a05ec1b70df909cce6c7afcff454fef
|
/testing-enc.scm
|
2ba0f36e5b6842b48ec31609f5c3d6ec4e09052a
|
[] |
no_license
|
rachelbasse/hmm-np-chunker
|
5167a7923ac94e7b3fd157ffff84f7d69851f97e
|
764691063ac050c92b0eba1f2cf9ba38329f4ec4
|
refs/heads/master
| 2020-03-21T06:11:27.558971 | 2018-06-21T20:32:37 | 2018-06-21T20:32:37 | 138,204,706 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 250,709 |
scm
|
testing-enc.scm
|
;;;; HELLO! I am the encoded input matrices.
; encode the input matrices.
#|(define enc-obs-matrix
(vector-map
(lambda (row) (encode row (form-ref 'obs-alph)))
obs-matrix))
(define enc-state-matrix
(vector-map
(lambda (row) (encode row (form-ref 'state)))
state-matrix))|#
(define enc-state-matrix #(
#(2 2 2 0 2 2 1 2 1 2 2 2 1 2 2 1 2 2 1 1 2 2 1 2 0 2 2 1)
#(2 1 2 2 1 1 2 1 1 2 2 2 2 1 2 2 1)
#(2 1 1 1 2 2 1 2 2 0 2 2 2 1 2 2 2 1 2 2 1 2 2 2 1 2 2 1 2 2 2 2 1)
#(1 2 2 2 1 2 1 1 2 1 1 1 2 1 2 2 1 2 1)
#(2 1 1 1 2 2 1 2 1 1 2 2 2 2 2 2 2 2 2 1)
#(2 2 2 1 1 1 2 2 2 0 2 1 1 2 2 1 1 2 2 1 2 2 0 2 1)
#(2 2 1 2 2 1 1 1 1 2 2 1 2 2 2 1)
#(1 2 1 2 1 2 2 1 2 2 1 2 2 1 2 2 2 2 1)
#(2 2 2 2 2)
#(2 2 2 1 2 2 1 1 1 1 2 1 2 2 2 1 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1)
#(2 1 2 1 2 1 2 2 1 1 2 2 1 1 1 1)
#(2 2 1 1 2 2 2 1 2 1)
#(1 2 1 2 2 2 2 2 2 2 1 2 2 1 2 1 2 1 2 2 1)
#(2 2 1 1 1 1 2 2 1 2 1 2 1 1 2 2 2 2 1)
#(2 1 1 1 1 2 2 2 1)
#(2 2 2 1 1 2 2 2 2 2 1 1 2 2 2 1 2 2 2 1 1 2 2 0 2 1)
#(2 2 1 1 2 2 2 1 2 1 2 2 2 1 1 2 2 0 2 1)
#(1 2 2 2 1 2 1 2 2 1 2 2 2 1 1 2 2 0 2 1 1 2 1 2 2 2 1 1 2 2 0 2 1 1 2 2 2 1)
#(2 2 1 2 1 2 2 2 1 2 2 2 1 1 2 2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2 2 1 2 2 2 2 1 1 2 2 1 1 1 1 2 2 1 1 1 1 2 2 2 1 2 1 1 1 1 1 1 2 2 2 2 1)
#(1 2 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 2 1 2 2 1 1)
#(1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1)
#(2 1 2 2 2 1 2 2 2 1 1 1 2 2 2 1 1 2 1 1 2 2 2 1 2 2 2 1 2 1 2 2 1 1)
#(2 2 1 1 2 2 1 2 2 1 1 2 2 2 2 1 2 1 2 2 1 2 2 2 2 1 2 1 2 1 1)
#(2 2 1 2 1 2 1 1 2 1 2 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 1 1 2 2 2 1)
#(2 1 2 2 2 2 2 2 1 2 2 2 1 2 1 1 2 2 2 1 2 1 2 2 2 1 2 2 1 1 2 0 2 1 2 2 2 1)
#(2 1 2 1 2 2 2 1 1 1 2 1 1 1 2 1 2 1 1 2 2 1 2 1)
#(1 1 2 2 1 2 2 1 1 1 2 1 1 1 2 2 1 2 0 2 2 2 1)
#(2 1 1 1 2 0 2 1)
#(1 2 2 1 1 2 1 2 1 1 2 2 2 2 1 2 0 2 1 1 1 1 1 1 1 2 2 1)))
(define enc-obs-matrix #(
#(33 33 33 30 33 43 22 14 22 41 35 43 27 26 43 42 33 33 37 36 35 34 42 33 30 25 34 29)
#(33 22 41 43 40 42 14 37 36 25 35 35 34 42 41 34 29)
#(41 28 32 42 35 34 32 41 43 30 25 35 34 32 41 43 43 32 43 43 32 38 27 34 42 41 34 31 41 35 43 43 29)
#(42 41 27 43 32 33 22 32 14 40 39 38 25 42 41 34 37 33 29)
#(33 32 38 42 33 33 32 33 32 40 41 43 32 34 32 35 31 34 28 29)
#(33 33 33 22 38 37 41 34 43 30 43 32 27 41 43 38 42 41 43 42 33 33 35 33 29)
#(33 33 32 25 34 35 32 38 42 43 43 42 41 33 43 29)
#(42 33 32 14 22 41 43 42 43 43 42 33 33 32 41 43 43 43 29)
#(33 33 33 33 29)
#(33 33 33 32 25 34 35 32 22 38 43 31 35 27 43 42 33 33 32 41 33 32 33 32 43 42 41 33 33 43 43 43 29)
#(33 32 9 40 34 42 35 43 32 22 41 43 40 39 38 29)
#(33 33 22 38 35 43 43 42 33 29)
#(42 43 37 26 35 43 43 31 43 34 32 33 33 40 43 42 43 31 43 43 29)
#(41 34 22 38 38 42 33 33 32 25 32 12 22 42 41 35 43 43 29)
#(33 40 42 35 42 33 33 33 29)
#(33 33 33 32 27 35 33 35 43 34 32 22 41 35 43 42 17 25 25 32 31 17 25 41 43 29)
#(41 43 11 32 41 34 28 22 34 42 17 25 25 32 31 25 34 41 43 29)
#(42 41 25 34 32 14 22 41 43 42 17 25 25 32 31 17 25 41 43 32 42 34 42 17 25 25 32 31 17 25 41 43 32 42 41 25 43 29)
#(33 33 22 14 22 26 43 34 42 17 25 25 42 27 26 43 43 32 27 26 35 43 31 35 43 34 37 17 25 25 29)
#(42 41 43 43 32 14 22 32 14 22 27 43 42 17 25 25 42 41 43 29)
#(41 43 22 41 43 42 35 34 42 35 34 42 33 35 43 34 32 27 41 27 43 42 41 43 29)
#(42 43 37 41 38 43 32 41 34 28 22 41 35 43 42 17 43 25 27 35 31 35 34 42 43 34 31 35 34 32 31 14 22 41 17 25 25 43 42 38 43 43 34 32 27 41 43 42 10 34 28 27 26 34 29)
#(34 22 39 41 39 35 34 42 41 43 42 33 33 43 29)
#(36 42 12 22 37 33 30 43 32 33 33 33 32 31 26 35 35 43 32 33 33 33 29)
#(42 41 43 41 33 15 34 22 33 33 22 31 43 43 34 22 26 43 32 33 33 31 33 22 26 35 35 34 28 37 36 42 34 42 33 32 33 30 43 43 32 22 17 25 42 41 33 33 37 36 42 17 25 29)
#(27 33 30 43 32 9 40 38 41 25 34 43 34 42 17 25 25 32 38 42 12 14 20 36 38 38 41 34 31 35 43 42 33 38 42 42 17 25 41 43 29)
#(8 43 43 42 41 43 22 35 43 32 39 22 33 30 43 29)
#(39 42 41 34 28 41 43 43 42 17 25 41 43 32 41 25 34 20 39 36 39 17 25 25 10 42 14 22 37 36 42 41 35 43 29)
#(33 33 40 25 33 34 31 40 34 37 36 41 25 42 17 25 41 29)
#(42 41 17 35 43 32 9 22 39 17 25 25 29)
#(42 43 30 43 42 43 32 14 22 35 42 41 35 17 25 25 29)
#(42 43 32 33 33 32 25 34 35 32 40 41 34 29)
#(14 22 26 35 25 34 42 33 15 31 33 33 42 38 43 34 42 39 17 25 25 32 31 33 22 14 41 17 25 25 43 8 14 22 14 29)
#(26 25 43 22 17 25 32 42 41 17 25 43 29)
#(41 35 35 33 33 40 39 38 34 39 4 42 13 41 43 34 4 37 36 39 41 43 42 43 29)
#(33 22 14 41 17 25 43 37 36 14 39 42 33 15 32 31 14 22 38 41 43 42 17 25 35 43 42 41 17 25 43 29)
#(33 33 40 25 33 34 31 40 34 37 36 41 25 42 17 25 41 29)
#(41 22 37 41 38 17 25 25 42 41 17 35 43 32 31 39 17 25 25 42 43 30 43 29)
#(42 41 38 17 25 25 41 25 34 22 38 37 36 42 41 43 32 14 22 37 36 42 41 43 39 17 25 25 32 27 43 42 41 34 42 34 22 37 36 43 34 39 41 43 20 36 41 43 29)
#(33 30 34 22 14 32 31 26 34 32 43 43 37 41 33 15 4 35 35 43 32 31 17 25 41 43 42 43 42 39 29)
#(39 32 42 41 35 43 32 14 20 36 38 39 37 43 34 42 43 29)
#(33 33 33 32 43 42 41 33 43 42 33 33 32 22 38 43 42 33 33 33 33 32 41 33 43 32 31 35 43 43 42 33 33 29)
#(33 33 40 33 33 33 32 12 22 37 36 35 34 32 42 41 34 29)
#(33 40 41 43 31 43 34 28 29)
#(14 33 33 22 33 33 33 22 37 36 39 42 43 43 42 41 43 27 43 29)
#(24 21 22 41 43 42 43 42 37 41 43 43 42 41 43 32 24 41 43 22 29)
#(33 33 22 37 36 29)
#(42 41 43 32 14 15 22 33 33 30 43 43 40 42 14 37 36 42 41 43 37 41 43 42 25 34 29)
#(14 20 39 36 41 43 32 14 15 22 32 31 20 39 36 42 41 43 34 29)
#(33 33 20 36 38 42 41 35 43 42 33 33 32 14 15 43 31 43 29)
#(42 41 35 43 32 14 15 39 22 14 22 38 39 25 42 26 35 34 42 41 35 43 29)
#(34 22 39 38 29)
#(41 43 40 42 25 43 42 41 43 30 34 32 38 42 41 25 25 34 35 42 42 33 25 29)
#(42 35 35 43 43 32 14 15 22 42 17 25 32 35 29)
#(25 27 43 34 22 35 35 34 32 38 42 35 34 42 10 32 35 34 34 9 28 35 43 34 29)
#(33 31 33 22 41 25 43 43 42 34 4 33 33 30 43 22 25 43 31 33 33 31 33 30 35 43 22 25 43 29)
#(41 34 22 42 43 42 34 30 34 29)
#(33 31 33 29)
#(33 32 33 32 33 32 22 37 36 41 43 42 41 35 34 43 42 41 43 31 43 34 28 29)
#(41 10 33 43 22 35 31 35 34 43 25 43 31 25 43 32 39 29)
#(35 34 22 42 25 43 42 35 43 34 42 41 25 34 32 38 42 25 43 41 43 11 29)
#(34 42 41 43 22 37 17 25 25 42 17 25 25 29)
#(33 32 33 30 35 35 43 32 22 10 34 42 41 35 43 43 40 39 38 42 41 33 42 41 43 27 43 32 41 43 22 29)
#(41 43 22 38 42 33 33 41 43 29)
#(35 43 32 39 32 38 37 43 34 34 42 41 43 42 33 30 38 43 31 43 34 32 27 33 31 33 29)
#(42 33 33 33 33 35 43 43 32 33 34 22 42 17 25 32 42 25 34 29)
#(33 33 29)
#(33 32 33 33 32 33 32 22 34 9 22 41 43 42 41 43 31 41 35 43 42 41 43 42 25 43 31 11 35 34 43 29)
#(38 42 43 42 35 34 42 41 43 30 43 34 32 33 22 25 20 36 41 13 43 42 26 43 32 42 35 34 38 37 36 10 42 25 43 37 39 17 25 29)
#(34 42 41 43 22 37 17 25 25 42 17 25 25 29)
#(43 35 34 22 25 43 42 41 43 37 17 25 25 4 33 34 22 25 43 29)
#(41 43 30 43 22 38 42 34 42 41 35 34 33 32 41 43 43 32 31 33 32 41 43 43 43 29)
#(35 34 42 33 30 35 43 34 32 35 42 33 43 34 32 33 43 32 31 33 43 43 32 38 25 43 37 17 25 25 42 41 35 43 4 33 34 22 43 43 29)
#(35 34 34 39 22 35 43 42 41 43 29)
#(35 34 42 33 43 32 33 43 34 32 31 33 43 31 43 34 32 38 25 43 37 17 25 25 29)
#(33 34 22 42 17 25 41 43 32 42 17 25 32 42 33 33 35 43 43 29)
#(33 33 31 33 29)
#(33 22 43 35 31 35 34 37 35 34 42 34 32 35 34 31 43 34 42 35 43 34 42 41 43 9 22 34 39 29)
#(34 22 37 36 34 42 42 41 10 43 43 32 43 42 41 43 42 41 43 43 22 42 33 33 42 43 42 33 30 43 42 33 33 33 42 25 32 31 35 34 42 41 43 42 43 43 42 33 30 33 33 43 29)
#(35 34 42 41 33 32 33 32 43 22 25 43 37 17 25 25 42 17 25 25 29)
#(35 34 22 25 43 37 17 25 25 42 17 25 25 41 43 11 29)
#(34 42 33 32 41 43 32 38 34 34 29)
#(10 34 42 34 31 35 43 34 10 42 36 41 35 43 42 41 34 42 43 34 37 36 41 43 42 35 35 43 34 32 33 22 29)
#(33 33 33 33 31 33 15 33 34 22 43 42 41 35 34 43 29)
#(33 34 22 43 42 35 43 42 41 33 33 42 17 25 32 39 25 34 29)
#(33 33 32 43 42 33 33 32 22 14 40 24 35 24 42 34 30 34 42 35 34 22 37 42 25 34 31 17 25 41 43 29)
#(41 40 42 35 34 42 27 34 42 25 34 41 43 11 4 27 38 34 32 43 22 25 34 41 43 39 29)
#(41 35 34 28 41 34 43 30 35 43 32 38 37 42 17 25 25 31 17 25 25 32 42 17 25 25 41 35 43 29)
#(34 28 33 30 35 35 34 22 42 25 43 37 17 25 25 29)
#(33 33 22 41 34 43 37 35 34 42 33 33 32 33 31 33 29)
#(34 22 39 38 42 24 41 39 35 24 43 42 27 43 42 33 30 33 43 32 33 33 22 29)
#(43 43 42 33 30 33 43 34 31 35 34 22 25 43 42 41 43 32 33 33 22 29)
#(14 22 41 43 22 41 43 42 43 34 38 42 27 43 34 32 27 25 34 34 31 27 11 39 41 43 30 35 34 29)
#(41 38 43 42 33 30 33 34 22 41 34 42 43 29)
#(33 30 43 34 43 32 9 40 35 34 42 33 43 43 31 33 43 32 40 38 41 35 43 29)
#(34 28 33 30 34 42 43 34 42 41 33 22 35 42 41 43 32 31 14 22 27 34 42 39 25 43 37 25 43 29)
#(24 42 14 20 36 26 43 42 41 33 22 35 32 31 35 39 39 32 9 20 36 35 32 24 40 33 33 32 41 43 42 33 33 31 33 29)
#(24 31 14 40 39 35 32 14 40 41 35 43 29 24)
#(33 33 22 42 33 30 35 43 32 39 42 26 39 35 33 30 33 15 43 32 40 38 29)
#(24 14 28 38 41 43 37 36 18 33 29 16 34 32 31 41 43 10 20 36 38 32 24 33 33 22 29)
#(24 27 43 42 33 34 40 41 39 35 43 42 41 43 29 24)
#(37 36 42 26 35 34 43 32 33 22 26 33 43 43 42 25 29)
#(33 33 33 22 38 41 43 42 41 43 32 9 39 40 34 42 43 31 43 34 32 27 41 43 42 34 37 25 29)
#(33 39 40 33 34 32 43 34 31 35 43 34 29)
#(33 33 40 43 32 35 34 32 42 33 33 33 33 32 9 40 38 42 33 33 33 29)
#(41 33 33 40 26 39 38 34 28 41 24 43 24 36 42 38 34 38 42 27 41 43 24 11 35 24 31 24 10 37 36 29 24)
#(39 39 4 42 14 20 36 8 26 35 43 22 29)
#(33 34 32 12 36 41 43 8 27 42 35 34 35 42 33 24 33 33 24 33 32 31 33 33 15 33 33 24 33 33 24 33 32 43 22 43 42 35 34 42 33 34 9 22 35 34 42 41 38 34 41 43 29)
#(42 35 35 43 32 33 33 33 33 33 32 27 37 41 20 42 26 34 32 22 41 35 34 29)
#(42 41 35 34 42 13 32 14 40 32 41 34 31 34 42 41 43 20 36 41 34 29)
#(43 22 32 43 22 14 22 43 29)
#(33 43 33 33 4 42 41 35 43 42 26 43 42 42 35 34 4 22 42 26 35 43 22 39 35 32 14 22 24 42 41 43 14 20 36 42 41 43 42 43 43 9 40 37 36 39 42 43 42 26 43 29 24)
#(33 33 22 34 42 14 39 40 39 38 33 43 42 27 41 17 25 43 43 14 22 42 27 26 43 42 27 41 43 29)
#(24 14 22 18 41 27 16 41 43 42 43 14 20 36 27 35 26 43 43 4 31 41 43 12 22 14 20 38 33 33 30 43 42 41 35 25 34 32 24 14 22 29)
#(33 33 22 39 10 37 41 34 42 34 33 33 18 24 40 37 36 41 43 24 16 32 20 33 18 24 40 42 42 14 22 42 33 33 24 16 31 33 33 32 2 24 35 43 39 40 39 41 43 14 40 41 43 29 24)
#(33 33 32 41 33 30 43 27 43 42 43 32 40 42 41 34 22 24 42 41 35 43 42 41 43 43 29 24)
#(33 33 33 43 33 33 32 12 39 40 42 43 24 34 24 31 43 32 22 42 41 35 34 22 38 37 36 33 33 30 24 39 27 43 24 31 41 35 34 42 24 35 24 33 33 32 41 33 34 43 29)
#(24 31 28 42 41 43 14 32 41 43 32 20 36 42 33 32 24 22 33 33 29)
#(24 39 42 27 34 42 26 34 32 39 36 5 42 34 30 34 4 29)
#(39 35 42 41 41 43 43 24 27 33 0 24 42 33 33 18 33 31 33 32 33 25 16 31 41 34 38 40 41 43 42 35 43 40 39 41 43 42 35 43 29)
#(40 35 41 43 38 29)
#(42 41 43 42 34 32 20 41 33 36 41 35 43 42 41 35 43 29)
#(39 39 29)
#(42 25 34 39 41 35 43 43 22 29)
#(35 43 34 22 42 41 43 42 33 33 32 35 33 31 33 29)
#(41 35 43 20 36 38 39 35 4 43 20 36 14 42 41 35 25 25 34 43 34 31 27 42 42 34 29)
#(39 32 41 43 40 39 38 37 36 41 43 42 41 35 43 42 35 35 43 29)
#(14 40 39 27 31 20 39 36 42 7 42 32 31 41 42 32 35 35 43 29)
#(14 28 37 41 25 42 26 43 42 26 35 43 32 31 42 14 28 35 42 35 43 14 20 36 42 41 35 43 31 39 36 41 33 33 37 36 14 42 41 35 4 43 43 42 41 35 43 42 43 29)
#(33 33 33 33 33 42)
#(41 33 33 33 40 37 36 14 10 42 41 35 43 29)
#(42 43 32 41 35 43 40 42 14 20 36 41 35 43 42 27 37 41 35 43 37 36 25 35 35 34 37 36 41 35 43 4 41 43 37 36 35 34 31 41 35 43 43 37 36 41 43 43 32 9 40 39 41 13 43 34 28 42 41 43 29)
#(41 33 39 22 42 14 20 36 41 43 42 35 35 43 32 12 20 36 38 42 42 41 43 29)
#(33 33 33 33 33 22 41 34 28 38 37 36 24 43 24 37 41 43 32 9 40 41 35 43 42 10 42 17 43 25 31 40 39 17 25 25 41 43 29)
#(24 26 43 31 43 30 43 40 42 14 28 39 36 41 34 42 43 9 28 14 39 31 39 36 31 36 26 43 32 24 33 33 22 29)
#(24 31 14 28 39 36 35 34 31 43 42 14 28 37 36 37 36 17 43 25 39 29 24)
#(33 33 32 12 22 42 42 43 42 41 33 42 33 32 40 38 38 42 12 14 40 41 43 32 43 31 43 42 43 42 41 34 42 41 35 35 43 29)
#(41 33 40 42 41 43 43 38 42 25 32 9 14 40 38 27 37 36 42 34 29)
#(31 41 43 32 9 22 42 35 25 42 41 17 25 25 43 43 32 40 38 42 41 27 43 42 35 43 29)
#(41 35 43 40 42 10 43 42 8 41 43 40 26 34 20 36 41 35 43 42 27 26 43 37 36 10 43 43 29)
#(24 14 28 42 14 20 36 41 35 43 42 41 43 43 31 43 43 9 32 42 43 32 14 28 20 36 42 41 35 43 42 43 32 24 14 22 29)
#(41 33 40 37 36 41 35 34 39 29)
#(39 32 14 20 36 43 35 34 42 42 41 43 32 31 33 33 22 14 40 37 24 28 41 43 24 42 41 35 43 43 31 41 43 29)
#(42 41 34 20 39 36 42 17 25 31 17 25 41 43 32 33 34 28 35 42 14 20 36 35 34 42 41 35 43 29)
#(24 14 28 27 43 14 20 36 41 35 25 31 25 31 25 31 25 34 42 26 43 27 42 41 7 35 31 35 43 42 41 43 43 42 41 35 43 39 32 24 33 33 22 29)
#(24 42 41 43 43 32 14 28 27 31 27 43 35 34 27 41 17 25 25 43 29)
#(8 33 33 33 32 41 43 42 41 35 43 42 33 32 22 38 32 26 43 22 35 43 34 32 41 38 43 31 38 34 31 34 29)
#(14 22 41 43 42 26 43 32 35 43 33 33 33 29)
#(41 43 43 30 35 31 35 43 32 42 41 43 42 33 30 43 43 32 22 39 38 42 33 33 32 40 41 33 43 42 43 37 43 34 29)
#(27 42 40 32 27 42 34 42 43 31 43 32 33 33 40 38 37 43 41 25 42 26 34 38 42 41 43 32 27 37 33 34 43 34 31 43 34 42 33 33 29)
#(14 40 39 27 41 43 14 40 41 43 32 39 10 42 39 41 43 29)
#(26 34 28 7 39 38 42 34 14 40 4 26 35 43 32 33 33 32 31 26 43 32 33 29)
#(31 14 40 27 41 34 42 41 12 22 41 34 37 36 14 42 26 35 43 42 43 42 26 43 29)
#(10 34 37 36 38 39 29)
#(42 41 25 34 42 41 43 32 9 41 33 39 22 32 33 33 40 38 42 26 7 35 4 31 35 4 42 27 43 29)
#(39 32 42 41 38 43 40 41 35 33 35 43 43 32 14 40 39 41 13 43 42 41 35 43 42 33 33 31 33 42 34 39 25 34 29)
#(33 30 43 42 41 43 42 41 35 25 34 32 27 26 43 42 43 34 42 33 25 32 40 41 43 42 41 43 29)
#(42 35 35 43 38 42 37 36 33 32 14 22 36 14 42 42 41 43 42 33 30 35 43 42 34 31 34 29)
#(42 7 42 41 35 25 34 32 41 43 22 25 42 43 29)
#(42 25 32 42 43 32 8 33 33 22 41 41 43 42 41 43 35 43 42 33 31 41 43 42 41 33 33 33 33 32 14 22 38 42 33 34 42 39 27 31 39 27 41 43 32 27 37 41 33 33 43 42 41 43 29)
#(41 43 22 39 38 29)
#(31 33 43 32 39 42 43 42 31 43 35 26 35 43 32 39 38 41 43 39 29)
#(33 33 30 34 42 27 34 42 26 43 22 38 11 35 37 33 34 29)
#(42 41 43 42 32 41 33 20 36 41 43 42 27 41 33 30 34 29)
#(41 33 40 38 31 39 22 42 35 34 32 31 43 39 39 35 29)
#(41 33 33 33 40 39 39 35 42 41 43 42 33 32 39 35 42 33 30 33 33 32 39 35 42 33 33 42 41 33 31 39 35 42 33 30 33 33 33 29)
#(39 14 40 38 11 35 42 41 42 14 29)
#(31 42 42 43 4 41 33 20 36 34 31 35 43 37 36 14 42 43 32 31 41 35 43 42 26 43 20 36 14 26 43 29)
#(24 41 33 22 33 41 42 32 24 40 33 33 32 41 35 33 37 33 29)
#(24 14 40 38 41 43 42 43 29 24)
#(42 27 42 33 30 35 43 42 27 42 33 33 32 35 33 34 28 38 39 42 38 26 43 29)
#(33 33 20 36 38 42 26 35 43 42 25 42 42 33 30 35 35 43 32 40 33 33 32 31 27 35 43 40 39 38 14 35 34 42 43 32 31 41 43 42 26 35 43 29)
#(24 42 41 33 22 38 39 31 38 43 32 14 20 39 36 38 14 42 25 32 24 33 33 40 29)
#(39 7 35 32 33 33 30 34 28 38 37 36 4 42 41 34 32 37 36 4 42 41 43 36 26 43 42 41 43 29)
#(25 35 43 43 32 42 43 42 25 42 33 33 22 27 42 41 33 37 36 26 43 42 41 35 43 32 22 14 41 35 43 43 38 42 26 43 29)
#(24 14 40 38 32 24 40 41 33 33 33 32 12 40 38 33 33 43 42 33 29)
#(24 41 15 28 38 14 42 41 43 39 29)
#(14 40 35 37 36 8 14 28 39 36 41 35 43 29 24)
#(26 35 43 42 41 43 4 26 35 43 42 35 34 31 34 29)
#(33 33 39 40 34 9 43 40 41 13 43 42 41 34 32 12 28 41 35 43 43 31 35 43 42 27 43 29)
#(41 33 22 41 35 33 33 42 35 25 32 8 14 22 42 26 35 43 42 41 33 33 33 42 33 32 27 37 35 33 43 34 29)
#(41 43 22 42 33 33 30 43 32 41 35 43 38 42 33 22 33 33 33 33 29)
#(33 33 32 27 42 27 41 15 20 36 41 43 42 41 35 43 32 22 33 30 34 42 41 35 34 14 22 42 26 43 34 31 32 11 35 32 42 26 34 31 34 29)
#(41 43 22 38 29)
#(14 22 41 35 43 42 41 35 31 39 38 33 33 32 12 22 38 37 26 34 42 33 3 33 4 43 43 29)
#(38 41 35 43 42 26 43 30 43 32 14 22 38 42 41 43 34 42 41 35 43 43 42 33 33 29)
#(33 22 25 34 10 42 7 42 26 43 34 32 31 22 43 37 41 43 42 26 43 22 38 26 43 43 29)
#(14 22 14 39 35 37 26 35 34 32 43 42 12 22 35 34 38 42 26 35 34 37 41 39 38 32 35 43 42 41 43 42 43 43 29)
#(42 26 22 35 43 31 39 38 32 35 43 32 33 22 11 38 31 35 42 39 42 26 35 43 32 34 42 41 43 28 29)
#(24 14 22 41 35 43 42 43 34 42 41 43 8 21 22 41 43 42 43 32 8 34 22 41 43 42 35 34 32 24 40 33 33 32 41 43 43 42 33 31 41 35 43 29)
#(33 33 30 43 37 35 43 34 22 35 42 41 25 31 25 32 43 34 28 29)
#(26 43 43 42 41 33 33 43 32 33 33 33 32 22 14 41 35 43 4 33 33 20 36 41 43 30 35 43 43 29)
#(41 43 43 20 36 25 34 4 41 35 43 32 42 27 35 34 42 41 43 32 31 41 33 32 42 27 41 27 33 43 42 41 34 38 42 33 33 33 30 43 34 42 33 33 33 31 33 33 29)
#(33 33 22 25 42 41 25 13 34 37 33 30 35 43 29)
#(27 26 34 22 41 43 42 41 35 43 29)
#(33 33 30 35 43 22 39 17 25 37 17 25 41 43 32 31 35 34 42 43 31 34 42 41 33 33 32 41 35 43 43 34 29)
#(14 22 35 43 42 35 34 32 31 41 35 43 37 26 35 35 43 32 9 43 34 28 42 27 38 17 25 37 17 25 35 29)
#(24 14 22 14 39 39 32 24 40 33 33 32 41 35 35 43 12 22 33 33 31 26 43 29)
#(24 14 22 27 41 34 9 22 14 28 43 29 24)
#(41 33 33 43 38 42 33 33 42 25 4 42 43 42 41 43 43 42 33 33 32 43 42 41 33 33 4 22 35 42 41 35 43 29)
#(42 27 43 31 43 34 12 22 34 32 14 22 41 35 43 42 43 29)
#(14 22 9 35 34 22 38 38 27 35 32 9 22 38 38 42 26 34 29)
#(41 22 39 35 37 41 35 43 42 25 32 8 43 34 22 27 41 33 33 43 42 41 43 22 20 36 35 29)
#(33 33 22 38 42 41 35 43 43 22 27 42 41 43 42 26 43 29)
#(39 14 22 41 43 42 34 42 14 22 42 41 35 43 42 33 33 32 9 22 38 42 33 33 33 29)
#(41 43 39 22 43 34 42 41 43 22 14 39 10 37 36 29)
#(24 14 22 42 41 43 42 33 32 24 40 33 33 29)
#(24 33 22 41 35 43 29)
#(14 22 35 29)
#(33 22 41 43 42 27 31 27 34 29 24)
#(42 26 34 42 33 32 39 32 33 33 39 22 14 42 41 43 39 35 42 14 22 35 29)
#(33 33 32 41 35 43 31 35 43 32 40 41 35 33 27 34 42 26 34 42 41 33 33 33 43 42 33 32 8 14 22 26 34 29)
#(33 33 20 36 14 41 37 36 42 26 34 31 36 42 41 43 35 32 27 42 14 31 39 27 37 26 43 29)
#(24 34 22 27 42 43 22 35 42 14 32 24 33 33 40 29)
#(31 42 41 43 32 39 39 42 41 33 43 22 38 32 33 33 22 41 43 43 29)
#(14 22 42 42 43 31 35 43 42 35 34 42 33 33 42 33 42 33 25 32 27 37 41 43 42 41 25 43 42 34 33 33 40 42 38 42 43 29)
#(14 22 37 33 33 32 33 32 42 33 42 41 43 42 41 43 42 35 34 32 27 37 41 33 42 41 33 42 33 42 41 35 43 38 24 35 43 42 34 29 24)
#(41 35 34 22 26 43 31 43 42 41 43 42 43 32 31 14 22 39 39 29)
#(14 22 37 43 42 43 42 33 30 35 43 42 25 42 27 35 43 33 41 35 43 37 36 41 43 43 42 14 41 43 11 29)
#(14 22 33 33 30 35 43 32 31 41 43 42 41 33 30 34 29)
#(33 33 32 42 39 41 43 43 32 22 26 34 37 36 41 15 4 39 37 36 41 15 32 41 35 31 41 35 43 43 9 22 27 29)
#(8 33 34 22 37 41 33 42 33 33 30 43 32 43 34 39 22 42 26 43 22 35 37 41 15 29)
#(24 39 42 42 41 33 33 32 14 22 37 27 14 41 43 32 42 43 37 26 43 37 39 43 41 35 43 34 42 33 31 41 33 15 32 24 40 33 33 33 32 12 32 42 43 43 43 42 43 42 35 34 32 35 22 42 34 42 33 33 42 25 29)
#(24 41 42 14 22 8 26 43 34 20 36 39 35 43 42 26 43 8 14 22 39 42 39 37 41 15 29 24)
#(39 42 41 35 43 32 34 22 35 34 29)
#(42 41 33 43 32 41 33 33 33 22 38 42 41 43 42 41 43 30 34 37 38 43 34 29)
#(25 33 43 22 42 41 43 42 25 34 42 27 42 33 33 32 25 42 9 22 43 29)
#(41 43 42 41 33 42 41 43 32 33 33 32 22 41 43 43 29)
#(31 14 22 36 37 33 37 36 43 33 42 41 43 34 42 35 34 32 27 33 33 29)
#(33 33 39 22 42 33 33 22 35 37 36 42 41 34 42 41 33 29)
#(24 43 22 35 42 14 32 24 33 33 40 29)
#(33 33 22 41 39 10 43 42 25 32 8 33 43 34 38 42 14 22 38 27 34 42 39 38 34 42 25 34 27 42 41 33 33 30 33 33 33 33 29)
#(41 34 22 34 42 33 33 30 35 43 32 27 37 35 43 34 29)
#(24 14 22 14 42 26 34 42 26 43 43 32 24 40 35 33 33 33 33 29)
#(42 41 35 43 32 41 33 22 27 33 33 42 26 43 43 4 31 41 34 22 35 32 33 33 40 29)
#(24 42 41 43 42 43 32 42 14 28 37 36 43 32 14 28 14 42 35 34 29)
#(41 43 40 8 35 14 28 38 42 42 35 34 42 14 20 36 14 29 24)
#(43 34 37 41 43 43 42 33 33 22 35 43 42 41 34 37 41 15 31 34 29)
#(33 33 22 35 39 37 36 41 33 43 42 41 43 42 41 43 42 41 33 43 29)
#(41 33 39 22 35 43 42 43 4 35 29)
#(34 42 33 33 22 25 34 42 34 42 39 27 34 37 33 34 27 37 36 41 35 43 42 33 33 29)
#(14 22 25 42 33 33 30 13 34 31 43 34 32 33 33 29)
#(31 41 34 22 39 27 42 42 33 33 14 29)
#(42 41 43 32 39 32 42 25 32 41 33 22 39 39 27 42 26 35 33 35 43 29)
#(33 33 22 34 37 36 37 33 42 41 43 42 26 43 42 41 33 29)
#(33 33 31 35 34 32 27 42 14 22 37 36 42 33 32 38 34 37 36 14 42 41 35 34 39 39 42 14 22 33 43 29)
#(14 22 41 33 42 33 29)
#(41 33 22 41 43 29)
#(27 37 35 34 42 41 43 32 43 22 38 37 33 33 42 26 35 34 42 41 43 20 36 27 29)
#(42 33 32 33 34 22 41 43 32 35 43 42 41 35 43 43 42 33 29)
#(24 35 37 43 34 32 33 33 33 40 38 37 36 26 43 37 33 32 24 14 28 29)
#(34 42 33 22 39 41 43 29)
#(26 35 43 42 33 33 32 41 43 42 33 33 32 31 41 35 25 22 38 42 41 43 29)
#(31 39 32 42 42 27 33 33 30 43 32 14 22 37 36 33 33 14 32 42 34 42 14 22 38 42 41 35 43 42 41 17 25 25 42 34 29)
#(42 33 25 32 33 33 32 42 43 33 43 32 22 38 37 41 43 42 41 33 33 42 33 43 38 37 41 33 42 43 32 33 31 33 42 33 29)
#(35 43 33 32 14 22 38 32 22 38 41 43 42 33 43 42 33 42 41 43 37 33 29)
#(33 33 22 38 33 33 30 43 32 33 33 32 20 36 27 41 43 30 43 29)
#(14 20 39 36 41 35 43 37 36 14 4 39 10 33 33 32 41 43 22 38 29)
#(42 27 42 33 33 32 33 33 33 33 22 42 33 33 34 42 33 37 36 41 43 36 29)
#(24 39 32 24 33 33 22 42 41 43 32 24 41 42 14 42 43 43 42 33 43 14 39 27 37 36 41 34 42 41 33 15 31 39 27 38 42 35 43 34 42 9 14 28 41 43 29 24)
#(41 43 32 42 42 41 38 43 43 32 22 42 41 34 42 33 34 42 34 42 41 43 22 41 35 43 29)
#(24 14 28 42 14 22 38 38 37 36 39 39 14 20 39 36 41 34 14 28 39 32 24 33 33 40 29)
#(24 42 14 22 38 38 35 32 14 20 36 38 14 29 24)
#(42 33 25 32 33 33 22 42 42 33 31 35 43 42 33 32 27 38 26 43 37 41 35 39 25 34 42 41 35 43 42 41 43 43 42 26 35 43 33 33 29)
#(39 32 41 43 22 41 35 43 27 35 31 35 34 29)
#(41 33 43 39 36 33 33 30 43 39 42 41 33 43 29)
#(34 22 39 17 25 41 43 42 41 33 33 33 33 31 41 33 29)
#(42 27 42 33 43 32 33 33 22 39 27 41 33 39 29)
#(42 41 33 34 14 22 26 43 31 43 34 42 41 15 31 41 15 29)
#(14 39 22 42 33 30 35 35 43 43 42 35 43 34 32 27 37 33 33 32 41 43 12 39 22 42 33 33 31 12 22 42 41 33 35 43 42 33 9 20 39 36 41 35 42 43 34 29)
#(31 33 33 22 38 41 33 33 33 20 39 36 42 14 32 40 26 43 43 33 33 32 42 14 22 41 43 43 4 26 43 42 41 33 34 42 33 29)
#(33 33 40 41 35 38 41 15 37 36 42 41 35 43 43 42 33 29)
#(33 33 39 22 43 42 26 43 43 42 41 35 43 42 33 29)
#(31 42 42 13 25 43 32 42 41 43 42 25 32 14 22 36 41 43 43 42 41 33 43 42 33 29)
#(42 32 26 43 42 41 33 43 22 35 32 14 22 39 37 36 14 35 34 42 41 33 43 32 40 33 33 33 32 41 33 33 12 39 38 42 41 33 33 33 29)
#(24 33 22 33 43 34 31 41 33 43 42 41 43 32 24 14 40 29)
#(41 43 42 25 22 25 35 34 42 9 33 33 20 36 38 35 43 42 33 4 42 27 33 34 29)
#(33 33 32 39 41 43 37 33 33 32 40 27 38 37 33 42 33 33 30 43 33 33 42 41 43 42 35 43 43 31 24 35 32 35 43 24 42 41 33 33 29)
#(33 33 22 33 33 33 32 41 33 43 37 33 32 42 41 43 29)
#(24 33 22 32 24 33 33 40 29)
#(14 40 33 33 22 14 14 22 27 38 42 42 41 24 43 43 32 24 42 9 33 33 20 36 37 36 14 42 41 43 31 35 43 41 43 24 42 43 31 43 29 24)
#(33 33 32 42 43 42 27 26 43 42 41 33 33 33 32 20 39 36 38 42 43 29)
#(42 33 33 30 35 34 22 32 39 22 26 34 42 43 37 41 15 32 41 35 43 37 36 10 43 42 33 29)
#(42 43 32 14 22 36 41 33 25 35 34 42 41 43 43 29)
#(31 39 25 43 39 32 14 39 22 17 25 37 41 33 43 32 27 37 34 38 42 33 33 30 35 43 42 33 32 33 29)
#(39 32 26 35 34 38 29)
#(33 33 22 38 42 27 42 25 41 43 42 33 33 32 26 7 35 35 43 31 41 35 43 37 39 43 33 33 42 43 43 34 29)
#(14 39 22 33 33 33 33 32 41 35 33 33 43 42 43 34 37 41 33 32 42 33 33 22 37 36 41 43 37 36 41 43 29)
#(31 32 6 41 43 32 33 30 43 34 22 37 36 29)
#(33 33 22 27 35 29)
#(42 35 25 32 14 22 41 43 14 22 41 33 20 39 36 29)
#(42 38 42 41 43 9 22 43 34 38 42 41 33 43 32 33 33 22 37 36 41 33 43 42 43 24 42 41 43 37 36 35 42 33 30 43 31 41 43 37 36 41 18 33 29 16 43 42 35 34 37 41 33 33 15 29 24)
#(24 33 32 24 41 43 22 42 32 27 37 33 33 32 24 40 38 33 30 43 42 33 43 22 35 34 29)
#(41 43 22 42 33 22 35 34 42 43 42 33 31 20 36 35 35 34 32 39 42 33 22 38 18 41 33 29 16 41 35 43 42 27 42 41 33 43 29 24)
#(33 33 22 41 43 37 26 34 31 37 33 33 42 33 33 33 32 12 22 14 37 33 42 33 33 33 29)
#(33 33 30 43 22 38 39 29)
#(31 33 33 39 22 33 33 42 41 43 20 36 38 42 39 14 20 36 26 38 43 29)
#(41 43 42 41 43 22 42 43 29)
#(42 34 41 27 33 43 22 39 33 33 30 43 43 29)
#(41 43 42 33 33 33 33 31 43 42 33 33 22 35 35 34 37 36 43 29)
#(35 34 42 14 22 38 42 33 25 35 37 34 42 33 33 32 26 35 43 42 43 32 42 33 33 22 38 41 25 43 31 22 38 41 43 42 33 33 31 33 29)
#(33 35 34 22 35 39 39 37 36 14 29)
#(34 42 33 4 41 43 27 39 42 43 4 38 37 36 14 38 42 43 34 42 33 25 29)
#(42 34 42 35 34 42 33 25 42 34 37 36 41 33 34 42 43 42 26 43 32 33 33 39 22 39 39 8 41 15 32 12 14 22 38 42 39 35 34 32 20 36 42 14 29)
#(39 32 41 43 4 41 33 31 33 33 4 40 41 35 39 29)
#(33 33 40 38 37 36 14 37 43 29)
#(33 33 40 14 40 39 41 43 31 37 36 27 37 36 29)
#(14 40 41 35 43 4 39 37 41 43 29)
#(42 41 43 32 40 33 33 41 35 43 42 33 30 43 32 38 42 41 35 31 35 35 43 29)
#(39 39 32 33 33 40 29)
#(24 42 35 34 32 34 22 35 37 36 42 42 14 29)
#(41 38 14 37 36 10 31 10 32 24 14 40 29)
#(24 14 28 39 36 14 22 14 39 35 42 14 22 14 32 22 14 31 36 14 36 36 37 36 35 31 35 29)
#(33 33 22 42 35 35 43 22 37 17 25 25 32 31 25 34 41 43 32 42 17 25 25 32 31 25 34 41 43 32 41 43 11 29)
#(43 30 43 22 34 30 34 42 41 43 8 35 34 22 35 29)
#(35 43 22 25 43 42 33 32 27 35 34 42 41 43 43 40 26 43 43 29)
#(41 33 33 33 22 43 42 41 43 30 34 32 34 31 34 38 42 41 35 43 42 25 43 42 41 35 43 32 39 10 42 41 25 43 35 43 42 41 35 43 29)
#(24 33 43 31 34 32 9 28 38 41 27 43 42 41 43 32 28 27 35 34 42 27 41 43 38 42 42 14 32 24 22 33 33 32 43 42 33 33 33 42 33 29)
#(41 35 34 42 43 32 9 22 38 42 41 11 33 33 43 42 43 34 38 42 25 42 33 32 36 41 33 41 43 37 36 36 26 43 42 43 31 10 43 34 29)
#(24 14 28 37 36 43 42 41 32 24 22 33 33 32 43 42 33 33 33 29)
#(41 33 39 22 33 43 38 42 25 43 42 43 35 43 32 39 42 25 43 42 33 29)
#(34 42 43 43 22 10 42 41 35 34 29)
#(43 43 22 25 43 32 26 35 43 42 33 32 42 27 38 35 42 33 29)
#(34 38 42 25 43 42 43 32 41 13 43 42 10 42 41 43 31 39 42 25 43 42 33 29)
#(41 34 39 22 35 43 42 35 34 32 41 38 37 36 10 42 25 34 29)
#(41 13 43 22 38 42 35 34 34 32 41 43 9 40 41 43 43 29)
#(43 42 43 43 22 35 42 33 29)
#(43 42 43 43 32 25 43 42 41 43 42 34 30 43 43 32 22 25 43 29)
#(41 34 28 35 34 42 43 43 29)
#(24 8 35 34 28 35 9 40 43 43 40 27 37 36 39 32 24 33 33 22 29)
#(24 14 28 39 38 41 35 43 42 41 39 29 24)
#(41 43 42 43 43 10 42 36 41 35 43 42 43 34 32 41 33 22 29)
#(34 28 39 36 41 33 43 42 43 43 37 36 38 42 41 27 34 29)
#(39 40 41 43 42 41 33 33 33 30 43 42 35 43 42 33 29)
#(41 34 28 39 38 29)
#(25 43 42 41 25 35 29)
#(33 33 32 43 31 35 35 43 42 41 43 27 43 32 22 38 37 41 35 34 42 43 32 43 31 35 43 42 41 43 30 33 33 33 33 43 29)
#(33 33 33 22 41 34 32 39 39 42 41 43 42 33 30 43 29)
#(33 40 39 41 43 42 33 29)
#(43 43 34 42 34 42 25 34 42 43 28 38 37 36 32 35 34 28 29)
#(41 43 40 39 35 42 35 34 32 42 35 34 31 35 31 35 34 39 28 10 43 34 29)
#(41 43 42 41 43 30 43 42 41 33 42 41 33 33 33 39 40 42 35 33 43 34 42 43 43 32 41 27 43 42 43 43 32 20 36 37 36 42 35 34 42 43 43 40 37 36 29)
#(41 43 32 9 40 25 34 42 41 33 33 33 22 41 43 43 42 41 34 42 43 32 40 41 13 43 37 36 42 41 43 42 43 40 27 37 10 43 34 42 43 43 29)
#(24 12 41 40 27 40 42 41 43 43 30 43 40 27 41 43 32 24 22 33 33 32 41 43 42 41 33 33 33 42 33 31 33 33 42 33 29)
#(41 33 33 33 43 40 43 34 42 25 34 42 34 42 41 34 42 25 31 25 41 43 39 29)
#(41 43 43 42 43 43 42 35 34 38 25 37 25 42 41 34 22 25 42 25 32 31 41 43 43 42 41 35 43 43 42 41 34 22 25 32 41 43 42 25 43 29)
#(38 41 35 43 32 41 43 42 35 34 22 25 43 29)
#(41 43 42 43 34 42 34 22 11 35 4 25 43 42 34 31 25 43 42 34 29)
#(41 43 32 42 33 33 32 33 33 31 33 33 42 41 43 30 43 32 39 40 42 41 43 42 43 43 39 39 42 41 43 43 22 42 41 43 42 41 34 42 41 35 43 43 32 42 35 34 29)
#(42 43 43 34 28 27 42 41 43 42 41 43 32 41 43 40 42 43 34 20 36 37 36 42 41 25 42 34 31 42 41 43 25 42 34 29)
#(43 43 34 28 42 43 31 28 27 37 36 42 41 43 34 42 43 32 42 35 34 42 43 31 35 34 29)
#(31 33 33 32 25 42 41 34 42 41 43 32 22 24 41 27 34 14 28 27 42 10 34 14 28 20 36 41 43 42 27 43 42 41 43 29 24)
#(39 32 14 22 42 41 43 40 42 41 38 43 42 43 29)
#(24 39 42 41 35 34 42 43 43 43 41 43 31 43 34 32 14 20 39 36 38 42 38 32 24 41 43 34 29)
#(24 33 43 34 20 36 10 34 42 41 43 32 39 34 32 34 31 34 29 24)
#(41 43 42 41 33 33 40 41 43 42 27 43 43 24 42 35 34 31 34 42 41 33 40 42 14 39 20 36 27 41 43 4 41 39 42 41 43 8 41 43 43 40 42 17 25 25 41 43 42 43 42 41 35 43 42 43 29 24)
#(31 41 43 32 42 33 33 42 41 33 33 33 32 40 41 43 43 31 43 43 34 28 27 42 27 34 29)
#(24 43 20 36 38 42 41 43 42 35 43 24 42 41 43 32 41 43 40 32 42 41 43 42 34 9 28 27 32 36 43 34 31 36 35 43 29)
#(38 42 43 32 33 33 32 41 43 43 42 41 33 33 32 22 35 34 37 36 43 43 42 41 33 20 36 41 33 33 43 42 35 43 29)
#(27 37 41 33 33 33 32 43 40 35 42 25 43 42 41 43 34 42 34 31 25 43 42 34 29)
#(41 33 43 40 41 34 42 43 34 42 43 37 35 43 34 29)
#(41 10 43 42 35 34 28 42 35 34 29)
#(42 39 35 34 42 35 31 35 34 35 43 32 42 41 34 10 34 28 38 42 43 42 34 29)
#(42 27 34 42 43 34 42 41 35 43 32 41 33 43 22 39 42 34 31 34 29)
#(34 31 35 15 22 39 38 4 15 22 38 42 34 29)
#(35 34 42 35 35 35 43 34 42 25 43 42 43 31 43 29)
#(33 15)
#(33 15)
#(33 15)
#(33 15)
#(34 22 33 33 33 32 35 43 43 43 32 27 32 37 36 41 43 30 33 32 33 32 43 29)
#(42 43 43 34 32 33 33 20 36 42 33 30 35 43 31 42 41 43 30 34 28 24 37 36 33 30 34 42 41 35 43 32 24 22 33 33 33 32 43 31 35 35 43 29)
#(33 33 22 41 43 24 40 41 27 43 42 43 42 26 43 29 24)
#(33 33 32 25 34 35 32 40 38 42 41 35 43 42 43 34 32 43 31 34 42 25 34 29)
#(34 27 37 36 42 41 35 43 42 35 34 22 41 33 35 43 32 27 39 10 34 42 43 34 29)
#(42 27 43 42 41 35 43 8 43 22 32 41 33 33 33 22 42 27 43 29)
#(41 34 42 43 22 35 43 32 39 39 42 25 43 34 31 35 34 12 22 38 43 42 41 43 42 41 35 43 29)
#(42 41 35 25 34 42 43 32 41 35 39 22 39 42 41 43 42 27 39 29)
#(41 33 33 22 39 25 32 31 25 43 32 37 25 29)
#(41 43 22 38 37 33 30 13 31 7 35 34 32 34 22 29)
#(41 33 25 33 22 41 43 42 25 32 22 25 43 42 25 43 32 31 22 42 25 43 42 41 29)
#(41 43 42 41 13 35 34 22 42 25 32 42 25 29)
#(26 43 32 41 33 33 33 32 22 35 42 7 42 41 43 32 27 25 37 25 42 41 43 42 43 29)
#(41 43 22 35 42 34 29)
#(24 41 43 20 36 38 42 31 39 25 35 34 32 24 22 33 33 32 43 42 33 43 42 33 33 29)
#(24 41 43 14 22 14 22 27 42 41 43 14 22 42 32 31 41 43 14 22 14 20 36 14 22 39 29)
#(41 40 41 35 43 29 24)
#(33 33 22 41 43 40 39 27 39 42 41 35 43 29)
#(13 42 43 43 39 40 42 35 34 12 28 27 37 36 43 42 41 43 34 37 36 41 35 43 32 14 31 35 34 22 29)
#(24 43 30 38 31 41 25 40 41 43 9 40 39 42 25 34 32 24 22 33 33 29)
#(24 41 43 42 41 35 34 28 39 27 39 31 39 29)
#(14 28 39 42 38 29 24)
#(33 33 32 43 42 33 43 42 33 29 33 31 33 32 42 33 32 22 43 43 40 27 41 34 35 29)
#(14 40 42 41 35 34 38 42 43 43 40 24 39 38 24 34 42 8 41 43 40 38 29)
#(43 43 40 24 27 41 35 37 41 43 42 35 31 14 28 43 20 36 43 42 14 32 24 14 22 29)
#(43 43 38 42 42 33 30 35 43 29)
#(43 43 22 37 25 25 29)
#(27 31 27 34 22 42 39 29)
#(42 41 25 34 9 22 34 32 25 22 31 25 22 29)
#(25 35 43 43 32 33 32 22 41 43 43 29)
#(41 43 32 9 22 33 42 25 25 32 22 39 35 42 25 25 31 39 35 42 25 25 42 27 42 25 25 32 39 25 29)
#(14 22 41 27 43 42 34 42 33 33 29)
#(41 43 22 25 25 42 43 42 14 20 36 37 36 41 43 42 34 42 14 20 39 39 36 41 43 42 26 35 43 32 33 33 32 42 26 43 43 32 33 29)
#(41 43 22 39 37 36 25 25 10 42 25 25 29)
#(42 41 43 32 33 33 22 41 43 42 33 34 42 34 42 41 43 42 35 34 42 33 43 38 42 17 25 25 29)
#(11 41 43 32 33 33 22 10 34 42 26 35 35 43 38 33 25 29)
#(33 33 22 25 25 37 25 42 25 25 34 29)
#(41 43 42 43 31 36 43 22 35 43 34 9 22 10 42 34 22 38 29)
#(41 43 39 22 34 42 27 25 35 43 34 38 42 35 25 32 27 35 33 29)
#(41 20 36 41 43 42 41 43 37 25 32 42 25 42 35 25 29)
#(24 41 43 14 28 38 27 42 35 43 42 41 43 29)
#(41 43 20 39 36 38 10 32 24 22 33 33 32 41 33 33 33 43 32 42 41 43 29)
#(33 32 41 43 42 35 43 34 32 39 22 10 35 34 29)
#(26 34 22 25 37 25 25 29)
#(31 35 34 22 39 41 43 42 41 43 30 43 20 36 43 29)
#(33 15 22 25 25 37 25 25 42 25 25 34 39 42 41 34 43 22 41 25 43 43 42 35 43 29)
#(33 33 22 25 37 25 25 42 35 43 42 27 42 35 34 38 37 17 25 41 43 42 17 25 41 43 41 43 11 29)
#(39 32 41 43 27 43 30 43 34 22 37 17 25 25 42 17 25 25 41 43 11 29)
#(33 33 22 25 37 25 29)
#(31 26 35 34 22 37 25 34 41 43 42 25 34 41 43 35 43 29)
#(33 15 22 25 37 36 25 29)
#(41 43 32 9 40 43 43 32 22 39 10 35 43 42 26 35 35 43 32 9 38 33 25 29)
#(33 33 33 32 25 32 22 38 43 31 35 27 43 42 41 39 38 43 29)
#(41 43 22 38 35 42 10 42 41 43 29)
#(33 33 22 38 35 43 43 42 34 29)
#(42 43 32 33 33 33 32 25 32 43 31 35 43 32 22 14 20 36 42 35 34 42 43 42 43 42 41 43 29)
#(33 33 22 42 43 42 43 29)
#(33 33 40 43 42 43 42 41 43 30 39 38 35 32 41 33 33 33 29)
#(39 32 33 33 33 32 25 32 22 38 35 43 43 32 43 31 35 35 43 29)
#(33 33 22 42 10 42 41 43 42 41 34 29)
#(33 33 22 38 43 35 43 37 41 43 29)
#(39 35 34 20 36 26 35 43 43 42 27 42 33 33 31 33 33 18 24 34 31 34 42 27 41 33 32 24 42 33 33 32 43 43 32 33 43 16 29)
#(33 33 22 43 34 31 34 29)
#(14 22 42 34 42 43 22 35 42 35 43 31 35 43 42 41 33 33 29)
#(39 43 43 43 31 41 35 43 22 38 42 43 4 31 43 34 42 41 43 42 41 35 43 29)
#(33 42 41 35 43 22 38 39 37 27 43 31 35 43 29)
#(39 41 35 43 22 41 43 42 35 43 34 32 9 22 35 43 29)
#(41 43 39 22 26 35 43 43 32 38 35 43 31 39 38 43 31 43 29)
#(13 35 34 22 38 42 41 35 43 29)
#(33 33 39 22 42 25 42 41 43 42 33 33 30 43 24 33 33 29 24)
#(39 39 32 35 34 22 37 36 27 9 22 35 34 20 36 41 38 32 35 43 39 42 41 43 42 41 43 29)
#(41 35 34 22 38 42 35 34 42 33 33 32 33 33 32 33 33 31 33 33 29)
#(27 42 41 25 33 33 22 42 41 35 43 20 36 38 42 25 34 32 31 33 33 22 41 43 42 43 20 36 42 25 29)
#(33 33 22 35 43 42 25 29)
#(21 22 39 10 29)
#(34 42 43 34 22 38 42 35 32 42 34 42 14 28 38 42 35 43 42 14 22 35 34 42 38 34 29)
#(35 42 25 22 41 35 34 42 43 43 32 43 43 31 43 43 32 41 42 9 22 27 35 43 31 35 43 29)
#(39 32 41 33 34 39 38 41 34 42 41 33 34 29)
#(35 43 34 28 35 43 31 43 42 26 43 29)
#(31 41 33 34 28 35 43 43 18 9 32 14 28 32 40 35 34 16 31 35 43 18 39 42 14 20 36 41 43 43 16 29)
#(14 28 42 41 43 42 27 41 43 42 35 34 31 34 42 43 31 39 36 35 34 42 43 35 42 35 43 29)
#(33 33 40 41 35 43 42 38 34 42 27 26 43 42 43 31 41 43 42 35 43 29)
#(36 30 36 26 34 42 27 43 34 42 41 35 43 42 39 29)
#(33 33 33 33 32 33 29)
#(26 43 22 41 35 34 42 41 43 42 24 41 33 33 4 28 14 27 29 24)
#(33 31 35 32 41 34 38 42 41 35 34 28 41 35 43 42 34 27 42 41 35 34 42 41 35 43 29)
#(36 32 42 43 32 41 43 43 31 43 43 4 35 35 35 34 32 27 25 42 41 33 33 42 33 32 43 21 40 41 10 42 25 43 43 42 41 35 43 42 41 43 29)
#(41 43 22 37 36 41 43 42 41 43 43 32 39 37 36 37 36 43 34 42 41 43 14 29)
#(31 22 14 22 37 36 41 43 42 35 34 32 42 35 34 22 38 29)
#(41 43 22 38 37 36 41 35 43 32 39 36 41 43 42 43 29)
#(41 43 39 22 43 31 43 28 27 8 14 40 37 35 43 43 29)
#(41 40 37 41 39 35 43 42 43 29)
#(42 41 34 28 37 36 10 42 27 41 43 42 41 35 31 35 34 32 42 39 20 36 38 35 43 29)
#(41 43 20 39 39 36 41 35 43 32 37 36 38 42 42 41 35 43 42 35 34 42 43 29)
#(14 28 39 38 41 43 31 43 42 26 43 30 43 29)
#(41 40 34 42 12 14 28 39 38 9 20 36 39 27 37 35 31 35 34 29)
#(41 34 42 41 43 28 39 38 32 39 39 38 42 26 35 43 42 43 31 39 35 42 14 40 35 14 20 36 35 37 36 14 39 42 35 34 28 38 42 10 42 25 34 29)
#(41 43 42 41 35 43 40 42 21 40 35 43 37 36 35 43 34 29)
#(41 32 14 28 39 27 29)
#(33 33 33 33 33 42 33 33 33 33)
#(33 15 33 32 27 26 35 34 43 42 25 32 22 26 35 35 43 22 25 43 42 35 43 29)
#(38 42 10 43 34 31 27 43 43 32 41 43 33 43 43 22 43 22 37 17 25 25 32 31 25 34 41 43 32 42 17 25 25 32 31 25 34 41 43 32 41 43 11 29)
#(41 34 22 34 42 34 32 12 22 39 38 26 34 42 41 43 22 42 35 33 42 26 25 34 20 36 39 35 42 25 43 29)
#(41 43 43 22 43 42 33 15 34 42 26 25 43 29)
#(35 43 22 35 42 17 25 25 29)
#(41 35 34 32 39 32 22 41 34 42 41 43 43 32 9 22 38 35 33 29)
#(27 41 43 43 32 33 15 30 43 32 38 42 34 42 43 32 22 39 25 43 29)
#(41 43 40 39 42 41 43 30 25 43 37 36 43 43 43 42 35 34 32 31 42 43 42 35 43 34 42 41 35 43 29)
#(41 13 35 43 39 40 42 41 39 35 25 43 43 42 41 35 43 29)
#(33 15 22 41 10 43 42 26 43 34 32 9 22 42 25 43 10 42 41 35 43 29)
#(34 28 38 38 37 27 34 42 38 34 42 35 34 29)
#(33 15 22 14 22 37 36 43 42 43 31 43 34 37 36 37 36 34 42 27 29)
#(41 43 22 14 40 34 20 36 37 35 35 34 29)
#(41 43 22 41 43 42 41 25 43 43 42 27 32 35 31 35 34 4 37 17 25 25 4 37 43 34 29)
#(24 14 28 42 39 27 42 35 32 27 37 36 34 42 42 43 32 24 22 33 33 32 41 43 42 33 32 33 31 33 29)
#(42 41 25 34 32 33 15 30 43 22 25 43 37 17 25 25 32 31 25 34 41 43 32 42 17 25 25 32 31 25 34 41 43 29)
#(43 22 35 42 39 17 25 25 29)
#(33 15 32 9 40 35 42 33 33 32 39 22 14 22 42 25 25 42 26 35 34 42 41 35 43 29)
#(41 43 40 43 42 41 35 43 43 32 42 9 33 15 39 39 40 38 41 43 42 25 25 34 29)
#(39 32 33 32 35 33 33 32 42 38 32 22 35 35 43 22 25 43 37 17 25 25 32 31 17 25 41 43 32 42 17 25 25 32 31 25 34 41 43 29)
#(34 22 25 43 37 17 25 25 42 17 25 25 29)
#(41 35 43 30 34 28 41 35 43 42 17 25 25 42 41 43 42 41 43 42 33 29)
#(42 35 43 42 41 33 33 33 33 32 33 15 22 42 17 25 41 43 32 39 25 34 29)
#(33 22 42 17 25 41 43 32 42 17 25 29)
#(33 33 33 40 38 37 36 41 43 42 43 41 43 37 36 33 33 33 37 43 32 28 34 35 42 41 34 29)
#(33 33 32 38 42 33 32 38 42 43 25 43 43 11 41 43 29)
#(39 32 26 43 43 32 33 33 42 33 32 33 32 40 27 38 42 41 35 43 29)
#(14 40 38 42 33 33 33 32 41 34 43 42 33 33 33 32 20 36 43 42 41 43 42 41 38 35 43 42 33 32 38 42 33 32 33 29)
#(41 43 42 33 33 22 37 36 29)
#(33 33 40 41 27 43 42 33 33 29)
#(14 40 27 17 25 25 42 43 43 37 41 43 31 40 38 37 36 39 35 42 17 25 25 42 43 42 33 33 31 33 31 33 33 32 33 33 30 25 39 38 43 34 29)
#(33 33 32 35 35 43 42 41 35 43 43 32 31 33 33 32 35 43 42 33 33 33 32 41 22 37 36 29)
#(39 32 33 33 40 25 43 42 41 43 4 33 33 22 26 25 43 43 42 41 43 42 33 25 29)
#(42 41 43 32 41 33 43 22 25 34 42 43 29)
#(43 32 21 28 25 34 32 41 38 42 43 34 29)
#(42 35 34 33 33 40 38 41 43 42 26 34 31 22 14 37 36 34 42 43 27 14 20 36 27 43 37 41 43 27 41 43 32 28 41 43 42 41 43 29)
#(41 43 32 41 43 42 35 35 34 28 38 32 27 34 42 34 32 31 33 33 39 22 34 42 14 20 39 36 43 34 29)
#(42 41 43 38 33 25 32 25 32 33 15 22 17 25 25 42 43 31 27 43 42 17 25 25 29)
#(41 43 43 22 38 42 42 43 42 33 29)
#(27 37 41 43 42 41 43 32 35 34 22 33 33 33 42 33 31 33 33 33 29)
#(33 33 33 40 27 33 33 42 41 43 42 41 33 43 29)
#(33 22 41 35 42 41 43 42 35 34 38 42 33 33 29)
#(41 43 22 38 42 33 42 25 42 25 34 32 33 31 33 33 32 12 22 42 33 30 15 29)
#(42 25 32 41 43 43 41 43 42 43 32 42 33 31 26 43 32 33 32 27 37 36 42 41 33 33 43 29)
#(41 43 42 33 15 40 43 37 43 42 33 33 33 42 33 33 33 29)
#(42 11 22 32 33 33 41 43 22 41 17 25 25 43 42 26 25 43 34 32 31 35 34 42 41 43 38 42 33 43 43 33 33 31 33 33 33 32 41 33 43 31 35 33 33 35 43 29)
#(41 43 32 9 22 39 36 41 33 43 32 40 27 38 42 33 33 29)
#(33 33 33 22 38 43 31 35 35 43 42 41 43 30 33 33 43 29)
#(33 33 22 38 43 31 35 43 42 33 33 33 29)
#(33 33 33 32 35 43 31 35 43 42 33 32 20 36 41 43 42 43 42 41 43 32 41 43 43 29)
#(41 34 20 36 38 42 35 34 27 33 32 41 33 33 31 41 15 29)
#(33 32 41 43 42 43 32 35 31 35 43 34 31 41 43 42 33 34 32 8 34 28 41 43 38 32 40 27 27 42 42 41 43 43 29)
#(39 32 43 34 28 32 14 20 24 36 24 42 40 42 41 43 9 40 39 38 42 41 43 43 4 34 29)
#(24 21 40 36 42 41 27 31 14 28 39 27 42 41 43 42 10 31 10 43 32 24 22 33 33 33 32 43 43 42 43 31 43 42 33 33 33 32 41 43 42 33 33 33 29)
#(33 33 22 42 33 33 33 33 33 32 12 22 37 36 38 32 40 24 27 42 34 39 31 20 36 41 34 42 41 43 42 43 29 24)
#(14 22 37 36 29)
#(33 30 34 20 36 42 35 43 37 34 40 32 42 41 43 22 37 36 29)
#(25 35 33 43 32 33 42 33 32 40 37 36 41 33 33 43 43 42 42 33 31 36 14 42 41 35 43 29)
#(41 35 43 20 36 38 42 34 42 33 34 29)
#(24 14 28 21 40 41 43 42 41 43 9 40 39 27 38 42 41 43 32 42 14 28 37 36 41 43 32 24 40 33 30 35 43 32 33 33 29)
#(24 14 28 39 36 34 39 29)
#(14 39 22 42 43 43 32 42 13 32 42 41 43 30 35 34 29 24)
#(41 33 43 40 41 43 20 24 39 36 24 41 33 43 32 31 40 14 40 41 35 43 37 36 29)
#(34 42 41 43 34 42 33 33 31 33 33 33 32 28 21 28 41 34 37 36 41 34 30 43 42 33 34 29)
#(41 35 43 42 33 43 40 39 39 35 42 41 34 29)
#(21 40 38 41 43 42 38 34 30 40 37 35 34 32 39 39 42 43 42 34 42 34 31 42 43 34 35 42 33 31 41 33 33 29)
#(42 41 35 43 32 21 40 37 36 41 43 42 35 43 4 33 33 33 33 30 33 33 33 40 26 13 34 32 42 42 35 43 32 42 33 34 29)
#(33 40 42 35 34 38 27 34 42 41 33 43 42 24 43 32 24 9 40 38 42 33 33 29)
#(41 43 30 35 43 43 32 33 15 32 40 41 43 35 43 38 24 33 42 41 33 29 24)
#(33 15 31 33 33 20 36 41 43 42 35 33 43 40 32 41 43 9 20 36 34 29)
#(35 34 32 9 28 38 42 42 43 34 32 43 41 43 39 17 25 42 43 29)
#(33 31 33 33 22 35 35 43 22 25 43 37 17 25 25 32 31 25 34 41 43 29)
#(42 41 35 43 32 41 34 43 22 43 42 17 25 25 32 31 25 34 41 43 29)
#(34 22 17 25 25 32 42 25 43 42 17 25 25 41 43 39 29)
#(33 31 33 32 9 40 37 36 27 25 35 43 34 41 43 32 22 41 43 43 39 37 10 35 43 29)
#(41 43 39 22 41 10 43 32 9 40 41 43 42 35 43 8 14 40 38 42 34 29)
#(42 43 32 41 43 22 32 14 22 38 42 10 42 35 34 42 35 34 32 42 41 34 28 38 42 41 35 43 29)
#(39 10 43 42 41 34 9 28 42 35 43 39 40 38 42 34 32 35 42 43 43 29)
#(42 41 25 34 32 33 31 33 43 22 17 25 25 32 31 17 25 41 43 32 39 25 43 42 17 25 25 32 31 17 25 41 43 32 41 43 39 29)
#(34 22 25 43 37 17 25 25 42 17 25 25 41 35 43 29)
#(42 33 33 33 33 35 43 32 33 31 33 22 42 17 25 41 43 32 39 17 25 29)
#(33 33 33 32 43 34 35 32 22 38 43 31 35 35 43 42 41 43 42 35 34 32 27 33 33 33 29)
#(33 33 32 25 32 22 42 43 31 35 43 31 20 36 42 35 34 32 22 33 33 33 32 43 29)
#(33 33 39 22 43 31 35 43 42 33 31 33 33 31 22 41 43 42 33 33 42 25 29)
#(33 33 33 22 38 27 43 31 43 43 42 43 43 42 33 32 38 42 33 29)
#(33 33 32 25 34 35 32 22 38 41 35 43 43 42 41 35 43 42 43 43 29)
#(14 40 33 33 32 12 22 42 33 29)
#(41 40 38 37 36 41 43 42 26 33 25 43 24 33 42 33 33 33 20 36 33 42 27 25 34 29 24)
#(42 41 43 32 14 22 38 37 36 22 32 24 41 43 42 35 43 43 40 39 27 35 43 42 14 40 39 27 41 43 29 24)
#(14 22 39 36 41 32 31 14 28 39 38 37 41 43 38 42 41 43 29)
#(14 28 39 38 31 20 39 36 35 43 42 41 25 34 32 43 31 35 32 37 41 42 26 43 34 29)
#(42 41 43 14 28 38 34 42 35 43 43 42 43 4 31 41 40 41 34 12 28 27 42 43 29)
#(41 40 39 39 35 39 29)
#(14 28 41 43 12 39 40 42 43 34 32 41 43 31 43 32 20 36 41 43 42 43 10 42 41 29)
#(26 43 32 36 39 42 41 38 43 35 37 41 34 27 41 33 33 33 43 43 32 22 41 27 4 24 33 35 34 28 39 42 43 27 37 36 41 34 29)
#(41 43 34 28 37 41 43 39 39 41 39 13 43 9 14 28 38 43 31 39 41 43 42 43 39 10 29)
#(14 28 41 43 42 35 43 40 27 35 43 42 14 40 39 38 41 43 29 24)
#(14 28 39 35 34 42 39 11 35 34 42 41 43 42 43 43 42 41 34 39 39 29)
#(41 43 32 39 32 20 39 36 38 42 14 28 43 31 35 42 41 27 43 29)
#(33 33 33 33 29 33 33 33 32 33 29)
#(41 43 31 43 34 32 38 42 26 43 42 33 33 30 43 42 34 9 28 42 43 34 32 22 41 35 43 43 9 20 36 42 41 35 43 29)
#(34 42 41 33 25 43 34 31 25 43 34 22 14 28 27 42 37 36 41 7 35 43 42 27 34 30 43 34 32 42 41 43 42 41 43 42 43 29)
#(39 32 26 43 39 20 39 36 35 43 31 35 43 4 41 25 35 43 34 4 42 34 37 36 38 42 35 43 29)
#(39 32 41 34 20 36 39 42 35 34 42 43 32 9 28 39 35 31 9 41 43 43 40 38 27 42 41 43 42 43 43 9 40 27 35 34 29)
#(34 22 41 43 42 39 41 34 28 37 36 42 41 33 33 43 37 36 41 25 34 41 43 9 28 42 35 34 42 25 29)
#(42 35 43 34 28 38 27 42 35 43 34 42 34 32 39 33 33 33 40 39 27 41 43 43 42 10 34 39 27 42 35 43 29)
#(41 35 17 25 25 43 43 20 36 41 7 35 43 37 36 42 38 34 32 22 33 33 32 43 42 34 31 34 42 33 15 33 43 34 29)
#(14 20 36 25 35 34 42 34 42 25 34 42 42 37 25 43 43 29)
#(41 35 43 42 43 32 9 40 39 27 38 32 20 36 38 34 42 10 43 34 39 27 38 42 43 42 25 31 25 34 29)
#(21 22 41 43 43 42 41 35 43 29)
#(24 41 35 43 39 40 41 43 31 43 34 28 35 34 32 24 22 33 33 32 41 35 43 43 42 43 42 33 33 29)
#(24 31 14 28 27 42 41 7 35 43 37 36 42 41 43 29 24)
#(31 33 33 32 41 35 43 42 41 33 33 33 33 32 22 41 43 40 39 37 36 41 43 37 36 38 43 29)
#(33 31 43 34 22 41 43 42 33 33 35 43 37 36 33 33 30 34 37 36 43 34 37 36 27 35 34 42 25 29)
#(39 32 41 33 43 22 41 34 28 9 39 40 38 43 42 41 43 29)
#(41 33 43 40 22 14 20 36 37 36 26 43 8 41 33 33 31 33 33 40 42 41 35 35 43 29)
#(33 33 32 43 42 41 33 33 33 33 32 22 33 33 31 33 33 20 36 38 38 42 41 43 42 25 37 36 34 42 14 22 20 36 34 39 35 42 17 25 25 29)
#(33 33 32 12 40 38 41 43 30 35 43 43 32 22 41 34 42 33 32 38 42 33 32 33 32 42 26 35 43 22 38 42 41 35 35 43 43 29)
#(14 22 26 34 42 33 33 33 34 37 36 12 40 37 36 41 13 43 43 42 41 35 43 29)
#(41 43 39 20 36 41 34 42 33 33 33 32 12 40 43 42 33 33 33 32 33 30 43 32 31 12 22 39 37 35 33 34 29)
#(33 33 22 41 43 42 41 33 33 33 32 41 43 38 37 36 35 34 32 40 38 33 30 43 34 42 35 34 27 39 37 25 29)
#(24 26 43 22 9 22 14 22 35 34 42 25 42 26 35 34 32 14 20 36 38 41 35 35 43 37 36 41 35 34 32 24 33 33 22 29)
#(8 33 22 38 42 41 43 32 42 43 32 25 43 42 26 34 32 31 17 25 25 32 22 37 34 12 22 27 35 43 42 25 42 33 33 30 25 35 34 32 27 37 33 33 29)
#(31 41 43 22 39 36 42 42 25 34 39 32 8 43 34 28 33 42 43 4 41 43 42 33 33 22 42 43 25 43 43 42 34 29)
#(41 43 43 32 41 43 40 38 42 41 17 25 25 35 43 32 22 43 42 41 43 37 36 38 34 37 41 43 43 32 9 22 41 34 42 41 43 42 43 34 29)
#(41 34 9 28 38 38 37 35 34 28 39 42 41 43 42 41 43 43 29)
#(24 14 28 14 40 39 35 18 33 33 16 22 32 24 42 34 22 38 37 36 33 32 33 33 22 29)
#(35 43 32 14 22 32 20 36 42 35 34 42 33 30 34 32 22 33 33 32 24 27 43 34 29 24)
#(33 33 32 42 26 43 32 40 38 43 27 42 34 39 38 41 43 29)
#(33 33 32 41 43 42 33 42 33 33 32 22 37 36 42 41 34 32 36 37 36 32 24 14 20 36 27 39 42 35 34 37 41 42 41 34 42 41 35 43 29 24)
#(33 30 43 42 35 43 34 32 42 41 43 38 42 41 35 43 32 40 38 35 42 25 34 12 22 34 42 34 42 43 34 42 33 33 29)
#(33 33 22 43 32 42 43 32 42 33 33 33 18 33 32 33 16 32 12 22 17 25 42 34 42 33 33 32 22 33 33 37 36 42 14 28 42 41 43 42 33 42 14 20 36 38 29)
#(42 41 43 43 22 38 42 33 32 33 33 22 41 43 34 29)
#(41 43 30 43 22 43 42 14 22 42 41 43 42 33 42 24 34 42 33 34 18 42 33 16 22 42 41 43 29 24)
#(33 33 33 33 33 33 18 33 32 33 29 16 40 39 38 34 14 22 42 33 33 41 43 39 29)
#(33 33 33 18 33 32 33 16 32 33 33 32 18 33 32 33 16 31 33 33 18 33 32 33 16 39 22 35 34 42 33 33 31 22 37 36 42 43 42 33 29)
#(33 33 33 33 33 33 18 33 32 33 16 22 33 33 22 37 36 42 41 33 43 32 42 35 29)
#(31 41 43 43 43 22 41 43 40 35 37 36 39 41 43 42 41 34 29)
#(42 41 43 32 33 33 22 41 33 40 39 38 17 25 25 42 33 42 43 29)
#(14 39 22 42 35 43 42 43 42 34 42 17 25 25 42 33 33 22 43 29)
#(41 42 41 34 28 38 41 43 32 27 14 22 14 22 27 35 34 42 43 29)
#(24 14 28 41 34 42 41 43 37 36 42 41 34 32 24 14 22 29)
#(33 15 30 34 43 32 35 42 41 43 30 34 42 27 42 43 34 32 22 26 35 34 37 36 35 34 37 41 43 29)
#(34 42 41 43 43 42 33 31 33 31 41 34 43 42 33 32 33 31 33 32 38 42 34 37 36 42 33 30 35 34 32 22 41 43 42 41 35 43 43 42 33 30 13 43 37 36 42 43 43 40 39 10 42 41 11 25 9 22 41 34 30 43 29)
#(27 37 25 43 35 42 41 43 32 33 30 35 43 40 39 24 39 35 29 24)
#(38 42 41 34 30 34 32 41 33 43 22 24 14 39 28 29 24)
#(14 22 14 28 24 38 31 22 41 35 34 9 28 26 43 39 35 29 24)
#(42 41 35 43 43 39 32 33 33 32 43 42 33 30 43 33 33 33 32 22 33 22 27 26 34 42 27 39 42 43 31 22 14 20 36 42 43 25 43 42 34 35 35 43 32 27 42 10 43 42 14 39 22 38 29)
#(14 22 32 42 14 40 39 32 42 34 20 36 38 42 35 42 41 43 29)
#(33 33 22 41 43 42 34 30 35 43 37 26 43 29)
#(24 14 28 42 41 43 42 27 41 38 43 42 41 34 31 36 43 9 22 43 39 32 24 33 33 22 34 29)
#(24 14 28 27 31 27 26 34 32 24 14 22 29)
#(42 33 32 33 31 26 34 22 42 41 43 43 9 22 42 33 37 36 17 25 25 42 34 31 37 36 42 43 43 42 34 26 35 43 29)
#(31 42 27 42 34 35 42 26 33 33 43 32 26 33 43 31 35 34 32 33 22 41 27 43 29)
#(14 20 39 36 26 35 35 34 32 25 42 41 35 34 38 42 43 29)
#(41 34 32 38 42 41 34 30 34 42 39 17 25 25 32 22 37 36 38 37 33 33 30 33 15 29)
#(41 35 43 42 34 42 33 32 42 41 35 43 42 33 31 41 33 33 43 32 22 41 43 37 36 29)
#(33 39 22 14 20 36 37 36 31 36 41 34 14 32 9 20 36 14 42 10 43 42 26 43 29)
#(14 39 20 36 33 41 10 43 42 41 35 25 38 42 41 35 43 29)
#(41 34 42 26 43 22 41 43 43 39 22 37 34 20 36 37 36 38 29)
#(42 39 32 33 40 38 27 42 34 42 34 32 31 41 34 43 40 38 27 34 42 41 34 29)
#(41 43 40 25 34 42 34 14 40 42 37 36 33 30 34 29)
#(41 22 41 35 43 20 39 36 29)
#(33 31 33 22 33 30 34 20 36 26 34 42 34 42 43 32 43 31 43 42 17 25 25 32 31 42 33 30 43 22 41 43 43 32 27 37 41 43 35 42 43 30 43 29)
#(34 42 33 33 22 33 20 36 41 35 43 42 17 25 25 37 17 25 25 32 41 43 22 29)
#(41 34 22 14 22 33 20 36 37 36 35 43 37 36 26 34 32 31 42 14 20 36 39 10 43 42 38 29)
#(35 34 39 20 36 32 27 43 32 42 33 40 41 10 43 29)
#(42 41 43 43 32 33 33 31 33 33 33 33 22 41 39 10 43 29)
#(38 42 43 34 32 34 31 43 34 38 42 35 35 35 34 32 14 22 33 40 38 26 35 34 31 40 27 26 34 29)
#(27 35 43 32 33 20 36 27 25 34 35 39 42 41 39 38 25 32 14 22 29)
#(33 33 22 37 36 42 33 30 35 34 32 31 22 14 22 39 36 33 20 36 37 36 42 41 43 42 43 34 39 38 42 43 29)
#(41 34 28 35 25 25 34 32 39 42 43 34 29)
#(41 43 33 40 37 36 32 14 22 32 40 42 33 37 36 17 25 25 42 43 42 43 30 43 29)
#(41 14 31 33 33 22 41 43 20 36 38 42 33 29)
#(42 37 34 42 34 32 33 33 22 42 34 42 41 43 24 14 20 36 37 36 8 14 18 34 16 36 42 29 24)
#(39 32 14 22 32 24 14 40 39 41 43 42 41 43 36 38 42 34 29)
#(14 20 36 38 42 41 43 29 24)
#(42 43 43 32 33 40 35 34 42 41 35 43 37 36 26 35 43 43 29)
#(41 43 40 38 38 39 31 20 36 38 39 29)
#(42 33 20 36 43 43 32 43 43 42 26 43 20 36 39 35 29)
#(31 34 28 35 37 36 42 43 43 42 26 35 43 32 31 41 43 20 36 41 34 31 36 26 35 29)
#(42 41 43 32 41 34 35 42 41 43 43 42 41 43 20 36 42 33 42 43 42 33 33 31 33 33 29)
#(33 22 43 43 41 35 34 42 41 35 43 22 33 25 29)
#(33 33 22 34 41 43 33 40 27 20 36 41 43 25 43 37 25 43 42 41 43 42 41 43 33 29)
#(14 22 14 20 36 27 42 25 34 41 43 42 35 43 32 39 39 10 42 41 43 30 35 43 42 25 41 43 29)
#(34 42 27 41 35 35 43 42 25 28 27 29)
#(41 43 42 27 41 25 43 43 32 38 42 14 40 43 22 41 35 43 32 40 35 42 41 43 42 25 32 40 37 25 30 43 43 29)
#(31 7 34 28 42 41 43 9 40 37 36 38 40 42 35 43 4 14 28 38 27 37 36 14 42 41 43 29)
#(34 31 33 33 33 22 41 43 43 42 41 27 33 43 43 32 31 41 43 40 42 37 36 41 35 43 43 29)
#(39 41 33 30 35 43 40 41 43 37 36 42 41 35 43 29)
#(34 42 43 43 42 41 34 42 27 14 42 41 35 43 28 27 29)
#(24 14 28 14 40 35 43 42 41 33 43 32 24 40 33 33 42 33 31 33 32 34 29)
#(42 41 43 40 39 38 32 14 40 32 24 14 28 38 27 42 34 9 28 39 35 37 36 32 42 21 28 39 35 35 43 34 37 36 29 24)
#(31 33 39 20 36 41 43 42 35 43 41 43 31 35 32 33 40 29)
#(33 40 34 20 36 36 42 35 34 42 43 34 29)
#(41 43 40 35 34 38 42 41 43 42 43 34 32 39 39 42 34 39 38 42 35 25 34 29)
#(14 40 34 28 37 36 43 34 42 41 25 31 38 25 34 32 9 40 41 10 43 43 4 14 28 42 33 25 37 36 29)
#(27 41 25 43 37 36 41 43 40 43 11 4 31 42 35 34 32 21 28 35 34 37 36 32 34 43 33 33 29)
#(41 43 4 42 43 34 4 40 35 39 37 41 43 42 14 40 17 25 31 42 41 43 30 35 34 28 25 43 42 38 35 43 4 34 20 36 41 43 8 43 40 10 31 34 10 29)
#(42 27 41 35 18 39 38 16 43 32 41 43 20 36 42 38 43 40 38 39 31 39 31 42 25 43 40 10 43 4 9 20 36 42 14 20 36 39 31 39 29)
#(41 33 40 35 34 42 33 30 34 29)
#(34 42 25 42 34 42 35 43 34 22 35 33 32 31 41 33 40 34 42 41 43 34 20 39 36 38 42 35 43 42 26 34 28 38 24 33 24 31 38 42 33 25 29)
#(43 20 36 38 42 35 34 32 31 43 34 42 41 34 20 36 38 42 41 43 35 31 38 40 25 43 31 10 42 41 43 29)
#(33 43 25 40 41 31 35 43 43 42 33 30 34 29)
#(42 41 34 4 35 34 42 34 35 35 33 20 39 36 38 42 14 28 4 31 36 41 43 4 31 36 43 35 42 33 25 29)
#(35 34 35 42 33 25 31 33 25 20 36 38 37 33 25 29)
#(34 20 39 36 38 42 27 35 34 35 33 25 31 42 27 38 34 32 31 35 34 20 36 38 42 34 38 42 33 25 29)
#(41 43 39 40 43 42 35 35 34 29)
#(35 34 42 41 35 43 22 34 42 35 34 42 33 33 33 33 32 41 33 33 32 33 32 43 42 35 34 29)
#(41 33 22 43 34 42 43 42 41 34 22 37 36 39 29)
#(31 41 33 33 22 41 34 22 35 31 35 31 22 41 34 29)
#(43 34 12 28 37 36 34 36 42 27 34 38 42 35 34 28 41 34 42 41 33 33 43 29)
#(27 42 41 43 20 36 17 25 25 41 43 32 34 22 41 43 42 25 35 34 31 24 34 24 42 35 34 29)
#(8 41 33 33 40 32 41 43 42 41 35 43 43 20 36 34 25 27 43 34 27 37 41 43 31 41 43 32 42 34 37 41 43 31 34 29)
#(33 43 43 25 40 41 27 34 29)
#(10 42 41 43 22 41 43 43 30 43 42 43 29)
#(34 39 28 43 31 43 42 34 37 36 43 34 37 41 33 29)
#(33 33 33 42 33 32 33 32 41 35 32 35 35 43 32 22 41 43 37 41 33 33 29)
#(31 34 39 28 41 35 43 40 37 36 43 42 38 43 4 31 41 33 22 33 20 36 38 35 43 4 42 14 22 41 43 4 42 14 22 17 25 42 41 43 43 42 25 42 27 43 42 39 17 25 29)
#(33 30 43 4)
#(41 34 22 42 34 22 42 41 33 43 4 14 22 17 25 42 25 42 27 42 43 34 31 27 34 31 17 25 42 35 34 42 26 35 43 32 12 22 38 41 43 42 25 29)
#(33 22 41 43 4 31 43 42 26 43 31 43 42 26 43 31 42 41 43 42 26 43 31 34 22 41 43 42 33 22 35 31 26 43 42 34 22 35 29)
#(41 33 22 41 43 42 38 34 42 35 43 32 39 33 33 22 26 34 29)
#(34 4)
#(38 8 14 22 35 34 42 17 25 42 42 38 35 43 42 17 25 32 33 33 33 42 33 32 33 32 22 41 33 33 14 22 38 26 43 29)
#(41 43 22 26 35 34 32 22 26 34 32 31 22 41 43 43 4 29)
#(33 33 18 33 32 33 16 22 41 43 37 36 42 43 34 42 34 27 37 41 43 42 35 34 29)
#(33 33 34 26 43 31 40 42 39 41 43 32 35 43 39 35 39 42 43 34 29)
#(42 41 35 43 32 14 40 38 42 41 43 43 4 41 43 42 35 34 42 41 35 35 43 29)
#(41 43 40 25 34 42 41 35 43 4 41 35 43 42 41 43 32 31 22 42 33 33 31 25 34 42 41 35 25 34 42 27 35 43 34 29)
#(24 41 32 24 40 33 33 32 24 40 12 14 40 41 42 29 24)
#(25 25 34 39 32 34 42 41 33 33 32 33 32 43 43 28 42 41 35 12 28 39 39 28 41 43 29)
#(41 43 32 27 34 22 38 42 41 43 42 41 33 33 43 32 42 9 41 43 4 38 42 41 43 9 22 38 37 34 4 22 26 43 29)
#(41 43 22 37 36 38 4 41 34 22 31 22 39 38 29)
#(42 35 34 42 33 33 32 34 28 38 38 37 36 34 32 38 42 43 34 31 43 43 34 37 36 39 31 35 43 29)
#(14 28 39 38 34 42 43 42 34 42 34 31 34 22 14 22 27 38 42 34 29)
#(24 14 22 27 38 32 24 40 33 33 32 34 43 42 41 33 33 33 33 33 29)
#(25 34 39 32 41 43 22 37 36 41 34 37 36 34 42 26 25 35 34 29)
#(42 42 25 25 34 39 32 41 43 42 43 34 42 41 33 40 38 37 36 37 25 25 42 25 29)
#(42 13 6 41 43 20 36 38 42 41 35 25 34 39 29)
#(41 43 22 42 42 41 43 42 41 35 34 40 25 42 41 7 35 34 37 36 42 41 35 43 43 42 35 43 29)
#(34 4 43 42 14 35 34 4 36 26 43 41 35 32 35 32 35 43 37 36 39 37 43 32 42 27 41 43 32 42 34 32 37 36 42 35 34 29)
#(31 41 34 30 27 34 32 43 34 31 43 42 14 28 35 34 28 38 34 32 42 41 15 37 41 33 33 32 37 36 14 42 41 35 43 29)
#(33 37 41 43 40 42 41 34 32 42 35 34 32 20 36 39 39 32 31 42 35 34 20 36 34 42 43 29)
#(41 35 43 20 36 42 41 35 43 37 41 43 42 41 43 43 42 27 43 29)
#(35 34 28 34 37 36 39 35 43 34 42 34 42 42 37 25 34 41 43 4 41 43 42 41 43 31 41 43 42 35 34 31 34 29)
#(42 38 35 34 42 41 43 32 41 43 40 39 37 36 41 34 29)
#(41 43 42 33 32 27 41 43 42 41 35 34 32 39 38 34 9 22 39 41 27 34 42 43 34 37 43 34 29)
#(41 43 39 40 14 37 34 38 42 35 34 29)
#(13 35 34 28 38 35 34 29)
#(41 34 28 35 42 34 42 35 34 29)
#(39 41 33 33 33 32 2 35 24 35 24 43 40 38 34 42 34 42 34 42 26 34 42 41 33 32 40 38 37 36 41 34 37 41 34 32 27 35 34 42 41 35 33 33 33 32 9 40 42 33 37 33 29)
#(39 41 34 28 42 35 35 43 42 43 34 32 41 39 35 33 33 42 14 29)
#(33 40 38 35 42 27 41 43 42 41 33 34 29)
#(14 40 38 27 41 35 43 37 36 39 41 43 32 38 42 33 43 34 32 37 36 41 34 42 39 38 43 34 32 8 14 28 39 38 29)
#(39 33 30 35 43 40 38 43 42 41 43 42 41 43 32 9 40 42 25 43 42 26 25 34 35 43 34 29)
#(43 42 41 34 22 41 43 39 37 36 26 35 43 4 14 39 39 32 42 43 32 40 41 34 42 41 35 43 42 34 31 35 35 35 34 29)
#(31 41 43 39 40 42 35 34 20 37 36 38 37 41 34 42 34 28 41 34 20 39 36 41 43 31 35 34 29)
#(24 14 28 41 43 43 32 39 42 41 43 14 28 38 36 42 41 43 42 34 27 5 41 43 43 42 14 32 24 40 33 33 32 41 43 42 33 30 43 42 33 33 32 27 41 34 42 35 34 29)
#(24 34 12 28 42 34 20 36 38 42 41 43 28 39 27 42 41 35 43 32 24 40 33 33 32 35 43 42 33 31 33 33 43 42 33 33 32 33 29)
#(33 33 40 42 41 34 42 34 12 22 26 35 43 42 43 42 34 31 34 29)
#(14 40 43 34 28 41 35 43 42 41 43 42 14 22 42 34 4 35 28 38 42 41 43 43 20 39 36 14 41 43 29)
#(37 36 39 32 34 35 42 33 33 28 27 34 37 36 43 34 42 43 34 31 36 43 34 37 36 42 41 34 20 39 36 34 29)
#(33 33 30 43 32 33 33 15 33 32 38 43 34 37 36 36 35 35 33 33 33 34 38 42 27 29)
#(33 34 42 33 32 33 32 33 31 33 28 38 35 34 32 40 33 33 32 43 43 43 42 33 43 29)
#(41 34 28 38 27 37 36 41 43 43 30 43 4 42 41 33 35 43 43 8 41 43 22 38 42 41 43 41 43 34 28 38 41 43 43 37 36 34 36 34 32 31 37 36 34 42 35 43 43 29)
#(39 35 35 33 34 28 42 25 43 42 41 34 28 7 42 41 34 29)
#(42 41 28 43 34 12 35 43 34 32 35 35 43 39 40 43 9 20 36 38 42 24 43 31 43 43 32 24 40 33 33 32 41 43 42 41 33 33 33 33 29)
#(24 14 28 14 28 27 43 29 24)
#(35 20 36 38 35 41 43 8 32 41 43 39 32 41 33 33 43 34 22 41 35 43 27 35 34 32 35 43 31 35 43 29)
#(14 22 41 43 9 20 36 14 37 36 42 35 43 39 35 37 34 29)
#(14 22 41 43 11 35 32 11 35 31 42 35 34 10 37 36 42 41 35 43 34 42 39 22 41 43 29)
#(8 41 34 35 22 43 43 42 25 32 14 22 38 42 41 43 29)
#(35 43 32 25 43 42 41 25 25 34 38 42 41 33 22 43 34 29)
#(42 33 32 41 43 43 32 14 22 42 10 42 25 43 42 41 43 34 29)
#(41 43 42 41 34 39 39 36 14 42 41 35 43 29)
#(43 34 28 14 42 14 28 39 42 43 32 36 39 42 34 31 43 42 43 43 42 39 11 35 34 42 27 34 29)
#(33 33 32 43 25 32 40 41 43 42 41 43 29)
#(42 25 43 32 43 39 42 25 40 42 13 25 43 29)
#(41 43 40 43 37 41 33 33 33 42 33 31 14 40 41 35 33 33 33 33 29)
#(41 43 32 41 43 38 10 34 42 41 13 43 42 41 43 30 43 43 43 29)
#(33 33 32 43 42 41 33 33 33 43 32 40 42 41 43 30 43 20 36 41 43 42 43 31 43 29)
#(24 41 43 43 40 39 35 42 41 24 43 24 43 14 22 42 41 43 32 31 14 20 36 39 39 10 32 24 14 40 29)
#(41 27 34 22 39 38 42 41 33 31 33 33 4)
#(33 30 33 42 33 33 32 43 43 42 42 37 17 25 25 42 34 29)
#(33 33 33 33 32 41 43 42 33 33 33 32 43 42 17 25 25 35 35 43 43 34 32 42 33 33 33 15 29)
#(33 33 31 33 32 43 42 25 25 34 42 35 35 35 43 32 33 33 32 42 33 32 33 31 33 32 33 33 33 32 31 33 33 29)
#(33 33 33 32 43 42 25 25 35 34 32 42 33 32 33 33 31 33 33 31 33 32 33 31 33 29)
#(43 34 39 22 43 34 32 42 41 43 22 42 41 38 43 29)
#(35 43 32 34 22 37 36 33 34 42 43 42 43 34 22 31 34 38 42 41 43 42 33 29)
#(31 34 39 22 32 27 7 42 26 35 34 29)
#(41 43 36 41 43 42 33 34 31 35 34 39 42 35 33 30 34 29)
#(41 33 33 33 33 32 39 10 42 25 34 39 42 41 43 32 22 25 34 10 42 25 29)
#(33 33 34 22 42 6 41 43 32 31 17 43 42 41 17 25 43 43 29)
#(24 41 43 43 39 40 27 41 43 34 32 24 22 33 33 32 41 35 43 43 42 33 33 29)
#(24 34 28 27 41 35 43 42 43 42 41 43 22 39 36 33 43 24 31 43 29)
#(33 32 41 39 38 43 42 43 43 32 22 39 38 29)
#(41 43 39 22 42 35 35 34 42 43 42 41 33 43 43 22 42 33 37 17 25 25 29)
#(31 41 43 39 22 32 27 39 10 42 41 43 42 39 10 42 41 43 29)
#(33 33 34 22 41 43 42 26 43 37 36 42 43 43 29)
#(42 41 35 43 37 36 41 43 42 35 43 34 32 41 33 39 39 38 43 42 41 43 43 29)
#(31 41 33 43 22 41 35 43 32 34 22 29)
#(35 34 28 35 37 36 26 43 43 41 35 42 41 35 43 40 39 36 35 32 35 43 34 22 29)
#(41 33 40 38 41 35 35 43 43 37 36 42 43 43 43 29)
#(41 35 34 43 42 35 34 42 34 40 38 27 42 25 25 43 32 39 42 25 43 39 29)
#(42 34 28 38 34 41 43 32 41 34 28 41 43 20 36 42 41 35 35 34 29)
#(33 30 33 33 40 41 35 43 42 33 43 35 35 43 20 36 39 33 43 34 29)
#(41 32 38 42 35 35 34 34 32 24 20 36 43 42 41 43 43 42 41 35 25 37 25 34 32 24 14 40 29)
#(31 35 35 34 28 34 28 38 37 43 34 32 31 42 43 34 20 36 37 36 29)
#(24 14 43 41 35 43 39 42 41 43 43 22 41 35 43 32 24 22 33 33 32 43 42 33 33 33 32 27 37 41 43 43 30 43 33 42 43 42 43 42 27 41 33 33 29 43 29)
#(42 35 43 43 4 33 43 34 22 29)
#(41 43 42 33 33 34 22 39 42 25 43 32 27 41 43 42 25 43 29)
#(41 43 22 38 29)
#(35 43 42 33 33 32 41 43 22 37 25 43 42 25 43 33 32 31 22 37 25 34 42 25 34 29)
#(41 33 33 31 33 33 43 43 31 33 33 31 33 33 28 38 41 35 43 37 36 43 43 34 42 35 34 42 41 43 29)
#(41 34 20 36 42 41 43 43 41 33 43 39 39 37 41 43 42 41 35 43 42 33 33 31 33 33 29)
#(33 40 41 35 43 42 41 33 33 33 32 41 43 42 33 33 33 32 31 33 33 33 29)
#(34 20 36 38 41 43 43 32 9 42 41 35 43 32 20 36 43 42 41 33 43 31 43 34 42 41 35 34 29)
#(33 20 36 25 32 35 34 32 27 42 33 25 29)
#(41 35 43 38 42 41 35 43 40 24 41 25 33 30 33 29 24)
#(35 34 31 35 34 20 36 38 42 34 42 43 32 34 32 35 43 32 41 13 34 32 31 34 29)
#(41 34 20 36 38 31 38 42 33 32 42 43 31 43 38 42 43 42 33 33 31 33 33 29)
#(33 33)
#(14 28 22 41 35 43 42 39 35 43 40 43 41 35 43 42 25 4 41 43 14 28 32 24 14 28 37 26 43 24 4 14 39 40 39 37 36 29)
#(4 33 33 33 29)
#(33 42)
#(41 43 34 28 14 28 35 42 14 39 28 39 38)
#(4 33 33 29)
#(43)
#(43 4 36 43 29)
#(4 33 33 29)
#(33 33 22 41 35 43 31 35 43 34 9 28 43 42 43 31 43 37 36 41 25 43 43 42 35 35 43 37 17 25 25 32 31 25 34 41 43 29)
#(42 41 25 35 43 32 41 34 43 22 43 42 17 25 25 32 31 25 34 41 43 29)
#(34 22 25 43 37 17 25 25 42 17 25 25 29)
#(42 41 25 34 32 41 43 22 41 25 43 43 42 43 37 17 25 25 32 31 17 25 41 43 32 42 17 25 25 32 31 17 25 41 43 29)
#(34 22 25 43 37 17 25 25 42 17 25 25 29)
#(34 42 41 25 35 43 31 25 34 28 41 35 43 42 17 25 25 42 41 43 30 43 43 31 43 43 32 31 41 43 42 17 25 25 42 41 43 42 41 43 30 35 43 29)
#(34 34 38 42 41 35 43 32 42 43 34 22 38 42 10 34 32 35 43 34 31 41 35 35 43 29)
#(41 27 34 34 28 39 38 38 34 35 37 35 43 31 43 43 29)
#(33 30 43 31 43 34 22 42 42 41 25 34 32 31 35 43 40 42 41 43 42 27 31 43 34 32 31 43 42 35 34 32 41 43 22 29)
#(27 39 37 41 35 43 32 41 43 22 43 43 31 43 34 20 36 35 32 42 43 31 43 34 20 36 10 29)
#(33 31 43 43 40 42 43 31 43 34 32 41 43 22 29)
#(33 33 33 33 33 22 41 13 35 33 43 37 36 34 42 26 34 37 35 34 32 27 41 17 25 25 35 43 37 26 43 29)
#(41 43 39 22 14 40 37 36 41 17 25 25 43 42 41 35 43 31 41 43 42 41 35 43 29)
#(41 35 34 28 41 43 30 43 42 34 37 33 33 34 37 17 25 25 32 31 25 43 42 33 33 30 43 31 35 34 37 41 34 29)
#(24 43 42 37 41 43 31 36 41 35 43 29)
#(36 41 43 42 14 31 28 39 36 39 32 24 22 33 33 33 32 43 42 33 32 33 31 33 32 42 27 42 41 43 29)
#(33 33 24 40 38 41 43 37 36 41 42 41 43 32 24 41 43 22 29)
#(14 40 33 37 36 41 35 43 41 43 29)
#(43 43 22 41 25 43 35 34 43 32 9 34 22 41 43 35 32 42 33 33 33 22 41 17 25 25 43 42 41 43 42 27 17 25 25 37 26 43 42 34 37 35 34 29)
#(25 35 35 33 34 22 34 34 29)
#(33 33 31 33 42 33 33 22 41 25 43 43 29)
#(33 33 33 32 41 43 42 33 33 33 32 22 35 43 22 25 43 32 42 35 42 33 25 33 42 33 32 33 32 22 25 43 29)
#(33)
#(34 22 39 39 38 42 33 30 34 29)
#(24 21 40 43 42 39 41 40 43 31 43 37 36 14 36 14 28 27 41 43 42 43 32 24 22 33 33 32 43 42 33 33 32 33 33 33 29)
#(34 42 41 43 30 35 43 43 22 25 43 29)
#(24 41 43 43 40 37 36 41 34 43 32 24 22 33 33 42 33 32 33 31 33 29)
#(35 43 31 43 34 42 43 34 42 41 33 42 33 33 31 33 22 24 39 35 32 39 35 32 24 41 43 22 32 31 43 42 41 43 22 25 43 29)
#(41 35 43 43 22 24 43 34 31 35 43 34 32 24 41 43 22 41 43 34 42 33 42 41 25 34 31 43 42 33 42 41 35 43 32 42 33 22 14 24 39 35 29 24)
#(39 32 41 43 22 26 35 43 37 17 25 25 42 17 25 25 41 43 11 29)
#(24 34 22 27 37 36 42 14 20 36 41 35 43 24 42 35 31 35 34 37 35 34 32 41 33 43 22 29)
#(31 14 22 41 43 30 43 42 14 40 35 42 41 35 43 42 17 25 25 32 27 42 25 43 42 41 17 25 25 42 35 34 35 29)
#(33 33 33 32 43 42 33 33 33 31 33 32 38 33 30 35 34 42 17 25 25 42 34 24 35 29 24)
#(41 24 27 24 43 41 43 22 22 41 25 43 43 42 34 32 9 41 43 34 37 34 42 27 41 26 43 43 34 31 26 35 43 43 29)
#(33 30 43 22 32 39 32 42 41 43 40 27 41 34 42 43 37 43 43 29)
#(33 33)
#(33 33 22 37 36 25 42 41 13 43 34 42 35 34 32 27 41 43 42 35 43 43 42 25 43 35 43 42 35 43 34 31 35 43 42 34 29)
#(26 43 22 39 25 43 34 32 31 25 42 41 43 43 32 42 41 43 39 32 38 42 41 35 43 42 33 33 33 31 39 10 34 42 34 42 35 34 42 41 43 29)
#(42 41 43 32 33 33 30 35 43 43 22 17 25 25 32 31 25 43 32 37 17 25 25 42 41 43 29)
#(35 43 22 39 37 17 25 25 42 17 25 25 32 42 33 33 22 37 39 28 35 43 32 9 22 39 35 42 17 25 25 29)
#(41 43 42 35 43 43 42 35 43 43 22 33 33 41 25 43 43 42 35 34 42 41 43 32 42 25 43 10 42 33 33 30 31 41 43 43 38 42 39 25 31 25 35 35 34 42 41 33 29)
#(33 33 30 43 42 43 38 37 25 43 42 25 43 29)
#(33 33 40 38 41 42 26 35 34 38 37 35 34 32 31 22 37 39 36 41 35 43 42 35 35 34 32 9 22 25 43 42 41 35 43 37 17 25 25 42 17 25 25 29)
#(31 41 43 22 39 25 43 10 42 41 35 43 32 31 25 43 10 42 41 43 42 35 34 29)
#(41 43 32 31 33 33 30 35 43 37 35 34 32 28 42 41 39 40 34 28 42 33 33 30 35 43 29)
#(33 33 40 27 26 43 43 32 9 22 37 17 25 25 42 33 25 42 17 25 25 41 35 43 31 22 39 42 17 25 25 41 43 39 32 8 41 43 39 22 41 35 35 34 29)
#(33 33)
#(33 33 22 42 27 41 43 37 26 34 32 35 43 34 32 31 41 35 17 25 25 43 42 41 43 42 41 43 42 41 35 43 43 32 35 34 22 17 25 25 29)
#(41 35 35 43 22 17 25 25 32 41 43 22 29)
#(41 43 30 35 34 22 34 42 34 37 35 34 37 17 25 25 32 27 25 43 42 26 43 31 35 34 35 37 41 34 29)
#(41 35 43 43 4 41 43 42 41 43 30 43 42 34 31 12 14 40 42 43 34 4 38 42 41 43 32 42 22 35 34 42 35 43 29)
#(34 42 27 34 22 25 43 32 37 17 25 25 29)
#(24 14 22 39 36 43 42 41 43 42 34 24 42 41 43 24 42 26 43 43 22 35 32 24 41 43 22 29)
#(34 35 37 36 22 25 43 32 37 17 25 25 29)
#(33 33)
#(33 33 22 10 43 42 34 35 37 36 31 22 14 40 37 36 34 29)
#(35 43 43 42 41 35 43 22 42 25 43 32 37 17 25 25 29)
#(43 43 22 25 43 32 37 17 25 25 32 42 43 34 32 34 31 34 38 25 43 32 37 17 25 25 29)
#(41 43 30 35 43 42 43 34 22 17 25 25 32 31 25 43 42 35 34 29)
#(33 33 33 33 22 41 43 35 43 42 35 34 42 41 34 28 20 36 14 31 26 43 33 18 14 16 33 43 42 41 43 29)
#(35 34 28 41 33 43 20 36 43 42 41 35 43 31 36 38 37 36 42 41 35 43 42 41 43 42 35 34 29)
#(34 42 41 35 32 35 31 35 43 28 39 35 37 36 29)
#(39 40 42 41 43 32 41 35 43 42 35 31 35 34 38 42 35 33 43 33 33 33 33 29)
#(41 13 43 40 42 41 34 20 36 41 43 42 31 42 33 33 31 26 25 34 42 43 4 25 34 42 34 31 34 32 40 31 34 31 35 34 42 43 29)
#(43 32 25 34 42 41 35 35 43 42 41 43 43 32 33 33 22 34 42 41 10 43 42 33 42 33 25 31 25 29)
#(41 34 20 36 38 42 35 34 42 25 42 41 25 34 29)
#(18 41 10 43 30 35 43 40 42 33 4 41 33 30 35 43 40 38 29 16)
#(41 34 20 36 41 35 43 42 41 35 35 43 31 33 18 14 16 32 9 42 35 34 40 38 42 25 42 33 30 25 34 42 43 29)
#(42 41 43 43 42 25 42 34 38 42 41 43 42 26 43 32 33 33 32 33 33 22 26 43 36 41 43 43 43 29)
#(26 35 34 37 36 33 41 35 43 36 22 39 42 35 43 29)
#(26 43 37 36 42 35 43 31 33 34 32 27 26 35 43 32 22 35 29)
#(26 24 33 33 24 43 22 38 42 41 43 43 32 9 20 36 41 35 43 43 29)
#(41 34 28 41 43 42 33 33 30 22 43 37 36 43 31 35 35 43 20 36 42 41 34 29)
#(24 21 40 41 35 43 42 43 42 41 43 32 24 40 33 33 33 42 41 33 42 33 33 32 42 33 33 29)
#(24 14 28 41 34 20 36 27 41 43 42 41 35 43 32 42 41 35 43 43 29)
#(41 20 36 41 35 43 42 41 35 43 29 24)
#(39 42 41 33 18 14 16 40 43 42 41 43 32 33 33 30 43 37 36 42 35 34 20 36 38 42 41 10 43 29)
#(35 34 28 26 35 43 42 41 33 43 35 32 31 35 28 27 42 35 35 34 42 14 40 38 39 37 36 29)
#(41 33 33 32 31 10 43 42 33 32 40 25 38 31 25 38 34 29)
#(42 25 32 41 33 18 14 16 38 25 34 32 41 13 43 42 41 43 42 33 43 29)
#(41 43 22 38 42 43 9 22 42 33 42 41 43 29)
#(33 33 22 38 38 42 35 15 32 31 35 15 22 26 43 20 36 39 29)
#(42 41 35 25 35 34 32 35 35 34 22 41 43 29)
#(42 25 32 41 33 33 22 42 33 30 43 42 41 33 43 29)
#(42 25 32 33 33 22 38 42 42 43 42 26 35 43 43 32 31 42 25 32 42 26 34 22 41 43 42 26 25 34 42 43 32 14 22 38 37 43 29)
#(13 35 34 28 42 42 33 33 30 43 40 37 36 35 34 42 7 34 32 41 33 18 14 16 20 36 35 29)
#(31 42 41 43 40 38 32 41 33 18 14 16 20 36 41 35 43 32 31 36 41 43 43 29)
#(33 33 32 41 43 31 35 33 43 32 40 33 18 14 16 20 36 39 25 34 32 41 43 42 41 43 32 42 41 43 40 35 34 42 25 43 42 41 34 29)
#(34 28 41 43 20 36 41 43 37 36 32 31 26 43 20 36 35 39 8 14 40 26 35 43 42 35 34 29)
#(41 43 43 40 35 37 36 25 42 41 35 43 34 42 41 43 32 31 14 40 35 8 14 40 38 42 35 33 34 29)
#(42 25 32 33 22 41 17 25 25 43 42 33 33 32 41 43 42 33 33 33 33 32 37 36 25 43 34 29)
#(41 43 22 38 42 41 34 30 25 35 34 32 31 22 38 37 36 35 42 34 31 34 30 34 29)
#(42 33 25 32 43 22 42 34 22 38 29)
#(41 43 38 42 41 43 22 38 37 36 33 43 34 32 41 43 38 42 33 33 30 43 29)
#(31 43 42 26 34 42 41 43 42 33 39 22 38 35 42 43 43 29)
#(41 43 40 38 31 38 32 31 35 34 38 14 39 42 41 43 34 32 31 41 40 38 36 41 43 32 9 35 43 22 43 42 25 35 43 34 29)
#(14 22 41 35 43 42 25 34 42 35 43 34 22 38 29)
#(42 41 43 8 41 43 40 38 37 36 41 43 32 41 43 32 31 39 42 41 43 32 41 43 33 40 38 41 35 43 43 42 41 43 29)
#(41 40 41 43 42 43 35 15 28 42 33 33 32 12 14 39 22 31 39 38 42 26 35 25 34 42 43 29)
#(26 43 40 38 41 35 34 42 34 32 42 41 43 31 42 41 35 43 32 31 40 38 42 41 34 29)
#(31 41 35 33 22 35 43 42 41 35 43 31 26 43 37 36 41 43 31 41 43 43 11 35 31 11 35 29)
#(26 34 42 41 25 34 39 32 31 39 39 32 38 35 15 29)
#(24 14 28 39 42 41 33 18 14 16 32 24 40 33 33 32 41 43 42 41 35 43 42 43 29)
#(24 41 33 43 40 27 41 34 30 43 31 39 27 14 41 43 29)
#(8 21 28 35 34 32 43 34 32 43 34 32 41 43 40 14 37 36 14 29 24)
#(41 13 43 27 42 33 33 31 41 33 18 14 16 33 40 41 35 43 42 41 43 29)
#(39 42 14 40 42 41 34 32 26 43 40 35 37 36 35 29)
#(8 41 33 18 14 16 22 41 25 43 32 27 33 33 30 22 43 43 32 41 35 43 22 43 31 39 22 29)
#(35 15 43 41 43 42 41 43 29)
#(33 25 32 25 4)
#(33 33 32 41 43 42 33 33 33 33 32 40 42 41 17 25 25 43 42 33 30 33 33 37 36 25 33 33 35 43 43 34 29)
#(42 25 32 33 33 33 33 32 42 26 34 42 39 33 33 33 33 33 32 22 41 43 42 41 43 28 41 34 29)
#(33 25 32 25 4)
#(33 33 33 34 42 39 17 25 25 4 39 25 43 42 41 35 43 4 22 38 42 33 42 34 37 34 29)
#(33 25 32 25 4)
#(33 30 33 33 33 34 26 43 27 43 42 39 17 25 25 37 35 15 29)
#(41 43 40 42 34 22 39 38 42 43 42 43 42 33 29)
#(33 40 14 20 39 36 41 34 42 41 34 42 14 20 36 35 43 29)
#(41 43 42 41 43 27 34 42 41 34 40 38 42 34 27 43 43 34 29)
#(33 25 32 25 4)
#(33 33 33 40 41 33 33 32 24 4 41 14 31 41 43 42 26 43 40 38 41 43 42 41 34 29)
#(41 40 41 43 29 24)
#(33 25 32 25 4)
#(33 40 34 42 17 25 25 37 34 29)
#(33 25 32 25 4)
#(41 33 43 40 34 42 43 34 42 35 34 31 34 42 33 31 35 35 34 38 37 41 43 42 41 34 37 33 29)
#(33 25 32 25 4)
#(41 35 35 43 38 42 41 33 18 14 16 33 40 42 21 22 41 34 42 41 43 31 41 43 37 41 33 43 31 43 29)
#(33 25 32 25 4)
#(41 43 31 43 42 33 40 35 34 42 41 43 30 35 31 35 43 42 41 33 43 29)
#(33 25 32 25 4)
#(35 43 33 42 33 33 33 40 42 41 43 42 14 22 42 33 25 42 41 43 43 41 33 43 29)
#(27 37 33 33 32 9 20 36 38 33 37 36 41 34 42 41 34 12 22 34 42 41 43 29)
#(26 43 22 38 42 41 43 29)
#(33 25 25 4)
#(41 33 43 40 41 38 43 42 41 33 33 33 33 30 43 29)
#(41 34 28 42 34 22 38 42 33 37 41 33 43 42 41 34 43 29)
#(33 33 33 31 33 33 33 22 14 20 36 34 42 35 34 27 37 41 43 31 43 42 33 33 33 29)
#(42 41 43 42 41 33 31 33 33 32 33 31 33 32 9 39 36 25 43 42 33 30 35 34 32 22 14 28 14 40 42 41 13 43 42 33 34 42 41 43 36 38 29)
#(33 32 38 42 33 32 33 32 22 14 22 39 38 41 43 42 33 31 33 31 39 22 41 43 29)
#(41 34 22 14 20 36 43 43 32 31 14 20 36 41 43 42 33 30 43 31 35 35 34 42 43 42 26 34 29)
#(27 37 41 43 32 33 31 33 28 38 42 33 32 33 32 31 28 38 42 41 35 35 43 32 33 33 33 29)
#(26 38 43 40 42 25 33 35 34 32 27 25 34 22 42 41 35 25 34 42 17 25 37 17 25 41 43 29)
#(35 34 20 36 38 31 38 42 41 35 43 32 42 35 34 31 39 32 27 42 43 34 31 35 34 29)
#(41 35 43 43 42 34 31 34 22 38 43 42 34 22 42 41 35 43 42 43 34 29)
#(31 43 34 28 37 36 41 43 43 42 41 35 43 43 29)
#(42 35 43 32 34 22 43 43 34 10 42 34 22 31 34 38 42 33 30 43 43 43 20 36 38 29)
#(31 41 35 43 42 41 33 33 33 33 32 9 22 38 39 10 42 25 34 42 43 32 22 41 34 29)
#(43 34 39 22 38 39 42 41 43 42 41 17 25 25 43 42 41 33 33 33 31 41 43 42 41 35 43 42 35 43 43 29)
#(24 33 34 22 27 42 43 34 20 36 37 36 32 24 22 33 33 32 41 43 43 42 33 33 33 32 33 29)
#(24 8 34 38 32 9 22 41 43 29 24)
#(39 32 42 41 35 35 43 32 41 43 43 22 35 43 37 41 33 33 30 35 43 34 29)
#(35 34 38 10 43 42 41 43 43 42 27 17 25 25 42 43 34 42 41 35 43 43 43 29)
#(41 43 22 38 37 36 41 43 42 43 34 31 37 36 43 43 29)
#(24 41 43 40 38 35 32 43 42 14 39 22 39 36 37 36 14 32 24 22 33 33 33 32 35 43 42 33 33 33 33 29)
#(14 22 41 11 35 43 22 39 38 29)
#(41 33 39 40 35 37 36 43 34 35 29)
#(14 39 40 38 41 39 38 35 34 43 37 36 25 43 43 37 42 25 25 43 42 26 35 43 43 42 42 25 43 29)
#(41 43 32 9 34 28 41 43 42 35 34 32 40 38 41 35 43 42 34 42 33 43 29)
#(14 22 42 42 25 25 43 43 32 31 22 39 35 42 25 25 43 33 29)
#(41 33 30 43 35 43 22 10 42 25 43 32 31 42 17 43 42 41 17 25 43 43 32 42 41 43 22 42 25 43 42 41 35 43 42 33 29)
#(35 35 32 35 31 35 34 39 22 29)
#(31 7 43 34 22 35 42 43 39 10 42 43 42 35 34 29)
#(41 35 35 43 34 32 35 42 33 33 31 33 30 25 25 43 22 34 32 22 29)
#(41 33 30 43 22 42 42 25 43 42 41 43 43 42 25 29)
#(41 33 30 35 43 43 22 26 35 42 25 34 29)
#(35 43 43 22 14 37 36 41 43 42 41 43 42 17 25 25 29)
#(34 22 27 38 37 41 33 43 39 22 33 34 29)
#(24 34 42 41 33 34 22 26 43 43 42 27 15 37 36 42 13 43 42 26 18 33 16 34 32 24 22 33 33 33 32 41 35 43 43 42 33 33 33 33 33 29)
#(41 33 34 39 24 38 37 36 41 43 42 21 20 36 39 11 35 43 32 24 22 33 33 33 32 41 27 43 42 33 33 15 31 33 29)
#(43 41 33 20 36 41 43 42 26 35 35 43 43 31 33 33 33 20 36 34 42 26 35 43 43 29)
#(41 34 28 17 25 25 42 35 35 15 20 36 38 35 43 32 31 14 28 33 37 36 17 25 25 37 17 25 25 42 35 24 43 24 34 29)
#(33 22 38 37 36 36 41 43 43 29)
#(41 43 43 22 37 36 43 29)
#(41 33 42 33 42 41 33 33 33 33 22 14 22 41 35 17 25 25 43 43 42 41 34 37 36 42 25 43 37 25 43 29)
#(41 43 42 35 35 34 22 35 43 42 41 43 32 27 41 43 42 41 33 43 43 38 37 41 39 35 17 25 25 42 33 32 42 42 41 38 17 25 25 42 33 29)
#(41 33 43 22 38 37 36 38 37 17 25 25 29)
#(33 15)
#(43 34 22 39 35 37 42 25 43 10 29)
#(41 43 35 43 22 38 39 42 25 25 37 36 25 43 32 38 42 25 25 37 36 25 43 33 29)
#(41 13 35 34 22 38 39 42 25 25 37 36 25 43 32 38 42 25 25 37 36 25 43 29)
#(35 34 38 29)
#(41 43 43 42 35 34 22 37 25 43 42 41 35 43 42 25 43 29)
#(41 43 42 35 34 22 37 25 43 42 41 35 43 42 25 43 29)
#(35 32 35 34)
#(35 35 34 22 25 37 25 43 10 32 42 7 43 34 22 35 29)
#(41 33 30 35 17 25 25 43 22 43 42 41 35 43 29)
#(33 22 17 25 25 42 35 34 38 37 36 25 43 4 17 25 25 42 35 34 38 37 36 25 43 4 31 17 25 25 42 35 34 38 37 36 25 43 29)
#(41 33 32 9 40 25 42 41 43 30 13 35 43 34 32 40 41 43 39 22 42 41 33 43 29)
#(43 30 43 43 22 43 42 41 17 25 25 43 43 37 36 42 35 43 41 33 40 41 33 33 33 32 41 43 42 41 33 29)
#(39 32 33 33 22 41 17 25 25 43 43 37 36 25 43 29)
#(35 15)
#(41 35 35 43 38 42 41 35 43 42 25 35 34 27 17 25 25 22 38 31 36 22 42 25 10 34 9 20 36 38 43 29)
#(41 43 42 41 35 43 43 43 43 43 22 41 35 43 42 41 43 43 42 25 34 42 35 43 29)
#(34 22 42 14 40 35 37 36 35 34 8 34 28 27 39 29)
#(41 25 34 38 22 41 17 25 25 33 33 33 33 33 43 38 42 33 33 33 31 41 17 25 25 33 33 33 33 43 38 42 33 33 15 29)
#(41 33 43 22 34 42 33 33 31 33 33 34 32 9 22 42 10 42 33 33 33 33 34 42 41 43 43 29)
#(33 33 25 43 34 42 33 43 22 42 25 25 32 39 25 4 25 25 43 34 42 25 25 32 39 25 4 31 25 43 34 42 25 25 32 39 25 29)
#(33 33 25 43 34 22 42 25 25 32 39 25 29)
#(41 33 33 25 43 43 22 27 25 43 37 41 35 35 43 43 32 42 41 43 42 41 33 35 43 38 42 25 43 34 29)
#(34)
#(43 42 41 35 43 42 34 22 41 35 43 32 42 34 42 41 43 43 22 37 36 34 29)
#(33 35 43 34 22 39 35 37 25 43 10 42 41 35 43 42 27 39 37 34 42 35 35 43 29)
#(34 42 35 35 34 22 38 42 43 42 33 33 33 32 42 43 42 41 43 32 20 36 34 43 42 25 35 34 42 34 9 28 35 35 34 29)
#(41 34 35 17 25 25 29)
#(35 34 28 38 42 26 13 43 43 42 41 38 34 42 41 43 43 29)
#(39 32 35 35 34 22 38 29)
#(34 38 42 33 33 22 35 43 42 17 25 25 42 33 33 33 33 33 43 34 42 33 33 29)
#(35 43 34 22 38 42 25 43 42 25 37 25 43 42 25 29)
#(42 43 42 26 33 33 33 32 33 22 17 25 25 42 35 43 43 43 34 38 37 36 37 43 42 25 43 42 25 37 25 43 42 25 32 25 31 25 29)
#(41 33 15 43 22 41 17 25 25 33 35 43 34 30 43 43 43 35 33 25 32 25 29)
#(41 25 25 43 34 28 25 43 29)
#(35 34)
#(35 35 43 43 34 22 41 35 43 43 32 22 39 42 33 30 33 43 43 34 39 42 42 41 35 33 43 43 31 27 33 43 34 29)
#(33 33 30 25 43 43 35 33 25 22 42 25 35 43 32 42 25 43 42 33 32 37 36 25 43 29)
#(41 25 25 43 34 35 33 25 22 42 25 43 37 25 37 36 25 43 29)
#(35 43 34 22 42 38 43 42 41 43 43 29)
#(41 33 25 25 43 43 35 25 22 25 37 25 25 37 36 25 43 29)
#(31 35 34 22 10 29)
#(41 43 43 25 25 43 43 35 25 22 42 34 30 34 42 41 43 42 25 32 42 25 43 37 36 25 43 29)
#(41 33 43 22 41 38 17 25 25 35 25 43 43 9 40 41 25 43 43 42 43 43 31 43 31 40 35 34 27 41 35 43 43 29)
#(41 35 43 42 43 34 38 42 41 33 33 33 20 36 38 37 17 25 29)
#(39 32 41 43 40 43 37 41 33 43 37 36 41 43 42 39 35 34 42 35 31 35 34 29)
#(41 35 43 32 27 35 25 34 32 40 38 35 43 42 43 34 38 42 41 33 33 33 29)
#(31 41 43 42 35 35 33 34 38 42 41 33 33 43 33 15 22 37 41 33 42 41 35 43 37 36 41 43 29)
#(42 41 35 43 32 33 34 22 37 36 41 25 43 43 43 32 31 42 35 34 32 41 43 22 14 28 42 41 35 43 42 34 31 34 29)
#(41 43 39 40 27 41 38 25 34 42 25 43 42 41 25 43 32 31 39 35 37 35 34 32 41 43 40 38 37 36 42 13 17 25 25 42 34 42 35 25 29)
#(41 43 40 38 38 39 42 34 35 37 36 43 39 32 31 35 33 33 33 43 41 43 42 41 35 43 42 35 34 29)
#(24 14 28 34 39 32 39 42 41 43 34 32 31 41 34 32 24 22 41 33 33 29)
#(41 43 22 42 41 43 22 35 35 43 42 17 25 25 42 43 42 34 38 42 33 42 33 29)
#(41 43 42 41 43 20 36 38 42 41 33 33 42 33 32 31 41 43 40 39 39 38 42 14 40 38 38 42 34 27 41 43 30 35 43 31 26 35 43 29)
#(41 33 22 38 35 33 37 36 43 31 43 43 32 31 42 41 35 43 32 41 35 43 22 43 43 31 22 39 34 27 37 36 41 35 43 31 36 14 39 42 35 43 37 35 34 29)
#(35 43 4 42 41 35 43 43 4 22 39 42 43 32 31 41 43 22 41 35 43 42 34 32 27 33 33 33 31 33 33 31 33 33 33 31 33 33 29)
#(41 43 20 36 38 42 43 43 31 43 43 32 31 10 42 43 40 35 37 36 37 41 33 33 33 43 29)
#(34 22 35 43 34 20 39 36 41 43 43 30 27 32 31 25 43 40 42 42 35 43 41 35 43 42 41 43 43 30 34 20 36 38 42 41 43 30 33 33 33 29)
#(42 41 34 43 43 32 41 17 25 25 43 40 41 35 13 42 41 35 35 43 34 31 40 41 35 43 42 34 42 43 32 43 32 34 31 41 43 29)
#(41 43 37 36 41 43 42 33 43 34 39 40 35 43 42 41 33 29)
#(31 14 40 38 42 41 35 35 34 9 28 38 34 37 36 37 35 43 34 37 36 39 35 42 17 25 25 42 43 9 20 39 36 41 43 42 43 29)
#(41 34 20 36 41 43 43 42 35 25 32 31 41 43 35 40 33 37 41 43 42 35 34 32 27 41 35 43 34 42 41 43 43 29)
#(41 43 40 38 17 25 25 42 41 17 25 25 38 42 43 31 43 42 41 33 33 31 33 33 32 31 41 43 30 35 43 43 4 36 42 41 33 4 20 36 39 35 42 17 25 25 42 35 34 31 34 29)
#(39 32 41 33 22 37 36 39 17 25 25 37 36 43 42 41 38 34 43 43 32 27 38 42 33 33 33 29)
#(31 42 27 41 35 43 42 17 25 25 42 41 38 43 43 32 41 43 38 17 25 25 42 41 43 42 41 33 43 32 41 43 37 41 33 43 43 29)
#(42 35 35 34 32 41 33 33 33 40 37 36 34 39 42 41 38 42 41 43 32 42 43 43 31 43 34 27 42 25 43 37 39 17 25 25 29)
#(41 38 17 25 25 40 39 38 42 41 33 33 33 32 31 42 41 33 31 33 33 33 32 10 42 17 25 25 40 38 42 39 38 43 32 27 41 38 43 37 36 35 43 34 9 28 41 13 34 29)
#(37 41 35 43 32 41 35 43 40 38 41 43 42 34 37 36 34 42 34 42 43 34 29)
#(42 41 43 22 38 42 41 43 32 41 43 43 40 38 42 34 30 34 32 35 34 31 35 34 38 42 35 34 29)
#(41 7 35 43 43 20 36 38 42 43 43 34 32 8 41 25 34 22 39 38 41 43 42 25 34 38 42 17 25 25 32 31 41 43 22 25 11 38 42 17 25 25 37 39 36 24 43 24 42 41 33 31 33 29)
#(43 30 43 43 40 41 35 35 43 37 36 42 34 41 43 32 42 34 22 41 35 25 43 43 35 33 9 40 41 27 43 42 43 42 7 35 43 34 29)
#(41 43 20 36 42 34 39 42 25 34 37 33 31 33 32 31 34 42 41 43 43 43 36 41 31 42 25 34 20 36 38 29)
#(39 32 41 35 43 43 27 41 17 25 25 33 31 33 33 43 22 38 37 41 33 42 27 41 33 42 41 35 43 43 43 29)
#(31 42 34 42 43 32 41 34 28 40 27 37 36 41 35 43 29)
#(33 31 35 43 28 41 25 7 35 34 27 42 41 43 30 43 29)
#(31 42 35 34 32 41 7 35 43 40 33 33 43 37 43 34 38 37 36 34 27 41 33 42 33 31 33 42 33 31 33 33 29)
#(41 35 43 40 37 36 42 37 41 35 43 43 32 31 33 33 39 40 27 37 36 41 43 9 40 35 34 27 33 43 42 41 33 33 33 42 33 33 29)
#(42 41 39 38 43 32 33 33 33 32 43 42 41 33 34 43 42 35 34 32 22 33 33 42 41 43 42 26 24 43 24 20 36 34 37 36 41 43 39 29)
#(24 42 41 43 42 26 43 32 24 40 41 33 33 32 24 14 28 21 40 39 39 41 43 42 27 43 34 42 43 42 35 34 42 43 32 39 39 42 26 43 14 39 28 37 36 41 43 29)
#(34 39 36 22 42 14 28 31 43 29)
#(33 32 9 40 39 38 31 38 39 42 39 41 43 32 43 38 12 20 36 41 35 43 42 43 4 41 7 39 38 34 34 22 35 42 35 34 42 41 41 43 31 41 43 43 29)
#(41 43 34 42 41 33 32 33 31 33 43 34 22 39 42 33 30 35 34 29)
#(41 33 25 43 32 9 40 41 13 43 43 32 22 42 17 25 41 43 29)
#(41 35 34 22 34 42 25 34 37 25 34 41 43 29)
#(27 37 25 43 32 33 33 42 33 32 33 33 32 41 43 43 30 43 42 33 37 36 42 35 33 30 43 4 9 22 37 36 42 41 43 22 39 27 37 36 41 4 22 41 43 42 42 35 34 34 32 31 42 42 43 30 32 42 43 29)
#(43 32 43 38 42 41 35 43 29)
#(33 22 37 36 42 33 31 22 42 41 35 43 9 40 38 43 34 42 10 42 41 43 4 27 42 43 34 32 12 28 37 36 41 13 35 43 42 26 43 29)
#(24 33 43 43 40 27 42 41 43 42 17 25 37 17 25 18 41 43 16 31 40 27 43 27 42 42 41 32 24 33 33 22 29)
#(24 34 42 41 43 43 41 43 41 35 25 42 9 37 36 43 29 24)
#(39 32 33 33 22 32 43 43 34 27 10 43 28 27 42 27 34 39 42 35 34 42 24 14 28 27 10 42 41 35 43 9 40 39 36 43 31 35 34 35 29 24)
#(33 33 32 43 42 33 33 32 33 35 34 34 32 22 21 40 35 37 36 43 34 37 36 41 43 29)
#(24 34 42 41 33 31 33 28 35 42 41 34 42 41 18 33 33 16 42 26 43 37 36 43 37 35 43 32 9 22 41 43 43 43 42 33 32 24 14 22 29)
#(21 40 39 41 43 42 41 43 42 34 42 41 33 37 36 43 32 14 22 29)
#(24 14 39 28 41 43 42 33 25 32 8 14 22 43 42 41 43 43 22 31 22 42 27 43 42 43 34 39 22 32 24 33 33 22 29)
#(24 14 40 41 43 14 28 39 36 37 36 29 24)
#(42 41 43 43 34 28 39 38 42 43 32 14 22 32 31 42 42 41 43 32 24 43 30 43 42 41 43 40 38 27 39 39 40 42 41 43 28 39 27 35 43 42 43 29 24)
#(33 33 32 35 43 43 42 33 33 33 32 22 4 24 21 40 35 43 42 41 43 42 34 37 36 43 42 41 43 43 20 36 10 31 43 20 36 41 42 26 24 43 37 36 30 43 29)
#(21 40 35 43 37 36 43 42 42 41 43 43 40 10 32 14 20 36 39 41 35 43 29)
#(41 40 27 41 43 34 38 29 24)
#(41 7 35 43 42 43 30 43 22 42 41 43 42 39 17 25 41 43 22 38 42 35 39 42 43 34 42 41 43 37 39 36 43 32 33 33 22 29)
#(24 14 28 39 36 12 14 40 42 41 35 43 32 31 42 41 35 43 32 14 40 42 43 34 28 35 42 41 17 25 31 39 41 43 40 38 42 41 35 43 31 39 32 24 14 22 29)
#(39 32 14 22 32 43 34 22 37 39 42 42 41 27 43 43 32 27 34 28 39 35 42 35 42 27 29)
#(33 33 22 42 41 33 43 43 43 32 9 22 39 42 33 32 27 37 43 30 43 32 40 38 27 10 31 10 43 42 41 43 43 29)
#(24 41 43 40 39 38 35 37 14 32 39 43 40 39 41 32 24 14 22 29)
#(42 35 43 34 43 4)
#(43 4)
#(35 43 34 22 39 42 35 43 42 34 42 41 34 22 37 36 43 42 41 43 43 29)
#(42 43 43 34 22 35 33 32 34 42 41 34 28 38 35 29)
#(8 34 28 35 42 41 43 43 40 38 32 43 34 28 38 37 36 42 43 31 43 34 39 39 36 41 35 43 29)
#(35 43 42 33 43 22 42 42 25 34 41 43 37 17 25 41 43 29)
#(43 43 34 39 22 29)
#(33 43 22 39 29)
#(43 4)
#(34 34 22 42 41 43 42 33 20 36 37 36 41 43 34 29)
#(41 33 43 22 25 43 41 43 37 25 34 29)
#(27 37 41 43 32 33 20 39 36 41 26 43 34 31 40 38 33 37 36 41 43 42 34 38 42 39 41 43 32 42 35 35 43 29)
#(24 33 40 38 42 41 35 43 9 20 36 39 42 41 43 43 31 36 41 43 32 24 41 43 22 29)
#(14 22 41 43 42 41 43 9 22 43 34 32 41 43 22 29)
#(41 43 22 42 33 40 38 27 34 42 35 34 29)
#(24 37 41 34 42 41 43 14 22 39 36 35 43 29)
#(41 33 34 28 38 39 35 42 25 34 32 31 20 39 36 41 43 32 24 14 22 29)
#(33 31 15 4)
#(41 34 42 34 32 34 31 43 43 34 34 22 42 43 34 22 42 34 42 41 33 43 43 43 20 36 43 43 32 9 42 43 20 36 35 34 42 43 31 43 29)
#(41 34 42 7 43 34 34 22 38 39 33 29)
#(34 34 34 22 39 38 43 42 40 42 43 34 28 27 34 37 36 26 34 27 43 29)
#(34 31 34 4)
#(41 34 42 7 43 31 43 34 34 22 42 34 42 41 33 33 40 35 42 27 42 41 33 31 33 33 42 25 35 34 42 34 31 39 35 42 25 35 34 42 43 43 29)
#(34 28 39 35 37 34 42 35 33 43 34 42 33 34 28 27 29)
#(42 33 25 32 42 25 25 10 34 42 33 34 28 38 38 35 42 42 41 35 43 35 43 29)
#(43 34 34 22 39 42 43 34 22 38 29)
#(33 30 33 33 33 32 27 42 27 35 43 42 33 32 22 39 17 25 25 42 43 34 42 43 42 35 43 29)
#(34 42 43 28 33 30 35 43 43 34 32 43 35 34 31 34 32 43 35 43 31 41 43 30 35 43 42 35 43 29)
#(33 30 22 14 40 27 41 34 33 30 43 20 36 42 27 35 34 42 41 35 34 29)
#(41 43 43 22 14 40 27 39 42 41 43 43 43 30 34 37 36 34 32 36 34 31 36 26 35 43 42 26 35 43 32 43 43 31 35 29)
#(41 34 42 35 33 36 41 43 42 27 34 4 26 34 28 27 29)
#(31 41 34 42 33 31 33 33 28 38 14 28 10 29)
#(42 41 43 30 33 43 42 33 32 14 22 41 35 43 43 9 40 37 36 35 34 29)
#(41 33 43 22 42 41 43 20 24 36 41 43 42 41 43 29 24)
#(35 34 32 12 28 41 43 42 27 41 34 32 20 36 42 42 43 29)
#(34 20 36 41 35 43 29)
#(35 34 22 35 37 36 41 43 32 31 33 43 33 33 31 34 22 41 39 29)
#(41 15 42 41 33 33 22 41 43 43 32 39 41 43 29)
#(39 32 41 34 42 35 33 28 39 39 22 26 43 29)
#(25 34 22 14 20 39 36 12 25 33 43 39 22 41 24 38 42 33 24 43 29)
#(42 43 32 14 22 41 43 35 29)
#(41 43 42 33 30 33 33 22 35 34 42 24 35 35 34 42 35 34 12 28 39 36 41 43 42 33 29 24)
#(41 40 39 35 4 14 28 39 41 43 29)
#(33 43 40 34 42 43 42 33 33 35 34 29)
#(41 33 33 33 40 38 10 42 25 35 34 42 43 34 42 42 41 43 29)
#(42 25 43 42 34 42 33 43 34 32 9 39 28 35 37 34 32 36 42 35 34 32 38 42 41 25 43 43 43 42 7 34 29)
#(41 33 40 37 36 39 17 25 25 42 33 33 34 29)
#(41 43 43 40 38 42 43 34 29)
#(7 38 42 33 42 33 33 22 35 34 38 37 41 43 43 31 34 42 43 31 38 43 29)
#(41 33 33 33 22 42 41 33 33 37 36 35 43 29)
#(42 33 43 43 33 33 43 41 43 43 32 14 22 38 42 25 40 29)
#(35 43 32 41 33 33 42 33 22 27 26 35 43 43 37 36 43 32 35 42 43 32 42 43 34 29)
#(35 34 31 34 28 34 28 42 34 29)
#(24 14 40 14 32 31 34 28 10 27 37 43 12 40 38 42 41 35 43 32 24 41 33 43 34 29)
#(43 34 28 41 35 43 43 32 39 42 43 25 34 29)
#(41 33 32 42 27 43 25 43 42 26 43 43 32 39 40 38 37 36 41 33 42 43 37 36 41 43 32 9 40 34 37 36 35 34 37 34 31 34 39 29)
#(42 27 42 35 43 34 32 41 33 33 42 33 33 20 36 42 43 9 20 36 35 34 41 25 43 43 43 42 26 35 43 34 32 42 42 25 43 39 29)
#(31 41 43 20 36 42 41 35 43 36 43 34 42 12 20 36 38 42 34 30 43 43 29)
#(43 34 39 20 36 41 35 43 42 43 9 20 36 35 34 29)
#(31 14 39 28 42 39 35 41 35 43 43 43 38 42 33 33 33 18 33 32 33 29 16 42 26 43 37 36 42 35 43 39 39 29)
#(21 40 39 36 42 41 33 33 27 35 43 43 20 39 36 34 42 35 34 29)
#(41 43 25 43 20 36 41 43 42 27 14 10 37 36 34 42 35 43 34 29)
#(24 42 41 43 42 43 25 32 14 20 39 39 36 14 28 27 34 42 43 43 34 32 24 40 33 33 32 41 33 42 33 30 43 43 29)
#(33 41 33 4)
#(33 33 33 18 33 32 33 16 22 38 42 41 35 43 37 33 33 32 43 42 41 33 33 42 33 33 32 22 42 41 43 43 27 42 41 33 33 33 43 20 36 43 42 43 25 29)
#(39 42 41 43 22 35 42 41 43 32 14 22 38 42 41 43 30 43 29)
#(24 14 22 14 32 24 33 33 40 39 29)
#(24 14 22 41 43 43 29 24)
#(33 15 4)
#(33 33 33 18 33 32 33 29 16 34 27 43 37 36 41 43 42 41 35 43 43 40 42 27 35 43 31 35 34 37 43 34 29)
#(43 34 28 34 37 36 27 35 43 32 39 42 43 43 40 42 27 43 34 29)
#(35 43 32 41 34 30 34 37 41 33 22 17 25 25 29)
#(43 34 28 42 10 43 37 36 42 34 34 29)
#(34 27 41 35 35 34 28 41 43 42 41 33 33 43 22 5 42 34 31 33 33 33 18 33 32 33 29 16 29)
#(41 43 20 36 41 43 42 43 34 37 25 34 31 25 34 42 25 34 31 25 42 35 34 29)
#(31 41 43 42 10 34 20 36 38 37 25 34 31 25 34 29)
#(41 43 34 28 14 20 36 42 43 34 20 36 11 35 37 36 39 37 34 42 41 10 34 42 25 34 29)
#(41 43 34 28 39 38 32 39 29)
#(34 38 42 41 33 33 33 33 31 41 33 33 33 33 36 41 43 42 43 43 29)
#(14 28 41 39 41 43 32 41 39 34 20 39 36 37 43 34 32 9 39 36 43 43 9 20 39 36 37 36 34 29)
#(41 33 33 33 20 36 41 43 39 41 43 29)
#(33 33 32 41 33 43 43 12 40 41 39 43 32 40 42 41 35 43 34 14 39 35 42 17 25 41 43 42 38 43 29)
#(33 33 4)
#(41 25 43 42 34 12 39 22 41 33 43 28 14 20 36 37 36 42 31 36 41 35 43 32 39 7 36 34 42 35 34 32 40 41 43 42 41 33 33 33 32 41 33 33 27 43 4 29)
#(33 33 33 42 33 32 33 32 40 41 33 33 33 33 43 37 36 41 24 43 43 42 41 33 43 27 43 29)
#(33 25 33 22 33 33 33 40 37 36 42 41 43 27 43 30 43 35 33 25 29)
#(33 25 22 24 14 40 38 24 42 33 33 33 32 43 31 35 35 43 32 20 36 41 35 43 42 43 42 33 33 30 43 29)
#(33 33 32 25 34 35 32 22 43 31 35 43 42 33 33 33 32 33 32 8 41 43 27 43 38 42 33 25 42 33 25 29)
#(41 43 22 33 33 40 37 36 42 41 43 42 27 33 33 42 33 25 24 40 38 38 29 24)
#(33 33 20 36 42 43 42 41 43 31 43 42 41 35 43 42 33 25 33 33 32 41 43 43 37 33 33 33 32 31 20 39 39 36 35 42 35 43 29)
#(14 20 36 42 41 33 25 43 29)
#(41 33 40 37 36 17 25 25 42 35 43 42 41 43 33 42 39 17 25 25 42 35 34 37 36 17 25 25 42 27 34 29)
#(41 43 20 36 38 39 42 35 31 35 34 27 42 33 25 32 25 32 31 33 25 32 25 32 39 29)
#(34 42 41 34 32 35 42 35 17 25 34 32 20 36 38 42 25 43 33 33 42 41 33 31 42 33 33 34 31 34 29)
#(33 30 33 33 33 22 14 22 34 42 39 17 25 25 42 33 33 43 32 27 41 39 38 33 43 43 30 38 43 29)
#(41 34 28 22 14 22 33 34 32 34 31 35 35 43 34 37 35 42 35 31 41 43 30 38 34 37 33 42 43 29)
#(33 30 22 41 38 43 20 24 36 41 43 30 43 37 36 26 43 35 24 31 42 27 34 42 41 35 43 42 35 20 36 24 35 43 34 29 24)
#(41 33 43 22 39 36 40 27 36 29)
#(33 32 9 22 35 42 41 17 25 25 35 43 42 25 32 22 35 43 42 14 20 36 39 37 36 36 34 39 35 42 17 25 25 42 35 43 31 43 34 29)
#(8 41 15 22 26 35 43 22 38 33 42 33 32 41 34 42 43 22 41 31 38 42 42 41 35 43 42 43 29)
#(14 22 24 41 15 24 33 29 24)
#(41 33 43 20 36 29)
#(34 42 34 20 36 43 29)
#(41 43 43 20 36 42 33 29)
#(41 12 22 41 43 28 39 38 29)
#(25 34 42 33 33 33 22 42 41 43 42 41 33 32 41 35 43 40 42 33 32 41 34 28 42 26 34 32 31 41 43 42 35 43 40 42 39 42 42 39 29)
#(31 21 39 22 41 43 42 41 35 43 20 36 41 33 43 39 31 39 29)
#(35 34 22 14 20 36 26 33 34 42 41 40 35 4 31 22 29)
#(41 33 22 14 20 39 36 41 43 4 31 22 39 29)
#(42 41 33 25 33 34 24 27 37 33 32 24 41 33 33 22 43 14 22 37 36 35 43 29)
#(41 34 42 41 33 34 28 33 35 37 36 26 34 42 33 42 43 42 41 43 4 27 41 43 42 35 43 34 4 42 27 41 33 31 33 37 36 42 43 29)
#(41 35 43 42 41 35 43 22 41 35 43 42 41 35 35 43 32 42 33 43 37 41 43 20 36 39 39 42 35 43 37 33 22 29)
#(31 39 39 42 41 34 22 38 32 35 34 39 38 43 29)
#(42 33 25 32 8 41 15 22 14 22 38 26 43 32 41 33 43 14 35 29)
#(39 39 41 15 29)
#(33 33 14 22 35 34 38 37 36 42 10 42 17 25 25 42 35 43 31 34 42 41 33 43 29)
#(42 41 43 43 32 33 40 38 42 41 35 17 25 37 17 25 25 35 42 43 4 39 17 25 25 42 33 32 43 37 41 35 33 43 37 41 43 42 25 34 29)
#(41 40 12 33 33 33 33 33 39 22 24 35 35 35 34 32 24 27 10 42 25 33 34 29)
#(42 35 33 32 33 22 38 32 42 43 32 25 34 32 42 25 34 32 43 31 34 42 35 43 34 29)
#(39 41 43 32 14 22 41 35 43 43 32 27 25 43 34 31 10 42 25 43 35 43 27 34 29)
#(42 33 32 41 35 33 33 33 33 42 41 35 25 43 34 32 25 10 34 31 25 35 35 34 22 38 42 33 29)
#(42 41 35 35 34 32 33 40 38 43 34 32 41 43 43 42 41 43 32 43 35 43 32 34 32 9 20 36 33 30 35 34 32 31 33 43 34 32 9 20 36 41 34 29)
#(33 40 41 40 41 38 37 36 41 33 43 42 41 43 43 29)
#(14 40 35 42 41 35 35 43 40 38 42 35 34 29)
#(31 41 40 39 41 35 35 43 32 31 14 40 39 39 33 30 39 35 43 29)
#(35 34 28 38 38 31 38 42 41 33 31 35 33 43 34 4 25 37 25 42 41 34 28 38 29)
#(42 43 32 41 43 40 38 35 35 34 27 10 42 25 32 27 25 35 34 42 41 33 33 18 43 16 32 9 39 40 38 42 25 33 33 34 29)
#(39 42 39 6 41 34 28 38 37 41 43 32 14 28 39 35 42 14 29)
#(31 34 42 35 34 28 38 38 37 41 33 33 32 8 14 28 43 42 41 43 42 26 34 29)
#(42 25 32 33 35 34 28 38 27 41 33 43 29)
#(42 43 42 41 43 32 33 32 33 31 33 33 22 25 34 42 35 25 39 35 33 34 37 36 41 42 41 11 35 35 35 34 29)
#(35 35 34 39 28 38 35 42 33 42 25 29)
#(41 15 43 41 43 42 33 4 41 43 35 43 42 33 42 43 42 35 43 42 35 43 29)
#(41 43 22 38 42 41 43 42 41 33 33 33 33 37 41 35 35 43 29)
#(39 32 35 34 28 38 38 42 41 38 43 42 35 34 29)
#(42 26 43 42 25 32 33 33 42 33 39 22 42 35 35 34 22 27 38 42 33 39 42 34 22 39 38 29)
#(33 33 33 18 33 32 33 16 34 42 41 22 25 37 25 33 33 33 33 33 15 32 39 35 42 15 31 27 35 34 29)
#(39 32 41 33 43 40 39 35 42 27 41 43 42 35 34 29)
#(42 41 14 28 38 42 34 42 33 32 35 32 35 31 33 43 42 41 7 35 34 4 35 33 34 42 34 2 34 28 43 37 41 35 43 29)
#(41 43 42 43 42 41 13 40 38 10 32 35 34 29)
#(42 43 35 43 32 42 43 32 41 43 43 42 33 22 38 37 36 41 43 37 43 34 29)
#(42 41 35 43 32 39 32 35 34 22 42 33 33 32 39 41 7 22 31 22 42 41 34 32 42 41 43 42 41 43 36 38 37 26 34 29)
#(41 43 22 42 32 31 33 40 41 35 43 43 29)
#(41 43 40 39 35 43 43 32 43 31 43 31 39 35 34 42 34 32 43 34 32 31 35 43 34 29)
#(38 43 34 22 37 36 43 43 31 43 34 37 36 5 41 43 29)
#(39 32 14 22 38 42 33 30 33 32 41 43 42 26 43 32 42 27 33 29)
#(14 22 10 42 25 43 34 4 34 28 42 14 22 34 42 43 34 29)
#(41 43 40 39 42 41 43 40 38 37 36 41 33 43 32 31 42 14 40 37 36 31 43 42 41 29)
#(35 43 32 42 43 37 35 43 32 41 33 33 31 41 33 22 14 22 38 35 43 37 41 43 34 42 14 22 38 42 4 31 14 40 39 35 8 43 40 27 38 31 8 14 20 36 29)
#(42 34 41 43 40 38 35 42 43 43 29)
#(39 39 21 40 41 43 42 14 28 38 38 42 15 31 35 35 34 29)
#(39 32 33 34 28 38 37 41 43 42 41 43 42 43 40 42 12 43 41 38 43 40 42 41 43 42 41 43 29)
#(33 31 33 20 36 38 41 43 35 29)
#(42 41 43 33 43 40 38 35 32 38 42 43 31 41 43 42 35 31 35 43 29)
#(41 43 38 42 34 20 36 41 35 34 37 36 42 26 43 29)
#(41 43 42 33 35 43 20 39 36 14 37 36 42 35 29)
#(43 42 41 35 32 35 33 43 40 35 35 29)
#(33 33 32 43 31 43 42 24 33 4 41 33 33 33 24 18 33 33 16 32 40 41 33 33 43 42 33 33 29)
#(43 22 41 43 42 33 33 31 26 34 39 35 42 41 43 37 36 33 30 33 34 32 31 41 43 42 27 41 35 43 43 37 36 42 35 35 34 29)
#(39 42 33 33 30 35 43 32 33 33 32 41 25 38 43 34 28 27 42 41 43 29)
#(31 32 39 32 39 10 42 41 43 42 43 40 27 38 32 39 42 34 39 22 43 27 41 15 31 41 33 33 33 29)
#(24 41 34 28 43 32 24 40 33 33 33 32 41 35 33 42 33 29)
#(39 32 14 40 32 24 14 28 42 4 31 14 28 32 24 12 28 41 34 29)
#(12 40 27 37 36 41 43 29 24 24)
#(14 40 39 35 42 33 33 40 39 38 41 43 37 36 42 41 15 31 33 29)
#(42 14 39 40 41 34 32 33 33 40 39 38 41 35 43 42 41 43 32 42 33 33 22 29)
#(12 40 35 40 42 21 40 39 10 42 41 35 43 42 41 33 43 40 41 34 28 5 41 35 43 29)
#(41 43 42 34 4 41 43 42 41 34 32 41 43 42 41 43 42 41 35 43 31 41 43 42 35 34 4 36 37 36 41 35 43 29)
#(42 41 32 39 32 35 15 12 28 38 41 41 15 31 33 28 35 37 36 41 33 43 42 27 37 36 10 4 42 41 43 20 36 27 29)
#(24 14 28 37 36 32 14 28 37 36 43 42 14 32 31 14 28 27 37 42 14 40 10 32 24 40 33 33 33 32 41 33 33 12 40 38 41 35 33 43 29)
#(24 31 14 40 42 27 26 43 42 41 34 29)
#(14 28 37 36 14 42 14 40 26 43 29 24)
#(33 33 40 34 30 43 42 33 33 30 35 43 42 41 35 35 43 42 33 20 36 14 11 35 37 36 39 29)
#(42 43 32 41 33 33 31 41 33 40 39 38 41 15 31 33 29)
#(33 33 40 38 41 43 42 35 34 37 36 35 43 37 41 15 42 33 40 35 34 35 33 29)
#(31 41 43 40 38 41 43 37 36 35 43 42 41 34 29)
#(31 41 43 30 43 42 33 40 35 35 34 41 43 37 36 42 39 35 43 35 43 32 42 41 34 28 35 37 36 43 36 42 33 29)
#(13 34 28 21 40 35 43 41 15 20 36 41 35 43 43 42 33 34 32 31 42 41 33 43 26 43 42 41 43 20 36 35 42 13 29)
#(39 42 27 42 41 15 32 33 33 40 38 37 27 34 42 33 4 7 39 42 41 33 33 43 43 4 37 36 43 42 41 43 43 42 35 34 42 33 30 33 43 29)
#(41 43 40 37 36 33 32 31 33 33 32 31 14 39 22 37 36 41 33 37 36 41 42 41 34 14 22 37 36 42 41 43 29)
#(31 39 35 43 32 33 33 33 33 22 41 35 43 43 24 35 34 24 37 36 39 42 33 31 27 14 20 36 33 33 37 36 41 43 43 42 24 35 24 43 42 41 43 29)
#(31 41 35 43 42 33 33 20 36 39 35 39 35 37 36 43 37 33 29)
#(41 33 40 39 38 42 41 35 43 42 43 32 31 42 41 43 41 43 30 34 20 36 39 38 37 36 42 41 43 42 43 35 43 29)
#(31 42 41 43 43 40 27 42 32 33 33 14 40 39 38 41 35 43 37 36 42 43 32 42 33 33 22 29)
#(41 43 39 40 42 14 40 39 27 33 33 30 35 43 42 41 24 35 43 24 27 41 35 33 32 31 39 41 11 35 43 29)
#(11 35 37 33 34 32 41 33 43 40 37 36 39 38 41 35 43 43 42 41 33 33 9 40 35 43 42 33 15 29)
#(41 15 28 38 37 36 41 43 27 35 34 42 27 34 42 35 34 29)
#(31 41 15 39 28 27 42 14 20 36 41 43 37 36 42 41 38 35 43 39 42 42 41 33 40 33 43 31 43 42 41 15 28 40 41 27 35 43 29)
#(14 20 36 35 5 41 43 37 36 33 37 36 43 42 33 40 42 34 28 41 34 20 36 41 38 43 29)
#(42 41 43 32 33 33 32 41 35 33 33 43 12 39 40 41 33 42 33 33 32 40 42 41 43 30 24 34 42 38 43 37 43 31 43 42 41 33 43 43 43 29 24)
#(39 32 34 20 36 27 39 42 10 43 42 14 28 35 34 28 38 42 43 41 35 34 31 27 43 42 33 4 39 8 41 43 40 41 35 43 40 27 42 33 33 29)
#(42 43 32 42 43 40 37 36 27 41 35 43 32 41 34 20 39 36 39 38 42 26 35 43 40 27 42 14 28 39 36 41 43 42 41 43 37 36 35 34 29)
#(24 41 43 42 14 40 42 41 7 35 42 14 20 39 36 42 39 36 41 43 42 43 27 32 24 40 33 33 32 41 35 33 33 33 43 12 39 40 43 42 41 33 33 29)
#(41 34 28 27 37 36 41 43 42 41 25 34 29)
#(31 14 28 14 20 39 36 35 43 42 42 41 43 42 35 34 42 41 43 37 36 41 43 29)
#(25 35 43 42 41 34 42 33 32 33 43 33 33 42 33 32 40 38 42 34 42 26 34 32 34 28 29)
#(35 35 34 32 42 33 33 33 33 33 32 41 35 33 43 32 28 39 36 41 43 42 41 33 33 33 42 14 22 42 33 33 29)
#(42 41 32 39 32 34 28 41 41 33 31 41 33 43 20 36 38 35 35 42 11 35 43 29)
#(24 42 21 37 36 43 42 41 34 42 41 43 32 41 35 43 40 37 36 27 42 41 34 32 24 40 33 33 29)
#(41 41 34 33 33 37 36 42 41 35 43 37 36 42 10 43 29)
#(24 12 14 20 36 37 36 32 42 14 40 42 37 14 32 40 42 33 37 36 37 41 43 37 36 43 42 33 32 24 41 43 34 29)
#(14 28 35 37 36 42 42 33 33 33 22 41 43 42 33 33 42 43 42 41 33 33 33 33 29)
#(33 33 32 38 42 33 33 32 22 39 38 42 27 42 41 43 34 42 26 34 29)
#(26 35 43 32 39 38 24 34 29 34 29 34 29 12 40 41 33 29 24 38 41 43 8 26 43 38 39 29)
#(33 33 30 34 22 37 36 26 35 43 24 35 32 35 31 39 35 29 24)
#(33 33 33 33 22 14 22 24 41 35 43 42 41 43 42 41 35 43 12 40 43 29 24)
#(33 33 33 32 41 33 33 32 22 33 33 42 41 43 20 36 24 42 41 43 42 41 43 30 43 29 24)
#(33 33 32 43 42 41 33 33 33 33 32 22 41 43 42 41 43 24 39 35 29 24)
#(14 28 39 36 41 43 29)
#(33 33 22 14 42 41 43 37 26 34 32 41 33 43 43 9 40 34 42 34 29)
#(14 22 42 35 34 42 41 43 24 28 39 36 42 41 34 42 15 20 36 38 37 34 12 28 35 32 24 31 42 24 14 28 37 36 14 37 41 35 43 29 24)
#(14 22 37 41 43 41 24 35 32 35 24 43 14 39 22 27 24 39 42 14 28 39 38 42 35 34 28 34 32 14 28 37 36 41 35 42 34 29)
#(24 33 33 22 37 41 43 42 14 40 37 24 36 41 43 42 34 37 42 42 34 4 42 41 35 43 42 43 32 42 43 29 24)
#(34 42 35 41 43 32 42 42 34 31 34 32 28 24 35 34 32 24 14 22 32 43 37 27 38 39 29)
#(14 40 41 43 42 26 43 22 37 36 26 43 42 15 28 34 42 34 32 39 42 34 42 35 36 34 29)
#(26 43 22 41 24 43 42 34 42 38 34 42 43 24 42 38 37 35 43 31 32 42 14 28 14 32 42 24 41 35 43 42 15 29 24)
#(39 42 27 42 35 43 32 33 33 22 42 34 31 34 20 36 37 36 35 43 42 41 43 31 39 36 42 35 34 9 20 36 24 35 43 42 43 43 29 24)
#(41 39 40 42 41 35 43 29)
#(12 40 39 27 42 39 29)
#(41 25 7 35 34 37 36 42 33 33 40 42 14 40 41 35 35 35 4 41 35 43 37 41 35 43 29)
#(33 33 32 12 40 43 42 35 33 33 33 42 33 31 20 36 41 43 42 41 43 32 40 38 34 27 42 35 34 28 34 30 34 29)
#(14 39 38 34 8 14 22 37 36 41 33 43 12 22 38 38 42 35 34 42 26 43 29)
#(33 33 39 22 42 42 41 35 43 39 32 9 39 38 41 35 43 42 24 33 34 24 42 41 34 42 35 15 29)
#(21 40 41 35 43 42 33 33 30 35 43 31 41 35 43 43 42 41 35 34 34 29)
#(39 32 41 43 40 39 35 42 33 33 30 34 28 37 36 41 43 29)
#(26 43 42 14 40 41 43 42 43 29)
#(26 43 37 36 14 42 42 33 40 41 43 37 41 35 43 42 26 35 43 29)
#(14 28 41 35 43 42 41 33 33 33 20 36 39 35 42 33 33 42 27 41 43 42 43 42 35 34 29)
#(33 33 22 26 43 32 33 33 33 32 20 36 42 41 43 42 41 43 42 33 25 29)
#(33 33 33 32 43 31 35 35 43 32 20 36 43 31 35 43 42 33 33 30 43 29)
#(33 33 33 32 35 43 43 31 35 27 43 32 20 36 43 31 35 27 43 29)
#(33 33 32 25 34 35 32 22 35 43 42 41 43 42 34 31 35 34 42 25 37 25 29)
#(14 20 36 42 41 43 29)
#(33 33 32 25 32 41 35 43 42 33 32 40 38 43 42 25 29)
#(33 33 32 25 32 22 33 42 33 25 42 33 33 33 32 8 14 22 43 31 35 27 43 29)
#(14 40 38 41 33 43 42 25 29)
#(41 34 28 43 42 41 38 43 42 41 43 29)
#(35 43 33 33 22 41 35 33 43 43 42 33 31 22 25 34 27 41 42 41 25 34 27 35 35 34 42 33 15 33 32 33 33 33 33 31 33 31 33 29)
#(42 41 33 33 36 32 33 33 33 32 41 43 43 32 22 14 41 43 43 29)
#(14 22 39 36 29)
#(41 43 42 41 33 33 31 33 33 40 41 27 33 43 42 41 43 30 43 32 42 43 42 41 25 34 40 41 35 17 25 25 29)
#(41 35 43 31 26 35 43 32 33 33 32 22 41 13 43 32 42 25 34 32 42 41 33 43 32 8 14 22 43 43 35 34 29)
#(42 41 33 43 32 14 39 22 42 41 27 33 32 27 37 36 42 43 34 29)
#(42 33 32 43 32 33 22 41 35 43 43 32 31 41 33 30 43 42 35 34 31 43 42 41 43 30 43 22 35 35 34 39 29)
#(34 22 25 34 42 25 34 32 27 41 33 32 22 34 32 39 42 42 25 34 42 10 42 25 34 42 41 35 43 42)
#(35 43 43 33 33 33 22 38 25 25 43 18 17 25 16 42 27 37 41 33 33 41 43 43 9 20 36 38 42 35 34 29)
#(41 33 43 42 43 42 34 8 41 43 22 43 22 38 37 41 15 42 25 22 41 38 35 43 43 29)
#(33 33 33 22 41 33 33 33 33 30 24 43 40 35 42 35 34 22 35 43 42 33 29 24)
#(33 42 41 43 42 38 43 37 33 34 40 38 42 35 43 31 42 35 43 29)
#(41 35 35 43 22 42 39 35 39 41 43 43 42 27 35 43 29)
#(41 43 33 33 22 41 43 22 41 43 37 36 5 35 34 39 38 42 33 37 41 43 30 25 34 24 40 39 36 41 35 34 42 41 35 43 29 24)
#(41 43 22 41 43 42 33 25 37 36 41 43 29)
#(41 43 22 41 27 43 42 41 38 33 35 29)
#(33 33 33 22 14 40 27 41 38 17 25 25 35 43 42 33 42 14 39 39 40 37 36 42 35 43 43 42 39 38 29)
#(41 43 43 31 43 43 32 9 20 36 38 42 25 34 42 41 33 33 43 32 22 38 38 42 33 30 43 43 29)
#(31 14 22 38 42 41 34 42 41 43 37 33 33 30 34 31 41 35 43 42 35 43 42 41 35 34 12 28 14 29)
#(33 33 33 42 33 40 27 26 34 43 31 27 43 37 33 33 37 36 42 41 35 43 30 35 34 31 43 43 29)
#(42 34 42 25 25 33 33 34 18 17 25 25 16 32 41 35 43 32 33 33 33 32 40 37 36 25 42 33 33 30 35 34 29)
#(14 39 40 37 36 42 41 35 35 43 42 41 33 43 35 33 31 37 36 41 43 43 42 33 31 43 34 42 33 32 33 32 33 32 33 31 33 42 33 25 29)
#(41 43 39 40 25 35 34 42 33 32 25 42 41 33 32 25 42 33 33 31 41 43 11 38 42 41 43 29)
#(33 35 43 34 28 27 39 37 35 34 29)
#(33 30 20 39 36 41 43 42 33 31 33 43 42 33 30 40 27 34 42 34 42 35 32 35 32 35 32 35 31 35 34 29)
#(42 33 32 33 3 33 33 22 34 31 34 4 42 42 34 31 34 29)
#(33 30 33 33 20 36 43 34 42 35 34 42 10 42 17 25 42 33 25 29)
#(41 43 43 32 38 42 26 34 42 43 35 31 35 43 34 32 40 27 24 41 43 37 34 12 28 39 36 37 36 39 26 35 43 34 32 24 40 33 33 30 33 33 29)
#(33 43 33 40 11 38 42 43 34 42 42 33 30 27 43 31 35 43 29)
#(24 43 40 37 36 41 35 42 34 32 24 40 33 30 33 33 32 12 40 27 34 37 36 43 34 29)
#(24 39 21 20 36 35 43 29 24)
#(27 35 43 42 41 33 33 42 25 20 36 10 42 25 34 32 41 33 33 33 33 22 29)
#(39 42 27 35 43 32 41 43 38 27 34 37 36 35 41 43 40 39 38 4 29)
#(35 31 35 34 22 34 42 33 22 42 27 34 38 42 42 26 25 43 42 41 33 15 29)
#(33 30 33 43 31 43 43 33 33 22 41 35 43 24 35 32 35 31 35 29)
#(33 33 32 27 42 43 34 32 22 41 35 43 42 35 43 34 31 35 43 42 17 25 25 32 31 25 34 41 43 32 42 35 34 29)
#(34 22 41 34 22 10 42 34 32 39 42 42 35 43 34 31 41 35 43 43 29)
#(39 32 14 22 41 43 30 35 43 22 41 43 32 31 41 43 42 34 42 33 30 35 35 43 42 41 33 28 38 35 29)
#(43 42 41 35 43 22 17 25 25 32 39 35 42 17 25 25 41 43 11 29)
#(33 22 27 43 42 34 31 43 34 42 17 25 25 42 41 35 43 32 10 42 36 41 35 17 25 25 29)
#(34 42 43 34 31 35 43 22 41 35 43 42 17 25 25 32 31 25 34 41 43 32 42 25 30 35 43 29)
#(24 14 28 39 35 42 41 27 43 24 42 33 34 32 22 33 33 32 41 43 42 33 33 31 33 29)
#(24 42 14 28 42 41 35 43 35 43 40 35 42 41 43 42 43 32 21 40 39 41 43 39 37 36 43 42 29 24)
#(33 33 32 41 43 42 33 32 40 33 34 38 14 43 42 33 34 42 41 43 30 35 35 43 43 32 38 42 41 35 43 32 28 38 24 35 24 42 41 35 43 29)
#(33 33 32 41 33 43 32 22 24 14 28 39 36 42 35 32 24 31 22 42 41 43 40 39 38 35 37 36 41 43 42 41 34 42 41 43 32 43 34 42 14 22 38 20 36 27 41 43 39 29)
#(33 33 22 41 43 32 25 33 32 40 39 38 42 42 25 35 34 32 27 34 31 34 29)
#(42 41 25 34 32 33 22 34 42 17 25 25 32 31 17 25 41 43 29)
#(35 43 32 41 43 22 41 35 43 42 17 25 25 32 31 25 34 41 43 29)
#(42 33 33 33 33 35 43 32 33 22 42 17 25 32 42 17 25 29)
#(8 40 41 43 43 39 39 35 29)
#(43 32 41 33 33 33 33 22 41 39 35 43 4 14 22 25 34 42 43 32 42 7 42 41 43 27 42 25 34 29)
#(39 32 14 22 37 36 39 39 25 34 29)
#(31 41 34 22 42 33 30 35 43 31 33 30 35 43 29)
#(24 14 40 43 4 42 42 41 43 14 20 36 42 39 35 43 32 24 40 33 33 32 43 42 33 33 33 33 32 33 29)
#(31 32 39 32 14 40 39 37 36 29)
#(33 33 32 35 35 43 42 33 33 31 33 32 40 32 24 26 43 43 40 42 14 20 36 42 41 34 42 41 43 29 24)
#(21 28 35 34 42 41 43 30 43 4 35 43 34 35 42 43 34 31 34 4 35 34 42 43 43 4 31 43 43 29)
#(31 7 28 38 42 41 35 43 4 43 4 41 43 37 36 42 31 42 42 41 43 39 29)
#(34 28 27 42 31 39 39 39 42 34 28 27 34 37 36 42 34 42 35 34 31 39 27 42 43 29)
#(24 34 28 27 34 32 24 40 33 33 32 12 40 41 43 43 43 42 33 33 33 33 29)
#(24 14 28 41 35 34 31 36 37 41 35 34 29)
#(42 34 32 14 28 37 36 42 41 35 43 42 35 43 29 24)
#(31 42 32 39 32 40 43 34 29)
#(34 4 12 35 43 42 7 43 4 43 42 27 35 37 36 31 36 35 34 42 43 42 41 43 29)
#(31 8 14 28 42 34 28 39 39 39 35 42 14 22 4 34 28 29)
#(42 33 32 42 43 32 33 33 32 41 43 42 33 32 33 31 33 32 22 42 24 14 20 39 36 34 42 38 34 42 27 42 29 24)
#(31 8 35 34 22 37 24 36 42 32 24 33 30 35 43 22 38 29)
#(43 42 34 31 34 32 41 34 28 32 20 36 37 43 29)
#(34 28 14 20 20 36 42 35 35 34 37 36 42 31 42 42 41 43 43 42 39 27 41 34 4 41 40 32 41 43 42 27 35 39 8 14 35 34 29)
#(41 31 35 35 43 34 24 28 37 36 35 34 42 34 32 24 40 33 33 32 35 43 43 42 33 33 33 33 29)
#(24 14 40 41 43 42 12 40 42 35 20 36 42 35 24 4 39 42 34 42 10 43 36 38 42 41 43 43 29)
#(25 35 43 43 38 24 43 43 24 34 43 34 42 34 32 34 31 43 8 43 34 28 25 40 11 35 29)
#(42 43 32 33 33 33 32 41 43 43 38 42 33 32 33 32 22 14 39 22 43 34 42 26 24 35 24 34 37 25 43 42 43 43 37 36 43 42 27 34 33 29)
#(14 22 41 43 43 33 42 34 22 29)
#(8 14 22 32 41 43 22 41 43 34 37 42 25 43 29)
#(41 35 43 42 34 30 43 42 43 40 43 43 32 39 39 38 29)
#(42 41 25 43 32 41 38 17 25 25 42 35 43 22 38 42 41 27 43 29)
#(41 43 22 37 24 36 24 41 43 42 41 43 42 27 34 8 43 34 22 4 27 41 43 37 36 41 34 14 29)
#(31 42 33 25 32 8 43 34 22 37 36 42 41 35 43 32 14 22 41 41 43 31 34 34 29)
#(39 35 43 32 34 28 39 27 34 42 43 43 42 39 27 37 31 39 42 41 34 29)
#(34 28 27 24 43 43 24 41 43 42 27 43 42 43 34 42 34 31 34 29)
#(42 35 35 34 32 41 42 41 42 36 42 43 34 28 42 43 37 36 43 42 27 31 27 34 42 41 43 29)
#(31 34 28 33 33 43 34 28 11 35 37 36 34 29)
#(34 28 39 36 41 29)
#(33 33 34 28 42 32 42 35 43 34 39 10 42 42 41 34 32 34 34 20 39 36 37 36 41 43 42 27 39 35 43 29)
#(24 14 28 43 40 41 39 11 35 32 24 40 33 33 32 43 42 43 43 42 33 33 33 33 29)
#(24 41 34 28 38 18 43 16 34 39 37 41 43 8 14 40 41 43 37 36 43 32 24 40 33 33 32 35 35 43 43 42 43 42 35 43 42 33 31 33 29)
#(24 8 20 14 36 43 42 41 43 42 12 40 27 14 25 34 41 43 29)
#(41 14 28 40 43 29 24)
#(43 42 43 20 39 36 42 43 24 34 29 24)
#(35 34 28 42 24 43 34 24 36 42 43 37 36 43 42 41 25 43 39 22 37 43 8 41 43 43 22 33 29)
#(41 43 34 22 41 35 43 42 43 42 33 31 33 30 35 43 34 28 42 41 34 22 27 29)
#(24 42 41 35 43 32 14 20 39 36 34 24 37 36 43 37 41 43 32 40 41 43 43 29)
#(24 14 22 35 37 34 27 42 14 20 39 36 26 34 42 29 24)
#(24 14 22 42 14 28 14 42 41 43 42 41 43 31 22 14 21 22 25 34 37 36 32 24 22 25 35 34 43 29)
#(24 39 14 22 32 24 42 41 43 32 25 42 41 34 28 38 29 24 24)
#(41 43 43 39 40 37 43 29)
#(33 33 40 41 35 43 29)
#(38 42 41 43 43 32 41 43 43 22 27 42 39 17 25 41 43 29)
#(8 41 43 22 42 43 32 41 43 22 4 14 22 42 17 25 43 29)
#(39 32 33 40 35 43 10 37 26 43 38 42 34 29)
#(42 43 32 35 35 34 28 35 37 36 35 43 34 29)
#(33 33 32 41 35 43 43 12 40 33 33 33 32 40 5 42 42 41 12 28 42 34 32 24 41 43 42 41 43 42 43 37 43 40 39 36 41 43 43 29 24)
#(41 34 28 34 28 39 39 35 42 39 38 29)
#(33 33 32 43 43 42 33 33 32 40 41 35 43 42 33 34 40 42 43 37 41 25 32 34 42 35 34 35 42 34 31 34 22 38 29)
#(24 14 39 20 39 36 42 41 34 42 41 35 43 28 27 41 42 41 43 32 24 14 40 29)
#(31 33 33 33 32 43 42 43 43 33 33 32 40 42 42 33 30 43 32 35 43 42 41 33 33 33 33 42 35 34 22 38 24 39 35 34 29 24)
#(41 34 28 37 36 42 41 35 43 40 10 42 43 34 42 14 22 8 41 43 43 22 10 29)
#(33 33 33 33 32 43 42 41 33 33 32 40 42 24 25 31 25 28 38 25 42 41 13 35 34 42 41 35 25 31 25 34 29 24)
#(31 41 35 35 43 33 33 40 27 42 40 39 41 43 42 41 43 42 35 43 34 42 41 35 43 29)
#(42 43 32 33 33 32 41 33 33 43 43 32 40 35 34 42 43 34 20 36 39 39 42 43 40 43 42 41 35 34 42 34 24 12 20 36 42 31 28 24 14 28 41 25 34 42 34 37 36 29 24 24)
#(41 34 28 41 43 42 43 40 35 29)
#(42 25 32 33 33 33 22 42 24 42 41 34 42 35 43 43 32 39 32 40 11 35 42 41 43 42 43 29 24)
#(14 40 34 37 36 42 35 43 34 4 24 41 43 42 35 34 32 24 14 22 14 4 39 42 42 35 35 43 29)
#(33 33 33 22 37 41 43 29)
#(41 33 33 31 33 33 22 41 43 43 40 38 25 42 26 34 31 40 27 35 34 38 37 26 33 43 43 32 9 40 37 36 38 43 29)
#(33 33 32 41 33 43 32 22 41 43 22 41 43 42 33 42 41 43 42 43 34 39 38 33 31 38 25 43 34 37 36 38 42 43 29)
#(42 41 43 40 39 38 37 41 43 34 9 28 41 33 31 41 43 32 43 42 41 43 20 36 34 42 33 34 39 41 43 40 35 29)
#(33 33 22 41 43 22 39 39 38 41 43 31 41 43 22 24 43 34 20 36 38 42 35 34 29 24)
#(14 22 14 20 36 41 43 42 41 43 43 43 37 36 41 43 42 41 43 43 29)
#(41 43 32 42 41 13 39 37 36 41 43 43 32 22 37 36 39 33 33 33 43 9 40 33 30 33 27 43 29)
#(14 40 35 37 41 35 43 42 35 43 38 33 32 41 39 10 43 38 42 34 42 34 32 34 31 43 34 42 41 43 29)
#(42 41 43 42 43 43 32 41 33 43 40 39 41 43 43 32 33 33 22 29)
#(41 43 40 42 41 27 43 42 41 43 31 40 42 35 42 35 34 38 42 34 29)
#(41 33 43 39 22 38 42 41 43 42 33 22 42 37 33 30 33 33 33 33 32 33 33 22 29)
#(33 22 41 33 43 22 39 38 26 34 31 41 34 42 35 43 34 42 14 22 38 26 34 37 36 34 29)
#(31 33 33 22 41 43 22 34 9 22 39 38 37 36 41 34 29)
#(33 33 32 41 35 43 42 33 32 41 43 43 32 22 14 22 38 42 41 43 40 42 41 43 43 42 27 42 35 34 4 35 42 34 9 28 41 35 42 41 43 30 43 29)
#(42 14 40 25 31 40 42 41 43 32 14 20 36 41 43 8 41 43 34 42 41 40 32 24 15 42 33 15 4 29)
#(14 28 42 34 42 43 42 41 32 31 39 36 42 43 29 24)
#(42 43 32 33 33 22 32 41 43 40 35 34 37 35 34 42 41 43 4 35 42 32 24 33 33 22 41 43 32 24 31 24 28 39 36 41 34 39 29 24)
#(41 43 39 40 42 35 34 9 28 10 34 42 41 43 29)
#(41 34 28 38 42 41 43 43 8 14 40 38 31 28 38 37 36 38 39 39 42 41 43 40 42 31 27 29)
#(42 14 40 25 42 41 34 32 33 33 22 32 41 43 20 36 35 34 42 43 34 30 34 37 41 43 42 35 34 32 27 14 42 27 42 37 41 43 29)
#(33 22 42 32 42 33 32 42 25 43 34 22 38 29)
#(43 32 41 43 22 37 25 4 43 41 43 40 38 37 36 37 25 29)
#(33 22 14 20 36 42 41 43 42 14 40 39 8 35 34 42 41 25 38 37 33 22 38 31 41 43 42 41 43 32 42 41 29)
#(35 34 28 38 41 43 42 41 33 43 43 37 33 42 14 40 43 37 36 41 43 38 37 36 41 43 29)
#(34 28 42 42 41 43 27 33 42 43 20 36 32 31 42 33 14 40 42 41 33 42 41 25 34 14 40 39 37 41 43 32 35 34 42 43 20 36 38 42 41 43 29)
#(39 39 33 40 38 38 39 32 39 42 42 41 43 43 38 42 41 43 43 32 31 43 42 42 41 43 29)
#(33 22 41 33 43 22 43 37 36 42 41 43 29)
#(33 33 42 33 22 34 28 38 42 33 39 29)
#(14 22 41 33 33 33 32 42 33 33 32 39 22 37 36 33 31 28 35 34 42 43 41 43 42 43 32 27 42 41 34 29)
#(14 40 39 41 43 42 34 28 27 35 34 42 34 8 42 41 35 34 39 39 41 35 43 42 7 20 36 38 38 29)
#(39 14 40 39 35 42 41 43 37 36 35 34 40 39 37 41 43 32 31 39 37 34 29)
#(27 42 41 35 35 43 32 42 33 31 33 31 33 32 41 33 33 40 39 38 42 41 35 43 37 36 43 37 36 42 41 35 43 31 39 35 32 42 39 38 42 35 43 32 20 36 35 43 42 41 43 42 43 42 34 29)
#(41 40 41 35 43 39 29)
#(42 43 32 39 32 41 43 42 43 31 43 42 41 35 43 35 39 22 37 36 29)
#(42 35 32 41 35 43 42 35 43 40 38 42 35 43 42 41 35 43 29)
#(42 43 32 42 43 43 40 39 38 35 32 14 40 39 38 39 38 29)
#(42 25 32 41 33 33 22 37 36 41 35 43 42 41 33 31 33 43 32 9 22 41 43 22 42 42 41 43 22 38 26 35 43 37 41 43 42 43 37 36 24 41 35 43 24 31 42 41 43 22 31 39 22 41 43 29)
#(39 32 39 32 10 34 31 34 28 38 41 43 37 26 43 43 29)
#(36 41 34 27 41 25 43 42 33 33 29)
#(39 37 41 43 43 42 33 42 33 33 42 25 32 41 43 42 41 33 30 43 43 22 41 35 35 37 36 26 37 36 26 43 34 42 43 29)
#(14 22 26 43 37 36 26 37 41 43 32 12 32 42 43 32 22 26 43 32 41 33 33 32 37 36 41 43 29)
#(33 42 41 43 32 41 43 22 14 42 26 43 32 33 33 32 31 33 33 39 22 42 26 35 43 31 35 34 29)
#(39 32 33 33 22 41 35 43 29)
#(22 33 33 32 26 43 32 43 41 35 43 18 31 32 42 39 32 37 12 16 29)
#(22 33 33 36 35 43 18 31 42 39 32 8 16 29)
#(31 22 33 33 39 36 41 43 43 18 9 14 20 39 36 42 16 29)
#(41 43 40 39 35 42 43 34 29)
#(41 35 43 40 38 42 41 35 35 43 38 42 33 33 32 39 28 42 43 42 33 32 33 31 33 29)
#(39 32 33 33 22 38 39 42 41 33 35 43 32 8 14 22 38 42 41 35 43 32 33 24 33 24 33 32 42 41 43 22 42 43 29)
#(42 27 34 37 36 32 33 33 22 33 33 32 41 43 43 42 33 32 33 31 33 32 12 22 27 42 41 43 32 37 36 41 34 29)
#(33 33 22 33 33 12 26 43 22 31 32 42 43 42 14 22 33 33 32 22 4 24 0 32 26 43 40 41 35 43 29 24)
#(41 35 24 43 24 42 41 43 30 35 43 22 39 39 41 43 42 34 39 38 37 36 42 41 43 29)
#(22 41 43 38 37 36 41 35 34 20 36 38 4)
#(22 21 41 35 43 42 43 37 36 35 43 29)
#(22 33 33 28 43 42 41 29)
#(39 32 22 41 43 43 29)
#(39 32 6 41 34 28 43 37 41 11 35 43 4 12 40 31 12 20 36 27 41 35 43 39 29)
#(14 40 39 26 43 42 41 33 33 31 33 33 22 41 35 43 42 35 43 29)
#(39 32 41 22 42 43 42 26 43 22 42 13 35 29)
#(31 39 42 14 22 39 32 34 39 28 37 36 31 36 41 35 43 42 35 35 43 42 41 43 42 43 43 29)
#(34 31 34 28 34 42 39 35 34 31 28 41 35 37 39 35 34 42 34 29)
#(35 35 43 42 41 43 30 43 40 39 38 41 35 43 30 43 29)
#(8 39 35 43 40 38 32 41 43 40 41 35 34 42 35 43 31 43 42 43 29)
#(39 32 35 43 43 27 42 41 43 40 35 37 41 43 43 38 42 41 43 42 43 3 18 31 39 35 16 34 29)
#(8 41 43 40 42 41 35 43 30 43 22 35 31 39 40 41 43 42 43 43 37 36 41 43 32 14 40 39 36 41 39 35 43 42 35 34 9 20 36 38 42 41 38 43 29)
#(39 32 41 43 40 39 38 37 36 34 42 41 35 43 42 41 38 43 29)
#(42 43 32 42 27 42 33 33 30 43 37 36 35 43 42 41 43 30 43 32 25 40 39 39 36 42 41 43 43 42 41 43 4 12 42 41 43 22 38 35 29)
#(20 41 43 43 43 41 43 43 37 36 35 42 41 39 35 43 40 42 43 35 29)
#(42 41 43 32 39 39 20 35 34 36 38 37 36 5 35 34 42 41 43 32 31 34 38 42 41 35 43 34 22 38 42 41 34 37 36 39 37 35 34 42 34 34 29)
#(43 32 42 33 33 30 43 32 21 40 41 43 9 40 41 35 31 35 29)
#(42 41 43 32 41 35 34 42 35 34 28 35 4 18 25 16 42 14 40 32 41 43 39 20 36 41 34 42 34 42 6 41 38 42 26 43 32 39 39 41 35 34 42 41 43 4 31 18 25 16 41 43 20 36 24 35 43 24 34 9 28 10 43 42 41 35 34 42 34 29)
#(42 35 34 20 36 42 43 18 9 40 8 41 33 40 39 38 41 35 43 42 43 43 16 32 35 35 39 40 43 42 42 41 35 35 34 31 34 42 7 35 34 29)
#(42 13 8 41 34 28 35 32 43 42 43 34 42 43 32 42 34 28 39 36 37 36 41 35 43 39 29)
#(41 35 43 31 43 43 34 28 39 10 34 42 41 35 43 42 41 35 35 43 42 35 43 29)
#(42 25 32 41 33 33 22 42 33 31 33 37 36 41 35 43 42 41 34 42 27 41 43 42 35 43 42 35 35 34 29)
#(39 32 35 35 43 32 33 39 22 41 43 42 27 41 35 43 9 22 43 37 36 41 43 37 36 41 42 24 41 35 43 42 35 34 29 24)
#(42 41 43 32 41 20 36 41 35 34 18 31 39 41 34 42 41 43 31 43 16 29)
#(35 41 43 40 41 35 43 4 33 40 14 40 10 37 36 39 35 34 32 9 41 34 20 39 36 32 42 37 36 42 41 35 35 34 9 28 39 26 43 29)
#(14 28 38 10 42 41 35 43 43 42 42 41 35 43 29)
#(39 32 8 38 42 39 35 43 32 34 20 36 41 43 35 38 34 28 14 29)
#(42 41 35 43 32 39 32 35 34 20 36 35 43 29)
#(33 33 40 41 43 42 33 33 33 29)
#(33 33 22 41 25 43 43 42 35 35 43 37 17 25 25 32 31 25 34 41 43 32 42 17 25 25 32 31 17 25 41 43 32 41 43 11 29)
#(41 35 43 22 41 35 43 42 17 25 25 42 41 43 42 33 30 34 42 35 34 29)
#(42 41 43 32 27 43 22 17 25 25 32 31 25 34 41 43 29)
#(41 34 32 43 43 32 35 34 31 35 43 22 41 13 43 22 41 43 43 42 17 25 29)
#(41 43 11 32 43 22 41 17 25 43 43 29)
#(34 22 25 43 37 17 25 25 42 17 25 25 29)
#(33 30 43 31 35 35 43 32 33 33 33 32 22 27 43 22 37 36 35 42 41 34 31 43 31 43 34 29)
#(31 41 35 43 22 39 31 43 34 22 42 34 29)
#(42 42 35 34 32 33 33 22 43 22 24 39 35 24 35 39 37 41 35 43 42 33 33 42 33 27 41 43 42 41 35 43 31 41 43 42 34 37 33 29)
#(39 32 43 22 38 42 41 43 42 41 43 35 9 39 38 41 43 30 35 43 29)
#(42 33 33 33 33 35 43 32 33 22 42 17 25 32 39 25 34 29)
#(33 32 41 35 43 9 22 33 30 43 43 32 43 22 34 39 43 29)
#(42 25 34 42 41 25 43 43 43 42 33 32 43 42 33 15 32 41 33 33 33 33 22 39 25 34 37 41 35 43 29)
#(35 43 39 22 42 32 31 41 34 22 25 34 42 25 34 29)
#(41 43 34 28 42 41 43 43 40 35 31 35 4 35 37 36 42 41 13 43 4 41 35 34 42 26 35 35 43 29)
#(35 34 22 37 36 26 43 37 35 34 42 27 35 34 29)
#(41 35 43 22 39 25 32 37 25 29)
#(33 33 33 33 43 22 41 35 25 34 29)
#(34 42 41 33 33 22 34 32 25 37 25 29)
#(33 22 38 39 31 38 39 29)
#(41 43 22 25 25 37 25 42 43 42 25 25 34 29)
#(41 43 40 39 39 35 42 34 31 43 42 27 34 29)
#(33 32 9 40 27 37 36 41 43 43 42 34 20 39 36 32 40 41 43 42 25 42 41 7 35 34 42 41 43 43 4 35 43 29)
#(41 35 43 42 41 43 4 41 35 43 42 43 34 32 22 39 37 36 34 31 34 4 22 37 36 41 43 42 34 29)
#(24 14 22 41 39 35 43 32 24 22 33 33 32 43 42 41 33 33 43 43 33 32 33 29)
#(41 43 20 39 36 39 29)
#(41 33 40 41 24 35 35 43 32 24 33 33 30 43 42 41 35 35 43 42 41 43 42 43 43 34 32 43 34 31 34 42 35 34 29)
#(34 28 39 27 26 43 34 29)
#(35 35 34 42 41 33 33 33 34 31 33 31 33 30 35 43 34 28 38 35 43 29)
#(24 14 28 42 25 42 41 34 8 14 28 27 37 36 41 43 42 35 43 43 32 24 22 33 33 32 43 42 43 43 42 33 33 29)
#(34 22 27 43 32 31 14 22 27 38 37 43 35 34 35 42 33 31 33 32 9 22 25 25 37 25 29)
#(34 24 28 27 34 9 28 35 34 32 24 22 33 33 33 32 43 42 43 43 42 33 33 29)
#(42 41 43 32 34 22 43 34 31 34 42 34 9 28 35 43 31 35 35 43 34 42 26 34 29)
#(24 41 34 28 10 42 41 43 42 35 43 39 32 24 22 33 33 32 35 43 43 42 33 33 29)
#(33 33 32 9 22 25 25 35 34 42 25 25 33 42 41 43 43 38 42 33 33 32 22 39 25 37 25 29)
#(33 22 25 37 25 32 31 33 33 22 25 37 25 25 29)
#(33 31 33 30 33 28 38 42 41 33 43 43 29)
#(41 33 31 33 33 22 34 43 29)
#(42 41 35 43 42 43 32 42 25 25 40 41 43 22 34 42 41 33 33 42 35 43 43 43 34 22 34 10 29)
#(18 42 43 43 32 34 28 31 36 35 34 42 34 42 27 34 42 34 29 16)
#(34 22 43 42 41 43 34 28 34 27 38 39 42 41 33 30 43 29)
#(39 42 35 43 32 43 34 22 41 43 42 39 29)
#(41 33 33 33 33 22 25 37 36 42 25 29)
#(33 32 41 43 42 33 15 32 22 37 36 42 41 43 42 33 33 43 33 33 30 43 37 36 26 17 35 43 43 29)
#(41 43 22 25 25 37 25 25 42 25 25 34 29)
#(33 33 15 22 25 25 37 25 25 32 33 33 22 25 37 25 25 32 33 15 22 25 37 25 31 33 33 33 22 25 37 25 25 29)
#(31 33 33 32 41 43 42 33 31 33 34 32 22 41 43 30 43 42 27 25 37 25 25 42 33 33 33 43 29)
#(33 22 14 40 39 42 43 42 27 26 34 42 43 11 41 43 42 43 25 43 43 32 42 9 14 40 37 36 35 35 43 29)
#(33 33 32 41 7 35 33 33 43 42 41 35 35 43 32 22 35 42 25 25 42 25 25 34 29)
#(35 35 43 34 39 22 39 39 4 33 22 25 25 37 25 25 4 33 33 22 35 42 25 25 4 33 30 39 22 35 42 25 25 32 31 33 22 25 37 25 25 29)
#(10 34 39 22 29)
#(33 31 33 30 35 43 22 25 37 25 32 31 41 33 33 33 33 33 33 22 25 37 25 29)
#(42 41 35 34 9 22 42 43 22 33 32 9 22 39 25 25 37 25 25 29)
#(33 15 22 25 37 25 25 4 33 15 22 25 25 37 25 31 33 33 22 25 25 37 25 25 29)
#(42 35 35 34 32 33 22 25 37 25 25 29)
#(33 33 22 25 25 37 25 25 32 33 33 22 25 37 25 32 33 22 25 37 25 32 31 33 33 22 39 25 37 25 25 29)
#(41 35 43 43 37 36 41 43 42 41 35 43 30 43 35 42 33 25 40 34 29)
#(42 41 25 35 34 32 42 34 42 25 43 37 25 43 32 28 34 32 34 31 34 34 29)
#(43 39 22 35 42 41 35 43 29)
#(41 33 35 43 22 39 25 37 25 42 43 42 25 25 34 29)
#(24 41 43 40 41 43 11 35 32 24 22 33 33 32 43 42 43 43 42 41 33 43 43 33 31 33 42 33 33 29)
#(24 42 21 40 41 43 10 43 39 32 42 34 28 42 14 20 36 41 35 25 43 31 25 43 43 32 14 20 36 14 29 24)
#(33 33 22 25 25 37 25 25 42 25 25 34 32 27 43 43 42 41 34 42 26 39 38 35 43 29)
#(33 33 22 25 25 37 25 25 29)
#(41 43 30 35 34 22 42 41 34 30 34 31 41 35 43 29)
#(33 33 22 25 37 25 25 29)
#(41 35 43 34 37 36 26 43 37 33 32 41 43 42 26 33 43 32 31 36 42 43 42 39 17 25 25 42 35 43 42 41 35 43 37 27 42 41 33 29)
#(33 22 25 37 25 25 29)
#(33 33 33 22 26 43 42 41 43 42 35 34 29)
#(33 22 25 25 37 25 25 29)
#(41 43 22 42 34 42 34 42 41 33 43 22 42 42 25 43 42 41 43 11 29)
#(33 33 32 9 22 14 20 36 38 37 36 42 43 25 42 14 20 39 36 41 43 42 26 34 37 36 26 43 43 32 22 25 25 37 25 25 29)
#(41 33 33 33 33 22 25 37 25 29)
#(43 22 25 34 29)
#(42 35 33 34 32 41 35 43 34 42 33 15 22 25 37 25 25 42 43 42 25 29)
#(43 34 31 34 22 41 43 42 33 33 20 36 34 12 28 37 36 42 33 43 34 42 41 35 43 42 43 34 20 39 36 39 35 42 42 41 35 43 29)
#(33 42 41 33 22 25 37 25 25 42 25 34 29)
#(33 33 22 25 25 37 25 42 25 34 29)
#(33 33 33 33 41 22 25 37 25 25 42 25 34 29)
#(33 34 42 35 43 43 34 22 25 33 33 15 35 34 32 27 37 41 43 42 38 43 42 43 34 42 41 43 38 42 43 43 29)
#(33 30 33 43 35 22 25 43 32 31 25 25 32 37 25 25 4 41 33 43 35 22 25 43 32 31 25 32 37 25 25 29)
#(41 13 43 43 42 41 33 22 33 32 9 22 25 43 32 31 25 32 37 25 25 42 43 42 25 34 29)
#(42 33 32 41 43 32 41 43 42 35 43 34 32 22 41 11 35 35 43 31 22 41 43 42 26 35 25 35 43 32 31 22 41 43 40 38 42 41 42 35 25 29)
#(31 26 43 32 33 31 33 32 22 33 30 35 43 40 24 35 43 42 26 43 37 36 42 41 27 43 29 24)
#(33 33 15 22 25 43 32 31 25 25 32 37 25 25 29)
#(33 33 31 33 33 22 37 41 43 29)
#(25 33 15 33 22 41 43 42 25 34 41 43 42 26 17 25 35 35 35 43 32 35 33 25 37 36 42 43 33 25 29)
#(31 34 42 41 33 33 32 33 32 35 43 43 43 22 39 36 42 41 35 43 43 29)
#(31 14 20 39 36 35 41 43 32 41 43 22 32 42 34 28 35 42 41 35 43 42 25 29)
#(42 43 32 41 43 22 41 43 37 36 43 42 35 34 29)
#(27 37 41 43 32 25 33 20 36 38 5 42 34 41 38 43 42 26 35 43 37 36 26 35 43 42 41 35 43 43 43 29)
#(34 28 27 37 36 42 35 34 32 42 27 43 34 29)
#(34 42 43 34 42 43 22 42 42 6 41 43 42 35 35 34 41 43 32 27 37 33 33 15 32 41 43 43 38 39 29)
#(34 20 36 39 10 34 42 34 42 17 25 42 14 20 42 34 42 17 25 31 39 29)
#(24 33 28 37 36 35 32 24 22 33 33 32 43 42 33 29)
#(24 33 40 41 35 43 43 31 39 14 28 10 43 4 42 34 27 41 43 43 29 24)
#(41 34 28 27 10 34 42 35 42 34 42 33 29)
#(24 34 42 34 28 42 21 40 38 10 43 42 41 35 43 31 39 32 24 22 33 33 32 41 43 43 42 33 33 42 33 33 29)
#(33 22 34 33 22 39 17 43 25 10 42 35 31 14 40 10 43 42 34 28 41 34 42 34 42 43 29)
#(24 41 40 41 43 37 36 27 42 41 43 4)
#(41 33 40 10 34 31 34 42 41 43 32 24 22 41 43 33 42 33 33 34 32 27 33 33 33 30 35 33 29)
#(33 33 32 33 30 35 35 43 43 32 22 21 40 39 39 38 24 41 35 43 32 24 42 41 43 22 41 43 9 20 36 39 42 41 43 29)
#(33 30 43 43 22 39 42 41 43 42 41 13 43 42 33 34 32 8 41 43 42 34 31 34 39 28 34 42 43 29)
#(33 33 33 42 33 32 42 43 32 40 27 35 35 34 41 35 43 42 41 43 43 42 35 31 35 34 29)
#(41 34 39 22 34 42 41 13 43 34 42 41 13 43 29)
#(33 33 30 33 32 42 43 32 22 41 43 42 43 35 34 37 25 43 42 25 43 29)
#(42 35 32 39 32 35 34 42 35 34 28 27 41 43 42 41 43 43 10 42 14 22 41 43 39 29)
#(35 34 42 34 38 42 35 34 22 10 42 43 39 35 42 34 42 33 34 38 42 33 30 43 29)
#(35 34 42 17 25 31 10 22 41 35 25 43 42 41 43 38 33 32 39 42 25 43 32 27 37 33 29)
#(41 43 42 35 34 22 37 25 43 42 33 32 42 25 43 41 43 39 29)
#(39 32 41 35 43 42 35 34 42 10 42 17 25 22 37 25 43 42 41 13 43 32 27 37 33 32 42 25 43 41 43 39 29)
#(33 33 22 42 35 34 28 39 35 42 35 31 43 34 32 31 34 42 34 38 42 41 35 43 28 38 42 11 35 43 29)
#(34 38 42 35 43 34 32 9 42 35 34 28 37 39 36 43 43 34 32 39 22 10 40 42 34 29)
#(41 35 32 35 33 32 42 43 32 22 27 41 35 25 43 42 41 13 43 32 41 43 42 41 43 43 10 42 41 43 39 29)
#(42 35 33 32 8 43 34 22 42 26 35 34 32 35 34 38 42 34 22 43 34 6 41 43 43 31 10 10 42 34 29)
#(35 34 28 39 38 37 36 35 42 27 34 29)
#(24 12 22 42 41 43 43 31 41 10 43 43 24 22 43 24 36 14 35 42 35 43 34 20 36 24 41 43 39 32 22 33 33 42 33 29)
#(24 39 42 41 43 43 32 34 22 39 42 6 41 43 43 32 24 22 33 33 33 32 35 43 43 42 35 43 42 33 33 33 33 42 33 33 29)
#(24 41 40 43 42 33 34 29)
#(34 28 41 35 43 37 36 41 43 29)
#(42 41 35 34 42 41 33 33 31 33 33 33 32 41 33 43 22 26 43 37 36 42 43 41 43 42 41 35 43 42 41 33 30 43 43 29)
#(42 41 33 43 42 41 43 39 20 39 36 41 17 25 25 31 11 35 42 41 33 30 43 42 41 43 42 26 17 25 25 43 32 41 43 39 20 36 37 41 35 43 29)
#(41 20 36 35 42 26 27 43 42 41 33 33 31 33 43 43 32 31 42 26 35 43 37 33 32 33 31 34 29)
#(41 33 40 35 34 42 27 41 43 29)
#(26 43 42 41 34 42 27 34 40 38 39 42 41 34 29)
#(41 43 31 43 42 34 20 36 35 42 41 33 33 32 9 40 10 31 10 34 37 22 34 29)
#(42 13 25 35 34 28 38 41 33 37 36 42 38 43 29)
#(39 32 14 40 42 26 43 43 20 36 38 42 43 37 36 26 43 35 37 43 35 34 32 42 9 14 40 41 43 29)
#(35 32 41 33 33 30 35 17 25 25 43 43 4 17 25 25 42 41 33 4 40 38 41 33 43 10 42 35 43 42 35 35 34 29)
#(33 32 41 33 20 36 37 36 33 30 43 42 38 43 18 39 25 43 16 29)
#(33 40 38 41 10 43 42 41 33 42 35 43 34 32 31 40 41 35 35 43 42 35 34 42 27 34 29)
#(42 35 34 20 36 42 41 43 43 32 21 40 41 35 35 43 42 14 29)
#(34 42 41 43 28 42 41 33 34 35 43 42 27 35 34 29)
#(14 28 42 41 33 40 41 43 42 27 34 32 38 26 35 43 37 36 35 34 42 34 34 29)
#(34 28 42 21 28 39 10 34 35 42 35 43 34 29)
#(14 28 42 35 33 43 42 27 34 20 39 36 42 27 33 43 42 35 35 43 43 32 41 35 43 41 39 29)
#(14 28 34 32 9 40 41 34 42 34 32 43 43 31 43 34 32 40 41 35 37 35 43 32 39 41 33 30 35 43 42 43 34 32 35 34 31 43 43 29)
#(14 28 42 41 35 35 34 9 28 35 32 38 31 38 14 42 43 42 35 33 34 29)
#(34 42 34 42 41 33 30 43 43 39 28 38 42 41 43 32 42 35 43 42 33 29)
#(41 35 33 35 43 32 42 25 32 22 41 35 43 31 22 41 17 25 25 43 43 42 42 14 37 36 35 34 29)
#(41 34 42 41 25 35 43 28 35 37 36 35 37 41 42 35 34 29)
#(34 20 36 41 27 32 35 43 42 41 33 42 25 34 4 42 41 43 43 34 42 35 15 30 43 20 39 36 38 42 14 42 35 43 34 4 31 42 41 43 43 4 42 34 4 35 31 35 34 29)
#(33 15 20 36 38 41 43 42 27 31 27 26 43 30 35 43 42 41 43 43 29)
#(41 33 43 37 36 41 33 26 43 43 32 31 43 14 37 25 43 32 20 36 41 35 43 42 35 35 43 32 31 20 39 36 38 39 29)
#(34 20 36 42 41 34 42 41 33 43 43 31 41 43 42 43 35 34 29)
#(42 35 34 31 41 35 34 28 14 20 36 41 43 42 41 43 43 32 41 35 33 43 20 36 41 43 38 29)
#(39 32 41 33 43 42 41 43 43 18 31 43 42 34 37 33 16 20 36 33 41 43 42 43 40 42 35 43 29)
#(42 41 35 43 32 41 43 37 36 41 33 30 43 20 36 41 35 35 43 42 35 34 42 27 34 29)
#(42 41 43 32 39 11 35 43 31 43 20 36 38 42 27 35 35 34 37 27 42 35 43 34 9 28 35 35 34 29)
#(27 41 43 20 36 35 43 39 11 32 42 34 28 35 34 42 43 42 10 35 43 29)
#(34 20 36 41 43 39 37 41 43 30 43 43 29)
#(41 34 28 39 35 37 36 38 37 41 35 31 43 34 27 42 41 43 42 41 43 43 32 39 42 26 43 29)
#(42 34 28 39 36 41 43 42 41 33 30 43 32 39 14 40 35 42 14 37 36 42 39 31 36 41 43 29)
#(33 33 40 41 33 43 42 41 33 33 33 42 33 29)
#(41 33 33 33 22 31 38 25 34 34 38 42 27 38 34 42 41 43 42 39 38 41 43 29)
#(43 34 22 33 33 33 22 38 27 41 43 30 43 42 26 43 42 35 34 34 42 33 37 33 25 29)
#(41 33 22 33 33 22 42 41 43 35 34 42 43 42 41 43 32 33 33 29)
#(41 33 22 33 33 17 25 31 38 26 43 43 42 25 34 29)
#(39 32 14 31 33 33 22 38 37 36 43 42 17 25 37 41 43 29)
#(33 33 22 38 17 25 31 38 42 25 34 29)
#(33 33 31 33 20 39 36 38 42 43 29)
#(41 33 22 42 42 43 42 41 35 43 32 41 43 22 32 31 22 41 38 34 29)
#(31 22 42 41 25 34 22 35 33 42 41 35 43 42 34 42 41 41 33 31 41 33 33 42 33 29)
#(42 41 43 9 20 36 41 35 35 43 37 33 33 33 30 35 33 33 33 32 43 43 33 33 22 37 36 43 42 33 33 33 42 33 33 42 17 25 25 29)
#(41 43 40 42 39 25 34 42 35 35 34 42 33 31 33 32 9 40 39 38 41 43 42 41 43 42 33 42 35 43 34 29)
#(33 40 41 35 43 25 37 33 33 33 32 31 42 33 22 41 17 25 25 35 43 42 33 33 32 27 41 43 31 26 33 31 33 33 43 34 42 27 37 36 41 43 43 43 29)
#(33 40 39 37 25 25 34 37 26 33 31 33 34 32 42 33 31 26 43 43 32 41 33 33 32 28 39 42 25 25 32 27 37 33 33 15 32 41 33 32 33 32 43 43 29)
#(42 33 32 41 43 42 33 40 14 42 41 35 43 4 42 41 13 43 43 32 42 43 42 39 37 25 25 42 41 43 30 25 25 43 34 32 33 40 33 30 13 43 29)
#(31 33 33 33 33 40 39 38 38 42 33 30 43 42 41 43 43 43 32 31 40 38 35 37 36 33 42 41 35 43 29)
#(24 14 40 35 37 41 43 43 42 14 28 41 35 31 35 43 43 32 24 33 33 22 42 41 43 29)
#(42 41 43 43 32 33 33 32 33 35 43 43 32 22 33 30 43 42 33 24 40 39 36 14 32 31 43 14 28 27 39 40 41 43 37 41 29 24)
#(14 22 32 24 14 28 39 36 37 36 38 42 14 32 24 27 42 33 20 39 36 41 35 43 42 41 43 42 33 29)
#(27 42 33 42 41 13 43 43 42 41 33 20 39 36 26 34 29)
#(33 22 14 20 36 42 35 43 34 42 34 32 41 43 14 40 38 42 41 43 42 34 42 35 43 34 32 35 42 41 33 33 29)
#(35 43 34 20 36 34 39 35 29)
#(33 33 22 36 29)
#(42 43 37 27 33 32 33 33 40 33 33 31 33 33 32 41 43 30 35 13 43 43 42 33 29)
#(33 39 40 43 34 32 31 14 40 41 35 13 43 42 35 34 32 42 10 42 25 25 34 29)
#(41 33 43 40 41 35 43 42 33 30 35 35 43 32 33 33 32 31 33 33 33 32 43 42 41 33 43 29)
#(24 41 40 41 43 42 33 30 43 31 40 14 39 39 31 42 41 32 24 33 33 22 42 41 43 43 29)
#(41 43 42 33 31 33 40 39 35 42 33 33 40 41 35 35 43 42 33 32 31 33 33 22 42 43 42 43 42 41 43 29)
#(14 22 41 38 42 33 33 32 41 33 43 12 22 43 42 33 25 34 39 42 41 35 43 29)
#(33 33 40 39 38 41 42 33 30 34 29)
#(33 33 32 39 38 42 26 34 43 32 43 38 42 43 34 42 26 34 31 38 26 34 24 39 35 29 24)
#(39 32 39 32 41 43 22 37 36 42 33 42 41 33 33 33 33 33 42 41 35 43 22 32 27 37 41 43 29)
#(41 43 42 41 34 22 41 43 22 41 43 37 36 26 34 32 9 22 41 25 43 43 43 42 41 35 43 31 25 43 42 41 35 31 35 34 29)
#(41 43 40 42 25 34 31 35 34 29)
#(26 43 40 33 25 29)
#(39 32 41 35 43 40 38 37 36 43 42 33 34 31 34 42 25 35 34 29)
#(24 14 20 36 35 34 37 36 41 32 24 22 41 43 42 41 34 43 29)
#(24 14 28 39 36 37 36 35 43 41 34 20 36 29 24)
#(34 39 28 38 41 43 9 20 36 38 41 25 43 43 43 31 34 42 41 35 43 42 41 43 29)
#(14 39 20 36 38 35 43 29)
#(33 33 33 22 26 43 42 33 33 33 31 22 41 43 42 35 34 29)
#(14 22 39 35 32 39 32 42 41 34 22 38 37 41 43 42 41 35 43 31 33 33 43 33 33 42 43 42 33 33 32 41 33 33 32 35 43 34 43 29)
#(33 33 32 41 43 34 43 32 22 38 42 37 33 34 42 25 32 42 33 33 22 43 29)
#(42 33 33 22 14 22 27 34 42 34 42 43 37 36 43 42 33 42 33 33 32 41 35 43 38 25 43 42 33 30 34 29)
#(42 41 33 31 33 33 43 32 33 33 22 42 33 25 37 33 25 32 14 22 25 34 42 33 35 34 42 17 25 37 17 25 41 29)
#(41 34 22 26 43 37 25 43 42 41 34 35 29)
#(41 43 39 22 35 34 9 28 37 34 27 25 43 31 10 42 33 35 43 32 22 38 42 33 42 33 33 32 12 40 43 42 41 43 29)
#(33 33 20 39 36 38 42 43 29)
#(41 35 43 20 36 35 32 35 43 42 41 33 43 41 43 42 41 38 43 37 36 41 43 42 38 35 43 43 32 41 33 33 22 29)
#(24 42 27 35 32 35 32 35 43 14 20 36 43 37 39 36 14 39 42 25 34 4 41 12 28 41 43 31 41 12 28 39 32 24 41 33 43 43 22 42 41 35 43 29)
#(41 43 40 41 11 38 43 42 33 31 40 41 10 27 43 42 35 35 34 29)
#(14 40 42 41 33 43 24 20 36 41 43 42 43 42 41 43 43 32 36 43 34 31 35 35 43 29 24)
#(14 40 42 35 43 43 40 27 37 36 41 33 43 42 14 40 41 43 42 34 20 36 43 24 35 29 24)
#(31 41 43 40 4 24 41 39 35 43 40 43 42 35 34 32 24 31 43 40 41 35 43 37 36 42 43 29)
#(33 30 34 38 42 14 20 36 10 42 17 25 25 41 43 37 36 41 35 43 42 41 34 42 25 31 25 34 35 29)
#(42 43 32 41 43 40 42 35 31 43 34 28 35 43 37 41 12 28 35 29)
#(41 39 35 43 42 41 33 43 43 42 33 22 41 43 10 33 32 31 43 42 35 34 22 41 43 43 37 36 38 42 35 34 29)
#(42 41 43 22 35 34 42 33 33 30 34 32 14 22 42 41 35 43 42 34 37 36 41 43 39 42 41 43 30 34 29)
#(39 42 41 43 42 41 33 43 34 32 41 43 22 37 41 35 43 42 25 43 29)
#(14 39 22 42 41 43 31 22 39 36 26 35 43 42 25 34 42 25 34 39 29)
#(41 43 38 42 43 33 33 43 42 42 25 34 31 25 43 32 27 35 34 42 41 33 33 33 22 38 37 36 41 43 30 43 29)
#(41 43 22 42 26 35 34 29)
#(34 22 42 41 35 43 43 30 35 35 43 37 41 33 43 34 22 38 39 42 41 24 10 43 42 41 34 29 24)
#(41 33 33 33 22 41 17 25 25 43 42 33 32 38 42 41 38 33 43 42 17 25 25 29)
#(34 22 38 41 17 25 25 43 29)
#(41 33 43 22 41 25 43 43 42 34 31 41 25 43 43 42 34 29)
#(33 33 33 32 41 43 42 33 33 33 42 33 33 32 22 42 42 41 34 28 37 36 41 39 27 33 43 43 32 21 40 39 39 35 43 42 41 34 37 36 27 34 29)
#(14 22 42 42 41 33 43 43 42 33 40 38 39 32 41 43 43 42 33 33 31 33 40 37 36 29)
#(31 14 22 9 22 34 34 28 39 27 29)
#(41 43 30 35 43 40 35 32 27 37 43 34 32 12 28 41 43 42 24 27 29 24)
#(42 35 33 33 43 43 32 41 43 22 38 42 25 34 32 39 42 25 34 35 33 32 31 42 25 43 32 42 42 25 43 35 33 29)
#(33 22 35 42 17 25 29)
#(42 33 33 32 41 33 43 22 42 43 42 25 43 32 35 42 33 30 33 43 29)
#(39 32 41 33 43 22 37 42 25 43 42 43 34 42 41 33 33 43 29)
#(41 34 28 35 31 43 5 42 41 43 40 37 36 35 43 42 35 43 34 42 33 31 33 32 35 34 42 35 43 34 42 41 43 35 34 4 41 34 28 42 41 43 42 34 22 17 25 25 4 31 41 35 43 42 41 33 33 33 33 29)
#(14 28 42 41 33 43 40 27 42 41 35 43 42 41 38 43 34 38 42 41 33 42 25 43 34 29)
#(41 33 40 33 33 32 41 33 32 33 32 41 33 32 33 32 33 31 33 29)
#(41 33 33 43 22 38 37 36 38 34 42 25 34 37 25 34 31 25 43 37 25 43 29)
#(14 28 42 41 35 43 42 43 42 41 33 43 43 40 38 35 32 31 14 28 39 36 35 43 42 41 33 33 33 29)
#(41 33 22 17 25 25 42 43 43 34 33 32 41 35 43 43 42 25 34 29)
#(41 43 32 9 40 43 42 41 43 32 40 38 42 41 43 37 36 41 35 34 42 41 33 35 43 40 35 37 36 41 35 43 29)
#(31 35 34 28 42 42 41 33 30 43 37 36 43 40 39 38 35 32 14 39 40 41 35 43 42 32 42 13 42 39 32 41 33 40 38 26 43 42 43 29)
#(14 28 42 41 33 40 38 41 35 35 34 28 43 37 36 37 42 25 25 43 42 26 34 42 39 42 25 43 35 43 29)
#(41 35 34 43 40 41 35 43 43 42 34 28 41 43 29)
#(43 34 22 42 41 43 40 37 36 41 7 35 34 42 41 43 29)
#(42 41 33 33 42 33 33 32 43 42 35 43 22 42 17 25 41 43 32 42 25 34 29)
#(38 43 22 41 35 25 25 34 29)
#(42 35 43 42 33 33 33 32 43 22 42 17 25 41 43 29)
#(33 33 33 22 14 22 41 35 43 43 43 42 33 33 33 42 27 41 17 25 25 43 42 33 42 43 42 27 33 35 34 42 41 34 38 29)
#(41 25 34 39 22 37 36 41 43 43 34 34 42 41 35 25 34 42 43 43 32 41 34 22 29)
#(41 34 28 35 43 38 34 9 28 34 42 41 43 34 32 43 31 35 43 34 29)
#(33 33 32 33 32 33 32 22 41 43 24 35 32 24 42 34 38 42 41 38 34 28 42 42 25 43 42 26 35 34 29)
#(41 34 28 22 14 39 40 38 17 25 25 42 41 43 37 33 33 32 33 33 32 33 32 31 20 36 41 27 17 25 25 42 35 34 42 41 35 25 34 29)
#(41 34 28 39 38 37 36 41 43 42 27 27 34 32 33 22 29)
#(33 30 27 43 40 38 38 29)
#(41 33 33 33 32 41 43 42 33 33 33 32 22 26 35 35 43 42 41 35 34 43 22 43 42 33 32 41 43 42 33 33 33 29)
#(42 41 34 38 42 41 33 33 33 32 33 32 9 43 41 33 33 32 22 41 43 42 41 25 43 31 25 43 29)
#(33 22 35 42 41 25 43 31 25 43 38 42 33 33 30 43 43 42 41 25 43 31 25 43 29)
#(18 41 34 28 40 25 43 34 4 34 28 41 43 42 34 42 43 29 16)
#(41 35 25 34 42 41 33 33 42 41 33 33 31 33 33 33 22 39 36 42 41 35 25 4 39 14 22 42 35 31 35 43 29)
#(41 35 43 40 37 36 33 30 24 33 29 24)
#(33 22 25 42 41 35 25 40 4 33 22 25 31 33 22 25 29)
#(33 22 41 35 43 42 35 43 25 34 4 25 34 4 42 41 25 43 29)
#(33 31 33 33 32 33 32 27 26 43 42 41 43 43 43 32 22 14 22 33 33 15 32 41 43 43 32 42 41 43 43 38 42 33 33 33 42 33 33 32 33 29)
#(34 22 39 38 29)
#(33 33 33 15 32 9 22 34 42 39 17 25 25 35 43 32 40 43 42 41 33 33 31 33 34 37 34 32 34 32 34 31 34 29)
#(41 43 24 40 14 35 43 43 42 41 43 43 43 43 31 41 10 43 43 32 24 41 33 43 22 29)
#(33 39 40 26 33 43 43 43 37 43 43 34 32 31 39 37 42 35 34 42 33 33 29)
#(42 43 32 33 42 42 39 40 39 38 43 37 34 31 40 39 35 43 42 34 31 35 43 34 29)
#(33 33 39 40 43 32 9 40 39 42 33 30 43 43 43 32 31 35 43 34 29)
#(41 43 22 41 43 40 38 38 31 38 42 41 33 33 33 29)
#(41 43 40 41 35 43 42 33 32 33 32 31 41 38 43 42 33 29)
#(33 33 33 22 14 22 25 25 35 34 18 17 25 25 16 42 41 43 42 35 35 34 29)
#(33 33 32 41 33 32 33 33 32 43 34 28 32 22 41 25 43 43 40 35 33 25 32 25 29)
#(34 20 36 38 37 36 27 35 43 31 37 36 43 43 32 14 22 29)
#(33 33 20 36 41 43 27 41 15 42 33 32 33 31 33 31 33 33 42 14 20 36 35 43 42 34 42 34 42 43 31 43 32 41 33 33 22 29)
#(33 33 22 38 41 43 39 29)
#(31 14 28 42 41 43 43 42 26 34 31 34 22 42 41 43 9 20 36 34 42 35 34 42 41 43 35 37 41 43 29)
#(33 33 33 33 33 33 22 34 42 33 34 31 34 22 33 42 43 29)
#(13 34 28 14 20 36 39 35 42 33 33 30 34 42 41 43 43 37 36 42 41 34 38 37 36 41 43 29)
#(31 21 39 20 36 38 43 31 35 43 9 40 42 41 17 25 25 43 43 42 41 35 43 9 22 33 25 29)
#(33 33 40 22 14 39 40 42 34 42 41 34 42 43 32 43 31 43 37 41 43 42 41 43 29)
#(31 14 40 38 33 43 42 34 42 35 34 12 28 14 28 34 42 43 31 43 32 27 42 41 34 28 38 39 39 42 14 36 41 43 42 34 42 35 34 29)
#(34 4)
#(33 33 33 40 37 36 25 42 26 33 33 35 43 34 32 33 33 33 33 31 33 33 32 9 39 28 25 34 29)
#(33 33 22 14 40 38 34 42 35 34 31 40 37 36 41 43 42 25 29)
#(14 20 39 36 41 43 29)
#(33 33 31 15 40 37 36 41 34 29)
#(33 33 31 33 32 33 33 32 20 36 41 35 34 42 33 33 33 33 37 36 41 38 43 43 30 43 29)
#(11 41 43 32 41 33 33 42 33 33 32 41 43 30 35 43 32 22 41 34 37 36 41 43 43 31 36 34 29)
#(33 22 41 35 43 37 36 34 42 14 22 43 34 37 42 41 35 43 42 34 30 34 42 25 25 33 33 34 18 17 25 25 16 29)
#(33 40 38 25 43 42 33 33 33 32 33 33 30 13 43 43 32 31 25 43 42 33 33 33 32 41 35 31 43 43 42 33 33 42 33 33 29)
#(41 43 42 33 33 32 43 42 41 43 33 33 33 33 32 22 26 43 37 36 41 34 31 22 37 36 29)
#(41 34 22 42 41 35 43 43 42 33 20 36 36 33 30 43 31 36 36 34 29)
#(41 34 28 39 36 37 36 41 43 42 33 25 29)
#(41 35 43 20 36 41 35 43 42 34 38 42 41 33 43 32 41 35 33 43 22 29)
#(39 32 9 40 39 36 14 20 36 42 41 43 29)
#(26 43 20 39 36 38 42 41 35 35 43 40 38 42 41 33 42 33 32 27 37 33 33 32 43 42 38 35 43 43 43 42 33 33 33 33 42 33 29)
#(33 33 30 43 42 35 34 27 41 33 43 38 42 33 33 42 33 33 32 33 32 22 42 41 43 42 33 43 34 42 33 35 33 29)
#(41 43 32 33 33 32 40 38 39 38 37 25 34 32 41 42 12 28 27 35 34 42 35 34 29)
#(24 41 35 43 38 37 36 42 14 20 39 36 41 35 43 42 41 38 35 24 42 27 14 42 35 35 34 32 33 33 22 29)
#(24 14 28 38 42 14 20 29 24)
#(14 22 35 34 22 34 42 34 38 42 35 33 29)
#(35 34 38 42 41 43 28 42 41 43 39 35 42 35 34 42 38 31 35 34 32 14 22 29)
#(25 42 41 34 42 33 40 8 38 34 28 35 34 42 34 32 31 36 39 29)
#(33 31 33 33 22 14 22 41 43 37 36 26 33 43 37 39 38 33 33 33 32 41 33 43 42 33 33 33 42 33 32 33 29)
#(41 43 39 40 41 43 42 33 31 33 30 33 31 33 18 33 16 33 43 42 41 35 43 42 33 33 29)
#(33 31 33 40 39 27 26 43 43 42 41 35 35 43 32 33 33 33 32 37 33 33 29)
#(33 31 33 32 41 33 33 32 33 32 35 43 32 22 41 35 34 43 42 41 35 43 40 17 25 25 29)
#(41 33 43 22 25 42 25 34 28 42 42 43 42 33 31 33 30 43 43 22 42 33 29)
#(33 31 33 22 34 28 42 43 42 41 43 42 41 43 32 33 29)
#(41 35 43 43 22 37 25 43 42 33 30 17 25 25 35 43 42 35 35 43 32 31 35 34 32 42 25 43 42 35 43 30 43 29)
#(34 27 17 25 25 22 38 32 31 22 34 22 42 25 43 29)
#(33 39 22 42 41 35 43 22 37 25 43 42 26 17 25 25 43 42 35 35 43 42 25 43 42 35 43 30 43 29)
#(34 27 17 25 25 22 38 32 31 22 34 22 42 25 43 29)
#(41 43 27 43 20 36 41 17 25 25 42 35 43 42 41 43 35 33 29)
#(33 33 22 26 25 35 43 22 25 43 32 31 22 42 26 35 43 42 41 25 43 43 42 34 42 41 42 25 20 36 38 42 41 35 43 29)
#(41 35 34 31 43 43 22 35 35 35 43 42 41 35 25 34 42 25 22 25 25 34 18 17 25 25 16 32 38 42 25 25 34 18 17 25 25 16 42 41 35 43 42)
#(43 43 22 25 43 32 37 25 25 34 42 25 25 42 41 35 43 42 25 29)
#(33 22 41 35 43 42 35 43 39 22 41 43 42 25 25 34 42 41 43 30 35 43 42 27 34 42 41 35 43 42 41 43 37 25 25 34 42 25 25 41 43 11 29)
#(21 22 39 41 43 42 41 43 30 35 35 34 37 25 25 34 42 25 25 41 43 39 29)
#(41 34 22 38 32 39 32 42 41 35 43 42 35 43 43 34 37 25 25 34 42 25 25 42 41 35 25 34 42 25 29)
#(33 22 41 35 43 42 26 35 34 22 38 42 41 25 43 43 42 35 43 37 25 25 34 42 25 25 41 43 11 29)
#(33 33 33 18 33 32 33 29 16 22 14 31 33 33 33 18 33 32 33 29 16 28 27 39 42 26 43 37 36 41 33 33 41 43 43 42 41 33 33 43 42 34 35 43 29)
#(33 33 22 41 43 20 36 38 39 37 36 42 25 34 41 43 42 41 33 30 35 43 43 31 41 33 33 32 41 43 42 41 33 42 33 15 31 41 43 42 41 33 42 33 31 33 29)
#(41 35 43 22 39 38 42 41 33 31 39 38 42 34 42 41 33 42 41 43 37 36 41 35 43 30 43 29)
#(35 34 32 39 32 22 14 42 41 35 35 43 37 36 41 43 42 43 31 43 37 41 43 42 35 43 29)
#(33 33 22 41 43 42 41 34 20 36 37 24 36 34 31 39 43 42 41 35 43 31 41 33 29 24)
#(33 33 33 33 40 39 42 43 42 33 33 33 33 31 34 39 42 33 33 33 33 31 33 33 32 43 42 41 33 42 33 15 29)
#(41 43 34 28 39 39 36 42 41 35 43 42 41 35 43 43 29)
#(33 33 33 22 35 34 22 25 43 42 42 10 34 42 43 43 34 32 41 43 30 13 43 43 29)
#(43 22 37 17 25 25 32 31 17 25 41 43 32 42 17 25 25 32 31 17 25 41 43 32 41 43 11 29)
#(34 42 41 43 22 25 43 37 17 25 25 42 17 25 25 29)
#(43 43 43 24 40 38 43 31 14 28 27 38 43 34 42 41 43 32 24 22 33 33 33 32 43 31 35 43 29)
#(34 42 35 33 43 28 38 10 42 25 43 42 35 33 32 14 22 29)
#(41 43 43 40 38 42 41 35 43 42 34 32 27 43 32 43 31 35 43 43 29)
#(33 30 34 28 22 27 43 42 41 43 42 17 25 25 32 10 42 6 41 17 25 25 42 41 35 43 29)
#(35 43 43 42 41 34 28 22 39 37 17 25 25 42 17 25 25 29)
#(31 27 43 42 43 34 22 39 25 43 37 17 25 25 42 17 25 25 29)
#(42 33 33 33 33 35 43 32 40 42 41 33 32 35 43 22 17 25 37 17 25 29)
#(33 33 29 33 32 33 30 27 35 43 32 40 27 24 35 24 34 42 33 33 30 33 33 42 41 43 42 34 42 41 43 43 32 33 34 22 29)
#(39 32 41 34 22 14 22 39 35 37 36 41 43 42 41 38 34 31 36 8 41 34 20 36 38 29)
#(33 33 33 33 22 33 30 35 35 3 33 25 33 42 34 28 27 43 42 41 34 30 43 34 29)
#(24 42 33 33 30 34 28 14 39 39 32 21 39 28 41 34 42 43 27 41 35 43 32 24 41 33 43 22 29)
#(42 41 43 32 33 33 22 14 40 27 35 42 43 42 41 43 43 32 31 24 42 41 35 43 32 14 28 39 36 37 36 5 42 14 20 39 36 41 43 10 42 35 34 29 24)
#(33 33 32 33 43 42 33 33 15 42 33 32 22 41 39 39 24 41 43 40 39 27 38 42 41 43 42 43 32 24 27 37 41 35 43 42 41 34 38 42 33 33 31 42 41 43 27 43 43 40 41 43 29)
#(33 33 22 38 43 32 35 35 43 31 43 42 41 43 31 35 43 43 29)
#(14 40 33 33 33 32 12 22 42 35 34 29)
#(33 33 22 38 43 42 33 33 30 33 33 33 33 43 29)
#(33 33 20 36 42 33 33 42 41 43 31 41 43 42 41 35 43 29)
#(14 40 39 38 37 36 43 42 41 35 43 37 36 38 37 36 43 34 32 41 43 22 29)
#(38 34 32 42 26 43 37 36 43 34 32 20 36 42 35 37 26 33 34 29)
#(41 40 41 43 42 41 34 39 12 28 42 33 30 27 43 42 43 34 39 20 36 25 33 43 34 27 42 14 29)
#(43 32 33 33 22 42 14 40 38 26 43 42 33 37 25 43 42 43 43 29)
#(41 33 31 26 35 33 15 39 38 26 34 42 27 35 43 34 42 41 35 43 29)
#(33 30 13 43 40 41 43 42 33 37 36 26 35 34 42 33 39 29)
#(33 40 35 37 36 41 35 43 43 14 40 38 27 42 42 25 34 32 35 34 28 29)
#(42 41 43 34 20 36 41 35 32 35 43 29)
#(41 43 42 41 43 42 33 20 39 36 42 42 41 43 35 35 43 42 35 43 43 34 29)
#(41 34 28 41 43 42 27 10 42 25 43 42 33 34 42 43 29)
#(24 41 40 41 39 35 43 43 32 24 40 33 43 33 20 42 33 33 33 29)
#(33 30 35 43 34 22 42 25 43 42 41 35 43 32 27 42 25 25 29)
#(18 33 30 34 28 41 43 25 42 41 7 39 38 33 33 34 42 41 33 32 42 10 42 43 42 26 34 38 39 29 16)
#(33 22 41 35 43 42 41 33 35 43 33 29)
#(31 42 33 30 33 33 33 32 25 25 34 22 38 32 39 42 41 35 43 29)
#(33 30 43 34 39 22 42 43 42 33 30 35 43 29)
#(35 43 32 35 33 34 22 26 43 31 22 29)
#(34 42 33 30 43 20 36 43 43 33 34 42 43 42 33 22 26 35 34 42 33 29)
#(31 43 30 43 40 42 33 40 39 38 43 29)
#(41 33 30 33 29 20 31 33 33 32 35 43 43 42 41 33 43 43 33 31 33 32 39 22 26 33 34 37 36 42 43 29)
#(24 36 35 24 42 41 27 43 32 33 33 40 32 42 14 40 42 35 35 34 20 36 33 30 34 24 39 35 37 36 29 24)
#(31 41 35 43 40 8 33 40 8 33 32 41 43 30 13 43 43 32 40 42 26 38 43 42 33 29)
#(42 41 43 32 33 34 20 36 35 42 27 26 43 37 36 33 30 33 43 37 42 25 43 29)
#(33 40 38 37 36 39 19 25 25 18 17 25 25 16 42 27 41 33 34 32 31 39 36 33 43 30 43 42 41 35 25 43 43 29)
#(34 28 41 43 34 39 20 36 35 34 37 36 35 43 34 32 27 33 30 35 43 42 25 34 29)
#(43 34 20 36 37 36 35 41 35 43 29)
#(33 20 36 41 43 42 27 41 35 43 42 34 31 41 33 43 22 37 36 41 35 43 35 29)
#(24 14 28 33 40 27 37 36 42 42 35 34 27 32 24 33 33 40 29)
#(24 33 40 18 33 16 39 39 29 24)
#(33 35 34 32 12 20 36 42 25 43 31 25 43 42 33 32 20 36 33 39 40 37 36 41 33 43 29)
#(33 20 43 29)
#(39 32 33 29 20 40 32 24 14 28 41 43 43 42 25 39 35 32 39 38 35 34 29 24)
#(14 40 33 30 43 43 20 36 37 42 19 25 31 19 25 18 17 25 37 17 25 16 29)
#(24 21 40 39 41 43 42 43 38 42 41 18 33 16 34 39 39 42 14 28 38 42 24 39 32 40 33 33 32 41 43 43 42 35 33 33 33 29)
#(42 41 43 32 14 40 37 36 41 43 30 25 33 34 29)
#(41 43 40 42 33 30 43 43 20 36 42 33 30 43 42 33 39 40 42 26 33 35 29)
#(24 33 30 43 37 36 18 33 16 20 39 36 42 43 32 39 42 33 40 41 39 35 43 32 24 40 33 33 32 41 43 43 42 33 30 33 33 33 29)
#(14 40 33 33 42 33 20 36 41 43 42 25 43 42 26 43 43 37 33 4 41 34 28 38 27 10 43 42 34 29)
#(33 33 32 43 31 35 43 43 42 33 33 33 33 32 25 34 39 38 26 33 43 30 25 33 34 42 42 25 41 32 27 41 35 43 42 41 27 38 42 25 25 42 35 33 29)
#(24 14 22 41 34 42 18 41 43 43 16 27 22 10 32 24 14 40 29)
#(42 43 32 9 22 42 33 30 13 43 29)
#(33 18 33 4 43 4 33 16)
#(43 4 43 34)
#(43 38 33 25 32 25 4)
#(43 4 17 25 25)
#(35 43 4 17 25 25 4 31 25 34 41 43)
#(35 43 22 32 33 25 32 25 4)
#(35 43 4 17 25 25 42 35 43 4 17 25 25 4 31 25 34 41 43)
#(33 35 43 43 4 35 34 35 4 25 25)
#(43 4 41 34 28 38 42 33 34 38 42 35 43 34 29)
#(33 33 32 25 34 35 32 22 42 14 20 36 35 33 42 43 31 35 35 43 42 41 43 43 31 43 34 43 29)
#(41 43 22 39 38 29)
#(33 33 40 37 36 42 41 43 42 26 35 43 40 42 33 25 32 41 33 43 22 29)
#(33 33 33 42 33 33 32 33 32 22 33 33 33 32 12 40 41 25 43 43 32 22 41 35 34 30 43 35 33 37 36 25 35 34 31 36 41 43 43 29)
#(33 33 30 33 33 33 33 42 33 32 33 32 38 7 42 26 43 35 33 42 41 17 35 43 43 42 33 32 41 43 42 35 34 29)
#(33 22 33 33 40 27 34 37 36 39 25 43 32 33 33 33 32 41 33 43 43 29)
#(41 43 40 39 27 41 43 42 26 35 31 41 35 25 35 34 28 39 36 37 36 42 41 35 43 43 32 33 22 29)
#(33 33 24 40 41 35 43 31 40 37 36 43 32 24 22 33 33 33 32 33 30 43 29)
#(33 33 32 41 35 35 43 31 35 43 32 22 42 26 43 34 22 25 43 37 25 25 34 18 17 25 25 16 42 41 35 25 34 42 41 43 32 42 35 34 42 41 34 29)
#(41 43 10 34 22 25 25 34 29)
#(35 43 34 31 35 34 43 38 37 41 35 43 42 35 43 42 41 43 32 42 41 43 22 39 36 34 32 42 40 35 42 35 34 29)
#(33 22 14 40 41 24 35 43 24 42 35 43 42 41 35 43 32 27 35 43 43 34 29)
#(33 33 32 41 35 43 42 43 43 31 34 43 32 22 41 25 43 43 42 35 43 42 41 13 43 29)
#(41 19 25 25 18 17 25 25 16 42 35 43 42 41 25 34 37 33 25 22 39 42 19 25 25 18 17 25 25 16 41 43 11 31 42 43 34 42 19 25 25 31 19 25 25 29)
#(41 43 42 43 32 9 22 42 35 34 32 22 38 37 36 34 42 34 31 34 42 43 34 29)
#(33 30 43 42 34 22 41 39 35 25 43 32 37 19 25 25 42 19 25 25 41 43 11 29)
#(34 22 42 39 37 19 25 25 42 19 25 25 41 43 11 29)
#(33 33 30 34 43 22 37 36 42 42 7 42 26 34 31 34 42 41 43 43 32 42 14 22 41 25 43 43 42 35 35 34 42 41 25 43 43 43 29)
#(41 33 32 33 43 32 41 43 43 42 27 34 31 43 42 43 34 31 34 32 22 35 43 42 41 43 38 33 25 42 17 25 25 32 31 25 34 41 43 32 42 42 17 25 25 32 31 25 34 41 43 32 42 41 35 43 29)
#(43 22 37 17 25 25 32 42 17 25 25 29)
#(33 39 22 14 20 36 41 35 43 42 27 26 43 43 42 33 25 32 27 41 17 25 41 43 43 42 26 43 29)
#(31 26 43 22 39 43 42 14 22 39 35 34 42 41 34 29)
#(33 30 43 22 17 25 41 43 42 35 35 43 37 17 25 29)
#(41 43 22 38 41 43 42 17 25 41 43 35 35 43 31 22 37 17 25 42 41 33 43 43 29)
#(41 43 22 38 27 27 34 42 42 38 34 42 43 34 32 9 28 10 34 42 28 27 34 29)
#(31 41 43 22 41 43 22 38 42 41 35 43 42 10 34 42 43 31 34 42 43 29)
#(42 41 43 32 33 30 43 42 34 32 42 41 43 42 34 32 22 25 43 42 41 35 43 31 25 43 42 41 35 43 29)
#(41 43 22 42 41 35 43 4 35 43 42 41 43 42 34 4 37 25 43 42 41 43 32 38 42 25 43 41 43 11 29)
#(33 34 22 41 35 34 39 22 27 35 43 42 26 43 34 31 27 34 29)
#(42 14 40 38 42 35 43 42 43 34 42 35 34 40 27 37 42 41 25 43 35 43 32 26 35 34 28 27 42 41 35 10 43 42 35 28 38 37 41 35 43 42 41 43 29)
#(41 43 40 37 36 35 35 34 32 42 41 43 32 31 43 43 32 42 41 43 40 27 35 43 31 39 40 34 29)
#(38 42 26 35 43 32 41 35 43 42 26 25 35 43 32 43 22 25 43 32 31 34 22 25 43 29)
#(33 33 33 32 33 32 22 41 35 43 43 42 33 33 33 33 37 36 41 27 27 43 42 43 34 29)
#(33 40 41 43 42 12 40 38 42 43 38 27 32 31 33 32 41 43 27 34 31 35 43 29)
#(42 27 33 32 33 33 40 35 34 42 27 33 42 41 35 43 43 29)
#(33 33 33 32 33 33 33 32 33 33 31 33 33 32 42 34 32 28 35 34 42 33 32 38 42 33 32 33 29)
#(33 33 22 14 40 26 35 35 43 43 37 36 38 35 43 29)
#(41 43 42 33 40 42 33 33 37 36 26 43 42 34 43 32 41 34 22 29)
#(33 33 39 22 14 40 27 12 14 22 41 24 43 24 43 32 41 33 25 32 38 42 34 32 34 31 35 34 42 35 35 34 29)
#(33 43 22 41 35 17 25 32 37 17 25 32 42 35 15 22 14 20 36 42 41 39 38 43 42 41 35 17 25 25 43 42 33 33 30 43 29)
#(33 40 38 17 25 32 31 25 43 32 42 41 25 43 34 42 43 42 41 43 30 43 22 41 43 43 29)
#(39 32 43 33 33 22 14 40 35 42 33 32 31 14 22 26 11 17 35 43 43 29)
#(43 34 22 39 42 35 43 32 38 42 35 43 27 31 35 34 42 33 31 35 43 34 29)
#(41 33 33 34 22 42 25 34 32 42 25 32 42 27 42 25 34 42 41 43 29)
#(43 34 22 10 42 41 35 43 32 42 41 43 22 38 29)
#(41 33 43 43 22 37 17 25 25 42 33 32 27 34 42 41 43 30 43 43 22 38 29)
#(34 22 42 41 35 43 42 41 43 32 42 34 22 37 41 43 29)
#(41 43 22 14 25 42 41 13 43 34 42 41 43 38 42 42)
#(35 43 22 25 43 42 33 32 41 13 43 43 40 27 29)
#(41 43 22 10 43 43 31 34 29)
#(33 33 22 17 25 25 37 34 42 33 33 34 32 41 13 35 43 37 36 35 41 43 29)
#(14 40 41 17 25 25 35 43 29)
#(33 22 41 25 43 43 42 35 43 29)
#(33 33 22 41 43 35 37 41 35 43 43 29)
#(33 42 33 33 40 37 36 41 34 31 22 42 25 43 42 26 43 43 42 41 43 42 35 34 31 27 43 34 29)
#(33 15 30 34 28 38 27 43 34 37 41 43 25 43 42 14 28 35 42 41 43 30 13 43 29)
#(33 22 37 36 43 42 33 33 42 33 42 17 25 25 29)
#(41 43 20 36 41 35 43 37 33 33 30 33 33 33 29)
#(41 33 40 37 36 35 43 42 34 34 32 42 9 34 28 31 36 41 42 26 35 43 31 42 34 29)
#(41 43 40 35 37 43 34 29)
#(33 33 33 22 42 33 33 31 33 42 33 20 36 38 38 42 25 37 36 34 14 22 20 36 34 39 35 42 17 25 25 29)
#(41 17 25 25 43 43 22 38 42 33 34 9 40 35 34 27 41 35 43 43 29)
#(33 30 33 43 40 38 37 36 42 43 41 43 37 36 26 33 15 43 37 43 32 27 37 34 29)
#(41 43 43 22 38 42 34 37 36 41 33 43 42 41 43 42 43 42 41 33 43 29)
#(33 15 22 34 28 38 42 41 35 43 42 26 43 34 29)
#(25 35 43 34 22 35 35 34 29)
#(33 30 43 22 25 43 32 33 30 25 43 31 33 33 30 25 43 29)
#(34 4)
#(34 4 43 25 34 29)
#(33 33 34 25 32 42 25 4 43 25 32 42 25 4 34 25 32 42 25 29)
#(34 4 33 33 33 33 43 25 32 42)
#(34 4 33 33 34 43 25 32 35 4 43 43 25 32 42 25 29)
#(43 4 25 43 32 42 25 4 25 34 32 42 25 29)
#(33 33 32 35 43 42 33 15 32 41 35 43 38 42 33 33 32 33 32 22 38 41 43 42 41 43 43 29)
#(33 33 32 25 34 35 32 39 40 41 43 37 25 34 29)
#(39 32 43 33 33 40 22 14 20 39 36 43 42 41 43 30 35 43 35 43 29)
#(33 33 33 32 41 33 33 43 43 2 17 35 43 42 33 33 33 22 38 39 42 41 27 43 42 41 35 43 32 38 42 14 22 26 35 25 43 33 43 29)
#(33 32 41 33 32 33 32 43 43 32 22 38 33 30 43 29)
#(14 40 42 38 34 39 37 39 28 26 34 42 41 35 17 35 32 31 17 25 25 32 43 42 33 33 42 33 32 42 33 34 28 38 26 43 29)
#(42 41 33 31 33 33 43 32 33 22 14 22 41 25 33 34 42 17 25 25 42 41 35 43 42 33 25 29)
#(33 22 39 36 41 43 42 41 34 32 31 41 43 42 41 43 38 42 25 43 41 35 43 30 43 43 32 31 41 38 43 42 41 34 38 40 33 30 17 35 43 43 43 29)
#(41 33 43 22 41 43 22 41 43 42 41 35 43 31 39 20 39 36 41 43 31 34 29)
#(33 33 32 25 34 35 32 40 38 38 37 41 43 42 41 43 29)
#(33 33 32 35 43 42 33 33 33 31 41 33 35 43 32 7 39 22 33 33 15 32 41 35 34 43 43 29)
#(33 33 32 41 35 35 43 37 36 42 41 33 43 32 40 41 43 37 41 43 32 27 26 43 37 25 29)
#(33 33 32 41 35 34 31 43 43 32 22 41 35 43 42 26 35 35 43 43 32 27 35 34 32 37 25 25 34 18 17 25 25 16 42 25 25 34 41 43 11 29)
#(41 35 43 22 26 10 43 4 41 43 43 42 41 42 25 20 36 39 37 41 25 25 34 22 42 25 4 40 35 29)
#(27 42 43 27 34 31 34 32 33 30 43 35 43 42 41 35 25 34 42 41 43 22 25 25 34 32 39 36 41 35 43 42 25 25 34 29)
#(34 22 33 30 34 42 41 35 43 20 36 38 42 41 43 43 42 41 43 42 41 33 43 42 41 43 43 9 40 25 43 38 42 33 29)
#(33 33 32 33 32 33 32 22 14 22 43 42 41 33 33 31 33 33 37 36 41 35 43 9 20 36 42 43 31 43 42 43 31 43 43 29)
#(41 33 43 43 43 40 11 35 42 27 34 42 27 41 43 42 43 32 42 14 40 43 31 42 21 40 41 43 27 43 32 22 33 33 33 33 29)
#(33 33 22 41 43 39 20 36 38 42 43 42 34 31 35 34 32 31 39 20 36 41 43 42 43 43 29)
#(33 33 22 41 43 20 36 38 42 25 34 37 34 31 35 34 29)
#(33 33 33 32 41 43 43 43 42 41 33 33 33 32 22 41 43 40 39 38 42 43 34 31 40 39 27 41 35 43 42 14 40 39 39 35 42 27 41 7 35 43 29)
#(31 41 43 20 36 37 36 11 35 42 27 42 41 43 40 43 31 38 27 43 32 33 33 22 29)
#(24 14 28 39 36 39 8 35 14 40 27 37 36 32 24 14 22 29)
#(33 32 41 35 43 42 35 35 34 32 40 42 41 43 43 20 36 14 37 36 26 35 43 42 41 35 43 42 25 32 33 33 22 29)
#(41 43 20 36 17 25 42 41 43 31 34 39 17 25 25 42 43 42 41 43 42 41 35 25 34 42 43 32 14 22 29)
#(33 33 32 33 32 33 32 22 14 22 41 35 34 42 39 38 33 33 33 33 42 41 43 31 34 43 38 42 17 25 25 29)
#(33 22 26 39 38 33 33 43 38 17 25 25 42 43 32 22 17 25 25 42 34 31 17 25 25 42 35 43 37 36 33 30 34 42 41 33 33 29)
#(33 32 9 40 35 43 34 32 22 42 33 32 38 42 33 32 33 32 42 41 43 42 34 29)
#(42 27 41 43 32 41 43 20 36 24 34 32 24 22 33 33 32 33 30 35 35 43 29)
#(14 39 20 36 33 35 34 29)
#(42 33 33 32 42 43 32 33 40 38 41 35 43 43 42 33 30 43 40 38 11 35 32 27 37 33 33 29)))
| false |
b81730fb298e6aed32d429efdd7d8cc1767fbe0e
|
c2868a520d45d57e37f8e5a0b1c0e3f0c94889ec
|
/game-of-life-tdd/life-display.scm
|
23c0f82f087dd7a58384ed23d345173bbb6bf7c2
|
[] |
no_license
|
drcz/random-crap
|
b19098e95eede27a07936728e88751b83ecc6abb
|
b3289eafd4b9870caa53a8586a870d02d1cb91ac
|
refs/heads/master
| 2021-07-18T18:45:08.613994 | 2021-01-31T19:48:57 | 2021-01-31T19:48:57 | 46,229,422 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 862 |
scm
|
life-display.scm
|
;;; just a display loop... and press any key to quit.
(use-modules (ncurses curses))
(include "life.scm")
;;; start with ``B-heptomino''...
(define (init-world)
(put-pattern (empty-world)
66 33
'[(_ X _ _)
(X X X _)
(X _ X X)]))
(define (disp-area scr x y w h world)
(map (lambda (dy)
(map (lambda (dx)
(addstr scr
(if (eq? (state-at world (+ x dx) (+ y dy)) 'alive)
"0"
" ")
#:y dy
#:x dx))
(iota w)))
(iota h)))
(let* ((scr (initscr))
(sizes (getmaxyx scr))
(h (car sizes))
(w (cadr sizes)))
(halfdelay! 1)
(let loop ((world (init-world))
(x 0)
(y 0))
(clear scr)
(disp-area scr x y w h world)
(refresh scr)
(if (getch scr) ;; TODO perhaps add some moving of x,y?
(begin
(endwin)
(quit))
(loop (next-generation world) x y))))
| false |
d221cc8015964ff8f4560a94021c3efd8c6631fc
|
c146bf025d0d330185badb8ef0de0fe0c56267f3
|
/cKanren/oldmatche.scm
|
a707b49a97718ae4ee8e540c7049c05e07bbad2c
|
[
"MIT"
] |
permissive
|
webyrd/peano-challenge
|
ea6a35cd8859026327d83f4ee0af6264bf27019b
|
5fe83bd2e5e9a8fe0ea2e079af82f6b3fe34e5c8
|
refs/heads/master
| 2020-04-04T09:38:06.082340 | 2014-01-05T06:25:29 | 2014-01-05T06:25:29 | 15,646,599 | 3 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,200 |
scm
|
oldmatche.scm
|
;; Example:
;; (print-gensym #f)
;; (pretty-print (expand '(matche '(1 2 3) ((,a ,b ,c) 1) ((,x d ,y) 2) (5) (,w) ((a b c)))))
;; (print-gensym #t)
(library (cKanren matche)
(export matche)
(import (rnrs) (cKanren ck))
(define-syntax lambdae
(syntax-rules ()
((_ (x ...) c c* ...)
(lambda (x ...) (matche (list x ...) (c c* ...))))))
(define-syntax fresh* ;;; easy way to deal with duplicate vars (as if fresh used let*)
(syntax-rules ()
((_ () g ...) (fresh () g ...)) ;;; just in case there were no vars in pattern.
((_ (x) g ...) (fresh (x) g ...)) ;;; exactly one var
((_ (y x z ...) g ...) (fresh (y) (fresh* (x z ...) g ...))))) ;;; more than one.
(define-syntax matche
(syntax-rules ()
((_ (f x ...) g* . cs)
(let ((v (f x ...))) ;;; evaluate first argument once.
(matche v g* . cs)))
((_ v (pat g ...) ...) ;;; pass to driver list of uns and (empty) list of dones.
(mpat0 ((pat (fresh* () (== `pat v) g ...)) ...) ()))))
(define-syntax mpat0 ;;; body is alwasys (fresh* (x ...) g ...)
(syntax-rules ()
((_ () (done ...)) (conde done ...)) ;;; all done (no more undone)
((_ ((pat body) un* ...) done*) (mpat pat () body (un* ...) done*)))) ;;; do one un.
(define-syntax mpat ;;; virtually the same reasoning as earlier versions.
(syntax-rules (unquote fresh*)
((_ (unquote x) () (fresh* (y ...) g ...) un* (done ...))
(mpat0 un* (done ... ((fresh* (y ... x) g ...))))) ;;; empty stack. add var; one un done.
;;; turn g to clause.
((_ (unquote x) (top stack ...) (fresh* (y ...) g ...) un* done*)
(mpat top (stack ...) (fresh* (y ... x) g ...) un* done*)) ;;; pop; add var
((_ (a . d) (top ...) body un* done*) (mpat a (d top ...) body un* done*)) ;;; push d
((_ ignore () body un* (done ...)) (mpat0 un* (done ... (body)))) ;;; empty stack
;;; turn g to clause.
((_ ignore (top stack ...) body un* done*) (mpat top (stack ...) body un* done*)))) ; pop
)
| true |
55c6b14d91253f94e31c2ffe92bdd49894b6dd24
|
d85c3267f8f89b6acadcac7829cc3ebc43275ca1
|
/input/scheme-inexact.scm
|
09670123f6758516969e9d2eb2b82cbb3891a75c
|
[] |
no_license
|
ecraven/r7rs-coverage
|
21f1f25c6db2d451ee7b99e5e84743859a55f791
|
6d9f8eafc391de9c41a0e23e32fa691b601814ec
|
refs/heads/master
| 2021-08-02T22:45:53.621181 | 2021-07-23T19:35:09 | 2021-07-23T19:35:09 | 68,798,065 | 6 | 5 | null | 2021-09-15T13:16:42 | 2016-09-21T08:47:40 |
HTML
|
UTF-8
|
Scheme
| false | false | 915 |
scm
|
scheme-inexact.scm
|
;; TEST acos
(assert (and (> (acos 0.5) 1.047) (< (acos 0.5) 1.048)))
;; TEST asin
(assert (and (> (asin 0.5) 0.523) (< (asin 0.5) 0.524)))
;; TEST atan one parameter
(assert (and (> (atan 0.5) 0.463) (< (atan 0.5) 0.464)))
;; TEST atan two parameters
(assert (and (> (atan 2 1) 1.107) (< (atan 2 1) 1.108)))
;; TEST cos
(assert (and (> (cos 5) 0.283) (< (cos 3) 0.284)))
;; TEST exp
(assert (and (> (exp 3) 20.085) (< (exp 3) 20.086)))
;; TEST finite?
(assert (finite? 123))
;; TEST infinite?
(assert (infinite? +inf.0))
;; TEST log one parameter
(assert (and (> (log 15) 2.70) (< (log 15) 2.71)))
;; TEST log two parameters
(assert (and (> (log 10 4) 1.660) (< (log 10 4) 1.661)))
;; TEST nan?
(assert (not (nan? 17)))
;; TEST sin
(assert (and (> (sin 3) 0.141) (< (sin 3) 0.142)))
;; TEST sqrt
(assert (and (> (sqrt 17) 4.123) (< (sqrt 17) 4.124)))
;; TEST tan
(assert (and (> (tan 1) 1.557) (< (tan 1) 1.558)))
| false |
edc1095f0191eaf0556a9718bc7b9842e7f277f0
|
648776d3a0d9a8ca036acaf6f2f7a60dcdb45877
|
/queries/uxntal/highlights.scm
|
795c73d09639c108d0e2192b350d06313fbf0010
|
[
"Apache-2.0"
] |
permissive
|
nvim-treesitter/nvim-treesitter
|
4c3c55cbe6ff73debcfaecb9b7a0d42d984be3e6
|
f8c2825220bff70919b527ee68fe44e7b1dae4b2
|
refs/heads/master
| 2023-08-31T20:04:23.790698 | 2023-08-31T09:28:16 | 2023-08-31T18:19:23 | 256,786,531 | 7,890 | 980 |
Apache-2.0
| 2023-09-14T18:07:03 | 2020-04-18T15:24:10 |
Scheme
|
UTF-8
|
Scheme
| false | false | 1,042 |
scm
|
highlights.scm
|
; Includes
(include
"~" @include
_ @text.uri @string.special)
; Variables
(identifier) @variable
; Macros
(macro
"%"
(identifier) @function.macro)
((identifier) @function.macro
(#lua-match? @function.macro "^[a-z]?[0-9]*[A-Z-_]+$"))
(rune
. rune_start: (rune_char ",")
. (identifier) @function.call)
(rune
. rune_start: (rune_char ";")
. (identifier) @function.call)
((identifier) @function.call
(#lua-match? @function.call "^:"))
; Keywords
(opcode) @keyword
; Labels
(label
"@" @symbol
(identifier) @function)
(sublabel_reference
(identifier) @namespace
"/" @punctuation.delimiter
(identifier) @label)
; Repeats
((identifier) @repeat
(#eq? @repeat "while"))
; Literals
(raw_ascii) @string
(hex_literal
"#" @symbol
(hex_lit_value) @string.special)
(number) @number
; Punctuation
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
[
"%"
"|"
"$"
","
"_"
"."
"-"
";"
"="
"!"
"?"
"&"
] @punctuation.special
; Comments
(comment) @comment @spell
| false |
f3d5e33366ce9de37825ee2eadeea9d6aad0b770
|
e0473dbe38d6e9587fdcc7be255c3bc6ee8646a1
|
/example/hello.k
|
1e48c803f1591905d40af855fb186cf9ccfcaa5a
|
[
"MIT"
] |
permissive
|
propella/tamacola
|
658f1ab12a4be1ee4c15a51e2fef45bfa6e8fa62
|
b3b200e6ba445ea72ead1cde6d40c5546115e8c3
|
refs/heads/master
| 2021-01-01T16:00:19.036549 | 2010-10-04T02:43:58 | 2010-10-04T02:43:58 | 904,133 | 7 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 22 |
k
|
hello.k
|
(print "Hello world")
| false |
6e181c949d97e1a5fbe675769e787891b8d67110
|
1de1eae1b985ae18547fa56648f353c5d16a0c62
|
/srfi/206.sld
|
ca0001053c4c74815461b5a574c395800ea6c0f7
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
Zipheir/bytestrings
|
4917fcdd8a368c4054e9bd74451127fa7ec1e51e
|
2838e3ce8b23e92bc338a76ffbdbf7e475e88530
|
refs/heads/master
| 2022-12-06T17:38:18.064287 | 2020-08-26T23:11:59 | 2020-08-26T23:11:59 | 267,740,986 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,767 |
sld
|
206.sld
|
(define-library (srfi 206)
(import (scheme base)
(scheme case-lambda)
(srfi 1)
(srfi 151)
(foof hex)
(foof base64))
(cond-expand
((library (scheme bytevector))
(import (only (scheme bytevector) bytevector=? bytevector->u8-list))
(begin
(define (bytestring->list bstring)
(bytevector->u8-list bstring))))
(else
(begin
(define bytevector=? equal?)
(define (bytestring->list bstring)
(assume (bytevector? bstring))
(list-tabulate (bytevector-length bstring)
(lambda (i) (bytevector-u8-ref bstring i)))))))
(cond-expand
((library (srfi 145))
(import (srfi 145)))
(else
(begin
(define (assume _) #t))))
(cond-expand
((library (srfi 152))
(import (srfi 152)))
((library (srfi 130))
(import (srfi 130)))
((library (srfi 13))
(import (srfi 13)))
(else
(error
"No string library found (need one of SRFIs 152, 130, or 13).")))
(export bytestring list->bytestring bytevector->hex-string bytestring->list
hex-string->bytevector bytevector->base64 base64->bytevector
bytestring-pad bytestring-pad-right bytestring-trim
bytestring-trim-right bytestring-trim-both bytestring-replace
bytestring-index bytestring-index-right bytestring-break
bytestring-span
bytestring=? bytestring>? bytestring<? bytestring<=? bytestring>=?
bytestring-ci=? bytestring-ci>? bytestring-ci<? bytestring-ci<=?
bytestring-ci>=?
bytestring-error? bytestring-error-message bytestring-error-irritants
bytestring-join bytestring-split
write-bytestring)
(include "206.scm"))
| false |
a9706b38fcb91104bfafbee787736aa2ad3fc9e4
|
ae76253c0b7fadf8065777111d3aa6b57383d01b
|
/chap1/exec-1.15.ss
|
152cada4d2fe277cf580c9e944738aaeb534267b
|
[] |
no_license
|
cacaegg/sicp-solution
|
176995237ad1feac39355f0684ee660f693b7989
|
5bc7df644c4634adc06355eefa1637c303cf6b9e
|
refs/heads/master
| 2021-01-23T12:25:25.380872 | 2014-04-06T09:35:15 | 2014-04-06T09:35:15 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 480 |
ss
|
exec-1.15.ss
|
(define (cube x) (* x x x))
(define (p x) (- (* 3 x) (* 4 (cube x))))
(define (sine angle)
(if (not (> (abs angle) 0.1))
angle
(p (sine (/ angle 3.0)))))
; 12.15 -> 4.05 -> 1.34999 -> 0.44999 -> 0.15 -> 0.04
; p procedure will be applied for 5 times
(sine 12.15)
; Order growth of Space -> O(log(n))
; Due to the depth of recursive tree is grow for each 3*n
;
; Order growth of Time -> O(log(n))
; Since each p procedure is constant, it will grow with p procedure
| false |
5f0486499cbd63e3bce6769e18d613e635f5f037
|
3508dcd12d0d69fec4d30c50334f8deb24f376eb
|
/v8/src/bench/fcomp.scm
|
9710effcdf3ded3a2ee76e5a86a4f3c64512f0a0
|
[] |
no_license
|
barak/mit-scheme
|
be625081e92c2c74590f6b5502f5ae6bc95aa492
|
56e1a12439628e4424b8c3ce2a3118449db509ab
|
refs/heads/master
| 2023-01-24T11:03:23.447076 | 2022-09-11T06:10:46 | 2022-09-11T06:10:46 | 12,487,054 | 12 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 6,490 |
scm
|
fcomp.scm
|
(declare (usual-integrations))
(define (compile exp)
(compile-expr exp #F))
(define (compile-expr exp s-env)
(let ((exp (macro-expand exp)))
(cond ((symbol? exp)
(compile-lookup exp s-env))
((not (pair? exp))
(compile-constant exp s-env))
((eq? (car exp) 'QUOTE)
(compile-constant (second exp) s-env))
((eq? (car exp) 'SET!)
(compile-set! (second exp) (third exp) s-env))
((eq? (car exp) 'BEGIN)
(compile-sequence (cdr exp) s-env))
((eq? (car exp) 'LAMBDA)
(compile-lambda (second exp) (cddr exp) s-env))
((eq? (car exp) 'IF)
(compile-if exp s-env))
(else
(compile-combination exp s-env)))))
(define (macro-expand exp)
(cond ((not (pair? exp))
exp)
((eq? (car exp) 'LET)
`((LAMBDA ,(map first (second exp)) ,@(cddr exp))
,@(map second (second exp))))
((eq? (car exp) 'LETREC)
(let ((names (map car (second exp)))
(values (map cadr (second exp)))
(body (cddr exp)))
`((LAMBDA ,names
,@(map (lambda (n v) `(SET! ,n ,v)) names values)
,@body)
,@(make-list (length names) '(quote undefined)))))
(else exp)))
(define (compile-constant cst s-env)
s-env
(let ((place? (assoc cst *common-constants*)))
(if place?
(cdr place?)
(lambda (d-env) cst))))
(define *common-constants*
(list (cons '0 (lambda (d) 0))
(cons '1 (lambda (d) 1))
(cons '2 (lambda (d) 2))
(cons '() (lambda (d) '()))
(cons #T (lambda (d) #T))
(cons #F (lambda (d) #F))))
(define *global-env*
(list 'global-environment
(cons '+ +)
(cons '- -)
(cons '* *)
(cons '< <)
(cons 'list list)
(cons 'cons (lambda (u v) (cons u v)))
(cons 'car (lambda (p) (car p)))
(cons 'cdr (lambda (p) (cdr p)))
(cons 'null? (lambda (x) (null? x)))
(cons 'display display)))
(define (var->path var s-env)
;; returns an access path, either pair from the global env or a
;; (spine-index.frame-index) pair
(let frame-loop ((frame s-env) (spine-index 0))
(cond ((not frame)
(or (assq var (cdr *global-env*))
(let ((pair (cons var 'uninitialized)))
(set-cdr! *global-env* (cons pair (cdr *global-env*)))
pair)))
((let loop ((bindings (cdr frame)) (index 1))
(cond ((pair? bindings)
(if (eq? (car bindings) var)
(cons spine-index index)
(loop (cdr bindings) (+ index 1))))
((null? bindings)
#F)
(else ;; rest arg
(if (eq? bindings var)
(cons spine-index index)
#F)))))
(else
(frame-loop (car frame) (+ spine-index 1))))))
(define (compile-lookup var s-env)
(let ((path (var->path var s-env)))
(if (symbol? (car path))
(lambda (d-env) d-env (cdr path))
(let loop ((ups (car path)))
(if (zero? ups)
(compile-frame-ref (cdr path))
(let ((ups* (loop (- ups 1))))
(lambda (d-env) (ups* (vector-ref d-env 0)))))))))
(define (compile-set! var exp s-env)
(let* ((path (var->path var s-env))
(frame (car path))
(index (cdr path)))
(let ((exp* (compile-expr exp s-env)))
(if (symbol? frame)
(lambda (d-env) (set-cdr! path (exp* d-env)) unspecific)
(let loop ((ups frame))
(if (zero? ups)
(lambda (d-env) (vector-set! d-env index (exp* d-env)))
(let ((ups* (loop (- ups 1))))
(lambda (d-env) (ups* (vector-ref d-env 0))))))))))
(define (compile-global-access place)
(lambda (d-env) d-env (cdr place)))
(define (compile-frame-ref index)
(case index
((0) (lambda (d-env) (vector-ref d-env 0)))
((1) (lambda (d-env) (vector-ref d-env 1)))
((2) (lambda (d-env) (vector-ref d-env 2)))
((3) (lambda (d-env) (vector-ref d-env 3)))
((4) (lambda (d-env) (vector-ref d-env 4)))
(else (lambda (d-env) (vector-red d-env index)))))
(define (compile-lambda args sequence s-env)
(let ((body (compile-sequence sequence (cons s-env args))))
(cond ((null? args)
(lambda (d-env)
(lambda () (body (vector d-env)))))
((symbol? args)
(lambda (d-env)
(lambda args (body (vector d-env args)))))
((null? (cdr args))
(lambda (d-env)
(lambda (arg1) (body (vector d-env arg1)))))
((symbol? (cdr args))
(lambda (d-env)
(lambda (arg1 . rest) (body (vector d-env arg1 rest)))))
((null? (cddr args))
(lambda (d-env)
(lambda (arg1 arg2) (body (vector d-env arg1 arg2)))))
((symbol? (cddr args))
(lambda (d-env)
(lambda (arg1 arg2 . rest) (body (vector d-env arg1 arg2 rest)))))
((null? (cdr (last-pair args)))
(lambda (d-env)
(lambda args (body (list->vector (cons d-env args))))))
(else (error "Illegal or unimplemented lambda list" args)))))
(define (compile-sequence seq s-env)
(cond ((null? seq) (error "Null sequence"))
((null? (cdr seq))
(compile-expr (car seq) s-env))
(else
(let ((this (compile-expr (car seq) s-env))
(rest (compile-sequence (cdr seq) s-env)))
(lambda (d-env)
(this d-env)
(rest d-env))))))
(define (compile-if exp s-env)
(let ((pred (compile-expr (second exp) s-env))
(conseq (compile-expr (third exp) s-env)))
(if (null? (cdddr exp))
(lambda (d-env)
(if (pred d-env) (conseq d-env) unspecific))
(let ((alt (compile-expr (fourth exp) s-env)))
(lambda (d-env)
(if (pred d-env) (conseq d-env) (alt d-env)))))))
(define (compile-combination exps s-env)
(let ((rator (compile-expr (car exps) s-env))
(rands (map (lambda (e) (compile-expr e s-env)) (cdr exps))))
(case (length rands)
((0) (lambda (d-env) ((rator d-env))))
((1) (let ((rand1 (first rands)))
(lambda (d-env) ((rator d-env) (rand1 d-env)))))
((2) (let ((rand1 (first rands))
(rand2 (second rands)))
(lambda (d-env) ((rator d-env) (rand1 d-env) (rand2 d-env)))))
((3) (let ((rand1 (first rands))
(rand2 (second rands))
(rand3 (third rands)))
(lambda (d-env)
((rator d-env) (rand1 d-env) (rand2 d-env) (rand3 d-env)))))
((4) (let ((rand1 (first rands))
(rand2 (second rands))
(rand3 (third rands))
(rand4 (fourth rands)))
(lambda (d-env)
((rator d-env)
(rand1 d-env) (rand2 d-env) (rand3 d-env) (rand4 d-env)))))
(else
(lambda (d-env)
(apply (rator d-env) (map (lambda (f) (f d-env)) rands)))))))
(define bench1
`(begin
(set! fib
(lambda (n)
(if (< n 2)
n
(+ (fib (- n 1)) (fib (- n 2))))))
(fib 20)))
(define (go)
((compile bench1) #F)
((compile bench1) #F)
((compile bench1) #F)
((compile bench1) #F)
((compile bench1) #F))
(lambda () (go))
| false |
6026685efe78a3d953724e8789021dc4884c821f
|
ab05b79ab17619f548d9762a46199dc9eed6b3e9
|
/sitelib/pregexp.scm
|
32831deb8590a6bbc5e71e573c6e97c8b2c3b382
|
[
"BSD-2-Clause"
] |
permissive
|
lambdaconservatory/ypsilon
|
2dce9ff4b5a50453937340bc757697b9b4839dee
|
f154436db2b3c0629623eb2a53154ad3c50270a1
|
refs/heads/master
| 2021-02-28T17:44:05.571304 | 2017-12-17T12:29:00 | 2020-03-08T12:57:52 | 245,719,032 | 1 | 0 |
NOASSERTION
| 2020-03-07T23:08:26 | 2020-03-07T23:08:25 | null |
UTF-8
|
Scheme
| false | false | 241 |
scm
|
pregexp.scm
|
#!nobacktrace
(library (pregexp)
(export pregexp
pregexp-match
pregexp-match-positions
pregexp-quote
pregexp-replace
pregexp-replace*
pregexp-split)
(import (ypsilon pregexp)))
| false |
144696c13a5423951d1d9625f9a458fa16ac4b56
|
6c6cf6e4b77640825c2457e54052a56d5de6f4d2
|
/ch2/2_47-test.scm
|
58e6feb9ee5c938d50bc565ea48d596cf9d6c2d4
|
[] |
no_license
|
leonacwa/sicp
|
a469c7bc96e0c47e4658dccd7c5309350090a746
|
d880b482d8027b7111678eff8d1c848e156d5374
|
refs/heads/master
| 2018-12-28T07:20:30.118868 | 2015-02-07T16:40:10 | 2015-02-07T16:40:10 | 11,738,761 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 296 |
scm
|
2_47-test.scm
|
;test for 2.47
(load "2_46-vect.scm")
;(load "2_47-frame1.scm")
(load "2_47-frame2.scm")
(define f (make-frame (make-vect 0.0 0.0) (make-vect 1.0 0.0) (make-vect 0.0 1.0)))
(print-vect (origin-frame f))
(newline)
(print-vect (edge1-frame f))
(newline)
(print-vect (edge2-frame f))
(newline)
| false |
fddb070c18dcbd6ac87cd125a940d57dd644d5ca
|
84bd214ba2422524b8d7738fb82dd1b3e2951f73
|
/02/2.35_Count_Leaves.scm
|
fe9ba577365b2a6f2b6c542bffa7372dc24d13a3
|
[] |
no_license
|
aequanimitas/sicp-redux
|
e5ef32529fa727de0353da973425a326e152c388
|
560b2bd40a12df245a8532de5d76b0bd2e033a64
|
refs/heads/master
| 2020-04-10T06:49:13.302600 | 2016-03-15T00:59:24 | 2016-03-15T00:59:24 | 21,434,389 | 1 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 247 |
scm
|
2.35_Count_Leaves.scm
|
(define a (list 1 3 0 5 0 1))
(define (accumulate initial combiner seq)
(if (null? seq)
initial
(combiner (car seq) (accumulate initial combiner (cdr seq)))))
(define (count-leaves t)
(accumulate 0 (lambda (x y)
| false |
286a7b31d594a8eb762a1b43457e5c0765512ec4
|
9998f6f6940dc91a99e0e2acb4bc4e918f49eef0
|
/src/test/sample-moby-programs/net.ss
|
b4c92a10ee8524e18a3d6bc55c4d036f11c6ad12
|
[] |
no_license
|
JessamynT/wescheme-compiler2012
|
326d66df382f3d2acbc2bbf70fdc6b6549beb514
|
a8587f9d316b3cb66d8a01bab3cf16f415d039e5
|
refs/heads/master
| 2020-05-30T07:16:45.185272 | 2016-03-19T07:14:34 | 2016-03-19T07:14:34 | 70,086,162 | 0 | 0 | null | 2016-10-05T18:09:51 | 2016-10-05T18:09:51 | null |
UTF-8
|
Scheme
| false | false | 627 |
ss
|
net.ss
|
;; The first three lines of this file were inserted by DrScheme. 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 net) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
(define (content w)
w)
(define (ignore-change w n)
w)
(define (refresh w)
(get-url "http://ip.hashcollision.org/"))
(define view
(col
(text-field content ignore-change)
(button "Refresh!" refresh)))
(big-bang (get-url "http://ip.hashcollision.org/")
view)
| false |
a6d1b9547ba33cd3fbab6cfb5fd89278db972c9f
|
961ccc58c2ed4ed1d84a78614bedf0d57a2f2174
|
/lisp/pkhuong/struct-update.scm
|
b2233b7543abe138088579a70f484e94c9ca4ebd
|
[] |
no_license
|
huangjs/mostly-lisp-code
|
96483b566b8fa72ab0b73bf0e21f48cdb80dab0d
|
9fe862dbb64f2a28be62bb1bd996238de018f549
|
refs/heads/master
| 2021-01-10T10:11:50.121705 | 2015-11-01T08:53:22 | 2015-11-01T08:53:22 | 45,328,850 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,784 |
scm
|
struct-update.scm
|
(define struct-update-table (make-table test: eq? weak-keys: #t))
(define (concat-map fn list)
(let loop ((list list) (acc '()))
(if (null? list)
(reverse acc)
(loop (cdr list)
(append (reverse (fn (car list)))
acc)))))
(define (hash-consed-equal? x y)
(if (and (##structure? x)
(##structure? y))
(eq? x y)
(equal? x y)))
(define (make-struct-table)
;; should be weak on value
(make-table
test: (lambda (x y)
(let loop ((x x) (y y))
(cond ((null? x))
((hash-consed-equal? (car x) (car y))
(loop (cdr x) (cdr y)))
(else #f))))
hash: (lambda (x)
(equal?-hash
(map (lambda (x)
(if (##structure? x)
(eq?-hash x)
x))
x)))))
(define (generate-struct-update-function type)
(let* ((field-info (##type-all-fields type))
(field-defns (let loop ((info field-info)
(names '())
(count 1))
(if (null? info)
(reverse names)
(loop (cdddr info)
(cons (cons (car info) count)
names)
(+ count 1)))))
(_type (gensym 'type))
(_struct (gensym 'struct))
(_hash (gensym 'hash))
(function ((eval
`(lambda (,_type ,_hash)
(lambda (,_struct
#!key
,@(map (lambda (field)
(let ((name (car field))
(idx (cdr field)))
`(,name (##structure-ref ,_struct ,idx ,_type #f))))
field-defns))
(let ((params (list ,@(map car field-defns))))
(or (table-ref ,_hash params #f)
(let ((struct (##structure ,_type ,@(map car field-defns))))
(table-set! ,_hash params struct)
struct))))))
type (make-struct-table))))
function))
(define (get-struct-update-function type)
(or (table-ref struct-update-table type #f)
(let ((fun (generate-struct-update-function type)))
(table-set! struct-update-table type fun)
fun)))
(define (update-struct struct . args)
(apply (get-struct-update-function (##structure-type struct))
struct
args))
| false |
400c6b60604adfc8f71775bb4eb2b0a31507e52b
|
000dbfe5d1df2f18e29a76ea7e2a9556cff5e866
|
/sitelib/srfi/%3a127/lseqs.scm
|
385cd5cfdca24f9b1c43d4dc54165925fec593cd
|
[
"BSD-3-Clause",
"LicenseRef-scancode-other-permissive",
"MIT",
"BSD-2-Clause"
] |
permissive
|
ktakashi/sagittarius-scheme
|
0a6d23a9004e8775792ebe27a395366457daba81
|
285e84f7c48b65d6594ff4fbbe47a1b499c9fec0
|
refs/heads/master
| 2023-09-01T23:45:52.702741 | 2023-08-31T10:36:08 | 2023-08-31T10:36:08 | 41,153,733 | 48 | 7 |
NOASSERTION
| 2022-07-13T18:04:42 | 2015-08-21T12:07:54 |
Scheme
|
UTF-8
|
Scheme
| false | false | 7,728 |
scm
|
lseqs.scm
|
;;; -*- mode:scheme; coding:utf-8; -*-
;;;
;;; srfi/%3a127/lseqs.scm - Lazy sequence
;;;
;;; Copyright (c) 2016 Takashi Kato <[email protected]>
;;;
;;; Redistribution and use in source and binary forms, with or without
;;; modification, are permitted provided that the following conditions
;;; are met:
;;;
;;; 1. Redistributions of source code must retain the above copyright
;;; notice, this list of conditions and the following disclaimer.
;;;
;;; 2. Redistributions in binary form must reproduce the above copyright
;;; notice, this list of conditions and the following disclaimer in the
;;; documentation and/or other materials provided with the distribution.
;;;
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;
(library (srfi :127 lseqs)
(export ;; Constructors
generator->lseq
;; Predicates
lseq? lseq=?
;; Selectors
lseq-car lseq-cdr
lseq-first lseq-rest lseq-ref
lseq-take lseq-drop
;; The whole lazy sequence
lseq-realize lseq->generator
lseq-length
lseq-append lseq-zip
;; Mapping and filtering
lseq-map lseq-for-each
lseq-filter lseq-remove
;; Searching
lseq-find lseq-find-tail
;; Do we need this?
(rename lseq-find-tail lseq-find-rest)
lseq-any lseq-every
lseq-index
lseq-take-while lseq-drop-while
lseq-member lseq-memq lseq-memv)
(import (rnrs)
(rnrs mutable-pairs)
(sagittarius generators)
(sagittarius control))
(define (generator->lseq gen)
(let ((obj (gen)))
(if (eof-object? obj)
'()
(cons obj gen))))
(define-inline (lseq-car lseq) (car lseq))
(define lseq-first lseq-car)
(define-inline (lseq-cdr lseq)
(let ((g? (cdr lseq)))
(if (procedure? g?)
(let* ((o (g?))
(d (if (eof-object? o) '() (cons o g?))))
(set-cdr! lseq d)
d)
g?)))
(define lseq-rest lseq-cdr)
(define (lseq? o)
(or (null? o) ;; seems ok from test
;; TODO should we check arity?
(and (pair? o)
(or (procedure? (cdr o))
(lseq? (cdr o))))))
;; NB: it won't stop if both sequences are infinite....
(define (lseq=? = lsq1 lsq2)
(cond ((and (null? lsq1) (null? lsq2)))
((or (null? lsq1) (null? lsq2)) #f)
(else
(and (= (lseq-car lsq1) (lseq-car lsq2))
(lseq=? = (lseq-cdr lsq1) (lseq-cdr lsq2))))))
(define (lseq-take lseq i)
(unless (integer? i)
(assertion-violation 'lseq-take "integer is required" i))
(when (< i 0)
(assertion-violation 'lseq-take "zero or positive integer is required" i))
(generator->lseq
(lambda ()
(if (zero? i)
(eof-object)
(let ((r (lseq-car lseq)))
(set! lseq (lseq-cdr lseq))
(set! i (- i 1))
r)))))
(define (lseq-drop lseq n)
(unless (integer? n)
(assertion-violation 'lseq-take "integer is required" n))
(when (< n 0)
(assertion-violation 'lseq-take "zero or positive integer is required" n))
(let loop ((i 0) (lseq lseq))
(if (= i n)
lseq
(loop (+ i 1) (lseq-cdr lseq)))))
(define (lseq-ref lseq i)
(lseq-first (lseq-drop lseq i)))
;; lseq-length follows the lazy sequence so this is fine.
;; TODO better way
(define (lseq-realize lseq) (lseq-length lseq) lseq)
(define (lseq->generator lseq)
(lambda ()
(if (null? lseq)
(eof-object)
(let ((o (lseq-car lseq)))
(set! lseq (lseq-cdr lseq))
o))))
(define (lseq-length lseq)
(let loop ((i 0) (lseq lseq))
(if (null? lseq)
i
(loop (+ i 1) (lseq-cdr lseq)))))
;; TODO better implementation...
(define (lseq-append . lseq)
(define gens (map lseq->generator lseq))
(generator->lseq
(lambda ()
(let loop ()
(if (null? gens)
(eof-object)
(let* ((gen (car gens))
(o (gen)))
(cond ((eof-object? o)
(set! gens (cdr gens))
(loop))
(else o))))))))
(define (lseq-zip lseq . lseqs) (apply lseq-map list lseq lseqs))
;; TODO better way
(define (lseq-map proc lseq . lseqs)
(generator->lseq
(apply gmap proc (lseq->generator lseq) (map lseq->generator lseqs))))
(define (lseq-for-each proc lseq . lseqs)
(if (null? lseqs)
(for-each proc (lseq-realize lseq))
;; in case we have multiple lseqs, then we make sure the process
;; stops when the shortest lseq is realised.
;; TODO this is a bit memory inefficient.
(apply generator-for-each proc
(lseq->generator lseq) (map lseq->generator lseqs))))
(define (lseq-filter pred lseq)
(generator->lseq
(lambda ()
(let loop ()
(if (null? lseq)
(eof-object)
(let ((o (lseq-car lseq)))
(set! lseq (lseq-cdr lseq))
(if (pred o)
o
(loop))))))))
(define-inline (lseq-remove pred lseq)
(lseq-filter (lambda (o) (not (pred o))) lseq))
(define (lseq-find pred lseq)
(let ((l (lseq-find-tail pred lseq)))
(and l (lseq-car l))))
(define (lseq-find-tail pred lseq)
(let loop ((lseq lseq))
(cond ((null? lseq) #f)
((pred (lseq-car lseq)) lseq)
(else (loop (lseq-cdr lseq))))))
(define (lseq-any pred lseq . lseqs)
(define (lseq-any1 pred lseq)
(let loop ((lseq lseq))
(cond ((null? lseq) #f)
((pred (lseq-car lseq)))
(else (loop (lseq-cdr lseq))))))
(if (null? lseqs)
(lseq-any1 pred lseq)
(let loop ((lseqs (cons lseq lseqs)))
(cond ((exists null? lseqs) #f)
((apply pred (map lseq-car lseqs)))
(else (loop (map lseq-cdr lseqs)))))))
(define (lseq-every pred lseq . lseqs)
(define (lseq-every1 pred lseq)
(let loop ((lseq lseq) (v #f))
(cond ((null? lseq) v)
((pred (lseq-car lseq)) =>
(lambda (v)
(loop (lseq-cdr lseq) v)))
(else #f))))
(if (null? lseqs)
(lseq-every1 pred lseq)
(let loop ((lseqs (cons lseq lseqs)) (v #f))
(cond ((exists null? lseqs) v)
((apply pred (map lseq-car lseqs)) =>
(lambda (v)
(loop (map lseq-cdr lseqs) v)))
(else #f)))))
(define (lseq-take-while pred lseq)
(generator->lseq
(lambda ()
(if (null? lseq)
(eof-object)
(let ((r (lseq-car lseq)))
(cond ((pred r) (set! lseq (lseq-cdr lseq)) r)
(else (eof-object))))))))
(define (lseq-drop-while pred lseq)
(lseq-find-tail (lambda (o) (not (pred o))) lseq))
(define (lseq-index pred lseq . lseqs)
(define (lseq-index1 pred lseq)
(let loop ((lseq lseq) (i 0))
(cond ((null? lseq) #f)
((pred (lseq-car lseq)) i)
(else (loop (lseq-cdr lseq) (+ i 1))))))
(if (null? lseqs)
(lseq-index1 pred lseq)
(let loop ((lseqs (cons lseq lseqs)) (i 0))
(cond ((exists null? lseqs) #f)
((apply pred (map lseq-car lseqs)) i)
(else
(loop (map lseq-cdr lseqs) (+ i 1)))))))
(define-inline (lseq-memq x lseq) (lseq-find-tail (lambda (o) (eq? o x)) lseq))
(define-inline (lseq-memv x lseq) (lseq-find-tail (lambda (o) (eqv? o x)) lseq))
(define-inline (lseq-member x lseq :optional (= equal?) )
(lseq-find-tail (lambda (o) (= o x)) lseq))
)
| false |
efd86dba16bc2d955ebfcc1ca6cf693a715557df
|
26aaec3506b19559a353c3d316eb68f32f29458e
|
/modules/redcap/redcap-unittest.scm
|
1f4a7a10c25a9e53e863a8108ca96b5523e2fb26
|
[
"BSD-3-Clause"
] |
permissive
|
mdtsandman/lambdanative
|
f5dc42372bc8a37e4229556b55c9b605287270cd
|
584739cb50e7f1c944cb5253966c6d02cd718736
|
refs/heads/master
| 2022-12-18T06:24:29.877728 | 2020-09-20T18:47:22 | 2020-09-20T18:47:22 | 295,607,831 | 1 | 0 |
NOASSERTION
| 2020-09-15T03:48:04 | 2020-09-15T03:48:03 | null |
UTF-8
|
Scheme
| false | false | 42,045 |
scm
|
redcap-unittest.scm
|
;; Test information - must be filled in to work
;; To setup the test project that works with this unit test, import the files appropriately in REDCap:
;; REDCapDataDictionaryForUnitTest.csv, REDCapEventsForUnitTest.csv, and REDCapInstrumentMappingForUnitTest.csv
;; The unit test uses the default Arm 1.
;; For a true test, delete all records in the project before running it
(define redcap:testurl "/redcap/api/") ;; Update this if necessary
(define redcap:testhost "<add here>")
(define redcap:testtoken "<add here>")
;; HELPER FUNCTIONS
;; The folowing two are identical to Racket's take and drop: https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._take%29%29
(define (take lst n)
(if (eq? n 0)
'()
(cons (car lst) (take (cdr lst) (- n 1)))))
(define (drop lst n)
(if (eq? n 0)
lst
(drop (cdr lst) (- n 1))))
;; Test equality with given function; print both arguments if they are not equal
(define (test-success eqfn? result expectation)
(let ((success (eqfn? result expectation)))
(if (not success) (begin (display "Result obtained:\n") (display result) (display "\nis not equal to expected value:\n") (display expectation) (newline)))
success))
(define (test-failure eqfn? result expectation)
(test-success (lambda (r e) (not (eqfn? r e))) result expectation))
;; Unit test template
;; f takes no arguments and returns a boolean
(define (add-unit-test name f)
(unit-test "REDCap" name
(lambda ()
(display (string-append "TEST - " name "\n"))
(redcap-url-set! redcap:testurl)
(let ((success (f)))
(display (if success "PASS\n\n" "FAIL\n\n"))
success))))
;; UNIT TESTS
;; Metadata-related functions
;; - redcap-export-metadata
;; - forms
;; - format
;; - fields
;; - redcap-export-instrument
;; - redcap-export-fieldnames
(unit-test "REDCap" "Metadata"
(lambda ()
(redcap-url-set! redcap:testurl)
(let ((success #t))
(set! success (test-success equal? (redcap-export-metadata redcap:testhost redcap:testtoken) redcap:testmetadata))
(if success (set! success (test-success equal? (redcap-export-metadata redcap:testhost redcap:testtoken 'forms "form_2") (take (drop redcap:testmetadata 3) 6))))
(if success (set! success (test-success string=? (redcap-export-metadata redcap:testhost redcap:testtoken 'format "xml" 'fields "num") redcap:testnum)))
(if success (set! success (test-success string=? (redcap-export-metadata redcap:testhost redcap:testtoken 'format "csv" 'fields "firstrow") redcap:testfirst)))
(if success (set! success (test-success string=? (redcap-export-instrument redcap:testhost redcap:testtoken 'format "csv") "instrument_name,instrument_label\nform_1,\"Form 1\"\nform_2,\"Form 2\"\nform_3,\"Form 3\"\n")))
(if success (set! success (test-success string=? (redcap-export-instrument redcap:testhost redcap:testtoken 'format "xml") (string-append "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<instruments>\n"
"<item><instrument_name><![CDATA[form_1]]></instrument_name>"
"<instrument_label><![CDATA[Form 1]]></instrument_label></item>\n"
"<item><instrument_name><![CDATA[form_2]]></instrument_name>"
"<instrument_label><![CDATA[Form 2]]></instrument_label></item>\n"
"<item><instrument_name><![CDATA[form_3]]></instrument_name>"
"<instrument_label><![CDATA[Form 3]]></instrument_label></item>\n</instruments>\n"))))
(if success (set! success (test-success equal? (redcap-export-instrument redcap:testhost redcap:testtoken) '((("instrument_name" . "form_1") ("instrument_label" . "Form 1")) (("instrument_name" . "form_2") ("instrument_label" . "Form 2")) (("instrument_name" . "form_3") ("instrument_label" . "Form 3"))))))
;; Export all fields, does not include file fields
(if success (set! success (test-success equal? (redcap-export-fieldnames redcap:testhost redcap:testtoken) redcap:testfields)))
success)))
(define redcap:testmetadata '((("field_name" . "study_no") ("form_name" . "form_1") ("section_header" . "") ("field_type" . "text") ("field_label" . "Study No") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "y")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "yesno") ("form_name" . "form_1") ("section_header" . "") ("field_type" . "yesno") ("field_label" . "Yes or No?") ("select_choices_or_calculations" . "") ("field_note" . "A note here")
("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "RH") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "num") ("form_name" . "form_1") ("section_header" . "") ("field_type" . "text") ("field_label" . "This is an integer") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "integer") ("text_validation_min" . "0") ("text_validation_max" . "10") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "drop") ("form_name" . "form_2") ("section_header" . "") ("field_type" . "dropdown") ("field_label" . "Multiple choice dropdown") ("select_choices_or_calculations" . "1, One | 2, Two | 3, Three") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "radio") ("form_name" . "form_2") ("section_header" . "") ("field_type" . "radio") ("field_label" . "Single answer") ("select_choices_or_calculations" . "1, A | 2, B | 3, C") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "checks") ("form_name" . "form_2") ("section_header" . "Bottom section") ("field_type" . "checkbox") ("field_label" . "Names") ("select_choices_or_calculations" . "1, Fred Flinstone | 2, Jack Johnson | 3, Carl Sagan | 4, Bob Saget")
("field_note" . "") ("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "y") ("branching_logic" . "") ("required_field" . "y")
("custom_alignment" . "LH") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "firstrow") ("form_name" . "form_2") ("section_header" . "Look, a matrix!") ("field_type" . "radio") ("field_label" . "First row") ("select_choices_or_calculations" . "1, A | 2, B | 3, C")
("field_note" . "") ("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "y")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "mat") ("matrix_ranking" . "y") ("field_annotation" . "first!"))
(("field_name" . "secondrow") ("form_name" . "form_2") ("section_header" . "") ("field_type" . "radio") ("field_label" . "Second row") ("select_choices_or_calculations" . "1, A | 2, B | 3, C")
("field_note" . "") ("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "mat") ("matrix_ranking" . "y") ("field_annotation" . ""))
(("field_name" . "file") ("form_name" . "form_2") ("section_header" . "") ("field_type" . "file") ("field_label" . "A file") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "date_dec") ("form_name" . "form_3") ("section_header" . "") ("field_type" . "text") ("field_label" . "Date (decreasing)") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "date_ymd") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "date_inc_sec") ("form_name" . "form_3") ("section_header" . "") ("field_type" . "text") ("field_label" . "Date with seconds (increasing)") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "datetime_seconds_dmy") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "crawling") ("form_name" . "form_3") ("section_header" . "") ("field_type" . "text") ("field_label" . "Crawling") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "crawling") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "postal_code") ("form_name" . "form_3") ("section_header" . "") ("field_type" . "text") ("field_label" . "Postal Code") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "postalcode_canada") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "email") ("form_name" . "form_3") ("section_header" . "") ("field_type" . "text") ("field_label" . "Email") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "email") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "truefalse") ("form_name" . "form_3") ("section_header" . "") ("field_type" . "truefalse") ("field_label" . "Vrai ou faux") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "RH") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))
(("field_name" . "slider") ("form_name" . "form_3") ("section_header" . "") ("field_type" . "slider") ("field_label" . "Slider") ("select_choices_or_calculations" . "") ("field_note" . "")
("text_validation_type_or_show_slider_number" . "") ("text_validation_min" . "") ("text_validation_max" . "") ("identifier" . "") ("branching_logic" . "") ("required_field" . "")
("custom_alignment" . "RH") ("question_number" . "") ("matrix_group_name" . "") ("matrix_ranking" . "") ("field_annotation" . ""))))
(define redcap:testnum (string-append "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<records>\n"
"<item><field_name><![CDATA[num]]></field_name><form_name><![CDATA[form_1]]></form_name><section_header></section_header><field_type><![CDATA[text]]></field_type>"
"<field_label><![CDATA[This is an integer]]></field_label><select_choices_or_calculations></select_choices_or_calculations><field_note></field_note>"
"<text_validation_type_or_show_slider_number><![CDATA[integer]]></text_validation_type_or_show_slider_number><text_validation_min><![CDATA[0]]></text_validation_min><text_validation_max><![CDATA[10]]></text_validation_max>"
"<identifier></identifier><branching_logic></branching_logic><required_field></required_field><custom_alignment></custom_alignment><question_number></question_number>"
"<matrix_group_name></matrix_group_name><matrix_ranking></matrix_ranking><field_annotation></field_annotation></item>\n</records>\n"))
(define redcap:testfirst (string-append "field_name,form_name,section_header,field_type,field_label,select_choices_or_calculations,field_note,text_validation_type_or_show_slider_number,"
"text_validation_min,text_validation_max,identifier,branching_logic,required_field,custom_alignment,question_number,matrix_group_name,matrix_ranking,field_annotation\n"
"firstrow,form_2,\"Look, a matrix!\",radio,\"First row\",\"1, A | 2, B | 3, C\",,,,,,,y,,,mat,y,first!\n"))
(define redcap:testfields '("study_no" "yesno" "num" "form_1_complete" "drop" "radio" "checks___1" "checks___2" "checks___3" "checks___4" "firstrow" "secondrow" "form_2_complete" "date_dec" "date_inc_sec" "crawling" "postal_code" "email" "truefalse" "slider" "form_3_complete"))
;; Importing and exporting records functions
;; - redcap-import-record
;; - event
;; - overwrite
;; - instrument
;; - instance
;; - redcap-export-record
;; - records
;; - fields
;; - events
;; - filter
;; - forms
;; - redcap-export-ids
;; - event
(unit-test "REDCap" "Records"
(lambda ()
(redcap-url-set! redcap:testurl)
(let ((success #t))
;; Import json format
(redcap-import-record redcap:testhost redcap:testtoken "1" redcap:testrecord1a 'event "event_a_arm_1")
(redcap-import-record redcap:testhost redcap:testtoken "1" redcap:testrecord1b 'event "event_b_arm_1")
(redcap-import-record redcap:testhost redcap:testtoken "1" redcap:testrecord1c 'event "event_b_arm_1")
(redcap-import-record redcap:testhost redcap:testtoken "1" redcap:testrecord1d 'event "event_a_arm_1")
;; Import with overwrite turned on (by default), sets an existing value to blank
(redcap-import-record redcap:testhost redcap:testtoken "1" redcap:testchange1a 'event "event_a_arm_1")
;; Import with overwrite turned off does not set an existing value to blank
(redcap-import-record redcap:testhost redcap:testtoken "1" redcap:testchange1a 'event "event_b_arm_1" 'overwrite "normal")
;; Import csv with repeated events and instruments
(redcap-import-record-csv redcap:testhost redcap:testtoken redcap:testrecord2)
;; Import to specific repeated instrument
(redcap-import-record redcap:testhost redcap:testtoken "1" redcap:testrepeatable 'event "event_d_arm_1" 'instrument "form_2" 'instance "2")
;; Import to repeated event
(redcap-import-record redcap:testhost redcap:testtoken "1" redcap:testrepeatable 'event "event_c_arm_1" 'instance "2")
;; Export full data as json (default)
(set! success (test-success equal? (redcap-export-records redcap:testhost redcap:testtoken) redcap:testfullexport))
;; Export xml from a specific record
(if success (set! success (test-success string=? (redcap-export-records redcap:testhost redcap:testtoken 'records (list "1") 'format "xml") redcap:testrecord1exp)))
;; Export specific field values as csv, specify name of set of checkboxes - only includes unique ID field + redcap_event_name if the unique ID is included
(if success (set! success (test-success string=? (redcap-export-records redcap:testhost redcap:testtoken 'fields (list "study_no" "num" "radio" "checks") 'format "csv") redcap:testfieldsexp1)))
(if success (set! success (test-success string=? (redcap-export-records redcap:testhost redcap:testtoken 'fields (list "num" "radio" "checks") 'format "csv") redcap:testfieldsexp2)))
;; Export from a specific event
(if success (set! success (test-success equal? (redcap-export-records redcap:testhost redcap:testtoken 'events (list "event_b_arm_1")) redcap:testeventsexp)))
;; Export with filter
(if success (set! success (test-success equal? (redcap-export-records redcap:testhost redcap:testtoken 'filter "[num] = 42") redcap:testfilterexp)))
;; Export from a specific form
(if success (set! success (test-success equal? (redcap-export-records redcap:testhost redcap:testtoken 'records (list "2") 'forms (list "2")) redcap:testformsexp)))
;; Export ids
(if success (set! success (test-success equal? (redcap-export-ids redcap:testhost redcap:testtoken) '("1" "1" "1" "1" "2"))))
;; Export ids given event
(if success (set! success (test-success equal? (redcap-export-ids redcap:testhost redcap:testtoken 'event "event_a_arm_1") '("1" "2"))))
;; Get next available instance index
(if success (set! success (test-success eq? (redcap-get-next-instance redcap:testhost redcap:testtoken "1" "2") 3)))
(if success (set! success (test-success eq? (redcap-get-next-instance-index redcap:testhost redcap:testtoken "1" 'form "form_2" 'event "event_c_arm_1") 3)))
(if success (set! success (test-success eq? (redcap-get-next-instance-index redcap:testhost redcap:testtoken "1" 'form "form_2" 'event "event_d_arm_1") 3)))
(if success (set! success (test-success eq? (redcap-get-next-instance-index redcap:testhost redcap:testtoken "1" 'event "event_d_arm_1") 3)))
(if success (set! success (test-success eq? (redcap-get-next-instance-index redcap:testhost redcap:testtoken "1" 'form "form_2") 3)))
(if success (set! success (test-success eq? (redcap-get-next-instance-index redcap:testhost redcap:testtoken "1" 'form "form_3") #f)))
(if success (set! success (test-success eq? (redcap-get-next-instance-index redcap:testhost redcap:testtoken "1" 'event "event_b_arm_1") #f)))
success)))
(define redcap:testrecord1a '(("yesno" . "1") ("num" . "9") ("form_1_complete" . "1")))
(define redcap:testrecord1b '((checks 1 3)))
(define redcap:testrecord1c '(("yesno" "0") ("num" "8") ("form_1_complete" "2")
("drop" "1") ("radio" "2") ("checks___1" "0") ("checks___2" "0") ("checks___4" "1") ("firstrow" "1") ("secondrow" "2") ("form_2_complete" "0")))
;; Date must be in YY-MM-DD format; date + time must be in YY-MM-DD HH:MM[:SS]; crawling must be integer; slider 0-100 by default; email, postal code have format restrictions
(define redcap:testrecord1d '(("date_dec" "96-06-16") ("date_inc_sec" "96-06-16 09:09:09") ("email" "[email protected]") ("crawling" "0") ("postal_code" "v5v 5v5") ("slider" "80") ("truefalse" "1") ("form_3_complete" "2")))
(define redcap:testchange1a '(("yesno" "")))
(define redcap:testchange1b '(("drop" "")))
(define redcap:testrepeatable '(("firstrow" "2")))
(define redcap:testrecord2 (string-append "study_no,redcap_event_name,redcap_repeat_instrument,redcap_repeat_instance,yesno,num,form_1_complete,firstrow,form_2_complete\n"
"1,event_d_arm_1,,,,,0,,\n"
"1,event_c_arm_1,,1,1,,1,,0\n"
"1,event_c_arm_1,,2,,,0,1,2\n"
"1,event_d_arm_1,form_2,1,,,,2,1\n"
"1,event_d_arm_1,form_2,2,,,,1,2\n"
"2,event_a_arm_1,,,1,42,2,,"))
(define redcap:testfullexport '((("study_no" . "1") ("redcap_event_name" . "event_a_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . "") ("yesno" . "") ("num" . "9") ("form_1_complete" . "1")
("drop" . "") ("radio" . "") ("checks___1" . "") ("checks___2" . "") ("checks___3" . "") ("checks___4" . "") ("firstrow" . "") ("secondrow" . "") ("file" . "") ("form_2_complete" . "")
("date_dec" . "1996-06-16") ("date_inc_sec" . "1996-06-16 09:09:09") ("crawling" . "0") ("postal_code" . "v5v 5v5") ("email" . "[email protected]") ("truefalse" . "1") ("slider" . "80") ("form_3_complete" . "2"))
(("study_no" . "1") ("redcap_event_name" . "event_b_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . "") ("yesno" . "0") ("num" . "8") ("form_1_complete" . "2")
("drop" . "1") ("radio" . "2") ("checks___1" . "0") ("checks___2" . "0") ("checks___3" . "1") ("checks___4" . "1") ("firstrow" . "1") ("secondrow" . "2") ("file" . "") ("form_2_complete" . "0")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . ""))
(("study_no" . "1") ("redcap_event_name" . "event_d_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . "") ("yesno" . "") ("num" . "") ("form_1_complete" . "0")
("drop" . "") ("radio" . "") ("checks___1" . "") ("checks___2" . "") ("checks___3" . "") ("checks___4" . "") ("firstrow" . "") ("secondrow" . "") ("file" . "") ("form_2_complete" . "")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . ""))
(("study_no" . "1") ("redcap_event_name" . "event_c_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . 1) ("yesno" . "1") ("num" . "") ("form_1_complete" . "1")
("drop" . "") ("radio" . "") ("checks___1" . "0") ("checks___2" . "0") ("checks___3" . "0") ("checks___4" . "0") ("firstrow" . "") ("secondrow" . "") ("file" . "") ("form_2_complete" . "0")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . ""))
(("study_no" . "1") ("redcap_event_name" . "event_c_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . 2) ("yesno" . "") ("num" . "") ("form_1_complete" . "0")
("drop" . "") ("radio" . "") ("checks___1" . "0") ("checks___2" . "0") ("checks___3" . "0") ("checks___4" . "0") ("firstrow" . "2") ("secondrow" . "") ("file" . "") ("form_2_complete" . "2")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . ""))
(("study_no" . "1") ("redcap_event_name" . "event_d_arm_1") ("redcap_repeat_instrument" . "form_2") ("redcap_repeat_instance" . 1) ("yesno" . "") ("num" . "") ("form_1_complete" . "")
("drop" . "") ("radio" . "") ("checks___1" . "0") ("checks___2" . "0") ("checks___3" . "0") ("checks___4" . "0") ("firstrow" . "2") ("secondrow" . "") ("file" . "") ("form_2_complete" . "1")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . ""))
(("study_no" . "1") ("redcap_event_name" . "event_d_arm_1") ("redcap_repeat_instrument" . "form_2") ("redcap_repeat_instance" . 2) ("yesno" . "") ("num" . "") ("form_1_complete" . "")
("drop" . "") ("radio" . "") ("checks___1" . "0") ("checks___2" . "0") ("checks___3" . "0") ("checks___4" . "0") ("firstrow" . "2") ("secondrow" . "") ("file" . "") ("form_2_complete" . "2")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . ""))
(("study_no" . "2") ("redcap_event_name" . "event_a_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . "") ("yesno" . "1") ("num" . "42") ("form_1_complete" . "2")
("drop" . "") ("radio" . "") ("checks___1" . "") ("checks___2" . "") ("checks___3" . "") ("checks___4" . "") ("firstrow" . "") ("secondrow" . "") ("file" . "") ("form_2_complete" . "")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . "0"))))
(define redcap:testrecord1exp (string-append "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<records>\n"
"<item><study_no><![CDATA[1]]></study_no><redcap_event_name><![CDATA[event_a_arm_1]]></redcap_event_name><redcap_repeat_instrument><![CDATA[]]></redcap_repeat_instrument>"
"<redcap_repeat_instance><![CDATA[]]></redcap_repeat_instance><yesno><![CDATA[]]></yesno><num><![CDATA[9]]></num><form_1_complete><![CDATA[1]]></form_1_complete><drop><![CDATA[]]>"
"</drop><radio><![CDATA[]]></radio><checks___1><![CDATA[]]></checks___1><checks___2><![CDATA[]]></checks___2><checks___3><![CDATA[]]></checks___3><checks___4><![CDATA[]]></checks___4>"
"<firstrow><![CDATA[]]></firstrow><secondrow><![CDATA[]]></secondrow><file><![CDATA[]]></file><form_2_complete><![CDATA[]]></form_2_complete>"
"<date_dec><![CDATA[1996-06-16]]></date_dec><date_inc_sec><![CDATA[1996-06-16 09:09:09]]></date_inc_sec><crawling><![CDATA[0]]></crawling><postal_code><![CDATA[v5v 5v5]]></postal_code>"
"<email><![CDATA[[email protected]]]></email><truefalse><![CDATA[1]]></truefalse><slider><![CDATA[80]]></slider><form_3_complete><![CDATA[2]]></form_3_complete></item>\n"
"<item><study_no><![CDATA[1]]></study_no><redcap_event_name><![CDATA[event_b_arm_1]]></redcap_event_name><redcap_repeat_instrument><![CDATA[]]></redcap_repeat_instrument>"
"<redcap_repeat_instance><![CDATA[]]></redcap_repeat_instance><yesno><![CDATA[0]]></yesno><num><![CDATA[8]]></num><form_1_complete><![CDATA[2]]></form_1_complete><drop><![CDATA[1]]>"
"</drop><radio><![CDATA[2]]></radio><checks___1><![CDATA[0]]></checks___1><checks___2><![CDATA[0]]></checks___2><checks___3><![CDATA[1]]></checks___3><checks___4><![CDATA[1]]></checks___4>"
"<firstrow><![CDATA[1]]></firstrow><secondrow><![CDATA[2]]></secondrow><file><![CDATA[]]></file><form_2_complete><![CDATA[0]]></form_2_complete>"
"<date_dec><![CDATA[]]></date_dec><date_inc_sec><![CDATA[]]></date_inc_sec><crawling><![CDATA[]]></crawling><postal_code><![CDATA[]]></postal_code>"
"<email><![CDATA[]]></email><truefalse><![CDATA[]]></truefalse><slider><![CDATA[]]></slider><form_3_complete><![CDATA[]]></form_3_complete></item>\n"
"<item><study_no><![CDATA[1]]></study_no><redcap_event_name><![CDATA[event_d_arm_1]]></redcap_event_name><redcap_repeat_instrument><![CDATA[]]></redcap_repeat_instrument>"
"<redcap_repeat_instance><![CDATA[]]></redcap_repeat_instance><yesno><![CDATA[]]></yesno><num><![CDATA[]]></num><form_1_complete><![CDATA[0]]></form_1_complete><drop><![CDATA[]]>"
"</drop><radio><![CDATA[]]></radio><checks___1><![CDATA[]]></checks___1><checks___2><![CDATA[]]></checks___2><checks___3><![CDATA[]]></checks___3><checks___4><![CDATA[]]></checks___4>"
"<firstrow><![CDATA[]]></firstrow><secondrow><![CDATA[]]></secondrow><file><![CDATA[]]></file><form_2_complete><![CDATA[]]></form_2_complete>"
"<date_dec><![CDATA[]]></date_dec><date_inc_sec><![CDATA[]]></date_inc_sec><crawling><![CDATA[]]></crawling><postal_code><![CDATA[]]></postal_code>"
"<email><![CDATA[]]></email><truefalse><![CDATA[]]></truefalse><slider><![CDATA[]]></slider><form_3_complete><![CDATA[]]></form_3_complete></item>\n"
"<item><study_no><![CDATA[1]]></study_no><redcap_event_name><![CDATA[event_c_arm_1]]></redcap_event_name><redcap_repeat_instrument><![CDATA[]]></redcap_repeat_instrument>"
"<redcap_repeat_instance><![CDATA[1]]></redcap_repeat_instance><yesno><![CDATA[1]]></yesno><num><![CDATA[]]></num><form_1_complete><![CDATA[1]]></form_1_complete><drop><![CDATA[]]>"
"</drop><radio><![CDATA[]]></radio><checks___1><![CDATA[0]]></checks___1><checks___2><![CDATA[0]]></checks___2><checks___3><![CDATA[0]]></checks___3><checks___4><![CDATA[0]]></checks___4>"
"<firstrow><![CDATA[]]></firstrow><secondrow><![CDATA[]]></secondrow><file><![CDATA[]]></file><form_2_complete><![CDATA[0]]></form_2_complete>"
"<date_dec><![CDATA[]]></date_dec><date_inc_sec><![CDATA[]]></date_inc_sec><crawling><![CDATA[]]></crawling><postal_code><![CDATA[]]></postal_code>"
"<email><![CDATA[]]></email><truefalse><![CDATA[]]></truefalse><slider><![CDATA[]]></slider><form_3_complete><![CDATA[]]></form_3_complete></item>\n"
"<item><study_no><![CDATA[1]]></study_no><redcap_event_name><![CDATA[event_c_arm_1]]></redcap_event_name><redcap_repeat_instrument><![CDATA[]]></redcap_repeat_instrument>"
"<redcap_repeat_instance><![CDATA[2]]></redcap_repeat_instance><yesno><![CDATA[]]></yesno><num><![CDATA[]]></num><form_1_complete><![CDATA[0]]></form_1_complete><drop><![CDATA[]]>"
"</drop><radio><![CDATA[]]></radio><checks___1><![CDATA[0]]></checks___1><checks___2><![CDATA[0]]></checks___2><checks___3><![CDATA[0]]></checks___3><checks___4><![CDATA[0]]></checks___4>"
"<firstrow><![CDATA[2]]></firstrow><secondrow><![CDATA[]]></secondrow><file><![CDATA[]]></file><form_2_complete><![CDATA[2]]></form_2_complete>"
"<date_dec><![CDATA[]]></date_dec><date_inc_sec><![CDATA[]]></date_inc_sec><crawling><![CDATA[]]></crawling><postal_code><![CDATA[]]></postal_code>"
"<email><![CDATA[]]></email><truefalse><![CDATA[]]></truefalse><slider><![CDATA[]]></slider><form_3_complete><![CDATA[]]></form_3_complete></item>\n"
"<item><study_no><![CDATA[1]]></study_no><redcap_event_name><![CDATA[event_d_arm_1]]></redcap_event_name><redcap_repeat_instrument><![CDATA[form_2]]></redcap_repeat_instrument>"
"<redcap_repeat_instance><![CDATA[1]]></redcap_repeat_instance><yesno><![CDATA[]]></yesno><num><![CDATA[]]></num><form_1_complete><![CDATA[]]></form_1_complete><drop><![CDATA[]]>"
"</drop><radio><![CDATA[]]></radio><checks___1><![CDATA[0]]></checks___1><checks___2><![CDATA[0]]></checks___2><checks___3><![CDATA[0]]></checks___3><checks___4><![CDATA[0]]></checks___4>"
"<firstrow><![CDATA[2]]></firstrow><secondrow><![CDATA[]]></secondrow><file><![CDATA[]]></file><form_2_complete><![CDATA[1]]></form_2_complete>"
"<date_dec><![CDATA[]]></date_dec><date_inc_sec><![CDATA[]]></date_inc_sec><crawling><![CDATA[]]></crawling><postal_code><![CDATA[]]></postal_code>"
"<email><![CDATA[]]></email><truefalse><![CDATA[]]></truefalse><slider><![CDATA[]]></slider><form_3_complete><![CDATA[]]></form_3_complete></item>\n"
"<item><study_no><![CDATA[1]]></study_no><redcap_event_name><![CDATA[event_d_arm_1]]></redcap_event_name><redcap_repeat_instrument><![CDATA[form_2]]></redcap_repeat_instrument>"
"<redcap_repeat_instance><![CDATA[2]]></redcap_repeat_instance><yesno><![CDATA[]]></yesno><num><![CDATA[]]></num><form_1_complete><![CDATA[]]></form_1_complete><drop><![CDATA[]]>"
"</drop><radio><![CDATA[]]></radio><checks___1><![CDATA[0]]></checks___1><checks___2><![CDATA[0]]></checks___2><checks___3><![CDATA[0]]></checks___3><checks___4><![CDATA[0]]></checks___4>"
"<firstrow><![CDATA[2]]></firstrow><secondrow><![CDATA[]]></secondrow><file><![CDATA[]]></file><form_2_complete><![CDATA[2]]></form_2_complete>"
"<date_dec><![CDATA[]]></date_dec><date_inc_sec><![CDATA[]]></date_inc_sec><crawling><![CDATA[]]></crawling><postal_code><![CDATA[]]></postal_code>"
"<email><![CDATA[]]></email><truefalse><![CDATA[]]></truefalse><slider><![CDATA[]]></slider><form_3_complete><![CDATA[]]></form_3_complete></item>\n"
"</records>"))
(define redcap:testfieldsexp1 (string-append "study_no,redcap_event_name,redcap_repeat_instrument,redcap_repeat_instance,num,radio,checks___1,checks___2,checks___3,checks___4\n"
"1,event_a_arm_1,,,9,,,,,\n"
"1,event_b_arm_1,,,8,2,0,0,1,1\n"
"1,event_d_arm_1,,,,,,,,\n"
"1,event_c_arm_1,,1,,,0,0,0,0\n"
"2,event_a_arm_1,,,42,,,,,\n"))
(define redcap:testfieldsexp2 (string-append "num,radio,checks___1,checks___2,checks___3,checks___4\n"
"9,,,,,\n"
"8,2,0,0,1,1\n"
",,,,,\n"
",,0,0,0,0\n"
"42,,,,,\n"))
(define redcap:testformsexp '((("study_no" . "2") ("redcap_event_name" . "event_a_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . "") ("yesno" . "1") ("num" . "42") ("form_1_complete" . "2")
("drop" . "") ("radio" . "") ("checks___1" . "") ("checks___2" . "") ("checks___3" . "") ("checks___4" . "") ("firstrow" . "") ("secondrow" . "") ("file" . "") ("form_2_complete" . "")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . "0"))))
(define redcap:testeventsexp '((("study_no" . "1") ("redcap_event_name" . "event_b_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . "") ("yesno" . "0") ("num" . "8") ("form_1_complete" . "2")
("drop" . "1") ("radio" . "2") ("checks___1" . "0") ("checks___2" . "0") ("checks___3" . "1") ("checks___4" . "1") ("firstrow" . "1") ("secondrow" . "2") ("file" . "") ("form_2_complete" . "0")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . ""))))
(define redcap:testfilterexp '((("study_no" . "2") ("redcap_event_name" . "event_a_arm_1") ("redcap_repeat_instrument" . "") ("redcap_repeat_instance" . "") ("yesno" . "1") ("num" . "42") ("form_1_complete" . "2")
("drop" . "") ("radio" . "") ("checks___1" . "") ("checks___2" . "") ("checks___3" . "") ("checks___4" . "") ("firstrow" . "") ("secondrow" . "") ("file" . "") ("form_2_complete" . "")
("date_dec" . "") ("date_inc_sec" . "") ("crawling" . "") ("postal_code" . "") ("email" . "") ("truefalse" . "") ("slider" . "") ("form_3_complete" . "0"))))
;; Importing and exporting files functions
;; - redcap-import-file
;; - event
;; - repeat
;; - redcap-export-file
;; - event
;; - repeat
;; - redcap-delete-file
;; - event
;; - repeat
(unit-test "REDCap" "Files"
(lambda () (and
(redcap:filetest "event_b_arm_1" #f)
(redcap:filetest "event_c_arm_1" "1")
(redcap:filetest "event_d_arm_1" "2"))))
(define (redcap:filetest event repeat)
(redcap-url-set! redcap:testurl)
(let ((testfile (string-append (system-directory) (system-pathseparator) "test.csv"))
(csvcontent (list (list "header1" "header2") (list "A" "B")))
(success #t))
;; Remove the file if exists
(if (file-exists? testfile) (delete-file testfile))
;; Create a small csv file
(csv-write testfile csvcontent)
;; Import the file
(redcap-import-file redcap:testhost redcap:testtoken "1" "file" testfile 'event event 'repeat repeat)
;; Export the file
(let ((f (redcap-export-file redcap:testhost redcap:testtoken "1" "file" testfile 'event event 'repeat repeat)))
(if (list? f)
(let* ((filepath (string-append (system-directory) (system-pathseparator) "export.csv"))
(fh (open-output-file filepath))
(content (cadr f)))
;; Check file name is list
(if success (set! success (string-contains (car f) "name=\"test.csv\"")))
;; If file exists, delete it
(if (file-exists? filepath) (delete-file testfile))
(write-subu8vector content 0 (u8vector-length content) fh)
(close-output-port fh)
;; Check exported file
(let ((downloadedcontent (csv-read filepath)))
(if success (set! success (equal? csvcontent downloadedcontent)))))
(set! success #f)))
;; Check the a regular export shows a file
(if success (set! success (test-success string-contains (redcap-export-records redcap:testhost redcap:testtoken 'records (list "1") 'events (list event) 'fields (list "file") 'format "csv") "[document]")))
;; Delete file to prepare for next time
(redcap-delete-file redcap:testhost redcap:testtoken "1" "file" 'event event 'repeat repeat)
;; Check that the file is gone
(if success (set! success (test-failure string-contains (redcap-export-records redcap:testhost redcap:testtoken 'records (list "1") 'events (list event) 'fields (list "file") 'format "csv") "[document]")))
success))
| false |
0810edecd553c61d3d8c320898f9a129b668ea83
|
6cf2e78840970768168f583716e8826b1902dafa
|
/learning-functional/work-in-university/home-practice/scheme-practice/part-2-recursion/solutions/increasing.scm
|
9a48eaec4ae0d4956bcd8c3f2d4f72d34eb470dc
|
[] |
no_license
|
dianvaltodorov/learning-code
|
e4b3e5034c68cdf9d1e38f8b6a12af1d51d2e167
|
a92605345829e051c0b2420de6f3dfc1fe5eb65a
|
refs/heads/master
| 2021-01-17T12:24:58.618311 | 2016-02-02T17:48:55 | 2018-06-21T06:53:16 | 49,488,021 | 2 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 327 |
scm
|
increasing.scm
|
(load "../../lib/unit.scm")
(load "count_digits.scm")
(load "digit_at_position.scm")
(define (increasing? x)
(define (helper x position)
(cond
((= position (count-digits-iter x)) #t)
((< (digit-at-pos x position)
(digit-at-pos x (+ position 1))) (helper x (+ position 1)))
(else #f)))
(helper x 1))
| false |
0aac273607e6f25dbb64e12a20015d05eba1474d
|
9b2eb10c34176f47f7f490a4ce8412b7dd42cce7
|
/lib-compat/yunife-yunivm/runtime/define.sls
|
47395b2dc06141e8325f7c810c5312beb4f5428b
|
[
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] |
permissive
|
okuoku/yuni
|
8be584a574c0597375f023c70b17a5a689fd6918
|
1859077a3c855f3a3912a71a5283e08488e76661
|
refs/heads/master
| 2023-07-21T11:30:14.824239 | 2023-06-11T13:16:01 | 2023-07-18T16:25:22 | 17,772,480 | 36 | 6 |
CC0-1.0
| 2020-03-29T08:16:00 | 2014-03-15T09:53:13 |
Scheme
|
UTF-8
|
Scheme
| false | false | 316 |
sls
|
define.sls
|
(library (yunife-yunivm runtime define)
(export define)
(import (yunivm-core-syntax))
(define-syntax define
(syntax-rules ()
((_ name body0)
($define/core name body0))
((_ (name . args) body0 body1 ...)
($define/core name (lambda args body0 body1 ...)))))
)
| true |
ec641d29fe6254d97f9002023b0ad5f0422bdc5f
|
7666204be35fcbc664e29fd0742a18841a7b601d
|
/code/4-43.scm
|
776fcfba3419c5ed25fea3b367354b6cffb644a8
|
[] |
no_license
|
cosail/sicp
|
b8a78932e40bd1a54415e50312e911d558f893eb
|
3ff79fd94eda81c315a1cee0165cec3c4dbcc43c
|
refs/heads/master
| 2021-01-18T04:47:30.692237 | 2014-01-06T13:32:54 | 2014-01-06T13:32:54 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,698 |
scm
|
4-43.scm
|
(include "4.3.2-common.scm")
(define all-fathers (list 'Moore 'Downing 'Hall 'Barnacle 'Parker))
(define all-daughters (list 'Mary 'Gabrelle 'Lorna 'Rosalind 'Melissa))
;; copied from http://community.schemewiki.org/?sicp-ex-4.43
;; BOATS:
;; Moore - Lorna
;; Barnacle - Gabrielle
;; Hall - Rosalind
;; Downing - Melissa
;; Parker - Mary
(define (father-daughter)
(let ((Moore 'Mary)
(Barnacle 'Melissa)
(Hall (amb 'Gabrelle 'Lorna))
(Downing (amb 'Gabrelle 'Lorna 'Rosalind))
(Parker (amb 'Lorna 'Rosalind)))
; └> The name of Gabrielle's Father's Boat is Parker's daughter's name,
; so Parker's daughter won't be Gabrielle.
(require
; The name of Gabrielle's Father's Boat is Parker's daughter's name
(cond
((eq? Hall 'Gabrelle) (eq? 'Rosalind Parker)) ;Hall's boat's name is Rosalind
((eq? Downing 'Gabrelle) (eq? 'Melissa Parker)) ;Downing's boat's name is Melissa
(else false)))
(require (distinct? (list Moore Barnacle Hall Downing Parker)))
(list
(list 'Barnacle Barnacle)
(list 'Moore Moore)
(list 'Hall Hall)
(list 'Downing Downing)
(list 'Parker Parker))))
(father-daughter)
;; ANSWER:
;; (Moore Mary) (Barnacle Melissa) (Hall Gabrelle) (Downing Lorna) (Parker Rosalind)
;; 如果不知道Moore的女儿是Mary, 会多一个答案
;; (Moore Gabrelle) (Barnacle Melissa) (Hall Mary) (Downing Rosalind) (Parker Lorna)
(define (father-daughter)
(let ((Moore (amb 'Mary 'Gabrelle 'Rosalind ))
(Barnacle 'Melissa)
(Hall (amb 'Gabrelle 'Lorna))
(Downing (amb 'Gabrelle 'Lorna 'Rosalind))
(Parker (amb 'Lorna 'Rosalind)))
; └> The name of Gabrielle's Father's Boat is Parker's daughter's name,
; so Parker's daughter won't be Gabrielle.
(require
; The name of Gabrielle's Father's Boat is Parker's daughter's name
(cond
((eq? Moore 'Gabrelle) (eq? 'Lorna Parker)) ;Moore's boat's name is Lorna
((eq? Hall 'Gabrelle) (eq? 'Rosalind Parker)) ;Hall's boat's name is Rosalind
((eq? Downing 'Gabrelle) (eq? 'Melissa Parker)) ;Downing's boat's name is Melissa
(else false)))
(require (distinct? (list Moore Barnacle Hall Downing Parker)))
(list
(list 'Barnacle Barnacle)
(list 'Moore Moore)
(list 'Hall Hall)
(list 'Downing Downing)
(list 'Parker Parker))))
| false |
1508c4210fda1f42b7b7f6d84925a41a20d58ed3
|
4b480cab3426c89e3e49554d05d1b36aad8aeef4
|
/chapter-02/ex2.37-falsetru.scm
|
ee9a3112452e63e4ba9eecab36f9c920da4a19c3
|
[] |
no_license
|
tuestudy/study-sicp
|
a5dc423719ca30a30ae685e1686534a2c9183b31
|
a2d5d65e711ac5fee3914e45be7d5c2a62bfc20f
|
refs/heads/master
| 2021-01-12T13:37:56.874455 | 2016-10-04T12:26:45 | 2016-10-04T12:26:45 | 69,962,129 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 331 |
scm
|
ex2.37-falsetru.scm
|
(load "ex2.36-falsetru.scm")
(define (dot-product v w)
(accumulate + 0 (map * v w)))
(define (matrix-*-vector m v)
(map (lambda (mi) (dot-product mi v)) m))
(define (transpose m)
(accumulate-n cons null m))
(define (matrix-*-matrix m n)
(let ((cols (transpose n)))
(map (lambda (mi) (matrix-*-vector cols mi)) m)))
| false |
68991b44de196ac3fcf82b1a8c52e8ce11cba3f4
|
120324bbbf63c54de0b7f1ca48d5dcbbc5cfb193
|
/packages/slib/macrotst.scm
|
b5b50460240e0ad66a4d4ac56e34f026de9a2470
|
[
"MIT"
] |
permissive
|
evilbinary/scheme-lib
|
a6d42c7c4f37e684c123bff574816544132cb957
|
690352c118748413f9730838b001a03be9a6f18e
|
refs/heads/master
| 2022-06-22T06:16:56.203827 | 2022-06-16T05:54:54 | 2022-06-16T05:54:54 | 76,329,726 | 609 | 71 |
MIT
| 2022-06-16T05:54:55 | 2016-12-13T06:27:36 |
Scheme
|
UTF-8
|
Scheme
| false | false | 1,222 |
scm
|
macrotst.scm
|
;;;"macrotst.scm" Test for R4RS Macros
;;; From Revised^4 Report on the Algorithmic Language Scheme
;;; Editors: William Clinger and Jonathon Rees
;
; We intend this report to belong to the entire Scheme community, and so
; we grant permission to copy it in whole or in part without fee. In
; particular, we encourage implementors of Scheme to use this report as
; a starting point for manuals and other documentation, modifying it as
; necessary.
;;; To run this code type
;;; (require 'macro)
;;; (macro:load "macrotst.scm")
(write "this code should print now, outer, and 7") (newline)
(write
(let-syntax ((when (syntax-rules ()
((when test stmt1 stmt2 ...)
(if test
(begin stmt1
stmt2 ...))))))
(let ((if #t))
(when if (set! if 'now))
if)))
(newline)
;;; ==> now
(write
(let ((x 'outer))
(let-syntax ((m (syntax-rules () ((m) x))))
(let ((x 'inner))
(m)))))
(newline)
;;; ==> outer
(write
(letrec-syntax
((or (syntax-rules ()
((or) #f)
((or e) e)
((or e1 e2 ...)
(let ((temp e1))
(if temp temp (or e2 ...)))))))
(let ((x #f)
(y 7)
(temp 8)
(let odd?)
(if even?))
(or x
(let temp)
(if y)
y))))
(newline)
;;; ==> 7
| false |
9d1fe55057e8cb658d0bda740adea592c1572d7f
|
7301b8e6fbd4ac510d5e8cb1a3dfe5be61762107
|
/ex-4.35.scm
|
fc60674e1332f544a3ca989f855583542ee3294d
|
[] |
no_license
|
jiakai0419/sicp-1
|
75ec0c6c8fe39038d6f2f3c4c6dd647a39be6216
|
974391622443c07259ea13ec0c19b80ac04b2760
|
refs/heads/master
| 2021-01-12T02:48:12.327718 | 2017-01-11T12:54:38 | 2017-01-11T12:54:38 | 78,108,302 | 0 | 0 | null | 2017-01-05T11:44:44 | 2017-01-05T11:44:44 | null |
UTF-8
|
Scheme
| false | false | 819 |
scm
|
ex-4.35.scm
|
;;; Exercise 4.35. Write a procedure an-integer-between that returns an
;;; integer between two given bounds. This can be used to implement a procedure
;;; that finds Pythagorean triples, i.e., triples of integers (i,j,k) between
;;; the given bounds such that i < j and i^2 + j^2 = k^2, as follows:
;;;
;;; (define (a-pythagorean-triple-between low high)
;;; (let ((i (an-integer-between low high)))
;;; (let ((j (an-integer-between i high)))
;;; (let ((k (an-integer-between j high)))
;;; (require (= (+ (* i i) (* j j)) (* k k)))
;;; (list i j k)))))
(load "./sec-4.3.3.scm")
(ambtest
'(begin
(define (an-integer-between i j)
(require (<= i j))
(amb i (an-integer-between (+ i 1) j)))
(let ((k (an-integer-between 13 19)))
(print "k = " k))
))
| false |
97136797eec298b680bfe21d4523582bbf23120b
|
ee232691dcbaededacb0778247f895af992442dd
|
/kirjasto/lib/panna/työkalu.scm
|
aff60a89b3468cb86a25c07aad3bbde98b0f9df9
|
[] |
no_license
|
mytoh/panna
|
c68ac6c6ef6a6fe79559e568d7a8262a7d626f9f
|
c6a193085117d12a2ddf26090cacb1c434e3ebf9
|
refs/heads/master
| 2020-05-17T02:45:56.542815 | 2013-02-13T19:18:38 | 2013-02-13T19:18:38 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,652 |
scm
|
työkalu.scm
|
(define-module panna.työkalu
(use gauche.process)
(use gauche.parameter)
(use file.util)
(use text.tree)
(require-extension (srfi 98))
(use panna.väri)
(use maali)
(export
load-build-file
commands
url-is-git?
url-is-hg?
url-is-bzr?
url-is-cvs?
url-is-fossil?
url-is-svn?
message
))
(select-module panna.työkalu)
(define (load-build-file pullo kansio)
; find, load kaava file
(load (find-file-in-paths (string-append pullo ".scm")
:paths `(,kansio)
:pred file-is-readable?)))
(define-syntax commands
; run processes
(syntax-rules ()
((_ c1 ...)
(begin
(run-process c1 :output :null :wait #t)
...))))
(define (url-is-git? url)
(or (#/^git:\/\// url)
(#/\.git$/ url)))
(define (url-is-hg? url)
(or (#/^https?:\/\/(.+?\.)?googlecode\.com\/hg/ url)
(#/^hg:\/\// url)
(#/^http:\/\/hg\./ url)
(#/^http:\/\/(.+?\/)\/hg/ url)))
(define (url-is-svn? url)
(or (#/^https?:\/\/(.+?\.)?googlecode\.com\/svn/ url)
(#/^https?:\/\/(.+?\.)?sourceforge\.net\/svnroot/ url)
(#/^svn:\/\// url)
(#/^svn\+http:\/\// url)
(#/^http:\/\/svn.apache.org\/repos/ url)
(#/^http:\/\/svn\./ url)))
(define (url-is-bzr? url)
(cond ((#/^bzr:\/\// url) #t)
(else #f)))
(define (url-is-fossil? url)
(cond ((#/^fossil:\/\// url) #t)
(else #f)))
(define (url-is-cvs? url)
(cond ((#/^cvs:\/\// url) #t)
(else #f)))
(define (message msg)
(display (paint ":: " (colour-symbol1)))
(display (paint msg (colour-message))))
| true |
508b2b0a6562be67ad452b3239784a0383d60377
|
09e309c8c7dd86d201f965a12f4f174fd2bf8cf5
|
/scheme/sicp/exercise1-12.scm
|
8aafb34810c03b71552f81b7a940ebec57cf6ba3
|
[] |
no_license
|
googol-lab/lang
|
f21076846b2364ee08875530ab7a6680de61f55c
|
38cae455f85464a7f918d1a5a481a577ed5549fe
|
refs/heads/master
| 2020-03-29T13:32:29.159544 | 2010-05-24T03:09:54 | 2010-05-24T03:09:54 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 291 |
scm
|
exercise1-12.scm
|
(define (pascal n)
(define (pascal-iter result count)
(define (iter pas accum)
(if (null? (cdr pas))
accum
(iter (cdr pas) (cons (+ (car pas) (cadr pas)) accum))))
(if (= n count)
result
(cons 1 (iter (pascal-iter result (+ 1 count)) '(1)))))
(pascal-iter '(1) 1))
| false |
8dc3b46c5837072ce5057df21ad5ffa22060aea2
|
a4a6e51f015e7968b7760d089bbe2c4cf57d7b4d
|
/calvinball.scm
|
3d67be641b421e62e3a7f14fccd588d06e06a695
|
[] |
no_license
|
jpt4/womb
|
10bcc0c6cee0a6eefb6656518470ad5e64404942
|
a89cb5733e1d3a1b0a13ec583c9c33309b5c59da
|
refs/heads/master
| 2023-07-25T17:16:44.571894 | 2023-07-07T19:35:31 | 2023-07-07T19:35:31 | 37,166,949 | 0 | 2 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 9,653 |
scm
|
calvinball.scm
|
;;calvinball.scm
;;jpt4
;;A simple object-oriented implementation of Calvinball.
;;UTC20160330
;;Guile Scheme v2.0+
#|Game definition
Calvinball has no fixed set of rules of play, but it does have a
consistent internal schedule and scoring system.
A game of Calvinball is divided into 13 innings, each composed of an
upper and lower duoquarter (UDQ and ldq, respectively). The home
team (colloquially "Tiger") attempts to score during each UDQ, while
the away team ("Philosophe") attempts to score during each ldq.
The maximum number of points that can be scored during an entire
inning (UDQ + ldq) is 11. If Tiger scores all 11 points in the UDQ,
they receive 11 points plus the total score of the next
inning (Philosophe automatically receives a score of zero for the
current inning's ldq, but may choose to play anyway, for a maximum of
17.5 minutes, at their discretion). If the total score of an
inning (UQD + ldq) is 11, but Tiger did not score all 11 points, their
score is (UDQ - ldq), and Philosophe scores the number of points
earned in the ldq. If less than 11 points are scored during an inning,
each team receives the number of points earned in their respective
duoquarters.
In the special case of Tiger earning 11 points in the UDQ of the 13th
and last inning, Tiger scores 8 points while Philosophe scores 3.
Points are tallied in a running sum, and the winner of Calvinball is
the team with the most points at the end of the 13th inning.
Example 1:
Inn# 1 2 3
+-----+-----+-----+
UDQ | 11 | 2 | 3 |
lqd | 0 | 9 | 5 |
+-----+-----+-----+
Tiger | 22 | 15 | 18 |
Philo | 0 | 9 | 14 |
+-----+-----+-----+
In the first inning, Tiger earns all 11 possible points in the UDQ, to
which are added the 11 points cumulatively earned in the second
inning, for a total 1st inning score of 22. Philosophe earns 0 points
for the first inning. In the second inning, Philosophe scores 9
points, while Tiger scores (9 - 2 = -7) points, for a running total of
9 and 15. Less than 11 points are earned in the third inning, so each
team simply adds their respective points to their running total.
Example 2:
Inn# 12 13
+-----+-----+
UDQ | 4 | 11 |
lqd | 6 | 0 |
+-----+-----+
Tiger | 59 | 67 |
Philo | 63 | 66 |
+-----+-----+
Tiger has achieved the special case of earning 11 points in the UDQ of
the final inning, thus scoring 8 points to Philosophe's 3, for a final
score of (59 + 8 = 67) to (63 + 3 = 66), thus winning by one point.
Write a class "calvinball" which records each duoquartile's points
earned with the methods "upper-earned" and "lower-earned", and reports
the current score of each team with method "calculate-score".
|#
;;;semi-functional style - uses set!
;;initial scoreboard
;;scoreboard grows right to left, each member is a pair (UDQ ldq)
(define scoreboard '())
(define (clear-scoreboard) (set! scoreboard '()))
(define (upper-earned p)
(set! scoreboard (cons (list p) scoreboard)))
(define (lower-earned p)
(set! scoreboard (cons (cons (caar scoreboard) (list p)) (cdr scoreboard))))
(define (calculate-score)
(cond
[(not (eq? (length scoreboard) 13))
(begin
(display "error: scoreboard is length ")
(display (length scoreboard))
(newline))]
[(eq? (length scoreboard) 13)
(let loop ([s (reverse scoreboard)] [accT 0] [accP 0])
(cond
[(null? s) (begin (display `(T: ,accT P: ,accP)) (newline))]
[(and (eq? (length s) 1) (eq? (caar s) 11))
(loop '() (+ accT 8) (+ accP 3))] ;13th inning edge case
[(eq? (caar s) 11) ;T earns 11 in UDQ
(loop (cdr s) (+ accT (+ (caar s) (caadr s) (cadadr s))) accP)]
[(eq? (+ (caar s) (cadar s)) 11) ;inning total = 11
(loop (cdr s) (+ accT (- (caar s) (cadar s))) (+ accP (cadar s)))]
[else ;inning total < 11
(loop (cdr s) (+ accT (caar s)) (+ accP (cadar s)))]))]))
;;tests
(define (func-test)
(begin
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((0 0) (0 0) (0 0) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (0 0) (0 0)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((0 0) (0 0) (0 0) (0 0) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (0 0) (11 0)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((0 0) (0 0) (0 0) (0 0) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (11 0) (11 0)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((0 0) (0 0) (0 0) (0 0) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (0 0) (3 8)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((0 0) (0 0) (0 0) (0 0) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (11 0) (3 8)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((7 2) (0 0) (0 0) (0 0) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (11 0) (3 8)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((7 2) (0 11) (0 0) (0 0) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (11 0) (3 8)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((7 2) (0 11) (11 0) (0 0) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (11 0) (3 8)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((7 2) (0 11) (11 0) (0 11) (0 0) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (11 0) (3 8)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((7 2) (0 11) (11 0) (0 11) (9 1) (0 0) (0 0)
(0 0) (0 0) (0 0) (0 0) (11 0) (3 8)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
(for-each (lambda (s) (upper-earned (car s)) (lower-earned (cadr s)))
'((7 2) (0 11) (11 0) (0 11) (9 1) (11 0) (2 9)
(0 0) (0 0) (0 0) (0 0) (11 0) (3 8)))
(display scoreboard) (newline)
(calculate-score)
(clear-scoreboard)
(display scoreboard) (newline)
))
;;;object-oriented style - repurposes functions as methods
(define (mk-game)
;;stored state
(define scoreboard '())
;;method definitions
(define (clear-scoreboard) (set! scoreboard '()))
(define (upper-earned p)
(set! scoreboard (cons (list p) scoreboard)))
(define (lower-earned p)
(set! scoreboard (cons (cons (caar scoreboard) (list p)) (cdr scoreboard))))
(define (calculate-score)
(cond
[(not (eq? (length scoreboard) 13))
(begin
(display "error: scoreboard is length ")
(display (length scoreboard))
(newline))]
[(eq? (length scoreboard) 13)
(let loop ([s (reverse scoreboard)] [accT 0] [accP 0])
(cond
[(null? s) (begin (display `(T: ,accT P: ,accP)) (newline))]
[(and (eq? (length s) 1) (eq? (caar s) 11))
(loop '() (+ accT 8) (+ accP 3))] ;13th inning edge case
[(eq? (caar s) 11) ;T earns 11 in UDQ
(loop (cdr s) (+ accT (+ (caar s) (caadr s) (cadadr s))) accP)]
[(eq? (+ (caar s) (cadar s)) 11) ;inning total = 11
(loop (cdr s) (+ accT (- (caar s) (cadar s))) (+ accP (cadar s)))]
[else ;inning total < 11
(loop (cdr s) (+ accT (caar s)) (+ accP (cadar s)))]))]))
;;the (self) function: exports an interface; handles incoming messages;
;;dispatches methods according to message.
(define (self msg . arg)
(case msg
[(get-sb) scoreboard]
[(clear) (clear-scoreboard)]
[(set-udq) (upper-earned (car arg))]
[(set-ldq) (lower-earned (car arg))]
[(calculate) (calculate-score)]))
;;expose the (self) function to the outside
self
)
;;tests
(define game1 (mk-game))
(define (obj-test)
(begin
(display (game1 'get-sb)) (newline)
(for-each (lambda (s) (game1 'set-udq (car s)) (game1 'set-ldq (cadr s)))
'((7 2) (0 11) (11 0) (0 11) (9 1) (11 0) (2 9)
(0 0) (0 0) (0 0) (0 0) (11 0) (3 8)))
(display (game1 'get-sb)) (newline)
(game1 'calculate)
(game1 'clear)
(display (game1 'get-sb)) (newline)
(for-each (lambda (s) (game1 'set-udq (car s)) (game1 'set-ldq (cadr s)))
'((7 2) (0 11) (11 0) (0 11) (9 1) (11 0) (2 9)
(0 0) (0 0) (0 0) (11 0) (3 8)))
(display (game1 'get-sb)) (newline)
(game1 'calculate)
(game1 'clear)
(display (game1 'get-sb)) (newline)
))
| false |
fbdc3f9ef6ef107dd86758b3cb1b3a446e86b37f
|
3508dcd12d0d69fec4d30c50334f8deb24f376eb
|
/v8/src/compiler/machines/i386/compiler.pkg
|
c0d2fa6fd0072c072da450f019da31b6770ecb4c
|
[] |
no_license
|
barak/mit-scheme
|
be625081e92c2c74590f6b5502f5ae6bc95aa492
|
56e1a12439628e4424b8c3ce2a3118449db509ab
|
refs/heads/master
| 2023-01-24T11:03:23.447076 | 2022-09-11T06:10:46 | 2022-09-11T06:10:46 | 12,487,054 | 12 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 15,875 |
pkg
|
compiler.pkg
|
#| -*-Scheme-*-
Copyright (c) 1988-1999 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|#
;;;; Compiler Packaging
(global-definitions "../runtime/runtime")
(define-package (compiler)
(files "base/switch"
"base/object" ;tagged object support
"base/enumer" ;enumerations
"base/sets" ;set abstraction
"base/fasthash" ;eq-hash tables
"base/mvalue" ;multiple-value support
"base/scode" ;SCode abstraction
"machines/i386/machin" ;machine dependent stuff
"back/asutl" ;back-end odds and ends
"base/utils" ;odds and ends
"base/stats" ;statistics abstraction
"base/cfg1" ;control flow graph
"base/cfg2"
"base/cfg3"
"rtlbase/rgraph" ;program graph abstraction
"rtlbase/rtlty1" ;RTL: type definitions
"rtlbase/rtlty2" ;RTL: type definitions
"rtlbase/rtlexp" ;RTL: expression operations
"rtlbase/rtlcon" ;RTL: complex constructors
"rtlbase/rtlreg" ;RTL: registers
"rtlbase/rtlcfg" ;RTL: CFG types
"rtlbase/rtlobj" ;RTL: CFG objects
"rtlbase/regset" ;RTL: register sets
"rtlbase/valclass" ;RTL: value classes
"back/insseq" ;LAP instruction sequences
;; New stuff
"base/parass" ;parallel assignment
;; End of new stuff
)
(parent ())
(export ()
compiler:analyze-side-effects?
compiler:assume-safe-fixnums?
compiler:cache-free-variables?
compiler:coalescing-constant-warnings?
compiler:code-compression?
compiler:compile-by-procedures?
compiler:cse?
compiler:default-top-level-declarations
compiler:enable-expansion-declarations?
compiler:enable-integration-declarations?
compiler:enable-statistics?
compiler:generate-kmp-files?
compiler:generate-lap-files?
compiler:generate-range-checks?
compiler:generate-rtl-files?
compiler:generate-stack-checks?
compiler:generate-type-checks?
compiler:generate-profiling-instructions?
compiler:guru?
compiler:implicit-self-static?
compiler:intersperse-rtl-in-lap?
compiler:noisy?
compiler:open-code-flonum-checks?
compiler:open-code-primitives?
compiler:optimize-environments?
compiler:package-optimization-level
compiler:preserve-data-structures?
compiler:show-phases?
compiler:show-procedures?
compiler:show-subphases?
compiler:show-time-reports?
compiler:use-multiclosures?
compiler:display-statistics
compiler:reset-statistics!))
(define-package (compiler macros)
(files "base/macros")
(parent ())
(export (compiler)
assembler-syntax-table
compiler-syntax-table
early-syntax-table
lap-generator-syntax-table)
(import (runtime macros)
parse-define-syntax)
(initialization (initialize-package!)))
(define-package (compiler declarations)
(files "machines/i386/decls")
(parent (compiler))
(export (compiler)
sc
syntax-files!)
(import (scode-optimizer top-level)
sf/internal)
(initialization (initialize-package!)))
(define-package (compiler top-level)
(files "base/toplev"
"base/crstop"
"base/asstop")
(parent (compiler))
(export ()
cbf
cf
compile-bin-file
compile-expression
compile-file
compile-file:force?
compile-file:override-usual-integrations
compile-file:sf-only?
compile-procedure
compile-scode
compiler:dump-bci-file
compiler:dump-bci/bcs-files
compiler:dump-bif/bsm-files
compiler:dump-inf-file
compiler:dump-info-file
compiler:reset!
cross-compile-bin-file
cross-compile-bin-file-end)
(export (compiler)
canonicalize-label-name
;; New stuff
*argument-registers*
;; End of new stuff
*procedure-result?*
)
(export (compiler midend)
*output-prefix*
compiler-phase
compiler-subphase
with-kmp-output-port
compile-recursively/new)
(export (compiler rtl-generator)
*ic-procedure-headers*
*rtl-continuations*
*rtl-expression*
*rtl-graphs*
*rtl-procedures*)
(export (compiler lap-syntaxer)
*block-label*
*external-labels*
label->object)
(export (compiler debug)
*root-expression*
*rtl-procedures*
*rtl-graphs*)
(import (runtime compiler-info)
make-compiled-module
compiled-module?
compiled-module/expression
make-dbg-locator
dbg-locator/file
dbg-locator/timestamp
make-dbg-wrapper
split-inf-structure!)
(import (runtime unparser)
*unparse-uninterned-symbols-by-name?*))
(define-package (compiler debug)
(files "base/debug")
(parent (compiler))
(export ()
debug/find-continuation
debug/find-entry-node
debug/find-procedure
debug/where
dump-rtl
po
show-bblock-rtl
show-rtl
write-rtl-instructions)
(import (runtime pretty-printer)
*pp-primitives-by-name*)
(import (runtime unparser)
*unparse-uninterned-symbols-by-name?*))
(define-package (compiler pattern-matcher/lookup)
(files "base/pmlook")
(parent (compiler))
(export (compiler)
make-pattern-variable
pattern-lookup
pattern-variable-name
pattern-variable?
pattern-variables))
(define-package (compiler pattern-matcher/parser)
(files "base/pmpars")
(parent (compiler))
(export (compiler)
parse-rule
compile-pattern
rule-result-expression)
(export (compiler macros)
parse-rule
compile-pattern
rule-result-expression))
(define-package (compiler pattern-matcher/early)
(files "base/pmerly")
(parent (compiler))
(export (compiler)
early-parse-rule
early-pattern-lookup
early-make-rule
make-database-transformer
make-symbol-transformer
make-bit-mask-transformer))
(define-package (compiler debugging-information)
(files "base/infnew")
(parent (compiler))
(export (compiler top-level)
info-generation-phase-1
info-generation-phase-2
info-generation-phase-3)
(export (compiler rtl-generator)
generated-dbg-continuation)
(import (runtime compiler-info)
make-dbg-info
make-dbg-expression
dbg-expression/block
dbg-expression/label
set-dbg-expression/block!
set-dbg-expression/label!
;;make-dbg-procedure
;;dbg-procedure/block
;;dbg-procedure/label
;;dbg-procedure/external-label
;;set-dbg-procedure/external-label!
;;dbg-procedure<?
make-dbg-continuation
dbg-continuation/block
dbg-continuation/label
set-dbg-continuation/block!
set-dbg-continuation/label!
dbg-continuation<?
;;make-dbg-block
;;dbg-block/parent
;;dbg-block/layout
;;dbg-block/stack-link
;;set-dbg-block/procedure!
;;make-dbg-variable
;;dbg-variable/value
;;set-dbg-variable/value!
make-dbg-label
dbg-label/offset
dbg-label/external?
set-dbg-label/external?!)
(import (compiler midend)
new-dbg-procedure/block
new-dbg-procedure/label
set-new-dbg-procedure/block!
set-new-dbg-procedure/label!
new-dbg-procedure<?
new-dbg-block?
new-dbg-block/parent
new-dbg-block/parent-path-prefix
new-dbg-block/procedure
new-dbg-block/type
new-dbg-block/variables
set-new-dbg-block/parent!
new-dbg-block/parent-path-prefix!
set-new-dbg-block/variables!
new-dbg-variable?
new-dbg-variable/name
new-dbg-variable/path
set-new-dbg-variable/path!))
(define-package (compiler constraints)
(files "base/constr")
(parent (compiler))
(export (compiler)
make-constraint
constraint/element
constraint/graph-head
constraint/afters
constraint/closed?
constraint-add!
add-constraint-element!
add-constraint-set!
make-constraint-graph
constraint-graph/entry-nodes
constraint-graph/closed?
close-constraint-graph!
close-constraint-node!
order-per-constraints
order-per-constraints/extracted
legal-ordering-per-constraints?
with-new-constraint-marks
constraint-marked?
constraint-mark!
transitively-close-dag!
reverse-postorder))
(define-package (compiler rtl-generator)
(files
"rtlbase/rtline" ;linearizer
)
(parent (compiler))
(export (compiler)
make-linearizer)
(export (compiler top-level)
linearize-rtl
setup-bblock-continuations!
)
(export (compiler debug)
linearize-rtl)
(import (compiler top-level)
label->object))
(define-package (compiler rtl-cse)
(files "rtlopt/rcse1" ;RTL common subexpression eliminator
"rtlopt/rcse2"
"rtlopt/rcsemrg" ;CSE control-flow merge
"rtlopt/rcseep" ;CSE expression predicates
"rtlopt/rcseht" ;CSE hash table
"rtlopt/rcserq" ;CSE register/quantity abstractions
"rtlopt/rcsesr" ;CSE stack references
)
(parent (compiler))
(export (compiler top-level) common-subexpression-elimination))
(define-package (compiler rtl-optimizer)
(files "rtlopt/rdebug")
(parent (compiler)))
(define-package (compiler rtl-optimizer invertible-expression-elimination)
(files "rtlopt/rinvex")
(parent (compiler rtl-optimizer))
(export (compiler top-level) invertible-expression-elimination))
(define-package (compiler rtl-optimizer common-suffix-merging)
(files "rtlopt/rtlcsm")
(parent (compiler rtl-optimizer))
(export (compiler top-level) merge-common-suffixes!))
(define-package (compiler rtl-optimizer rtl-dataflow-analysis)
(files "rtlopt/rdflow")
(parent (compiler rtl-optimizer))
(export (compiler top-level) rtl-dataflow-analysis))
(define-package (compiler rtl-optimizer rtl-rewriting)
(files "rtlopt/rerite")
(parent (compiler rtl-optimizer))
(export (compiler top-level)
rtl-rewriting:post-cse
rtl-rewriting:pre-cse)
(export (compiler lap-syntaxer)
add-pre-cse-rewriting-rule!
add-rewriting-rule!))
(define-package (compiler rtl-optimizer lifetime-analysis)
(files "rtlopt/rlife")
(parent (compiler rtl-optimizer))
(export (compiler top-level) lifetime-analysis)
(export (compiler rtl-optimizer code-compression) mark-set-registers!))
(define-package (compiler rtl-optimizer code-compression)
(files "rtlopt/rcompr")
(parent (compiler rtl-optimizer))
(export (compiler top-level) code-compression))
(define-package (compiler rtl-optimizer register-allocation)
(files "rtlopt/ralloc")
(parent (compiler rtl-optimizer))
(export (compiler top-level) register-allocation))
(define-package (compiler lap-syntaxer)
(files "back/lapgn1" ;LAP generator
"back/lapgn2" ; " "
"back/lapgn3" ; " "
"back/regmap" ;Hardware register allocator
"machines/i386/lapgen" ;code generation rules
"machines/i386/rules1" ; " " "
"machines/i386/rules2" ; " " "
"machines/i386/rules3" ; " " "
"machines/i386/rules4" ; " " "
"machines/i386/rulfix" ; " " "
"machines/i386/rulflo" ; " " "
"machines/i386/rulrew" ;code rewriting rules
"back/syntax" ;Generic syntax phase
"back/syerly" ;Early binding version
"machines/i386/coerce" ;Coercions: integer -> bit string
"back/asmmac" ;Macros for hairy syntax
"machines/i386/insmac" ;Macros for hairy syntax
"machines/i386/inerly" ;Early binding version
"machines/i386/instr1" ;I386 instruction utilities
"machines/i386/instr2" ;I386 instructions
"machines/i386/instrf" ; " "
"machines/i386/insutl" ; " "
)
(parent (compiler))
(export (compiler)
available-machine-registers
pseudo-register-offset
interpreter-memtop-pointer
fits-in-5-bits-signed?
lap-generator/match-rtl-instruction
lap:make-entry-point
lap:make-label-statement
lap:make-unconditional-branch
lap:syntax-instruction)
(export (compiler top-level)
*block-associations*
*block-profiles*
*interned-assignments*
*interned-constants*
*interned-global-links*
*interned-uuo-links*
*interned-static-variables*
*interned-variables*
*next-constant*
generate-lap)
(export (compiler assembler)
profile-info/insert-info!)
(import (scode-optimizer expansion)
scode->scode-expander))
(define-package (compiler lap-syntaxer map-merger)
(files "back/mermap")
(parent (compiler lap-syntaxer))
(export (compiler lap-syntaxer)
merge-register-maps))
(define-package (compiler lap-syntaxer linearizer)
(files "back/linear")
(parent (compiler lap-syntaxer))
(export (compiler lap-syntaxer)
add-end-of-block-code!
add-extra-code!
bblock-linearize-lap
extra-code-block/xtra
declare-extra-code-block!
find-extra-code-block
linearize-lap
set-current-branches!
set-extra-code-block/xtra!)
;; New stuff
(export (compiler)
*strongly-heed-branch-preferences?*)
;; End of new stuff
(export (compiler top-level)
*end-of-block-code*
linearize-lap))
(define-package (compiler lap-optimizer)
(files "machines/i386/lapopt")
(parent (compiler))
(import (compiler lap-syntaxer)
entry->address
invert-condition
hook:compiler-profile-count)
(export (compiler lap-syntaxer)
lap:mark-preferred-branch!)
(export (compiler top-level)
optimize-linear-lap))
(define-package (compiler assembler)
(files "machines/i386/assmd" ;Machine dependent
"back/symtab" ;Symbol tables
"back/bitutl" ;Assembly blocks
"back/bittop" ;Assembler top level
)
(parent (compiler))
(export (compiler)
instruction-append)
(export (compiler top-level)
assemble))
(define-package (compiler disassembler)
(files "machines/i386/dassm1"
"machines/i386/dassm2"
"machines/i386/dassm3")
(parent (compiler))
(export ()
compiler:write-lap-file
compiler:disassemble
compiler:disassemble-memory)
(import (compiler lap-syntaxer)
code:-alist
hook:-alist)
(import (runtime compiler-info)
compiled-code-block/labels
compiled-entry/filename-and-index
compiled-module?
compiled-module/all-compiled-code-blocks
dbg-label/external?
dbg-label/name
dbg-labels/find-offset))
;;; New stuff
(define-package (compiler midend)
(files "midend/graph"
"midend/synutl"
"midend/kmp"
"midend/midend"
"midend/utils"
"midend/effects"
"midend/fakeprim"
"midend/types"
"midend/typedb" ; must go before typerew
"midend/dbgstr"
"midend/dbgred"
"midend/inlate"
"midend/envconv"
"midend/alpha"
"midend/expand"
"midend/assconv"
"midend/cleanup"
"midend/earlyrew"
"midend/typerew"
"midend/lamlift"
"midend/closconv"
;; "midend/staticfy" ; broken, for now
"midend/applicat"
"midend/simplify"
"midend/cpsconv"
"midend/laterew"
"midend/compat"
"midend/stackopt"
"midend/indexify"
"midend/rtlgen"
"midend/copier"
"midend/coerce"
"midend/dataflow"
"midend/split"
"midend/widen")
(parent (compiler))
(import (runtime compiler-info)
make-dbg-expression
;;make-dbg-procedure
make-dbg-continuation
make-dbg-block
;;set-dbg-block/procedure!
;;make-dbg-variable
;;dbg-variable/value
;;set-dbg-variable/value!
)
(export (compiler top-level)
kmp/pp kmp/ppp
*envconv/compile-by-procedures?*
*envconv/procedure-result?*
kmp->rtl
optimize-kmp
rtlgen/top-level
rtlgen/argument-registers
rtlgen/available-registers
scode->kmp
within-midend)
(export (compiler)
internal-error
internal-warning)
(export ()
compiler:debug)
(import (runtime compiler-info)
dbg-label/offset))
(define-package (compiler rtl-parser)
(files "rtlbase/rtlpars")
(parent (compiler))
(export (compiler)
rtl->rtl-graph))
;; End of New stuff
| true |
615c4026b2c73c07866ccfee8714095ed5059eb6
|
9b2eb10c34176f47f7f490a4ce8412b7dd42cce7
|
/lib-compat/racket-r7b/i6.sls
|
cc91b1585bfb159b9086b24c1f353884dffcb123
|
[
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] |
permissive
|
okuoku/yuni
|
8be584a574c0597375f023c70b17a5a689fd6918
|
1859077a3c855f3a3912a71a5283e08488e76661
|
refs/heads/master
| 2023-07-21T11:30:14.824239 | 2023-06-11T13:16:01 | 2023-07-18T16:25:22 | 17,772,480 | 36 | 6 |
CC0-1.0
| 2020-03-29T08:16:00 | 2014-03-15T09:53:13 |
Scheme
|
UTF-8
|
Scheme
| false | false | 818 |
sls
|
i6.sls
|
(library (racket-r7b i6)
(export
open-output-string
open-input-string
open-output-string
get-output-string)
(import (rnrs)
(rename (only (racket base)
open-output-string
open-input-string
get-output-string)
(open-output-string base:open-output-string)
(open-input-string base:open-input-string)))
;; Racket requires every R6RS port transcoded..
(define (open-output-string)
(define p (base:open-output-string))
(transcoded-port p (native-transcoder)))
(define (open-input-string str)
(define p (base:open-input-string str))
(transcoded-port p (native-transcoder)))
)
| false |
948639741026fdc71ef04701afc0ddb28609875e
|
6675ce914fe8f81480bad42f677362f43647f78f
|
/nanopass/a15.ss
|
8d5a794e843e7eb59f2657f89578f319f87d8071
|
[] |
no_license
|
tiancaiamao/yasfs
|
9ef06398e859fe47c585b17c4535110279ebe0c0
|
7e8fdb953d1b9bb9bf6ac809464a30ce9226ec18
|
refs/heads/master
| 2023-05-13T19:33:00.382963 | 2023-04-27T08:41:29 | 2023-04-27T08:41:29 | 5,788,134 | 14 | 5 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 157,119 |
ss
|
a15.ss
|
;;; Shiv Indap
;;; sindap
;;; Assignment 15
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; Parse-Scheme basically checks if the program is compatible with the subset of scheme the compiler is supposed to work on
;;; The Subset of Scheme for The Final Compiler
;;; Program ----> Expr
;;; Expr ----> constant
;;; | var
;;; | (quote datum)
;;; | (if Expr Expr)
;;; | (if Expr Expr Expr)
;;; | (and Expr*)
;;; | (or Expr*)
;;; | (begin Expr* Expr)
;;; | (lambda (uvar*) Expr+)
;;; | (let ([var Expr]*) Expr+)
;;; | (letrec ([var Expr]*) Expr+)
;;; | (set! uvar Expr)
;;; | (prim Expr*)
;;; | (Expr Expr*)
;;; where:
;;;
;;;constant is #t, #f, (), or a fixnum;
;;;fixnum is an exact integer;
;;;datum is a constant, pair of datums, or vector of datums; and
;;;var is an arbitrary symbol.
(define-who parse-scheme
;;;checks if x is #t #f () or fixnum
(define (datum? x)
(or (constant? x)
(if (pair? x)
(and (datum? (car x)) (datum? (cdr x)))
(and (vector? x) (andmap datum? (vector->list x))))))
;;; checks if x is a constant
(define (constant? x)
(or (memq x '(() #t #f))
(and (integer? x) (exact? x) (fixnum-range? x))))
;;; primitives and te number of arguments they are supposed to take
(define primitives
'((+ . 2) (- . 2) (* . 2) (<= . 2) (< . 2) (= . 2)
(>= . 2) (> . 2) (boolean? . 1) (car . 1) (cdr . 1)
(cons . 2) (eq? . 2) (fixnum? . 1) (make-vector . 1)
(null? . 1) (pair? . 1) (procedure? . 1) (set-car! . 2)
(set-cdr! . 2) (vector? . 1) (vector-length . 1)
(vector-ref . 2) (vector-set! . 3) (void . 0)))
;;; since each occurence of a symbol will be replaced by a uvar identified in our language by symbol.suffix eg x -> x.1
;;; generate returns a tuple of the symbol and the corresponding uvar
(define generate
(lambda (uvar)
`(,uvar . ,(unique-name uvar))))
;;; if x is a datum process it else return error in Datum expression, will be called only when we encounter an expression of the form
;;; (quote ,datum)
(define Datum
(lambda (x)
(match x
[,x (guard (datum? x)) x]
[,x (error who "error in Datum Expression ~s" x)])))
;;; The adjust function implements the shadowing of variables, if we have (letrec x (lambda (x) (+ 5 x)))
;;; the x in lambda expression will be shadowed by the parameter in the lambda expression and hence the x in letrec epression will no longer be valid here
(define adjust
(lambda (new-list old-list)
(cond
[(null? new-list) old-list]
[else (let* ([x (caar new-list)] [res (assq x old-list)])
(if res (adjust (cdr new-list) (cons (car new-list) (remq res old-list))) (adjust (cdr new-list) (cons (car new-list) old-list))))])))
;;; checks if the list of parameters passed to a lambda or the set of bindings for a let and letrec are unique
(define check-unique
(lambda (uvar* result* expr)
(cond
[(null? uvar*) #t]
[(memq (car uvar*) result*) (error who "duplicate variables in expression ~s " expr)]
[else (check-unique (cdr uvar*) (cons (car uvar*) result*) expr)])))
;;; env is a mapping between symbols and the corresponding uvars applicable to the expression we are now processing
(define Expr
(lambda (env)
(lambda (expr)
(match expr
[(begin ,[(Expr env) -> expr*] ... ,[(Expr env) -> expr]) (guard (not (assq 'begin env))) `(begin ,expr* ... ,expr)]
[(if ,[(Expr env) -> test] ,[(Expr env) -> conseq]) (guard (not (assq 'if env))) `(if ,test ,conseq (void))] ;;; one-armed if's
[(if ,[(Expr env) -> test] ,[(Expr env) -> conseq] ,[(Expr env) -> alt]) (guard (not (assq 'if env))) `(if ,test ,conseq ,alt)]
[(letrec ([,uvar* ,expr*] ...) ,tail* ...)
(guard (not (assq 'letrec env)))
(if (null? tail*)
(error who "Tail Expression in ~s must have atleast one value" expr)
(let* ([unique-name (check-unique uvar* '() expr)] ;;; check if all bindings unique
[local-letrec (map generate uvar*)] ;;;create a new-list of symbol to uvar mappings
[new-env (adjust local-letrec env)] ;;; add new-list to the existing env implemening shadowing
[new-exp* (map (Expr new-env) expr*)] ;;;process the exprs passing the new enviornment
[new-tail (map (Expr new-env) tail*)])
`(letrec ([,(map cdr local-letrec) ,new-exp*] ...)
,(make-begin new-tail))))]
[(let ([,uvar* ,expr*] ...) ,tail* ...)
(guard (not (assq 'let env)))
(if (null? tail*)
(error who "Tail Expression in ~s must have atleast one value" expr)
(let* ([unique-name (check-unique uvar* '() expr)]
[local-letrec (map generate uvar*)]
[new-env (append local-letrec env)]
[new-exp* (map (Expr env) expr*)]
[new-tail (map (Expr new-env) tail*)])
`(let ([,(map cdr local-letrec) ,new-exp*] ...)
,(make-begin new-tail))))]
[(lambda (,uvar* ...) ,tail* ...)
(guard (not (assq 'lambda env)))
(if (null? tail*)
(error who "Tail Expression in ~s must have atleast one value" expr)
(let* ([unique (check-unique uvar* '() expr)]
[local-bindings* (map generate uvar*)]
[new-env (adjust local-bindings* env)]
[new-tail (map (Expr new-env) tail*)]) ;;; Everytime I encounter a lambda-expression, I create a new enviornment
`(lambda (,(map cdr local-bindings*) ...) ,(make-begin new-tail))))]
[(and ,x* ...)
(guard (not (assq 'and env)))
(cond
[(null? x*) (quote #t)]
[(= (length x*) 1) ((Expr env) (car x*))]
[else `(if ,((Expr env) (car x*)) ,((Expr env) `(and ,(cdr x*) ...)) (quote #f))])]
[(or ,x* ...)
(guard (not (assq 'or env)))
(cond
[(null? x*) (quote #f)]
[(= (length x*) 1) ((Expr env) (car x*))]
[else
(let ([temp (unique-name 't)])
`(let ([,temp ,((Expr env) (car x*))])
(if ,temp ,temp ,((Expr env) `(or ,(cdr x*) ...)))))])]
[(not ,[(Expr env) -> x]) (guard (not (assq 'not env)))
`(if ,x (quote #f) (quote #t))]
[(set! ,x ,y)
(guard (not (assq 'set! env)))
(cond
[(and (symbol? x) (assq x env)) `(set! ,(cdr (assq x env)) ,((Expr env) y))]
[else (error who "Either ~s is not a symbol or ~s is not bound" x x)])]
[(quote ,[Datum -> x]) (guard (not (assq 'quote env))) `(quote ,x)]
[(,prim ,[(Expr env) -> x*] ...) (guard (and (assq prim primitives) (not (assq prim env))))
(if (= (length x*) (cdr (assq prim primitives)))
`(,prim ,x* ...)
(error who "Invalid arguments to primitive ~s " prim))]
[,x (guard (symbol? x))
(cond
[(assq x env) (cdr (assq x env))]
[else (error who "unbound variable ~s " x)])] ;;maybe we will need to replace the uvar by a new expression e.g y will be replaced by y.1
[,x (guard (constant? x)) `(quote ,x)]
[(,[(Expr env) -> x] ,[(Expr env) -> x*] ...) `(,x ,x* ...)]
[,x (error who "Invalid Expression ~s" x)]))))
(lambda (x)
((Expr '()) x)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who convert-complex-datum
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void))
(define Expr
(lambda (expr)
(match expr
[,x (guard (uvar? x)) (values x '())]
[(quote ,[Datum -> datum c-exp]) (values datum c-exp)]
[(if ,[Expr -> test c-test] ,[Expr -> conseq c-conseq] ,[Expr -> alt c-alt])
(values `(if ,test ,conseq ,alt) `(,c-test ... ,c-conseq ... ,c-alt ...))]
[(begin ,[Expr -> exp* c-exp*] ... ,[Expr -> expr c-exp]) (values `(begin ,exp* ... ,expr) `(,c-exp* ... ...,c-exp ...))]
[(lambda (,uvar* ...) ,[Expr -> body c-body]) (values `(lambda (,uvar* ...) ,body) `(,c-body ...))]
[(let ([,uvar* ,[Expr -> exp* c-exp*]] ...) ,[Expr -> tail c-tail])
(values `(let ([,uvar* ,exp*] ...) ,tail) `(,c-exp* ... ... ,c-tail ...))]
[(letrec ([,uvar* ,[Expr -> exp* c-exp*]] ...) ,[Expr -> tail c-tail])
(values `(letrec ([,uvar* ,exp*] ...) ,tail) `(,c-exp* ... ... ,c-tail ...))]
[(set! ,x ,[Expr -> expr c-exp]) (values `(set! ,x ,expr) c-exp)]
[(,prim ,[Expr -> expr* c-exp*] ...) (guard (memq prim primitives)) (values `(,prim ,expr* ...) `(,c-exp* ... ...))]
[(,[Expr -> expr c-exp] ,[Expr -> expr* c-exp*] ...) (values `(,expr ,expr* ...) `(,c-exp ...,c-exp* ... ...))])))
(define Datum
(lambda (imm)
(match imm
[,x (guard (memq imm '(#t #f ()))) (values `(quote ,imm) '(()))]
[,x (guard (and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm)))
(values `(quote ,imm) '(()))]
;; Return a new-uvar and add the expression to the top-level-let
[,x (let ([new-var (unique-name 'u)])
(values new-var `((,new-var (quote ,x)))))])))
;;; converts a list to its equivalent cons forms
(define make-list
(lambda (x)
(cond
[(null? x) (quote '())]
[(and (not (pair? x)) (not (vector? x))) `(quote ,x)]
[(vector? (car x))
(let ([vect (handle-vector (car x))])
`(cons ,vect ,(make-list (cdr x))))]
[(pair? (car x)) `(cons ,(make-list (car x)) ,(make-list (cdr x)))]
[else `(cons (quote ,(car x)) ,(make-list (cdr x)))])))
;;; driver for make-vector, just sets the initial parameters such as length, new temporary etc
(define handle-vector
(lambda (x)
(let* ([tmp (unique-name 't)] [len (vector-length x)] [ls (vector->list x)] [result (vector-make ls 0 tmp)])
`(let [(,tmp (make-vector (quote ,len)))]
,(make-begin `(,@result ,tmp))))))
;;; converts the vector form into make-vector, vector-set! etc
(define vector-make
(lambda (ls num tmp)
(cond
[(null? ls) '()]
[(pair? (car ls))
(let ([lst (make-list (car ls))])
(cons `(vector-set! ,tmp (quote ,num) ,lst) (vector-make (cdr ls) (add1 num) tmp)))]
[(vector? (car ls))
(let* ([vect (handle-vector (car ls))])
(cons `(vector-set! ,tmp (quote ,num) ,vect) (vector-make (cdr ls) (add1 num) tmp)))]
[else (cons `(vector-set! ,tmp (quote ,num) (quote ,(car ls))) (vector-make (cdr ls) (add1 num) tmp))])))
;;; checks if its a pair or vector and calls the helpers accordingly.
(define make-expression
(lambda (binding)
(match binding
[(quote ,x) (guard (pair? x)) (make-list x)]
[(quote ,y) (guard (vector? y)) (handle-vector y)])))
(lambda (x)
(match x
[,x (let-values ([(expr bindings) (Expr x)])
(if (null? (remq '() bindings)) expr
(let* ([final-bindings (remq '() bindings)]
[uvars* (map car final-bindings)]
[exp* (map make-expression (map cadr final-bindings))])
`(let ([,uvars* ,exp*] ...) ,expr))))])))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who uncover-assigned
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void ))
(define Expr
(lambda (expr)
(match expr
[,uvar (guard (uvar? uvar)) (values uvar '())]
[(if ,[Expr -> cond-expr cond-bindings] ,[Expr -> conseq-expr conseq-bindings] ,[Expr -> alt-expr alt-bindings])
(values `(if ,cond-expr ,conseq-expr ,alt-expr) (union cond-bindings conseq-bindings alt-bindings))]
[(quote ,datum) (values `(quote ,datum) '())]
[(begin ,[Expr -> exp-stmt* exp-binding*] ... ,[Expr -> tail-stmt tail-binding])
(values `(begin ,exp-stmt* ... ,tail-stmt) (union (apply append exp-binding*) tail-binding))]
[(lambda (,uvar* ...) ,[Expr -> tail sets])
(let ([assigned-uvars (intersection sets `(,uvar* ...))])
(values `(lambda (,uvar* ...) (assigned (,assigned-uvars ...) ,tail)) sets))]
[(letrec ([,uvar* ,[Expr -> exp* binding*]] ...) ,[Expr -> tail binding])
(let ([assigned-uvars (intersection uvar* (union binding (apply append binding*)))])
(values `(letrec ([,uvar* ,exp*] ...)
(assigned (,assigned-uvars ...)
,tail))
(difference (union binding (apply append binding*)) uvar*)))]
[(let ([,uvar* ,[Expr -> exp* binding*]] ...) ,[Expr -> tail binding])
(let ([assigned-uvars (intersection uvar* (union binding (apply append binding*)))])
(values `(let ([,uvar* ,exp*] ...)
(assigned (,assigned-uvars ...)
,tail))
(difference (union binding (apply append binding*)) uvar*)))]
[(set! ,x ,[Expr -> rhs rhs-assigned]) (values `(set! ,x ,rhs) (union `(,x) rhs-assigned))]
[(,prim ,[Expr -> expr* bindings*] ...) (guard (memq prim primitives))
(values `(,prim ,expr* ...) (apply append bindings* ))]
[(,[Expr -> expr binding] ,[Expr -> rem* bindings*] ...)
(values `(,expr ,rem* ...) (union (apply append bindings*) binding))])))
(lambda (x)
(let-values ([(final-expr final-bindings) (Expr x)])
final-expr)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who purify-letrec
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void ))
(define lambda-expr?
(lambda (expr)
(match expr
[(lambda (,uvar* ...) ,x) #t]
[,x #f])))
(define simple-expr?
(lambda (expr uvar*)
(match expr
[,uvar (guard (uvar? uvar)) (if (memq uvar uvar*) #f #t)]
[(if ,[test] ,[conseq] ,[alt]) (and test conseq alt)]
[(quote ,datum) #t]
[(begin ,[expr*] ... ,[tail]) (and expr* tail)]
[(set! ,x ,[rhs]) (if (memq x uvar*) #f rhs)]
[(,prim ,[expr*] ...) (guard (memq prim primitives)) (and expr*)]
[(,[expr] ,[rem*] ...) (and expr rem*)]
[,x #f])))
(define Expr
(lambda (expr)
(match expr
[,uvar (guard (uvar? uvar)) uvar]
[(if ,[Expr -> test] ,[Expr -> conseq] ,[Expr -> alt]) `(if ,test ,conseq ,alt)]
[(quote ,datum) `(quote ,datum)]
[(begin ,[Expr -> expr*] ... ,[Expr -> tail]) `(begin ,expr* ... ,tail)]
[(lambda (,uvar* ...)
(assigned (,assign* ...)
,[Expr -> tail])) `(lambda (,uvar* ...)
(assigned (,assign* ...) ,tail))]
[(letrec ([,uvar* ,[Expr -> exp*]] ...)
(assigned (,assign* ...)
,[Expr -> tail]))
(let ([all-pure (seperate-lambdas assign* uvar* exp*)])
(if (eq? all-pure #t)
`(letrec ([,uvar* ,exp*] ...)
,(if (null? assign*) `(,tail ...) `(assigned (,assign* ...) ,tail))) ;;;If the list of assigned is null then we dont add it to the output
;;; Hence I will be dealing with 2 different letrec forms in the output
(let* ([new* (map generate-uvar uvar*)]
[new-set! (map generate-set! new* uvar*)])
`(let ([,uvar* (void)] ...)
(assigned (,uvar* ...)
(begin
(let ([,new* ,exp*] ...)
(assigned ()
,(make-begin new-set!)))
,tail))))))]
[(let ([,uvar* ,[Expr -> exp*]] ...)
(assigned (,assign* ...)
,[Expr -> tail]))
`(let ([,uvar* ,exp*] ...)
(assigned (,assign* ...)
,tail))]
[(set! ,x ,[Expr -> rhs]) `(set! ,x ,rhs) ]
[(,prim ,[Expr -> expr*] ...) (guard (memq prim primitives)) `(,prim ,expr* ...)]
[(,[Expr -> expr] ,[Expr -> rem*] ...) `(,expr ,rem* ...) ])))
(define seperate-lambdas ;;; traverses over the exps bound by letrec to see if they all are pure, if they are then true else false
(lambda (assign* uvar* exp*)
(cond
[(and (null? assign*) (null? uvar*)) #t]
;;;Lambda Expression
[(and (null? assign*) (lambda-expr? (car exp*))) (seperate-lambdas assign* (cdr uvar*) (cdr exp*))]
[else #f])))
(define generate-set! ;;; generates the set! in the inner-let expression
(lambda (x y)
`(set! ,y ,x)))
(define generate-uvar ;;x.5 will be converted into a new unique also beginning with x
(lambda (uvar)
(unique-name (string->symbol (extract-root uvar)))))
(lambda (x)
(Expr x)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who convert-assignments
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void ))
(define Expr
(lambda (assigned*)
(lambda (expr)
(match expr
;;; check if uvar has been assigned, if so replace it by its car else return as is
[,uvar (guard (uvar? uvar))
(if (memq uvar assigned*)
`(car ,uvar)
uvar)]
[(if ,[(Expr assigned*) -> test] ,[(Expr assigned*) -> conseq] ,[(Expr assigned*) -> alt]) `(if ,test ,conseq ,alt)]
[(quote ,datum) `(quote ,datum)]
[(begin ,[(Expr assigned*) -> expr*] ... ,[(Expr assigned*) -> tail]) `(begin ,expr* ... ,tail)]
[(lambda (,uvar* ...)
(assigned (,assign* ...)
,[(Expr (union assigned* assign*))-> tail]))
;;Check if any of the parameters has been set!, if so we have to replace it by the new let form else return the lambda expression as is
(let ([intersect (intersection uvar* assign*)])
(if (null? intersect)
`(lambda (,uvar* ...)
,tail)
(let* ([new-bindings (map generate-uvar intersect)]
[new* (map cdr new-bindings)]
[new-lets (make-lets new-bindings intersect)])
`(lambda (,new* ...)
(let ,new-lets
,tail)))))]
[(letrec ([,uvar* ,[(Expr assigned*)-> exp*]] ...)
,[(Expr assigned*) -> tail])
`(letrec ([,uvar* ,exp*] ...)
,tail)]
;;; Letrec form is returned as is
;;; 2 forms were used to account for those expressions that dont have an assigned form encapsulated around the tail
[(letrec ([,uvar* ,[(Expr assigned*)-> exp*]] ...)
(assigned (,assign* ...)
,[(Expr (union assigned* assign*)) -> tail]))
`(letrec ([,uvar* ,exp*] ...)
,tail)]
[(let ([,uvar* ,[(Expr assigned*) -> exp*]] ...)
(assigned (,assign* ...)
,[(Expr (union assign* assigned*))-> tail]))
(if (null? assign*)
`(let ([,uvar* ,exp*] ...) ,tail)
(let* ([new-bindings (map generate-uvar assign*)]
[new* (map cdr new-bindings)]
[outer-let* (make-outer-lets uvar* assign* new-bindings `((,uvar* ,exp*) ...))]
[new-lets (make-lets new-bindings assign*)])
`(let ,outer-let*
(let ,new-lets
,tail))))]
[(set! ,x ,[(Expr assigned*) -> rhs]) `(set-car! ,x ,rhs)]
[(,prim ,[(Expr assigned*) -> expr*] ...) (guard (memq prim primitives)) `(,prim ,expr* ...)]
[(,[(Expr assigned*) -> expr] ,[(Expr assigned*) -> rem*] ...) `(,expr ,rem* ...) ]))))
;;; make-outer-let basically assigns the new-uvars to the previous uvars expressions, and in case they have not been set!-ed returns
;;; the expressions as is
(define make-outer-lets
(lambda (uvar* assign* new* exp*)
(cond
[(null? uvar*) '()]
[else
(let* ([current-var (car uvar*)])
(cond
[(memq current-var assign*)
(let ([new-assign (cdr (assq current-var new*))] [old-assign (cadr (assq current-var exp*))])
(cons `(,new-assign ,old-assign) (make-outer-lets (cdr uvar*) assign* new* exp*)))]
[else (cons (assq current-var exp*) (make-outer-lets (cdr uvar*) assign* new* exp*))]))])))
;;; inner-lets where we have (new-uvar (cons old-uvar (void)))
(define make-lets
(lambda (new* assign*)
(cond
[(null? assign*) '()]
[else
(let* ([current (car assign*)] [value (cdr (assq current new*))])
(cons `(,current (cons ,value (void))) (make-lets new* (cdr assign*))))])))
(define generate-uvar
(lambda (uvar)
(let ([unique (unique-name (string->symbol (extract-root uvar)))])
`(,uvar . ,unique))))
(lambda (x)
((Expr '()) x)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; Program --> <Expr>
;;; Expr --> <uvar>
;;; | (quote <Immediate>)
;;; | (if <Expr> <Expr> <Expr>)
;;; | (begin <Expr>* <Expr>)
;;; | <Lambda>
;;; | (let ([<uvar> <Expr>]*) <Expr>)
;;; | (letrec ([<uvar> <Lambda>]*) <Expr>)
;;; | (<primitive> <Expr>*)
;;; | (<Expr> <Expr>*)
;;; Lambda --> (lambda (<uvar>*) <Expr>)
;;; Immediate -> <fixnum> | () | #t | #f
;;; I am examining the application pattern of the function i.e if rator is a lambda expression and the parameters
;;; passed to it and the parameters it takes are the same, if so we convert the lambda to a let erxpression else
;;; we let it remain a lambda expression
(define-who optimize-direct-call
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void))
(define lambda-expr?
(lambda (expr)
(match expr
[(lambda (,uvar* ...) ,x) #t]
[,x #f])))
(define (Immediate imm)
(cond
[(memq imm '(#t #f ())) imm]
[(and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm))
imm]
[else (error who "invalid Immediate ~s" imm)]))
(define Expr
(lambda (expr)
(match expr
[(if ,[Expr -> test] ,[Expr -> conseq] ,[Expr -> alt]) `(if ,test ,conseq ,alt)]
[(quote ,[Immediate -> im]) `(quote ,im)]
[(let ([,uvar* ,[Expr -> exp*]] ...) ,[Expr -> tail]) `(let ([,uvar* ,exp*] ...) ,tail)]
[(begin ,[Expr -> exp*] ... ,[Expr -> exp]) `(begin ,exp* ... ,exp)]
[(letrec ([,uvar* (lambda (,param* ...) ,[Expr -> tail*])] ...) ,[Expr -> tail]) `(letrec ([,uvar* (lambda (,param* ...) ,tail*)] ...) ,tail)]
[(lambda (,uvar* ...) ,x) (Lambda expr)]
[(,prim ,[Expr -> x*] ...) (guard (memq prim primitives)) `(,prim ,x* ...)]
[(,x ,[Expr -> y*] ...) (guard (lambda-expr? x)) (convert-lambda x y*)]
[(,[Expr -> x] ,[Expr -> y*] ...) `(,x ,y* ...)]
[,x (guard (uvar? x)) x])))
(define convert-lambda
(lambda (oper exp*)
(match oper
[(lambda (,uvar* ...) ,[Expr -> x])
(if (= (length uvar*) (length exp*)) `(let ([,uvar* ,exp*] ...) ,x) `(lambda (,uvar* ...) ,x))])))
(define Lambda
(lambda (expr)
(match expr
[(lambda (,uvar* ...) ,[Expr -> x]) `(lambda (,uvar* ...) ,x)])))
(lambda (x)
(Expr x)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who remove-anonymous-lambda
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void))
(define lambda-expr?
(lambda (expr)
(match expr
[(lambda (,uvar* ...) ,x) #t]
[,x #f])))
(define (Immediate imm)
(cond
[(memq imm '(#t #f ())) imm]
[(and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm))
imm]
[else (error who "invalid Immediate ~s" imm)]))
(define Expr
(lambda (flag)
(lambda (expr)
(match expr
[(if ,[(Expr 1)-> test] ,[(Expr 1) -> conseq] ,[(Expr 1) -> alt]) `(if ,test ,conseq ,alt)]
[(quote ,[Immediate -> im]) `(quote ,im)]
[(let ([,uvar* ,[(Expr 0) -> exp*]] ...) ,[(Expr 1) -> tail]) `(let ([,uvar* ,exp*] ...) ,tail)]
[(begin ,[(Expr 1) -> exp*] ... ,[(Expr flag) -> exp]) `(begin ,exp* ... ,exp)]
[(letrec ([,uvar* (lambda (,param* ...) ,[(Expr 1) -> tail*])] ...) ,[(Expr flag) -> tail]) `(letrec ([,uvar* (lambda (,param* ...) ,tail*)] ...) ,tail)]
[(lambda (,uvar* ...) ,x) (Lambda expr flag)]
[(,prim ,[(Expr 1) -> x*] ...) (guard (memq prim primitives)) `(,prim ,x* ...)]
[(,[(Expr 1) -> x] ,[(Expr 1) -> y*] ...) `(,x ,y* ...)]
[,x (guard (uvar? x)) x]))))
(define Lambda
(lambda (exp flag)
(match exp
[(lambda (,uvar* ...) ,[(Expr 1) -> x])
(if (eq? flag 0)
`(lambda (,uvar* ...) ,x)
(let ([anon-var (unique-name 'anon)])
`(letrec ([,anon-var (lambda (,uvar* ...) ,x)]) ,anon-var)))])))
(lambda (x)
((Expr 0) x)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who sanitize-binding-forms
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void))
;;; determines if the expresion is a lambda expression
(define lambda-expr?
(lambda (expr)
(match expr
[(lambda (,uvar* ...) ,x) #t]
[,x #f])))
(define (Immediate imm)
(cond
[(memq imm '(#t #f ())) imm]
[(and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm))
imm]
[else (error who "invalid Immediate ~s" imm)]))
(define map2
(lambda (fn x* y*)
(cond
[(null? x*) '()]
[else (cons (fn (car x*) (car y*)) (map2 fn (cdr x*) (cdr y*)))])))
(define Expr
(lambda (expr)
(match expr
[(if ,[Expr -> test] ,[Expr -> conseq] ,[Expr -> alt]) `(if ,test ,conseq ,alt)]
[(quote ,[Immediate -> im]) `(quote ,im)]
;;; The function list returns all labels and their corresponding functions in a let expression
;;; The variables list returns all labels and non-function expressions in a let definition
[(let ([,uvar* ,[Expr -> exp*]] ...) ,[Expr -> tail])
(let* ([functions-list (map2 (lambda (uvar exp)
(if (lambda-expr? exp) `(,uvar ,exp) '())) uvar* exp*)]
[variables-list (map2 (lambda (uvar exp)
(if (lambda-expr? exp) '() `(,uvar ,exp))) uvar* exp*)]
[functions (remq '() functions-list)]
[variables (remq '() variables-list)])
(cond
[(and (null? variables) (null? functions)) tail] ;;;if there are no bindings return tail
[(null? functions) `(let ,variables ,tail)] ;;;if there are no function-bindings return only let expression
[(null? variables) `(letrec ,functions ,tail)] ;;;if there are no non-function-bindings return only letrec expression
[else `(letrec ,functions (let ,variables ,tail))]))] ;;;return a combination of both
[(begin ,[Expr -> exp*] ... ,[Expr -> exp]) `(begin ,exp* ... ,exp)]
[(letrec ([,uvar* (lambda (,param* ...) ,[Expr -> tail*])] ...) ,[Expr -> tail]) `(letrec ([,uvar* (lambda (,param* ...) ,tail*)] ...) ,tail)]
[(lambda (,uvar* ...) ,x) (Lambda expr)]
[(,prim ,[Expr -> x*] ...) (guard (memq prim primitives)) `(,prim ,x* ...)]
[(,x ,[Expr -> y*] ...) (guard (lambda-expr? x)) (convert-lambda x y*)]
[(,[Expr -> x] ,[Expr -> y*] ...) `(,x ,y* ...)]
[,x (guard (uvar? x)) x])))
(define convert-lambda
(lambda (oper exp*)
(match oper
[(lambda (,uvar* ...) ,[Expr -> x])
`(let ([,uvar* ,exp*] ...) ,x)])))
(define Lambda
(lambda (expr)
(match expr
[(lambda (,uvar* ...) ,[Expr -> x]) `(lambda (,uvar* ...) ,x)])))
(lambda (x)
(Expr x)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who uncover-free
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void ))
(define Expr
(lambda (expr)
(match expr
[,uvar (guard (uvar? uvar)) (values uvar `(,uvar))]
[(if ,[Expr -> cond-expr cond-bindings] ,[Expr -> conseq-expr conseq-bindings] ,[Expr -> alt-expr alt-bindings])
(values `(if ,cond-expr ,conseq-expr ,alt-expr) (union cond-bindings conseq-bindings alt-bindings))]
[(quote ,[Immediate -> im-expr]) (values `(quote ,im-expr) '())]
[(begin ,[Expr -> exp-stmt* exp-binding*] ... ,[Expr -> tail-stmt tail-binding])
(values `(begin ,exp-stmt* ... ,tail-stmt) (union (apply append exp-binding*) tail-binding))]
[(letrec ([,uvar* ,[Body -> body* free*]] ...) ,[Expr -> tail-expr tail-binding])
(values `(letrec ([,uvar* ,body*] ...) ,tail-expr) (difference (union (apply append free*) tail-binding) uvar*))]
[(let ([,uvar* ,[Expr -> exp* binding*]] ...) ,[Expr -> tail binding])
(values `(let ([,uvar* ,exp*] ...) ,tail) (difference (union binding (apply append binding*)) uvar*))]
[(,prim ,[Expr -> expr* bindings*] ...) (guard (memq prim primitives))
(values `(,prim ,expr* ...) (apply append bindings* ))]
[(,[Expr -> expr binding] ,[Expr -> rem* bindings*] ...)
(values `(,expr ,rem* ...) (union (apply append bindings*) binding))])))
(define Body
(lambda (body)
(match body
[(lambda (,param* ...) ,body)
(let-values ([(stmt* free*) (Expr body)])
(let ([free-vars (difference (clean-up free*) param*)])
(values `(lambda (,param* ...) (free ,free-vars ,stmt*)) free-vars)))])))
(define clean-up
(lambda (seti)
(cond
[(null? seti) '()]
[(and (list? (car seti)) (null? (car seti))) (clean-up (cdr seti))]
[(list? (car seti)) (set-cons (caar seti) (clean-up (cdr seti)))]
[else (set-cons (car seti) (clean-up (cdr seti)))])))
(define (Immediate imm)
(cond
[(memq imm '(#t #f ())) imm]
[(and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm))
imm]
[else (error who "invalid Immediate ~s" imm)]))
(lambda (x)
(let-values ([(final-expr final-bindings) (Expr x)])
(if (not (null? final-bindings))
(error who "Bindings not null")
final-expr))))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who convert-closures
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void ))
(define extract-body
(lambda (body*)
(cond
[(null? body*) '()]
[else (cons (caar body*) (extract-body (cdr body*)))])))
(define extract-closures
(lambda (body*)
(cond
[(null? body*) '()]
[else (cons (cadar body*) (extract-closures (cdr body*)))])))
(define Expr
(lambda (expr)
(match expr
[,uvar (guard (uvar? uvar)) expr]
[(if ,[Expr -> test] ,[Expr -> conseq] ,[Expr -> alt])
`(if ,test ,conseq ,alt)]
[(quote ,[Immediate -> im-expr]) `(quote ,im-expr)]
[(begin ,[Expr -> expr*] ... ,[Expr -> tail])
`(begin ,expr* ... ,tail)]
[(letrec ([,uvar* ,body*] ...) ,[Expr -> tail])
(let* ([label* (map Label uvar*)]
[process* (map Body uvar* body*)]
[new-body* (extract-body process*)]
[local-closures (extract-closures process*)])
`(letrec ([,label* ,new-body*] ...) (closures (,local-closures ...) ,tail)))]
[(let ([,uvar* ,[Expr -> exp*]] ...) ,[Expr -> tail])
`(let ([,uvar* ,exp*] ...) ,tail)]
[(,prim ,[Expr -> expr*] ...) (guard (memq prim primitives))
`(,prim ,expr* ...)]
[(,[Expr -> expr] ,[Expr -> rem*] ...)
(if (uvar? expr)
`(,expr ,expr ,rem* ...)
(let ([local (unique-name 't)])
`(let ([,local ,expr])
(,local ,local ,rem* ...))))])))
(define Body
(lambda (func-var body)
(match body
[(lambda (,param* ...) (free (,free* ...) ,[Expr -> body]))
(let ([func-ptr (unique-name 'fp)])
`((lambda (,func-ptr ,param* ...) (bind-free (,func-ptr ,free* ...) ,body)) (,func-var ,(Label func-var) ,free* ...)))])))
(define Label
(lambda (x)
(unique-label x)))
(define (Immediate imm)
(cond
[(memq imm '(#t #f ())) imm]
[(and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm))
imm]
[else (error who "invalid Immediate ~s" imm)]))
(lambda (x)
(Expr x)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; The strategy is that the function make-closures collects all the definitions enclosed within the closure form,
;;; while traversing over the structure of the program, if we find a uvar which is in rator position
;;; we simply check wether it is a uvar which points to a function, if it is we gebnerate the corresponding label
;;; Grammar for optimize-known-call
;;;
;;; Program --> <Expr>
;;; Expr --> <uvar>
;;; | (quote <Immediate>)
;;; | (if <Expr> <Expr> <Expr>)
;;; | (begin <Expr>* <Expr>)
;;; | (let ([<uvar> <Expr>]*) <Expr>)
;;; | (letrec ([<uvar> (bind-free (<uvar*) (closures (<closure*>) (lambda (<uvar>*) <Expr>)))]*) <Expr>)
;;; | (<primitive> <Expr>*)
;;; | (<Expr> <Expr>*)
;;; Immediate -> <fixnum> | () | #t | #f
(define-who optimize-known-call
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void ))
(define Expr
(lambda (func*)
(lambda (expr)
(match expr
[(if ,[(Expr func*) -> test] ,[(Expr func*) -> conseq] ,[(Expr func*) -> alt]) `(if ,test ,conseq ,alt)]
[(quote ,[Immediate -> im-expr]) `(quote ,im-expr)]
[(begin ,[(Expr func*) -> expr*] ... ,[(Expr func*) -> tail]) `(begin ,expr* ... ,tail)]
[(letrec ([,label* ,[(Body func*)-> body*]] ...)
(closures (,clos* ...) ,[(Expr func*) -> tail]))
`(letrec ([,label* ,body*] ...) (closures (,clos* ...) ,tail))]
[(let ([,uvar* ,[(Expr func*) -> exp*]] ...) ,[(Expr func*) -> tail]) `(let ([,uvar* ,exp*] ...) ,tail)]
[(,prim ,[(Expr func*) -> expr*] ...) (guard (memq prim primitives)) `(,prim ,expr* ...)]
[(,[(Expr func*) -> expr-a] ,[(Expr func*) -> expr] ,[(Expr func*) -> rem*] ...)
(if (memq expr-a func*) `(,(unique-label expr-a) ,expr ,rem* ...) `(,expr-a ,expr ,rem* ...))]
[,uvar (guard (uvar? uvar)) uvar]))))
(define Body
(lambda (func*)
(lambda (body)
(match body
[(lambda (,param* ...) (bind-free (,fptr ,free* ...) ,[(Expr func*)-> body]))
`(lambda (,param* ...) (bind-free (,fptr ,free* ...) ,body))]))))
(define collect-closures
(lambda (expr)
(match expr
[(if ,[collect-closures -> test] ,[collect-closures -> conseq] ,[collect-closures -> alt]) `(,test ... ,conseq ... ,alt ...)]
[(quote ,x) '()]
[(begin ,[collect-closures -> expr*] ... ,[collect-closures -> tail]) `(,expr* ... ...,tail ...)]
[(letrec ([,label* (lambda (,param* ...) (bind-free (,fptr ,free* ...) ,[collect-closures -> body*]))] ...)
(closures (,func* ...) ,[collect-closures -> tail]))
`(,body* ... ...,(map car func*) ,tail ...)]
[(let ([,uvar* ,[collect-closures -> exp*]] ...) ,[collect-closures -> tail]) `(,exp* ... ...,tail ...)]
[(,prim ,[collect-closures -> expr*] ...) (guard (memq prim primitives)) `(,expr* ... ...)]
[(,[collect-closures -> expr-a] ,[collect-closures -> expr] ,[collect-closures -> rem*] ...) `(,expr-a ...,expr ...,rem* ... ...)]
[,uvar (guard (uvar? uvar)) '()])))
(define (Immediate imm)
(cond
[(memq imm '(#t #f ())) imm]
[(and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm))
imm]
[else (error who "invalid Immediate ~s" imm)]))
(lambda (x)
(let ([closures (apply append (remq '() (collect-closures x)))])
((Expr closures) x))))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; Optimize self-reference is useful when aa function is being passed itself as a parameter, optimize-self reference will look for such functions
;;; and replace the paramter directly with a function pointer this will also save some additional pointers from being stored
(define-who optimize-self-reference
;;; builds an initial list of functions which are self-referenced
(define get-self-reference
(lambda (element)
(let ([func-name (car element)] [func-params (cddr element)])
(if (memq func-name func-params)
`(,(unique-label func-name) . ,func-name) '()))))
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void ))
;;; Called when (,expr ,expr* ...) is found, we need to evaluate each param, if it is a uvar we check if it is a function being referenced and replace
;;; that uvar with its corresponding function-pointer, I couldnot use map or union or intersection because the order in which the parameters are inserted
;;; matters
(define Process-params
(lambda (param* uvar env)
(cond
[(null? param*) '()]
[else (let* ([first (car param*)]
[present (assq first env)])
(if present
(cons (caddr present) (Process-params (cdr param*) uvar env))
(if (eq? uvar first)
(Process-params (cdr param*) uvar env)
(cons first (Process-params (cdr param*) uvar env)))))])))
;;; In case a uvar that is being self-refernced in the closures () form I replace that uvar with its corresponding closurepointer
(define sanitize-closure
(lambda (closure* env)
(lambda (closure)
(match closure
[(,uvar ,label ,param* ...)
(let ([intersect (intersection param* (map cdr closure*))])
(if (null? intersect)
`(,uvar ,label ,param* ...)
(let ([params (Process-params param* uvar env)])
`(,uvar ,label ,params ...))))]))))
;;; Expr helper takes 2 parameters, the first being a list of all functions self-referenced, and the next is a list of function-uvars and their
;;; corresponding functionpointers
(define Expr
(lambda (closure* env)
(lambda (expr)
(match expr
[(if ,[(Expr closure* env) -> test] ,[(Expr closure* env) -> conseq] ,[(Expr closure* env) -> alt]) `(if ,test ,conseq ,alt)]
[(quote ,im) `(quote ,im)]
[(begin ,[(Expr closure* env) -> expr*] ... ,[(Expr closure* env) -> tail]) `(begin ,expr* ... ,tail)]
[(letrec (,[(Body closure* '())-> body*] ...)
(closures (,[(sanitize-closure closure* env) -> clos*] ...)
,[(Expr closure* env) -> tail]))
`(letrec (,body* ...)
(closures (,clos* ...)
,tail))]
[(let ([,uvar* ,[(Expr closure* env) -> exp*]] ...) ,[(Expr closure* env) -> tail]) `(let ([,uvar* ,exp*] ...) ,tail)]
[(,prim ,[(Expr closure* env) -> expr*] ...) (guard (memq prim primitives)) `(,prim ,expr* ...)]
[(,[(Expr closure* env) -> expr-a] ,[(Expr closure* env) -> expr] ,[(Expr closure* env) -> rem*] ...)
(guard enable-optimize-self-reference)
`(,(Process `(,expr-a ,expr ,rem* ...) env) ... )]
[(,[(Expr closure* env) -> expr-a] ,[(Expr closure* env) -> expr] ,[(Expr closure* env) -> rem*] ...)
`(,expr-a ,(Process `(,expr ,rem* ...) env) ...)]
[,x (guard (or (uvar? x) (label? x))) x]))))
(define Process
(lambda (expr env)
(cond
[(null? expr) '()]
[(uvar? (car expr)) (let ([first (car expr)])
(if (assq first env)
(cons (caddr (assq first env)) (Process (cdr expr) env))
(cons first (Process (cdr expr) env))))]
[else (cons (car expr) (Process (cdr expr) env))])))
;;; Body form handles expressions of the form (,label (lambda() ....)), I needed to get each label and corresponding lambda expressions
;;; thats why I created this Helper
(define Body
(lambda (closure* env)
(lambda (body)
(match body
[(,label (lambda (,fptr ,param* ...)
(bind-free (,free* ...)
,tail)))
(let ([ispresent? (assq label closure*)]) ;;;check if this function has a self reference
;;;if present change the env and record its closurepointer
(if ispresent?
(let* ([uvar (cdr ispresent?)]
[new-env (cons `(,uvar . (,label ,fptr)) env)])
`(,label (lambda (,fptr ,param* ...)
(bind-free (,(remq uvar free*) ...)
,((Expr closure* new-env) tail)))))
;;; if not dont modify the enviornment pass it on as is
`(,label (lambda (,fptr ,param* ...)
(bind-free (,free* ...)
,((Expr closure* env) tail))))))]))))
;;; traverses over the entire program and gets a list of functions that are self referenced
(define collect-closures
(lambda (expr)
(match expr
[(if ,[collect-closures -> test] ,[collect-closures -> conseq] ,[collect-closures -> alt]) `(,test ... ,conseq ... ,alt ...)]
[(quote ,x) '()]
[(begin ,[collect-closures -> expr*] ... ,[collect-closures -> tail]) `(,expr* ... ...,tail ...)]
[(letrec ([,label* (lambda (,param* ...) (bind-free (,fptr ,free* ...) ,[collect-closures -> body*]))] ...)
(closures (,func* ...) ,[collect-closures -> tail]))
`(,body* ... ...,func* ... ,tail ...)]
[(let ([,uvar* ,[collect-closures -> exp*]] ...) ,[collect-closures -> tail]) `(,exp* ... ...,tail ...)]
[(,prim ,[collect-closures -> expr*] ...) (guard (memq prim primitives)) `(,expr* ... ...)]
[(,[collect-closures -> expr-a] ,[collect-closures -> expr] ,[collect-closures -> rem*] ...) `(,expr-a ...,expr ...,rem* ... ...)]
[,x (guard (or (uvar? x) (label? x))) '()])))
(lambda (x)
(let* ([closure-list (collect-closures x)]
[self-refer-closures (remq '() (map get-self-reference closure-list))])
((Expr self-refer-closures '()) x))))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who introduce-procedure-primitives
(define primitives
'(+ - * <= < = >= > procedure? boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void ))
(define Expr
(lambda (fptr free-list)
(lambda (expr)
(match expr
[(if ,[(Expr fptr free-list)-> test] ,[(Expr fptr free-list) -> conseq] ,[(Expr fptr free-list) -> alt])
`(if ,test ,conseq ,alt)]
[(quote ,[Immediate -> im-expr]) `(quote ,im-expr)]
[(begin ,[(Expr fptr free-list) -> expr*] ... ,[(Expr fptr free-list) -> tail])
`(begin ,expr* ... ,tail)]
[(letrec ([,label* ,[Body -> body*]] ...) ,[(Tail fptr free-list) -> tail])
`(letrec ([,label* ,body*] ...) ,tail)]
[(let ([,uvar* ,[(Expr fptr free-list) -> exp*]] ...) ,[(Expr fptr free-list) -> tail])
`(let ([,uvar* ,exp*] ...) ,tail)]
[(,prim ,[(Expr fptr free-list) -> expr*] ...) (guard (memq prim primitives))
`(,prim ,expr* ...)]
[(,expr-a ,[(Expr fptr free-list) -> expr] ,[(Expr fptr free-list) -> rem*] ...) (guard (label? expr-a))
`(,expr-a ,expr ,rem* ...)]
[(,[(Expr fptr free-list) -> expr-a] ,[(Expr fptr free-list) -> expr] ,[(Expr fptr free-list) -> rem*] ...)
(if (null? free-list)
`((procedure-code ,expr-a) ,expr ,rem* ...)
(let ([pos (find-pos 0 expr free-list)])
(if (eq? pos -1) `((procedure-code ,expr-a) ,expr ,rem* ...)
`((procedure-code (procedure-ref ,fptr (quote ,pos)))
(procedure-ref ,fptr (quote ,pos))
,rem* ...))))]
[,uvar (guard (uvar? uvar))
(if (null? free-list) uvar
(let ([pos (find-pos 0 expr free-list)])
(if (eq? pos -1) uvar
`(procedure-ref ,fptr (quote ,pos)))))]))))
(define make-funcs
(lambda (bindfree)
(let ([func-uvar (list-ref bindfree 0)]
[func-label (list-ref bindfree 1)]
[arg-length (length (cddr bindfree))])
`(,func-uvar (make-procedure ,func-label (quote ,arg-length))))))
(define make-list
(lambda (start val)
(cond
[(> start val) '()]
[else (cons start (make-list (add1 start) val))])))
;;; finds if a variable exists in the list of free variables passed to that function
(define find-pos
(lambda (pos needle haystack)
(cond
[(null? haystack) '-1 ]
[(eq? needle (car haystack)) pos]
[else (find-pos (add1 pos) needle (cdr haystack))])))
(define make-procs-set!
(lambda (closure)
(lambda (fptr free-vars)
(let* ([func-uvar (list-ref closure 0)] ;;;first position is uvar
[arg* (cddr closure)] ;;; free vars are everything after the 1st 2 places
[arg-length (length arg*)] ;;legth of the list
[index-list (make-list '0 (sub1 arg-length))]) ;;generates a list from 0 to length-1
;;; it is necessary to map each and every free variable to an index so that procedure-set!
;;; can set the correct arguments
(map (lambda (x y)
(let ([pos (find-pos '0 x free-vars)])
(if (eq? pos '-1)
`(procedure-set! ,func-uvar (quote ,y) ,x)
`(procedure-set! ,func-uvar (quote ,y) (procedure-ref ,fptr (quote ,pos)))))) arg* index-list)))))
(define Tail
(lambda (fptr free-list)
(lambda (tail)
(match tail
[(closures (,funcs* ...) ,[(Expr fptr free-list) -> new-tail])
(let ([functions* (map make-funcs funcs*)]
;;; necessary because make-proc-set! returns a list of functions
;;; so I define another map which applies these functions taking the appropriate
;;; parameters
[proc-set (map (lambda (fn)
(fn fptr free-list))(map make-procs-set! funcs*))])
`(let ,functions* ,(make-begin `(,proc-set ... ...,new-tail))))]))))
(define Body
(lambda (body)
(match body
[(lambda (,param* ...) (bind-free (,fptr ,free* ...) ,[(Expr fptr free*) -> body]))
`(lambda (,param* ...) ,body)])))
(define Label
(lambda (x)
(unique-label x)))
(define (Immediate imm)
(cond
[(memq imm '(#t #f ())) imm]
[(and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm))
imm]
[else (error who "invalid Immediate ~s" imm)]))
(lambda (x)
(set! closure-list '())
((Expr '() '()) x)))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who lift-letrec
;; Defines all the primitives in the Scheme Language
(define primitives
'(+ - * <= < = >= > boolean? car cdr cons eq? fixnum? make-vector null? pair? set-car! set-cdr! vector? vector-length vector-ref vector-set! void
make-procedure procedure-code procedure-ref procedure-set! procedure?))
(define definitions '())
;;; Parses The Expr form of the grammar
;;; The strategey in the Expr function is to process all the syntactic forms as they are
;;; letrec is handled differently as it gives us a list of labels and their definitions
;;; I use side effects to keep a list of definitions and then simply wrap around the tail with a
;;; letrec form containg all these definitions
(define Expr
(lambda (expr)
(match expr
[,label (guard (label? label)) label]
[,uvar (guard (uvar? uvar)) uvar]
[(if ,[Expr -> cond-expr] ,[Expr -> conseq-expr] ,[Expr -> alt-expr])
`(if ,cond-expr ,conseq-expr ,alt-expr)]
[(quote ,[Immediate -> im-expr]) `(quote ,im-expr)]
[(begin ,[Expr -> exp*] ... ,[Expr -> tail])
`(begin ,exp* ... ,tail)]
[(letrec ([,label* (lambda (,param* ...) ,[Expr -> body*])] ...) ,[Expr -> tail])
(begin
(set! definitions (append definitions `([,label* (lambda (,param* ...) ,body*)] ...)))
tail)]
[(let ([,uvar* ,[Expr -> exp*]] ...) ,[Expr -> tail])
`(let ([,uvar* ,exp*] ...) ,tail)]
[(,prim ,[Expr -> expr*] ...) (guard (memq prim primitives))
`(,prim ,expr* ...)]
[(,[Expr -> exp] ,[Expr -> rem*] ...)
`(,exp ,rem* ...)])))
;;;checks if a datatype is of immedeate form and returns it
(define (Immediate imm)
(cond
[(memq imm '(#t #f ())) imm]
[(and (integer? imm) (exact? imm))
(unless (fixnum-range? imm)
(error who "integer ~s is out of fixnum range" imm))
imm]
[else (error who "invalid Immediate ~s" imm)]))
(lambda (x)
(set! definitions '())
(let ([tail (Expr x)])
`(letrec ,definitions ,tail))))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who normalize-context
;;; The next 3 functions demarcate the various operators in the context in which they maybe encountered
(define val-primitive?
(lambda (x)
(memq x '(+ * - car cdr cons make-vector vector-length vector-ref make-procedure procedure-ref procedure-code))))
(define effect-primitive?
(lambda (x)
(memq x '(set-car! set-cdr! vector-set! procedure-set!))))
(define predicate-primitive?
(lambda (x)
(memq x '(<= < > = >= boolean? eq? fixnum? null? pair? vector? procedure?))))
(define Value
(lambda (val)
(match val
[,x (guard (or (label? x) (uvar? x))) x]
[(quote ,[Immediate -> imm]) `(quote ,imm)]
[(if ,[Pred -> test] ,[Value -> conseq] ,[Value -> alt]) `(if ,test ,conseq ,alt)]
[(begin ,[Effect -> ef*] ... ,[Value -> ef]) (make-nopless-begin `(,ef* ... ,ef))]
[(let ([,uvar* ,[Value -> value*]] ...) ,[Value -> tail])
`(let ([,uvar* ,value*] ...) ,tail)]
[(void) val] ;;In case void is encountered return its value
[(,value-prim ,[Value -> val*] ...) (guard (val-primitive? value-prim))
`(,value-prim ,val* ...)]
[(,pred-prim ,[Value -> val*] ...) (guard (predicate-primitive? pred-prim))
`(if (,pred-prim ,val* ...) '#t '#f)]
[(,effect-prim ,[Value -> val*] ...) (guard (effect-primitive? effect-prim))
(make-nopless-begin `((,effect-prim ,val* ...) (void)))] ;;Convert to (begin effect* ... (void))
[(,[Value -> val] ,[Value -> val*] ...) `(,val ,val* ...)]
)))
(define Effect
(lambda (ef)
(match ef
[(nop) '(nop)]
[(void) '(nop)]
[,x (guard (uvar? x)) '(nop)]
[(if ,[Pred -> test] ,[Effect -> conseq] ,[Effect -> alt]) `(if ,test ,conseq ,alt)]
[(begin ,[Effect -> ef*] ... ,[Effect -> ef]) `(begin ,ef* ... ,ef)]
[(let ([,uvar* ,[Value -> value*]] ...) ,[Effect -> tail])
`(let ([,uvar* ,value*] ...) ,tail)]
[(,effect-prim ,[Value -> val*] ...) (guard (effect-primitive? effect-prim))
`(,effect-prim ,val* ...)]
[(,value-prim ,val* ...) (guard (or (val-primitive? value-prim) (predicate-primitive? value-prim)))
'(nop)]
[(,[Value -> val] ,[Value -> val*] ...) `(,val ,val* ...)])))
;; Function for Immediate Primitives, we have well-defined values for #t,#f and '()
;; For integers we shift the value by 3 bits (since we use the lower 3 bits as tag)
(define Immediate
(lambda (im)
(match im
[#t #t]
[#f #f]
[,t (guard (integer? t)) t])))
(define Pred
(lambda (pred)
(match pred
[(true) '(true)]
[(false) '(false)]
[(quote ,[Immediate -> imm]) `(if (eq? (quote ,imm) '#f) (false) (true))]
[(if ,[Pred -> test] ,[Pred -> conseq] ,[Pred -> alt]) `(if ,test ,conseq ,alt)]
[(begin ,[Effect -> ef*] ... ,[Pred -> ef]) `(begin ,ef* ... ,ef) ]
[(let ([,uvar* ,[Value -> value*]] ...) ,[Pred -> tail]) `(let ([,uvar* ,value*] ...) ,tail) ]
[,var (guard (uvar? var)) `(if (eq? ,var '#f) (false) (true))]
[,label (guard (label? label)) '(true)]
[(void) `(if (eq? ,pred '#f) (false) (true))]
[(,pred-prim ,[Value -> val*] ...) (guard (predicate-primitive? pred-prim)) `(,pred-prim ,val* ...)]
[(,effect-prim ,[Value -> val*] ...) (guard (effect-primitive? effect-prim))
(make-nopless-begin `((,effect-prim ,val* ...) (true)))]
[(,value-prim ,[Value -> val*] ...) (guard (val-primitive? value-prim))
`(if (eq? (,value-prim ,val* ...) '#f) (false) (true))]
[(,[Value -> x],[Value -> x*]...) `(if (eq? (,x ,x* ...) '#f) (false) (true))])))
(lambda (prog)
(match prog
[(letrec ([,label* (lambda (,uvar* ...) ,[Value -> val*])] ...) ,[Value -> tail])
`(letrec ([,label* (lambda (,uvar* ...) ,val*)] ...) ,tail)]
[,x (error who "invalid program ~s" x)])))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define (make-nopless-begin x*)
(let ([x* (remove '(nop) x*)])
(if (null? x*)
'(nop)
(make-begin x*))))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who specify-representation
;;; Handles operators that we encounter in <Value> context
(define handle-operator
(lambda (rator rand*)
(cond
[(eq? rator 'cons)
(let ([first (unique-name 't)] [second (unique-name 't)] [third (unique-name 't)])
`(let ([,first ,(car rand*)] [,second ,(cadr rand*)])
(let ([,third (+ (alloc ,size-pair) ,tag-pair)])
(begin
(mset! ,third ,(- disp-car tag-pair) ,first)
(mset! ,third ,(- disp-cdr tag-pair) ,second)
,third))))]
;;; The - expression is necessary below because when we create a pair we tag it and hence the pointer gets displaced by a value
;;; given by tag-pair, all we do is subbtract it to get the real value of the pointer
[(eq? rator 'car)
`(mref ,(car rand*) ,(- disp-car tag-pair))]
[(eq? rator 'cdr)
`(mref ,(car rand*) ,(- disp-cdr tag-pair))]
;; The arguments to a make-vector can either be a variable or constant and hence the if statemnt is neccessary
[(eq? rator 'make-vector)
(let ([size-var (unique-name 't)] [size (car rand*)])
(if (integer? size)
`(let ([,size-var (+ (alloc ,(+ disp-vector-data size)) ,tag-vector)])
(begin
(mset! ,size-var ,(- disp-vector-length tag-vector) ,size)
,size-var))
`(let ([,size-var (+ (alloc (+ ,disp-vector-data ,size)) ,tag-vector)])
(begin
(mset! ,size-var ,(- disp-vector-length tag-vector) ,size)
,size-var))
))]
;;; a make-procedure expression looks like (make-procedure label num-args)
;;; size is specified by the number of args and the func-name is given by func
;;; I have used the same code used by make-vvector with the few changes I mentioned above
;;; I should be reporting an error in-case the number-of-args is a variable
;;; but I am not currently doing so
[(eq? rator 'make-procedure)
(let ([size-var (unique-name 't)] [size (cadr rand*)] [func (car rand*)])
(if (integer? size)
`(let ([,size-var (+ (alloc ,(+ disp-procedure-data size)) ,tag-procedure)])
(begin
(mset! ,size-var ,(- disp-procedure-code tag-procedure) ,func)
,size-var))
`(let ([,size-var (+ (alloc (+ ,disp-procedure-data ,size)) ,tag-procedure)])
(begin
(mset! ,size-var ,(- disp-procedure-code tag-procedure) ,func)
,size-var))
))]
[(eq? rator 'vector-length)
`(mref ,(car rand*) ,(- disp-vector-length tag-vector))]
;;; similar to vector-length
[(eq? rator 'procedure-code)
`(mref ,(car rand*) ,(- disp-procedure-code tag-procedure))]
[(eq? rator 'vector-ref)
(let ([value (cadr rand*)])
(if (integer? value)
`(mref ,(car rand*) ,(+ (- disp-vector-data tag-vector) value))
`(mref ,(car rand*) (+ ,(- disp-vector-data tag-vector) ,value))))]
;;; similar to vector-ref
[(eq? rator 'procedure-ref)
(let ([value (cadr rand*)])
(if (integer? value)
`(mref ,(car rand*) ,(+ (- disp-procedure-data tag-procedure) value))
`(mref ,(car rand*) (+ ,(- disp-procedure-data tag-procedure) ,value))))]
[(or (eq? rator '+) (eq? rator '-)) `(,rator ,@rand*)])))
;;; handles operators that can be encountered in <Effect> context
;;; since we are using set-car! we need to convert that to mset!
(define handle-effect-ops
(lambda (rator rand*)
(cond
[(eq? rator 'set-car!) `(mset! ,(car rand*) ,(- disp-car tag-pair) ,(cadr rand*))]
[(eq? rator 'set-cdr!) `(mset! ,(car rand*) ,(- disp-cdr tag-pair) ,(cadr rand*))]
[(eq? rator 'vector-set!)
(let ([value (cadr rand*)])
(if (integer? value)
`(mset! ,(car rand*) ,(+ (- disp-vector-data tag-vector) value) ,(caddr rand*))
`(mset! ,(car rand*) (+ ,(- disp-vector-data tag-vector) ,value) ,(caddr rand*))))]
;;; similar to vector-set!
[(eq? rator 'procedure-set!)
(let ([value (cadr rand*)])
(if (integer? value)
`(mset! ,(car rand*) ,(+ (- disp-procedure-data tag-procedure) value) ,(caddr rand*))
`(mset! ,(car rand*) (+ ,(- disp-procedure-data tag-procedure) ,value) ,(caddr rand*))))])))
;;; Handles operators that we can encounter in <Effect> context
(define handle-pred-op
(lambda (rator rand*)
(cond
[(memq rator '(> < = <= >= )) `(,rator ,@rand*)]
[(eq? rator 'eq?) `(= ,@rand*)] ;;; eq can be converted to = operator in scheme
;;; For all other primitives we unmask the values and check if the tag matches the particular data-type
;;; we are checking for
[(eq? rator 'boolean?)
`(= (logand ,(car rand*) ,mask-boolean) ,tag-boolean)]
[(eq? rator 'vector?)
`(= (logand ,(car rand*) ,mask-vector) ,tag-vector)]
[(eq? rator 'fixnum?)
`(= (logand ,(car rand*) ,mask-fixnum) ,tag-fixnum)]
[(eq? rator 'null?)
(Pred `(eq? ,(car rand*) '()))]
[(eq? rator 'pair?)
`(= (logand ,(car rand*) ,mask-pair) ,tag-pair)]
[(eq? rator 'procedure?)
`(= (logand ,(car rand*) ,mask-procedure) ,tag-procedure)])))
(define val-primitive?
(lambda (x)
(memq x '(+ - car cdr cons make-vector vector-length vector-ref procedure-ref procedure-code make-procedure))))
(define effect-primitive?
(lambda (x)
(memq x '(set-car! set-cdr! vector-set! procedure-set!))))
(define predicate-primitive?
(lambda (x)
(memq x '(<= < > = >= boolean? eq? fixnum? null? pair? vector? procedure?))))
(define Value
(lambda (val)
(match val
[,x (guard (or (label? x) (uvar? x) (integer? x))) x]
[(quote ,[Immediate -> imm]) imm]
[(mref ,x ,y) val]
[(if ,[Pred -> test] ,[Value -> conseq] ,[Value -> alt]) `(if ,test ,conseq ,alt)]
[(begin ,[Effect -> ef*] ... ,[Value -> ef]) `(begin ,ef* ... ,ef)]
[(let ([,uvar* ,[Value -> value*]] ...) ,[Value -> tail])
`(let ([,uvar* ,value*] ...) ,tail)]
[(void) $void] ;;In case void is encountered return its value
;;; Multiplication I have handled using a different case as we dont need to shift both the operands by 8 everytime
[(* ,[Value -> a] ,[Value -> b])
(cond
[(and (integer? a) (integer? b)) `(* ,(sra a shift-fixnum) ,b)]
[(integer? a) `(* ,b ,(sra a shift-fixnum))]
[(integer? b) `(* ,a ,(sra b shift-fixnum))]
[else `(* ,a (sra ,b ,shift-fixnum))])]
[(,value-prim ,[Value -> val*] ...) (guard (val-primitive? value-prim))
(handle-operator value-prim val*)]
[(,[Value -> val] ,[Value -> val*] ...) `(,val ,val* ...)])))
(define Effect
(lambda (ef)
(match ef
[(nop) '(nop)]
[(if ,[Pred -> test] ,[Effect -> conseq] ,[Effect -> alt]) `(if ,test ,conseq ,alt)]
[(begin ,[Effect -> ef*] ... ,[Effect -> ef]) `(begin ,ef* ... ,ef)]
[(let ([,uvar* ,[Value -> value*]] ...) ,[Effect -> tail])
`(let ([,uvar* ,value*] ...) ,tail)]
[(,effect-prim ,[Value -> val*] ...) (guard (effect-primitive? effect-prim))
(handle-effect-ops effect-prim val*)]
[(,[Value -> val] ,[Value -> val*] ...) `(,val ,val* ...)])))
;; Function for Immediate Primitives, we have well-defined values for #t,#f and '()
;; For integers we shift the value by 3 bits (since we use the lower 3 bits as tag)
(define Immediate
(lambda (im)
(match im
[#t $true]
[#f $false]
[() $nil]
[,t (guard (integer? t)) (ash t shift-fixnum)])))
(define Pred
(lambda (pred)
(match pred
[(true) '(true)]
[(false) '(false)]
[(if ,[Pred -> test] ,[Pred -> conseq] ,[Pred -> alt]) `(if ,test ,conseq ,alt)]
[(begin ,[Effect -> ef*] ... ,[Pred -> ef]) `(begin ,ef* ... ,ef) ]
[(let ([,uvar* ,[Value -> value*]] ...) ,[Pred -> tail]) `(let ([,uvar* ,value*] ...) ,tail) ]
[(,pred-prim ,[Value -> val*] ...) (guard (predicate-primitive? pred-prim)) (handle-pred-op pred-prim val*)])))
(lambda (prog)
(match prog
[(letrec ([,label* (lambda (,uvar* ...) ,[Value -> val*])] ...) ,[Value -> tail])
`(letrec ([,label* (lambda (,uvar* ...) ,val*)] ...) ,tail)]
[,x (error who "invalid program ~s" x)])))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who uncover-locals
(define (Body bd)
(define Value
(lambda (value)
(match value
[(if ,[Pred -> test] ,[conseq] ,[altern]) (union test conseq altern)]
[(begin ,[Effect -> ef*] ... ,[ef]) `(,ef* ... ... ,ef ...)]
[(let ([,new-uvar* ,[Value -> uvar* ]] ...) ,[tail]) `(,new-uvar* ... ,tail ... ,uvar* ... ...)] ;;;return the list of new-uvar*
[(,binop ,[Value -> x] ,[Value -> y])
(guard (memq binop '(+ - * logand logor mref)))
(union x y)]
[(alloc ,[Value -> val]) val]
[(,[Value -> rator ],[Value -> rand* ] ...) `(,rator ... ,rand* ... ...)]
[,triv '()])))
(define Effect
(lambda (ef)
(match ef
[(nop) '()]
[(if ,[Pred -> test] ,[conseq] ,[alt]) (union test conseq alt)]
[(let ([,new-uvar* ,[Value -> uvar* ]] ...) ,[Tail -> tail]) `(,new-uvar* ... ,tail ... ,uvar* ... ...)] ;;;return the list of new-uvar*
[(begin ,[Effect -> ef*] ... ,[ef]) `(,ef* ... ... ,ef ...)]
[(mset! ,[Value -> base] ,[Value -> offset] , [Value -> value]) (union base offset value)]
[(,[Value -> rator] ,[Value -> rand*] ...) `(,rator ... ,rand* ... ...)]
[,ef (error who "invalid Effect ~s" ef)])))
(define (Pred pr)
(match pr
[(true) '()]
[(false) '()]
[(let ([,new-uvar* ,[Value -> uvar* ]] ...) ,[Tail -> tail]) `(,new-uvar* ... ,tail ... ,uvar* ... ...)] ;;;return the list of new-uvar*
[(if ,[test] ,[conseq] ,[altern]) (union test conseq altern)]
[(begin ,[Effect -> ef*] ... ,[pr]) `(,ef* ... ... ,pr ...)]
[(,predop ,[Value -> x] ,[Value -> y])
(guard (memq predop '(< <= = >= >)))
(union x y)]
[,pr (error who "invalid Pred ~s" pr)]))
(define Tail
(lambda (tail)
(match tail
[(if ,[Pred -> test] ,[conseq] ,[altern]) (union test conseq altern)]
[(begin ,[Effect -> ef*] ... ,[tail]) `(,ef* ... ... ,tail ...)]
[(let ([,new-uvar* ,[Value -> uvar* ]] ...) ,[Value -> tail]) `(,new-uvar* ... ,tail ... ,uvar* ... ...)] ;;;return the list of new-uvar*
[(alloc ,[Value -> val]) val]
[(,binop ,[Value -> x] ,[Value -> y])
(guard (memq binop '(+ - * logand logor sra mref)))
(union x y)]
[(,[Value -> rator ],[Value -> rand* ] ...) `(,rator ... ,rand* ... ...)]
[,triv '()])))
(let ((tail (Tail bd)))
`(locals ,tail ,bd)))
(lambda (x)
(match x
[(letrec ([,label* (lambda (,uvar** ...) ,[Body -> bd*])] ...)
,[Body -> bd])
`(letrec ([,label* (lambda (,uvar** ...) ,bd*)] ...) ,bd)]
[,x (error who "invalid Program ~s" x)])))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who remove-let
(define (Body bd)
(define Value
(lambda (value)
(match value
[(if ,[Pred -> test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[ef]) (make-begin `(,ef* ...,ef))]
[(let ([,new-uvar* ,[Value -> uvar* ]] ...) ,[Value -> tail])
(let ((begin-exps (map (lambda (uvar exp)
`(set! ,uvar ,exp)) new-uvar* uvar*)))
(make-begin `(,begin-exps ...,tail)))]
[(,binop ,[Value -> x] ,[Value -> y])
(guard (memq binop '(+ - * logand logor mref)))
`(,binop ,x ,y)]
[(alloc ,[Value -> val]) `(alloc ,val)]
[(,[Value -> rator ],[Value -> rand* ] ...) `(,rator ,rand* ...)]
[,triv triv])))
(define Effect
(lambda (ef)
(match ef
[(nop) '(nop)]
[(if ,[Pred -> test] ,[conseq] ,[alt]) `(if ,test ,conseq ,alt)]
[(let ([,new-uvar* ,[Value -> uvar* ]] ...) ,[Value -> tail])
(let ((begin-exps (map (lambda (uvar exp)
`(set! ,uvar ,exp)) new-uvar* uvar*)))
(make-begin `(,begin-exps ...,tail)))]
[(begin ,[Effect -> ef*] ... ,[ef]) (make-begin `(,ef* ... ,ef))]
[(mset! ,[Value -> base] ,[Value -> offset] , [Value -> value]) `(mset! ,base ,offset ,value)]
[(,[Value -> rator ],[Value -> rand* ] ...) `(,rator ,rand* ...)]
[,ef (error who "invalid Effect ~s" ef)])))
(define (Pred pr)
(match pr
[(true) '(true)]
[(false) '(false)]
[(let ([,new-uvar* ,[Value -> uvar* ]] ...) ,[Value -> tail])
(let ((begin-exps (map (lambda (uvar exp)
`(set! ,uvar ,exp)) new-uvar* uvar*)))
(make-begin `(,begin-exps ...,tail)))]
[(if ,[test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[pr]) (make-begin `(,ef* ... ,pr))]
[(,predop ,[Value -> x] ,[Value -> y])
(guard (memq predop '(< <= = >= >)))
`(,predop ,x ,y)]
[,pr (error who "invalid Pred ~s" pr)]))
(define Tail
(lambda (tail)
(match tail
[(if ,[Pred -> test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[tail]) (make-begin `(,ef* ... ,tail))]
[(let ([,new-uvar* ,[Value -> uvar* ]] ...) ,[Value -> tail])
(let ((begin-exps (map (lambda (uvar exp)
`(set! ,uvar ,exp)) new-uvar* uvar*)))
(make-begin `(,begin-exps ...,tail)))]
[(alloc ,[Value -> val]) `(alloc ,val)]
[(,binop ,[Value -> x] ,[Value -> y])
(guard (memq binop '(+ - * logand logor sra mref)))
`(,binop ,x ,y)]
[(,[Value -> rator ],[Value -> rand* ] ...) `(,rator ,rand* ...)]
[,triv triv])))
(match bd
[(locals (,uvar* ...) ,[Tail -> tail]) `(locals (,uvar* ...) ,tail)]))
(lambda (x)
(match x
[(letrec ([,label* (lambda (,uvar** ...) ,[Body -> bd*])] ...)
,[Body -> bd])
`(letrec ([,label* (lambda (,uvar** ...) ,bd*)] ...) ,bd)]
[,x (error who "invalid Program ~s" x)])))
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
;;; ------------------------------------------------------------------------------------------------------------------------------------------------
(define-who verify-uil
(define verify-x-list
(lambda (x* x? what)
(let loop ([x* x*] [idx* '()])
(unless (null? x*)
(let ([x (car x*)] [x* (cdr x*)])
(unless (x? x)
(error who "invalid ~s ~s found" what x))
(let ([idx (extract-suffix x)])
(when (member idx idx*)
(error who "non-unique ~s suffix ~s found" what idx))
(loop x* (cons idx idx*))))))))
(define Triv
(lambda (label* uvar*)
(lambda (t)
(unless (or (label? t) (uvar? t) (and (integer? t) (exact? t)))
(error who "invalid Triv ~s" t))
(when (and (integer? t) (exact? t))
(unless (int64? t)
(error who "integer out of 64-bit range ~s" t)))
(when (uvar? t)
(unless (memq t uvar*)
(error who "reference to unbound uvar ~s" t)))
(when (label? t)
(unless (memq t label*)
(error who "unbound label ~s" t)))
t)))
(define Value
(lambda (label* uvar*)
(lambda (val)
(match val
[(if ,[(Pred label* uvar*) -> test] ,[conseq] ,[altern]) (void)]
[(begin ,[(Effect label* uvar*) -> ef*] ... ,[val]) (void)]
[(alloc ,[(Value label* uvar*) -> mem-size]) (void)] ;;clause for alloc
[(mref ,[(Value label* uvar*) -> base] ,[(Value label* uvar*) -> offset]) (void)] ;;clause for mref
[(sra ,[x] ,y)
(unless (uint6? y)
(error who "invalid sra operand ~s" y))]
[(,binop ,[x] ,[y])
(guard (memq binop '(+ - * logand logor sra)))
(void)]
[(,[rator] ,[rand*] ...) (void)]
[,[(Triv label* uvar*) -> tr] (void)]))))
(define Effect
(lambda (label* uvar*)
(lambda (ef)
(match ef
[(nop) (void)]
[(if ,[(Pred label* uvar*) -> test] ,[conseq] ,[altern]) (void)]
[(begin ,[ef*] ... ,[ef]) (void)]
[(set! ,var ,[(Value label* uvar*) -> val])
(unless (memq var uvar*)
(error who "assignment to unbound var ~s" var))]
[(mset! ,[(Value label* uvar*) -> base] ,[(Value label* uvar*) -> offset] ,[(Value label* uvar*) -> val]) (void)] ;;clause for mset!
[(,[(Value label* uvar*) -> rator]
,[(Value label* uvar*) -> rand*] ...)
(void)]
[,ef (error who "invalid Effect ~s" ef)]))))
(define Pred
(lambda (label* uvar*)
(lambda (pr)
(match pr
[(true) (void)]
[(false) (void)]
[(if ,[test] ,[conseq] ,[altern]) (void)]
[(begin ,[(Effect label* uvar*) -> ef*] ... ,[pr]) (void)]
[(,predop ,[(Value label* uvar*) -> x] ,[(Value label* uvar*) -> y])
(unless (memq predop '(< > <= >= =))
(error who "invalid predicate operator ~s" predop))]
[,pr (error who "invalid Pred ~s" pr)]))))
(define Tail
(lambda (tail label* uvar*)
(match tail
[(if ,[(Pred label* uvar*) -> test] ,[conseq] ,[altern]) (void)]
[(begin ,[(Effect label* uvar*) -> ef*] ... ,[tail]) (void)]
[(alloc ,[(Value label* uvar*) -> mem-size]) (void)] ;;clause for alloc
[(mref ,[(Value label* uvar*) -> base] ,[(Value label* uvar*) -> offset]) (void)] ;;clause for mref
[(sra ,[(Value label* uvar*) -> x] ,y)
(unless (uint6? y)
(error who "invalid sra operand ~s" y))]
[(,binop ,[(Value label* uvar*) -> x] ,[(Value label* uvar*) -> y])
(guard (memq binop '(+ - * logand logor sra)))
(void)]
[(,[(Value label* uvar*) -> rator]
,[(Value label* uvar*) -> rand*] ...)
(void)]
[,[(Triv label* uvar*) -> triv] (void)])))
(define Body
(lambda (label*)
(lambda (bd fml*)
(match bd
[(locals (,local* ...) ,tail)
(let ([uvar* `(,fml* ... ,local* ...)])
(verify-x-list uvar* uvar? 'uvar)
(Tail tail label* uvar*))]
[,bd (error who "invalid Body ~s" bd)]))))
(lambda (x)
(match x
[(letrec ([,label* (lambda (,fml** ...) ,bd*)] ...) ,bd)
(verify-x-list label* label? 'label)
(map (lambda (fml*) (verify-x-list fml* uvar? 'formal)) fml**)
(for-each (Body label*) bd* fml**)
((Body label*) bd '())]
[,x (error who "invalid Program ~s" x)])
x))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;;When I encounter any function calls in Value and effect contexts it simply calls trivialize calls, thats the only change from last weeks assignment
;;;To deal with new forms introduced by this weeks grammar I am trivializing the arguments to all the mref mset! and alloc
;;; eg (set! x.1 (alloc (begin (set! y.2 16) (set! z.3 32) (+ y.2 z.3)))) wiil get translated to
;;;(begin
;;;(set! y.2 16)
;;;(set! z.3 32)
;;;(set! t.4 (+ y.2 z.3))
;;;(set! x.1 (alloc t.4)))
;;;It will be similar if we encounter mrefs and mset! with complex arguments
;;;I am treating an mref as an ordinary binop for this pass as it produces the exactly same output as any other binop
;;;clauses are added for mset! in Effect and alloc in tail and value contexts
(define-who remove-complex-opera*
(define (Body bd)
(define new-local* '())
(define (new-t)
(let ([t (unique-name 't)])
(set! new-local* (cons t new-local*))
t))
(define (trivialize-call expr*)
(let-values ([(call set*) (break-down-expr* expr*)])
(make-begin `(,@set* ,call))))
(define break-down-expr*
(lambda (expr*)
(match expr*
[() (values '() '())]
[(alloc . ,[break-down-expr* -> rest* set*])
(values `(alloc ,rest* ...) set*)]
[(mset! . ,[break-down-expr* -> rest* set*])
(values `(mset! ,rest* ...) set*)]
[(,s . ,[break-down-expr* -> rest* set*])
(guard (simple? s))
(values `(,s ,rest* ...) set*)]
[(,[Value -> expr] . , [break-down-expr* -> rest* set*])
(let ([t (new-t)])
(values `(,t ,rest* ...) `((set! ,t ,expr) ,set* ...)))]
[,expr* (error who "invalid Expr ~s" expr*)])))
(define (simple? x)
(or (uvar? x) (label? x) (and (integer? x) (exact? x))
(memq x '(+ - * logand logor sra mref)) (memq x '(= < <= > >=))))
(define Value
(lambda (val)
(match val
[(if ,[Pred -> test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[val]) (make-begin `(,ef* ... ,val))]
[(alloc ,[Value -> val]) (trivialize-call `(alloc ,val))]
[(,binop ,[Value -> x] ,[ Value -> y])
(guard (memq binop '(+ - * logand logor sra mref)))
(trivialize-call `(,binop ,x ,y))]
[(,rator ,rand* ...) (trivialize-call `(,rator ,rand* ...))]
[,tr tr])))
(define (Effect ef)
(match ef
[(nop) '(nop)]
[(mset! ,[Value -> val1] ,[Value -> val2] ,[Value -> val3]) (trivialize-call `(mset! ,val1 ,val2 ,val3))]
[(if ,[Pred -> test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[ef*] ... ,[ef]) (make-begin `(,ef* ... ,ef))]
[(set! ,var ,[Value -> val]) `(set! ,var ,val)]
[(,rator ,rand* ...) (trivialize-call `(,rator ,rand* ...))]
[,ef (error who "invalid Effect ~s" ef)]))
(define (Pred pr)
(match pr
[(true) '(true)]
[(false) '(false)]
[(if ,[test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[pr]) (make-begin `(,ef* ... ,pr))]
[(,predop ,x ,y)
(guard (memq predop '(< <= = >= >)))
(trivialize-call `(,predop ,x ,y))]
[,pr (error who "invalid Pred ~s" pr)]))
(define (Tail tail)
(match tail
[(if ,[Pred -> test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[tail]) (make-begin `(,ef* ... ,tail))]
[(alloc ,[Value -> val]) (trivialize-call `(alloc ,val))]
[(,binop ,[Value -> x] ,[Value -> y])
(guard (memq binop '(+ - * logand logor sra mref)))
(trivialize-call `(,binop ,x ,y))]
[(,rator ,rand* ...) (trivialize-call `(,rator ,rand* ...))]
[,tr tr]))
(match bd
[(locals (,local* ...) ,[Tail -> tail])
`(locals (,local* ... ,new-local* ...) ,tail)]
[,bd (error who "invalid Body ~s" bd)]))
(lambda (x)
(match x
[(letrec ([,label* (lambda (,fml** ...) ,[Body -> bd*])] ...)
,[Body -> bd])
`(letrec ([,label* (lambda (,fml** ...) ,bd*)] ...) ,bd)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;; I decided to get rid of the alloc forms in this pass by introducing the allocaton pointer register;
;;; There are 2 essential places where the alloc form will be encountered
;;; a) tail context and b) Value context
;;; if i encounter alloc in tail context e.g (alloc 48)
;;; all I do is convert it into 3 statements (alloc 48) => (begin (set! temp.1 ap) (set! ap (+ ap 48)) temp.1)
;;; if i encounter alloc in value context e.g (set! x.2 (alloc 48))
;;; all I do is convert it into 2 statements (set! x.2 (alloc 48)) => (begin (set! x.2 ap) (set! ap (+ ap 48)))
;;; mrefs continue to be treated as binops
;;; msets are allowed to pass on as it is
(define-who flatten-set!
(define (Body bd)
(define trivialize-set!
(lambda (lhs rhs)
(match rhs
[(if ,[Pred -> test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[tail]) (make-begin `(,ef* ... ,tail))]
[(alloc ,val1) (make-begin
`((set! ,lhs ,allocation-pointer-register)
(set! ,allocation-pointer-register (+ ,allocation-pointer-register ,val1))))]
[(,binop ,x ,y)
(guard (memq binop '(+ - * logand logor sra mref)))
`(set! ,lhs (,binop ,x ,y))]
[(,rator ,rand* ...) `(set! ,lhs (,rator ,rand* ...))] ;This will make it (set! t.1 (ack$0 2 3)) and push the expression to the end
[,tr `(set! ,lhs ,tr)]))) ;;treating mref's as binop
(define Effect
(lambda (ef)
(match ef
[(nop) '(nop)]
[(if ,[Pred -> test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[ef]) (make-begin `(,ef* ... ,ef))]
[(mset! ,base ,offset ,value) `(mset! ,base ,offset ,value)]
[(set! ,var ,val) (trivialize-set! var val)]
[(,rator ,rand* ...) `(,rator ,rand* ...)]
[,ef (error who "invalid Effect ~s" ef)])))
(define (Pred pr)
(match pr
[(true) '(true)]
[(false) '(false)]
[(if ,[test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[pr]) (make-begin `(,ef* ... ,pr))]
[(,predop ,x ,y)
(guard (memq predop '(< <= = >= >)))
`(,predop ,x ,y)]
[,pr (error who "invalid Pred ~s" pr)]))
(define (Tail tail)
(match tail
[(if ,[Pred -> test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[tail]) (make-begin `(,ef* ... ,tail))]
[(alloc ,val)
(let ((new-temp (new-t)))
(make-begin `((set! ,new-temp ,allocation-pointer-register)
(set! ,allocation-pointer-register (+ ,allocation-pointer-register ,val))
,new-temp)))]
[(,binop ,x ,y)
(guard (memq binop '(+ - * logand logor sra mref)))
`(,binop ,x ,y)]
[(,rator ,rand* ...) `(,rator ,rand* ...)]
[,tr tr]))
(define new-local* '())
(define (new-t)
(let ([t (unique-name 't)])
(set! new-local* (cons t new-local*))
t))
(match bd
[(locals (,uvar* ...) ,[Tail -> tail]) `(locals (,uvar* ...,new-local* ...) ,tail)]
[,bd (error who "invalid Body ~s" bd)]))
(lambda (x)
(match x
[(letrec ([,label* (lambda (,fml** ...) ,[Body -> bd*])] ...)
,[Body -> bd])
`(letrec ([,label* (lambda (,fml** ...) ,bd*)] ...) ,bd)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;;Program -----> (letrec ([label (lambda (uvar*) Body)]*) Body)
;;;Body -----> (locals (uvar*) Tail)
;;;Tail -----> Triv
;;; | (binop Triv Triv)
;;; | (Triv Triv*)
;;; | (mref Triv Triv)
;;; | (if Pred Tail Tail)
;;; | (begin Effect* Tail)
;;;Pred -----> (true)
;;; | (false)
;;; | (relop Triv Triv)
;;; | (if Pred Pred Pred)
;;; | (begin Effect* Pred)
;;;Effect -----> (nop)
;;; | (set! uvar Triv)
;;; | (set! uvar (binop Triv Triv))
;;; | (set! uvar (Triv Triv*))
;;; | (mset! Triv Triv Triv)
;;; | (Triv Triv*)
;;; | (if Pred Effect Effect)
;;; | (begin Effect* Effect)
;;;Triv -----> uvar | int | label
;;;Now That I have got rid of the alloc forms impose calling conventions is trivial....
;;;mref continues to be treated as binop and mset! expressions are passed on as they are
;;; Though only addition is that the allocation pointer register is added here to the list of registers
;;; that are live on entry...This helps in allocating registers properly to conflicting variables, otherwise me may
;;;happen to override the alocation pointer regster and access wrong regions in the memory
(define-who impose-calling-conventions
(define (argument-locations fmls idx->fv)
(let f ([fmls fmls] [regs parameter-registers] [fv-idx 0])
(cond
[(null? fmls) '()]
[(null? regs) (cons (idx->fv fv-idx) (f (cdr fmls) regs (+ fv-idx 1)))]
[else (cons (car regs) (f (cdr fmls) (cdr regs) fv-idx))])))
(define (index->new-frame-var idx) (unique-name 'nfv))
;;Filters list for values based on the predicate passed by fn
(define filter
(lambda (fn ls)
(cond
[(null? ls) '()]
[(fn (car ls)) (cons (car ls) (filter fn (cdr ls)))]
[else (filter fn (cdr ls))])))
(define trivial?
(lambda (x)
(or (uvar? x) (integer? x) (label? x) (register? x))))
(define (Body bd fml*)
(define new-frame-var** '()) ;;Stores all the nfv assignments
(define Effect
(lambda (effect)
(match effect
[(nop) '(nop)]
[(if ,[Pred -> pred] ,[Effect -> conseq] ,[Effect -> alt]) `(if ,pred ,conseq ,alt)]
[(begin ,[Effect -> ef*] ... ,[Effect -> ef]) (make-begin `(,ef* ... ,ef))]
[(mset! ,base ,offset ,val) effect]
[(set! ,uvar ,triv) (guard (trivial? triv)) effect]
[(set! ,uvar (,binop ,x ,y)) (guard (memq binop '(+ - * logand logor sra mref))) effect]
[(set! ,uvar (,triv ,triv* ...))
(guard (trivial? triv))
(make-begin `(,(Effect `(,triv ,triv* ...)) (set! ,uvar ,return-value-register)))]
[(,triv ,triv* ...)
;This handles non tail call in Effect Context
(let* ((return-point-var (unique-label 'rp))
(fml-loc* (argument-locations triv* index->new-frame-var)) ;Assign a register or variable to each formal parameter
(expr (make-begin
`((set! ,fml-loc* ,triv*) ... (set! ,return-address-register ,return-point-var) (,triv ,return-address-register ,frame-pointer-register ,allocation-pointer-register ,@fml-loc*))))
(return-point-expr `(return-point ,return-point-var ,expr))) ;Create a return-point-expr
(set! new-frame-var** (cons (filter uvar? fml-loc*) new-frame-var**))
(make-begin `(,return-point-expr)))])))
(define (Pred pred)
(match pred
[(true) '(true)]
[(false) '(false)]
[(if ,[test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[pr]) (make-begin `(,ef* ... ,pr))]
[(,predop ,x ,y)
(guard (memq predop '(< <= = >= >)))
`(,predop ,x ,y)]))
(define Tail
(lambda (tail rp)
(match tail
[(begin ,[Effect -> ef*] ... ,tail)
(let ((tail-expr (Tail tail rp)))
(make-begin `(,ef* ... ,tail-expr)))]
[(if ,[Pred -> pred] ,conseq ,alt)
(let ((conseq-expr (Tail conseq rp))
(alt-expr (Tail alt rp)))
`(if ,pred ,conseq-expr ,alt-expr))]
[(,binop ,x ,y) (guard (memq binop '(+ - * logand logor sra mref)))
(let ((expr `((set! ,return-value-register ,tail) (,rp ,frame-pointer-register ,allocation-pointer-register ,return-value-register))))
(make-begin expr))]
[(,triv ,triv* ...)
(let ((fml-loc* (reverse (argument-locations triv* index->frame-var))) (triv* (reverse triv*)))
(make-begin
`((set! ,fml-loc* ,triv*) ... (set! ,return-address-register ,rp) (,triv ,return-address-register ,frame-pointer-register ,allocation-pointer-register ,@fml-loc*))))]
[,triv (let ((return-value-expr `(set! ,return-value-register ,triv))
(return-calling-expr `(,rp ,frame-pointer-register ,allocation-pointer-register ,return-value-register)))
(make-begin `(,return-value-expr ,return-calling-expr)))])))
(match bd
[(locals (,local* ...) ,tail)
(let ([rp (unique-name 'rp)]
[fml-loc* (argument-locations fml* index->frame-var)])
(let ([tail (Tail tail rp)])
`(locals (,rp ,fml* ... ,local* ... ,new-frame-var** ... ...)
(new-frames (,new-frame-var** ...)
,(make-begin
`((set! ,rp ,return-address-register)
(set! ,fml* ,fml-loc*) ...
,tail))))))]
[,bd (error who "invalid Body ~s" bd)]))
(lambda (x)
(match x
[(letrec ([,label* (lambda (,fml** ...) ,bd*)] ...) ,bd)
(let ([bd* (map Body bd* fml**)] [bd (Body bd '())])
`(letrec ([,label* (lambda () ,bd*)] ...) ,bd))]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;;Program -----> (letrec ([label (lambda () Body)]*) Body)
;;;Body -----> (locals (uvar*)
;;; (new-frames (Frame*) Tail))
;;;Frame -----> (uvar*)
;;;Tail -----> (Triv Loc*)
;;; | (if Pred Tail Tail)
;;; | (begin Effect* Tail)
;;;Pred -----> (true)
;;; | (false)
;;; | (relop Triv Triv)
;;; | (if Pred Pred Pred)
;;; | (begin Effect* Pred)
;;;Effect -----> (nop)
;;; | (set! Var Triv)
;;; | (set! Var (binop Triv Triv))
;;; | (return-point label (Triv Loc*))
;;; | (if Pred Effect Effect)
;;; | (begin Effect* Effect)
;;;Loc -----> reg | fvar
;;;Var -----> uvar | Loc
;;;Triv -----> Var | int | label
;;;uncover frame conflicts needs to handle mrefs and mset's in different way while updating the conflict table
;;;(set! x (mref base offset)) => will mean that x conflicts with both base and offset and hence we must record these conflicts
;;;(mset! base offset value) => in this we have to record the conflicts of each parameters with the other
(define-who uncover-frame-conflict
(define add-conflicts!
(lambda (ct lhs live*)
(define add-conflict!
(lambda (var1 var2)
(let ([a (assq var1 ct)])
(set-cdr! a (if (eq? var1 var2) (cdr a) (set-cons var2 (cdr a)))))))
(when (uvar? lhs)
(for-each
(lambda (live) (add-conflict! lhs live))
live*))
(for-each
(lambda (live) (when (and (uvar? live) (not (register? lhs))) (add-conflict! live lhs)))
live*)))
(define trivial?
(lambda (x)
(or (uvar? x) (integer? x) (label? x))))
(define remove-nulls
(lambda (ls)
(cond
[(null? ls) '()]
[(null? (car ls)) (remove-nulls (cdr ls))]
[else (set-cons (car ls) (remove-nulls (cdr ls)))])))
(define (Body x)
(define call-live* '())
(define Triv (lambda (x) (if (or (uvar? x) (frame-var? x)) `(,x) '())))
(define Effect*
(lambda (x live* ct)
(match x
[() live*]
[(,ef* ... ,ef) (Effect* ef* (Effect ef live* ct) ct)]
[,x (error who "invalid Effect* list ~s" x)])))
(define Effect
(lambda (x live* ct)
(match x
[(nop) live*]
[(if ,test ,[c-live*] ,[a-live*])
(Pred test c-live* a-live* ct)]
[(begin ,ef* ... ,[live*]) (Effect* ef* live* ct)]
[(mset! ,[Triv -> base] ,[Triv -> offset] ,[Triv -> value])
(begin
(if (not (null? base)) (add-conflicts! ct (car base) (union offset value live*)))
(if (not (null? offset)) (add-conflicts! ct (car offset) (union base value live*)))
(if (not (null? value)) (add-conflicts! ct (car value) (union offset base live*)))
(union base offset value live*))]
[(set! ,lhs (mref ,[Triv -> x-live*] ,[Triv -> y-live*]))
(begin
(add-conflicts! ct lhs (union x-live* y-live* live*))
(union x-live* y-live* (remq lhs live*)))]
[(set! ,lhs (,binop ,[Triv -> x-live*] ,[Triv -> y-live*]))
(guard (memq binop '(+ - * logand logor)))
(begin
(add-conflicts! ct lhs live*)
(union x-live* y-live* (remq lhs live*)))]
[(set! ,lhs ,var)
(begin
(add-conflicts! ct lhs live*)
(if (or (uvar? var) (frame-var? var)) (set-cons var (remq lhs live*)) (remq lhs live*)))]
[(return-point ,rplab ,tail)
(let ((new-live* (Tail tail ct)))
(set! call-live* (union call-live* live*))
(union live* new-live*))]
[,x (error who "invalid Effect list ~s" x)])))
(define Pred
(lambda (x t-live* f-live* ct)
(match x
[(true) t-live* ]
[(false) f-live* ]
[(if ,test ,[c-live*] ,[a-live*])
(union t-live* f-live* (Pred test c-live* a-live* ct))]
[(begin ,ef* ... ,[live*]) (Effect* ef* live* ct)]
[(,predop ,[Triv -> x-live*] ,[Triv -> y-live*])
(remove-nulls (union x-live* y-live* t-live* f-live*))]
[,x (error who "invalid Pred ~s" x)])))
(define Tail
(lambda (x ct)
(match x
[(begin ,ef* ... ,[live*]) (Effect* ef* live* ct)]
[(if ,test ,[c-live*] ,[a-live*]) (Pred test c-live* a-live* ct)]
[(,[Triv -> target] ,[Triv -> live*] ...) `(,target ... ,live* ... ...)]
[,x (error who "invalid Tail ~s" x)])))
(match x
[(locals (,uvar* ...) (new-frames (,nfv** ...) ,tail))
(let ([ct (map (lambda (x) (cons x '())) uvar*)])
(let ([uvar* (filter uvar? (Tail tail ct))])
(unless (null? uvar*)
(error who "found variables ~s live on entry" uvar*)))
(let ([spill* (filter uvar? call-live*)])
`(locals (,(difference uvar* spill*) ...)
(new-frames (,nfv** ...)
(spills ,spill*
(frame-conflict ,ct
(call-live (,call-live* ...) ,tail)))))))]
[,x (error who "invalid Body ~s" x)]))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> body*])] ...) ,[Body -> body])
`(letrec ([,label* (lambda () ,body*)] ...) ,body)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;Simpler version of assign frame assigns a frame variable for all variables in the spill list, done through the find-homes function
(define-who pre-assign-frame
(define replace ;;Replaces the occurences of variables in the conflict-list with the register-homes
(lambda (allocations ct)
(cond
[(null? allocations) ct]
[else (replace (cdr allocations) (replace-helper (car allocations) ct))])))
(define replace-helper
(lambda (allocation ct)
(map (lambda (ct-entry)
(cond
[(eq? (car allocation) (car ct-entry)) allocation]
[else (cons (car ct-entry) (replace* (cdr ct-entry) allocation))])) ct)))
(define replace*
(lambda (conflicts allocation)
(cond
[(null? conflicts) '()]
[(eq? (car conflicts) (car allocation)) (cons (cadr allocation) (replace* (cdr conflicts) allocation))]
[else (cons (car conflicts) (replace* (cdr conflicts) allocation))])))
(define update-bias-table
(lambda (uvar reg bt)
(map (lambda (entry)
(let ([tail (cdr entry)])
(if (memq uvar tail)
(begin
(set-cdr! entry (cons reg (remq uvar entry)))
entry)
entry))) bt)))
(define update-conflict-table
(lambda (uvar reg ct)
(map (lambda (entry)
(let ([tail (cdr entry)])
(if (memq uvar tail)
(begin
(set-cdr! entry (cons reg (remq uvar entry)))
entry)
entry))) ct)))
(define assign-homes
(lambda (var* bt ct)
(cond
[(null? bt) '() ]
[(null? var*) '()]
[else (let* ([current-var (car var*)]
[bt-entry (assq current-var bt)]
[friend-list (cdr bt-entry)]
[conflict-entry (cdr (assq current-var ct))])
(if (null? friend-list)
(assign-homes (cdr var*) bt ct)
(let ([friend-frame (get-frame friend-list conflict-entry)])
(cond
[(eq? friend-frame #f) (assign-homes (cdr var*) bt ct)]
[else (let ([updated-ct (update-conflict-table current-var friend-frame ct)]
[updated-bt (update-bias-table current-var friend-frame bt)])
(cons (list current-var friend-frame) (assign-homes (cdr var*) updated-bt updated-ct)))]))))])))
(define get-frame
(lambda (ls conflict-entry)
(cond
[(null? ls) #f]
[(and (frame-var? (car ls)) (not (memq (car ls) conflict-entry))) (car ls)]
[else (get-frame (cdr ls) conflict-entry)])))
(define find-used
(lambda (conflict* home*)
(cond
[(null? conflict*) '()]
[(frame-var? (car conflict*))
(set-cons (car conflict*) (find-used (cdr conflict*) home*))]
[(assq (car conflict*) home*) =>
(lambda (x) (set-cons (cadr x) (find-used (cdr conflict*) home*)))]
[else (find-used (cdr conflict*) home*)])))
(define find-frame-var
(lambda (used*)
(let f ([index 0])
(let ([fv (index->frame-var index)])
(if (memq fv used*) (f (+ index 1)) fv)))))
(define find-homes
(lambda (var* ct home*)
(if (null? var*)
home*
(let ([var (car var*)] [var* (cdr var*)])
(let ([conflict* (cdr (assq var ct))])
(let ([home (find-frame-var (find-used conflict* home*))])
(find-homes var* ct `((,var ,home) . ,home*))))))))
(define Body
(lambda (body)
(match body
[(locals (,local* ...)
(new-frames (,nfv** ...)
(spills (,spill* ...)
(frame-conflict ,ct
(call-live (,call-live* ...) ,tail)))))
(let* ([uvar* (union local* spill*)]
[bias-list (move-bias tail frame-var? uvar*)]
[biased-home* (assign-homes spill* bias-list ct)]
[home (if (null? biased-home*) '() (map car biased-home*))]
[new-ct (if (null? biased-home*) ct (replace biased-home* ct))]
[home* (find-homes (difference spill* home) ct '())])
`(locals (,local* ...)
(new-frames (,nfv** ...)
(locate (,biased-home* ... ,home* ...)
(frame-conflict ,ct
(call-live (,call-live* ...) ,tail))))))]
[,body (error who "invalid Body ~s" body)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> body*])] ...) ,[Body -> body])
`(letrec ([,label* (lambda () ,body*)] ...) ,body)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
(define-who move-bias
(define uncover-bias
(lambda (body bias-list fn)
(match body
[(begin ,ef* ...) (Effect* ef* bias-list fn)])))
(define Effect*
(lambda (effect* bias-list fn)
(match effect*
[,x (guard (null? x)) bias-list]
[(,ef,ef* ...) (Effect* ef* (Effect ef bias-list fn) fn)])))
(define Effect
(lambda (ef bias-list fn)
(match ef
[(set! ,x ,y) (guard (and (uvar? x) (uvar? y)))
(begin
(set-cdr! (assq x bias-list) (set-cons y (cdr (assq x bias-list))))
(set-cdr! (assq y bias-list) (set-cons x (cdr (assq y bias-list))))
bias-list)]
[(set! ,x ,y) (guard (and (uvar? x) (fn y)))
(begin
(set-cdr! (assq x bias-list) (set-cons y (cdr (assq x bias-list))))
bias-list)]
[(set! ,x ,y) (guard (and (fn x) (uvar? y)))
(begin
(set-cdr! (assq y bias-list) (set-cons x (cdr (assq y bias-list))))
bias-list)]
[,x bias-list])))
(lambda (tail fn uvar*)
(cond
[(eq? move-bias-enabled '#f) '()]
[else (let* ([bias-list (map (lambda (x) (cons x '())) uvar*)]
[new-bias-list (uncover-bias tail bias-list fn)])
new-bias-list)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;;(return-point rp-label tail) =>
;;; (begin
;;; (set! fp (+ fp nb))
;;; (return-point rp-label tail)
;;; (set! fp (- fp nb)))
(define-who assign-new-frame
(define Effect
(lambda (fs)
(lambda (x)
(match x
[(nop) '(nop)]
[(if ,[(Pred fs) -> test] ,[(Effect fs) -> conseq] ,[(Effect fs) -> altern])
`(if ,test ,conseq ,altern)]
[(begin ,[ef*] ... ,[ef]) (make-begin `(,ef* ... ,ef))]
[(mset! ,base ,offset ,value) `(mset! ,base ,offset ,value)]
[(set! ,lhs ,rhs) `(set! ,lhs ,rhs)]
[(return-point ,rplab ,[(Tail fs) -> tail])
(make-begin
`((set! ,frame-pointer-register (+ ,frame-pointer-register ,(ash fs align-shift)))
,x
(set! ,frame-pointer-register (- ,frame-pointer-register ,(ash fs align-shift)))))]
[,x (error who "invalid Effect ~s" x)]))))
(define Pred
(lambda (fs)
(lambda (x)
(match x
[(true) '(true)]
[(false) '(false)]
[(if ,[test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[(Effect fs) -> ef*] ... ,[pr]) (make-begin `(,ef* ... ,pr))]
[(,predop ,x ,y) `(,predop ,x ,y)]
[,x (error who "invalid Pred ~s" x)]))))
(define Tail
(lambda (fs)
(lambda (x)
(match x
[(if ,[(Pred fs) -> test] ,[(Tail fs) -> conseq] ,[ (Tail fs) -> altern])
`(if ,test ,conseq ,altern)]
[(begin ,[(Effect fs) -> ef*] ... ,[(Tail fs) -> tail]) (make-begin `(,ef* ... ,tail))]
[(,triv ,live* ...) `(,triv ,live* ...)]
[,x (error who "invalid Tail ~s" x)]))))
(define find-max ;;This function is used to determine the size of the frame used by the function
(lambda (ls)
(cond
[(null? ls) '-1 ]
[else (max (car ls) (find-max (cdr ls)))])))
;;; The function argument to map does all the work we basically have to find the max-index of all call-live variables which can either be a frame variable
;;; or we could look up the frame variable assigned to a uvar via the pre-assign frame pass
(define Body
(lambda (x)
(define frame-size
(lambda (call-live* home*)
(let ([ls (map (lambda (x)
(if (frame-var? x)
(frame-var->index x)
(frame-var->index (cadr (assq x home*))))) call-live*)])
(add1 (find-max ls)))))
(match x
[(locals (,local* ...)
(new-frames (,nfv** ...)
(locate (,home* ...)
(frame-conflict ,ct
(call-live (,call-live* ...) ,tail)))))
(let ([fs (frame-size call-live* home*)])
(define (do-assign var*)
(let f ([index fs] [ls var*] [rs '()])
(let ((fv (index->frame-var index)))
(cond
[(null? ls) rs]
[else (f (add1 index) (cdr ls) (cons `(,(car ls) ,fv) rs))]))))
`(locals (,(difference local* `(,nfv** ... ...)) ...)
(ulocals ()
(locate (,home* ... ,(map do-assign nfv**) ... ...)
(frame-conflict ,ct ,((Tail fs) tail))))))]
[,x (error who "invalid Body ~s" x)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> body*])] ...) ,[Body -> body])
`(letrec ([,label* (lambda () ,body*)] ...) ,body)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;; mrefs are still handled as binops here
;;; mset! clause added, if any of the parameters has been assigned as a frame it is reflected here
(define-who finalize-frame-locations
(define Var
(lambda (env)
(lambda (v)
(cond
[(and (uvar? v) (assq v env)) => cdr]
[else v]))))
(define Triv Var)
(define Pred
(lambda (env)
(lambda (pr)
(match pr
[(true) '(true)]
[(false) '(false)]
[(if ,[test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[(Effect env) -> ef*] ... ,[pr]) `(begin ,ef* ... ,pr)]
[(,predop ,[(Triv env) -> x] ,[(Triv env) -> y]) `(,predop ,x ,y)]
[,pr (error who "invalid Pred ~s" pr)]))))
(define Effect
(lambda (env)
(lambda (ef)
(match ef
[(nop) '(nop)]
[(set! ,[(Var env) -> x]
(,binop ,[(Triv env) -> y] ,[(Triv env) -> z]))
`(set! ,x (,binop ,y ,z))]
[(set! ,[(Var env) -> x] ,[(Triv env) -> y])
(if (eq? y x) `(nop) `(set! ,x ,y))]
[(mset! ,[(Var env) -> base] ,[(Var env) -> offset] ,[(Var env) -> value]) `(mset! ,base ,offset ,value)]
[(begin ,[ef] ,[ef*] ...) `(begin ,ef ,ef* ...)]
[(if ,[(Pred env) -> test] ,[conseq] ,[altern])
`(if ,test ,conseq ,altern)]
[(return-point ,rplab ,[(Tail env) -> tail]) ;;Handling return-point expressions in the Effect
`(return-point ,rplab ,tail)]
[,ef (error who "invalid Effect ~s" ef)]))))
(define Tail
(lambda (env)
(lambda (tail)
(match tail
[(begin ,[(Effect env) -> ef*] ... ,[tail]) `(begin ,ef* ... ,tail)]
[(if ,[(Pred env) -> test] ,[conseq] ,[altern])
`(if ,test ,conseq ,altern)]
[(,[(Triv env) -> t] ,[(Triv env) -> live*] ...) `(,t ,live* ...)]
[,tail (error who "invalid Tail ~s" tail)]))))
(define Body
(lambda (bd)
(match bd
[(locals (,local* ...)
(ulocals (,ulocal* ...)
(locate ([,uvar* ,loc*] ...)
(frame-conflict ,ct ,[(Tail (map cons uvar* loc*)) -> tail]))))
`(locals (,local* ...)
(ulocals (,ulocal* ...)
(locate ([,uvar* ,loc*] ...)
(frame-conflict ,ct ,tail))))]
[(locate ([,uvar* ,loc*] ...) ,tail)
`(locate ([,uvar* ,loc*] ...) ,tail)]
[,bd (error who "invalid Body ~s" bd)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> bd*])] ...) ,[Body -> bd])
`(letrec ([,label* (lambda () ,bd*)] ...) ,bd)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;; Select instructions requires mrefs and msets to be rewritten substantially in some cases
;;; I prepared a table based on base and offset values
;;;offset base ----------->
;;;| ur int32 fvar label
;;;| ur X1 X1 X3 X3
;;;| int32 X4 X2 X5 X5
;;;| fvar X6 X2 X5 X5
;;;| label X6 X2 X5 X5
;;;|
;;;v
;;;X1 => return expression as is
;;;X2 => (set! u base) (set! lhs (mref u offset))
;;;X3 => (set! u offset) (set! lhs (mref base u))
;;;X4 => (set! lhs (mref offset base))
;;;X5 => (set! u1 base) (set! u2 offset) (set! lhs (mref u1 u2))
;;;X6 => first do X4 and then X3
;;; This pretty much handles all cases that there are, mrefs and mset! are handled in the same way
(define-who select-instructions
(define (ur? x) (or (register? x) (uvar? x)))
(define (Body x)
(define new-ulocal* '())
(define int64-or-label?
(lambda (x) (or (and (not (int32? x)) (int64? x)) (label? x))))
(define (new-u)
(let ([u (unique-name 't)])
(set! new-ulocal* (cons u new-ulocal*))
u))
(define (select-binop-1 var binop triv1 triv2)
(cond
[(eq? var triv1) (select-binop-2 binop var triv2)]
[(and (eq? var triv2) (member binop '(+ * logor logand))) (select-binop-2 binop var triv1)]
[else (let ([u (new-u)])
`(begin (set! ,u ,triv1) ,(select-binop-2 binop u triv2) (set! ,var ,u)))]))
(define (select-binop-2 binop var triv)
(cond
[(and (member binop '(- + sra logor logand))
(or (int64-or-label? triv) (and (frame-var? var) (frame-var? triv))))
(let ([u (new-u)])
`(begin (set! ,u ,triv) (set! ,var (,binop ,var ,u))))]
;;; X2
[(and (eq? binop '*) (frame-var? var))
(let ([u (new-u)])
`(begin (set! ,u ,var) ,(select-binop-2 binop u triv) (set! ,var ,u)))]
;;; X1 for *
[(and (eq? binop '*) (ur? var) (int64-or-label? triv))
(let ([u (new-u)])
`(begin (set! ,u ,triv) (set! ,var (,binop ,var ,u))))]
[else `(set! ,var (,binop ,var ,triv))]))
(define (select-move var triv)
(if (and (frame-var? var) (or (frame-var? triv) (int64-or-label? triv)))
;;; X0
(let ([u (new-u)])
`(begin (set! ,u ,triv) (set! ,var ,u)))
`(set! ,var ,triv)))
(define select-relop
(lambda (relop x y)
(cond
[(and (int32? x) (or (ur? y) (frame-var? y))) `(,(relop^ relop) ,y ,x)]
[(or (and (frame-var? x) (frame-var? y))
(and (int32? x) (int32? y))
(and (int64-or-label? x) (or (ur? y) (frame-var? y) (int32? y))))
(let ([u (new-u)])
`(begin (set! ,u ,x) (,relop ,u ,y)))]
[(and (or (ur? x) (frame-var? x) (int32? x))
(int64-or-label? y))
(let ([u (new-u)])
`(begin (set! ,u ,y) (,(relop^ relop) ,u ,x)))]
[(and (int64-or-label? x) (int64-or-label? y))
(let ([u1 (new-u)] [u2 (new-u)])
`(begin (set! ,u1 ,x) (set! ,u2 ,y) (,relop ,u1 ,u2)))]
[else `(,relop ,x ,y)])))
;;;select mref and mset do the same thing the only difference being that the former returns mref expressions and the latter returns mset!
(define select-mref
(lambda (lhs base offset)
(cond
[(or (and (ur? base) (integer? offset))
(and (ur? base) (ur? offset))) `((set! ,lhs (mref ,base ,offset)))] ;;X1
[(and (integer? offset) (or (integer? base) (frame-var? base) (label? base)))
(let ((u (new-u)))
`((set! ,u ,base) (set! ,lhs (mref ,u ,offset))))] ;;X2
[(and (ur? base) (or (frame-var? offset) (label? offset)))
(let ((u (new-u)))
`((set! ,u ,offset) (set! ,lhs (mref ,base ,u))))]
[(and (ur? offset) (or (frame-var? base) (frame-var? offset)))
(select-mref lhs offset base)]
[else (let ((u1 (new-u)) (u2 (new-u)))
`((set! ,u1 ,base) (set! ,u2 ,offset) (set! ,lhs (mref ,u1 ,u2))))])))
(define select-mset
(lambda (base offset value)
(cond
[(or (and (ur? base) (integer? offset))
(and (ur? base) (ur? offset))) `((mset! ,base ,offset ,value))]
[(and (integer? offset) (or (integer? base) (frame-var? base) (label? base)))
(let ((u (new-u)))
`((set! ,u ,base) (mset! ,u ,offset ,value) (set! ,base ,u)))]
[(and (ur? base) (or (frame-var? offset) (label? offset)))
(let ((u (new-u)))
`((set! ,u ,offset) (mset! ,base ,u ,value)))]
[(and (ur? offset) (or (frame-var? base) (frame-var? offset)))
(select-mset offset base value)]
[else (let ((u1 (new-u)) (u2 (new-u)))
`((set! ,u1 ,base) (set! ,u2 ,offset) (mset! ,u1 ,u2 ,value)))])))
(define Effect
(lambda (ef)
(match ef
[(nop) '(nop)]
[(begin ,[Effect -> ef*] ... ,[Effect -> ef]) (make-begin `(,ef* ... ,ef))]
[(if ,[Pred -> test] ,[Effect -> conseq] ,[Effect -> altern]) `(if ,test ,conseq ,altern)]
[(set! ,lhs (mref ,base ,offset))
(cond
[(and (integer? base) (ur? offset)) (make-begin (select-mref lhs offset base))] ;;exchange base and offset
[(ur? lhs) (make-begin (select-mref lhs base offset))] ;;;pass lhs as it is
[(frame-var? lhs)
(let ((u (new-u)))
(make-begin `((set! ,u ,lhs) ,(select-mref u base offset) ... (set! ,lhs ,u))))] ;;;if frame-var assign a new unspillable and assign it back
[(label? lhs)
(let ((u (new-u)))
(make-begin `((set! ,u ,lhs) ,(select-mref u base offset) ...)))] ;;;if lhs a label assign new unspillable and call select-mref passing new lhs
[else '(nop)])]
[(set! ,lhs (,binop ,x ,y)) (select-binop-1 lhs binop x y)]
[(set! ,lhs ,rhs) (select-move lhs rhs)]
[(mset! ,base ,offset ,value)
(cond
[(and (integer? base) (ur? offset)) (make-begin (select-mset offset base value))]
[(or (ur? value) (integer? value)) (make-begin (select-mset base offset value))]
[(frame-var? value)
(let ((u (new-u)))
(make-begin `((set! ,u ,value) ,(select-mset base offset u) ... (set! ,value ,u))))]
[(label? value)
(let ((u (new-u)))
(make-begin `((set! ,u ,value) ,(select-mset base offset u) ...)))])]
[(return-point ,rplab ,[Tail -> tail]) `(return-point ,rplab ,tail)] ;;;Process tail and send the rest of instructions as is
[,x (error who "invalid Effect ~s" x)])))
(define (Pred x)
(match x
[(true) '(true)]
[(false) '(false)]
[(if ,[Pred -> pred] ,[Pred -> conseq] ,[Pred -> alt])
`(if ,pred ,conseq ,alt)]
[(begin ,[Effect -> ef*] ...,[Pred -> tail])
(make-begin `(,ef* ... ,tail))]
[(,relop ,conseq ,alt) (select-relop relop conseq alt)]))
(define (Tail x)
(match x
[(begin ,[Effect -> ef*] ... ,[Tail -> tail])
(make-begin `(,ef* ... ,tail))]
[(if ,[Pred -> pred] ,[Tail -> conseq] ,[Tail -> alt])
`(if ,pred ,conseq ,alt)]
[(,loc* ...) `(,loc* ...)]))
(match x
[(locals (,local* ...)
(ulocals (,ulocal* ...)
(locate (,home* ...) (frame-conflict ,ct ,[Tail -> tail]))))
`(locals (,local* ...)
(ulocals (,ulocal* ... ,new-ulocal* ...)
(locate (,home* ...)
(frame-conflict ,ct ,tail))))]
[(locate (,home* ...) ,tail) `(locate (,home* ...) ,tail)]
[,x (error who "invalid Body ~s" x)]))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> body*])] ...) ,[Body -> body])
`(letrec ([,label* (lambda () ,body*)] ...) ,body)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;;uncover register conflicts needs to handle mrefs and mset's in different way while updating the conflict table
;;;(set! x (mref base offset)) => will mean that x conflicts with both base and offset and hence we must record these conflicts
;;;(mset! base offset value) => in this we have to record the conflicts of each parameters with the other
(define-who uncover-register-conflict
(define add-conflicts!
(lambda (ct lhs live*)
(define add-conflict!
(lambda (var1 var2)
(let ([a (assq var1 ct)])
(set-cdr! a (if (eq? var1 var2) (cdr a) (set-cons var2 (cdr a)))))))
(when (uvar? lhs)
(for-each
(lambda (live) (add-conflict! lhs live))
live*))
(for-each
(lambda (live) (when (and (uvar? live) (not (frame-var? lhs))) (add-conflict! live lhs)))
live*)))
(define Triv (lambda (x) (if (or (uvar? x) (register? x)) `(,x) '())))
(define Effect*
(lambda (x live* ct)
(match x
[() live*]
[(,ef* ... ,ef) (Effect* ef* (Effect ef live* ct) ct)]
[,x (error who "invalid Effect* list ~s" x)])))
(define Effect
(lambda (x live* ct)
(match x
[(nop) live*]
[(if ,test ,[c-live*] ,[a-live*])
(Pred test c-live* a-live* ct)]
[(mset! ,[Triv -> base] ,[Triv -> offset] ,[Triv -> value])
(begin
(if (not (null? base)) (add-conflicts! ct (car base) (union offset value live*)))
(if (not (null? offset)) (add-conflicts! ct (car offset) (union base value live*)))
(if (not (null? value)) (add-conflicts! ct (car value) (union base offset live*)))
(union base offset value live*))]
[(begin ,ef* ... ,[live*]) (Effect* ef* live* ct)]
[(set! ,lhs (mref ,[Triv -> x-live*] ,[Triv -> y-live*]))
(begin
(add-conflicts! ct lhs (union x-live* y-live* live*))
(union x-live* y-live* (remq lhs live*)))]
[(set! ,lhs (,binop ,[Triv -> x-live*] ,[Triv -> y-live*]))
(begin
(add-conflicts! ct lhs live*)
(union x-live* y-live* (remq lhs live*)))]
[(set! ,lhs ,var)
(begin
(add-conflicts! ct lhs live*)
(if (or (uvar? var) (register? var)) (set-cons var (remq lhs live*)) (remq lhs live*)))]
; ignoring incoming live*, since it should not contain anything
; but caller-save registers, which the call kills (see note in
; the assignment description)
[(return-point ,rplab ,tail) (Tail tail ct)] ;;;Return the list of variables live in the tail ignoring the variables that were live before the call was made
[,x (error who "invalid Effect list ~s" x)])))
(define Pred
(lambda (x t-live* f-live* ct)
(match x
[(true) t-live* ]
[(false) f-live* ]
[(if ,test ,[c-live*] ,[a-live*]) (union t-live* f-live* (Pred test c-live* a-live* ct))]
[(begin ,ef* ... ,[live*]) (Effect* ef* live* ct)]
[(,predop ,[Triv -> x-live*] ,[Triv -> y-live*])
(union x-live* y-live* t-live* f-live*)]
[,x (error who "invalid Pred ~s" x)])))
(define Tail
(lambda (x ct)
(match x
[(begin ,ef* ... ,[live*]) (Effect* ef* live* ct)]
[(if ,test ,[c-live*] ,[a-live*]) (Pred test c-live* a-live* ct)]
[(,[Triv -> target-live*] ,[Triv -> live*] ...) `(,target-live* ... ,live* ... ...)]
[,x (error who "invalid Tail ~s" x)])))
(define Body
(lambda (x)
(match x
[(locals (,local* ...)
(ulocals (,ulocal* ...)
(locate (,home* ...)
(frame-conflict ,fv-ct ,tail))))
(let ([ct (map (lambda (x) (cons x '())) `(,local* ... ,ulocal* ...))])
(let ([uvar* (filter uvar? (Tail tail ct))])
(unless (null? uvar*)
(error who "found variables ~s live on entry" uvar*)))
`(locals (,local* ...)
(ulocals (,ulocal* ...)
(locate (,home* ...)
(frame-conflict ,fv-ct
(register-conflict ,ct ,tail))))))]
[(locate (,home* ...) ,tail) `(locate (,home* ...) ,tail)]
[,x (error who "invalid Body ~s" x)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> body*])] ...) ,[Body -> body])
`(letrec ([,label* (lambda () ,body*)] ...) ,body)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;assigns register to the uvars made a chnage documented below
(define-who assign-registers
(define remove-occurence ;;Removes the occurence of a var from var* and returns the list
(lambda (var ct)
(map (lambda (x)
(cond
[(eq? (car x) var) x]
[else (remq var x)])) ct)))
(define replace ;;Replaces the occurences of variables in the conflict-list with the register-homes
(lambda (allocations ct)
(cond
[(null? allocations) ct]
[else (replace (cdr allocations) (replace-helper (car allocations) ct))])))
(define replace-helper
(lambda (allocation ct)
(map (lambda (ct-entry)
(cond
[(eq? (car allocation) (car ct-entry)) allocation]
[else (cons (car ct-entry) (replace* (cdr ct-entry) allocation))])) ct)))
(define replace*
(lambda (conflicts allocation)
(cond
[(null? conflicts) '()]
[(eq? (car conflicts) (car allocation)) (cons (cadr allocation) (replace* (cdr conflicts) allocation))]
[else (cons (car conflicts) (replace* (cdr conflicts) allocation))])))
(define k (length registers))
(define low-degree?
(lambda (var ct)
(< (length (cdr (assq var ct))) k)))
(define num-conflicts
(lambda (var ct)
(let ((temp (assq var ct)))
(if (null? temp) 2000 (length (cdr (assq var ct)))))))
(define pick-min ;;Picks a node with least number of conflicts like the min function
(lambda (var degree var* ct)
(cond
[(null? var) 'xxx]
[(null? var*) var]
[(<= degree (num-conflicts (car var*) ct)) (pick-min var degree (cdr var*) ct)]
[else (let* ((node (car var*))
(degree^ (num-conflicts node ct)))
(pick-min node degree^ (cdr var*) ct))])))
(define assign-null
(lambda (ls)
(if (null? ls) 'xxx (car ls))))
(define uncover-register-bias
(lambda (body bias-list)
(match body
[(begin ,ef* ...) (Effect* ef* bias-list)])))
(define Effect*
(lambda (effect* bias-list)
(match effect*
[,x (guard (null? x)) bias-list]
[(,ef,ef* ...) (Effect* ef* (Effect ef bias-list))])))
(define Effect
(lambda (ef bias-list)
(match ef
[(set! ,x ,y) (guard (and (uvar? x) (uvar? y)))
(begin
(set-cdr! (assq x bias-list) (set-cons y (cdr (assq x bias-list))))
(set-cdr! (assq y bias-list) (set-cons x (cdr (assq y bias-list))))
bias-list)]
[(set! ,x ,y) (guard (and (uvar? x) (register? y)))
(begin
(set-cdr! (assq x bias-list) (set-cons y (cdr (assq x bias-list))))
bias-list)]
[(set! ,x ,y) (guard (and (register? x) (uvar? y)))
(begin
(set-cdr! (assq y bias-list) (set-cons x (cdr (assq y bias-list))))
bias-list)]
[,x bias-list])))
;;;altered the function here as advised by Andy Keep
;;;first I will assign all the variables in spillable list and then on the unspillable list
(define find-homes
(lambda (spillable* unspillable* ct)
(cond
[(and (null? spillable*) (null? unspillable*)) '()]
[(null? spillable*) (find-homes unspillable* '() ct)]
[else (let* ((current-var (pick-min (car spillable*) (num-conflicts (car spillable*) ct) (cdr spillable*) ct))
(new-conflict-table (remove-occurence current-var ct))
(results (find-homes (remq current-var spillable*) (remq current-var unspillable*) new-conflict-table))
(updated-ct (replace results ct))
(conflict-entry (cdr (assq current-var updated-ct)))
(remaining-registers (difference registers conflict-entry)))
(if (null? remaining-registers)
results
(let ((assign-register (car remaining-registers)))
(cons (list current-var assign-register) results))))])))
(define get-replacement
(lambda (var entry)
(list var (car (difference registers entry)))))
(define get-register
(lambda (ls conflict-entry)
(cond
[(null? ls) #f]
[(and (register? (car ls)) (not (memq (car ls) conflict-entry))) (car ls)]
[else (get-register (cdr ls) conflict-entry)])))
(define update-bias-table
(lambda (uvar reg bt)
(map (lambda (entry)
(let ([tail (cdr entry)])
(if (memq uvar tail)
(begin
(set-cdr! entry (cons reg (remq uvar entry)))
entry)
entry))) bt)))
(define assign-homes
(lambda (var* bt ct)
(cond
[(null? bt) '() ]
[(null? var*) '()]
[else (let* ([current-var (car var*)]
[bt-entry (assq current-var bt)]
[friend-list (cdr bt-entry)]
[conflict-entry (cdr (assq current-var ct))])
(if (null? friend-list)
(assign-homes (cdr var*) bt ct)
(let ([friend-register (get-register friend-list conflict-entry)])
(cond
[(eq? friend-register #f) (assign-homes (cdr var*) bt ct)]
[else (let ([updated-ct (replace (list (list current-var friend-register)) ct)]
[updated-bt (update-bias-table current-var friend-register bt)])
(cons (list current-var friend-register) (assign-homes (cdr var*) updated-bt updated-ct)))]))))])))
(define Body
(lambda (x)
(match x
[(locals (,local* ...)
(ulocals (,ulocal* ...)
(locate (,frame-home* ...)
(frame-conflict ,fv-ct
(register-conflict ,ct ,tail)))))
;; putting local* before ulocal* allows find-homes to choose the
;; first element of the list when all variables are high degree and
;; be guaranteed a spillable variable if one is left. if find-homes
;; wants to be more clever about choosing a high-degree victim, it
;; will have to be told which variables are spillable.
(let* ([uvar* (append local* ulocal*)]
[bias-list (move-bias tail register? uvar*)])
(let* ( [biased-home* (assign-homes uvar* bias-list ct)]
[homes (if (null? biased-home*) '() (map car biased-home*))]
[new-ct (if (null? biased-home*) ct (replace biased-home* ct))]
[home* (find-homes (difference local* homes) (difference ulocal* homes) new-ct)])
(let ([spill* (difference uvar* (union (map car home*) homes))])
(cond
[(null? spill*) `(locate (,frame-home* ... ,biased-home* ... ,home* ...) ,tail)]
[(null? (intersection ulocal* spill*))
(let ([local* (difference local* spill*)])
`(locals (,local* ...)
(ulocals (,ulocal* ...)
(spills (,spill* ...)
(locate (,frame-home* ...)
(frame-conflict ,fv-ct ,tail))))))]
[else
(error who "unspillable variables (~s) have been spilled"
(difference spill* local*))]))))]
[(locate (,home* ...) ,tail) `(locate (,home* ...) ,tail)]
[,x (error who "invalid Body ~s" x)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> body*])] ...) ,[Body -> body])
`(letrec ([,label* (lambda () ,body*)] ...) ,body)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
(define-who everybody-home?
(define all-home?
(lambda (body)
(match body
[(locals (,local* ...)
(ulocals (,ulocal* ...)
(spills (,spill* ...)
(locate (,home* ...)
(frame-conflict ,ct ,tail))))) #f]
[(locate (,home* ...) ,tail) #t]
[,x (error who "invalid Body ~s" x)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,body*)] ...) ,body)
(andmap all-home? `(,body ,body* ...))]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;;pass changed since last assignment
(define-who assign-frame
(define replace ;;Replaces the occurences of variables in the conflict-list with the register-homes
(lambda (allocations ct)
(cond
[(null? allocations) ct]
[else (replace (cdr allocations) (replace-helper (car allocations) ct))])))
(define replace-helper
(lambda (allocation ct)
(map (lambda (ct-entry)
(cond
[(eq? (car allocation) (car ct-entry)) allocation]
[else (cons (car ct-entry) (replace* (cdr ct-entry) allocation))])) ct)))
(define replace*
(lambda (conflicts allocation)
(cond
[(null? conflicts) '()]
[(eq? (car conflicts) (car allocation)) (cons (cadr allocation) (replace* (cdr conflicts) allocation))]
[else (cons (car conflicts) (replace* (cdr conflicts) allocation))])))
(define update-bias-table
(lambda (uvar reg bt)
(map (lambda (entry)
(let ([tail (cdr entry)])
(if (memq uvar tail)
(begin
(set-cdr! entry (cons reg (remq uvar entry)))
entry)
entry))) bt)))
(define update-conflict-table
(lambda (uvar reg ct)
(map (lambda (entry)
(let ([tail (cdr entry)])
(if (memq uvar tail)
(begin
(set-cdr! entry (cons reg (remq uvar entry)))
entry)
entry))) ct)))
(define get-frame
(lambda (ls conflict-entry)
(cond
[(null? ls) #f]
[(and (frame-var? (car ls)) (not (memq (car ls) conflict-entry))) (car ls)]
[else (get-frame (cdr ls) conflict-entry)])))
(define assign-homes
(lambda (var* bt ct)
(cond
[(null? bt) '() ]
[(null? var*) '()]
[else (let* ([current-var (car var*)]
[bt-entry (assq current-var bt)]
[friend-list (cdr bt-entry)]
[conflict-entry (cdr (assq current-var ct))])
(if (null? friend-list)
(assign-homes (cdr var*) bt ct)
(let ([friend-frame (get-frame friend-list conflict-entry)])
(cond
[(eq? friend-frame #f) (assign-homes (cdr var*) bt ct)]
[else (let ([updated-ct (update-conflict-table current-var friend-frame ct)]
[updated-bt (update-bias-table current-var friend-frame bt)])
(cons (list current-var friend-frame) (assign-homes (cdr var*) updated-bt updated-ct)))]))))])))
(define find-used
(lambda (conflict* home*)
(cond
[(null? conflict*) '()]
[(frame-var? (car conflict*))
(set-cons (car conflict*) (find-used (cdr conflict*) home*))]
[(assq (car conflict*) home*) =>
(lambda (x) (set-cons (cadr x) (find-used (cdr conflict*) home*)))]
[else (find-used (cdr conflict*) home*)])))
(define find-frame-var
(lambda (used*)
(let f ([index 0])
(let ([fv (index->frame-var index)])
(if (memq fv used*) (f (+ index 1)) fv)))))
(define find-homes
(lambda (var* ct home*)
(if (null? var*)
home*
(let ([var (car var*)] [var* (cdr var*)])
(let ([conflict* (cdr (assq var ct))])
(let ([home (find-frame-var (find-used conflict* home*))])
(find-homes var* ct `((,var ,home) . ,home*))))))))
(define Body
(lambda (body)
(match body
[(locals (,local* ...)
(ulocals (,ulocal* ...)
(spills (,spill* ...)
(locate (,home* ...)
(frame-conflict ,ct ,tail)))))
(let* ( [uvar* (union ulocal* local* spill*)]
[bias-list (move-bias tail frame-var? uvar*)]
[biased-home* (assign-homes spill* bias-list ct)]
[home (if (null? biased-home*) '() (map car biased-home*))]
[new-ct (if (null? biased-home*) ct (replace biased-home* ct))]
[home* (find-homes (difference spill* home) ct home*)])
`(locals (,local* ...)
(ulocals (,ulocal* ...)
(locate (,biased-home* ... ,home* ...)
(frame-conflict ,ct ,tail)))))]
[(locate (,home* ...) ,body) `(locate (,home* ...) ,body)]
[,body (error who "invalid Body ~s" body)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> body*])] ...) ,[Body -> body])
`(letrec ([,label* (lambda () ,body*)] ...) ,body)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;; mref and mset! are allowed to go as they are, as they are not affected by what this pass does
(define-who discard-call-live
(define Tail
(lambda (tail)
(match tail
[(begin ,[Effect -> ef*] ... ,[Tail -> tail]) `(begin ,ef* ... ,tail)]
[(if ,[Pred -> test] ,[Tail -> conseq] ,[Tail -> altern]) `(if ,test ,conseq ,altern)]
[(,t ,live* ...) `(,t)]
[,tail (error who "invalid Tail ~s" tail)])))
(define Pred
(lambda (pr)
(match pr
[(true) '(true)]
[(false) '(false)]
[(if ,[Pred -> test] ,[Pred -> conseq] ,[Pred -> altern]) `(if ,test ,conseq ,altern)]
[(begin ,[Effect -> ef*] ... ,[Pred -> pr]) `(begin ,ef* ... ,pr)]
[(,predop ,x ,y) `(,predop ,x ,y)]
[,pr (error who "invalid Pred ~s" pr)])))
(define Effect
(lambda (ef)
(match ef
[(nop) '(nop)]
[(set! ,x ,rhs) `(set! ,x ,rhs)]
[(mset! ,base ,offset ,value) ef]
[(begin ,[Effect -> ef*] ... ,[Effect -> ef]) `(begin ,ef* ... ,ef)]
[(if ,[Pred -> test] ,[Effect -> conseq] ,[Effect -> altern]) `(if ,test ,conseq ,altern)]
[(return-point ,rplab ,[Tail -> tail]) `(return-point ,rplab ,tail)]
[,ef (error who "invalid Effect ~s" ef)])))
(define Body
(lambda (bd)
(match bd
[(locate ([,uvar* ,loc*] ...) ,[Tail -> tail])
`(locate ([,uvar* ,loc*] ...) ,tail)]
[,bd (error who "invalid Body ~s" bd)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> bd*])] ...) ,[Body -> bd])
`(letrec ([,label* (lambda () ,bd*)] ...) ,bd)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;;finalize locations adds clauses for this weeks grammars and handles the mset! and mref clauses...If any of the arguments are assigned a frame-var
;;; or register it is assigned here
(define-who finalize-locations
(define Var
(lambda (env)
(lambda (v)
(if (uvar? v) (cdr (assq v env)) v))))
(define Triv
(lambda (env)
(lambda (t)
(if (uvar? t) (cdr (assq t env)) t))))
(define Pred
(lambda (env)
(lambda (pr)
(match pr
[(true) '(true)]
[(false) '(false)]
[(if ,[test] ,[conseq] ,[altern]) `(if ,test ,conseq ,altern)]
[(begin ,[(Effect env) -> ef*] ... ,[pr]) `(begin ,ef* ... ,pr)]
[(,predop ,[(Triv env) -> x] ,[(Triv env) -> y]) `(,predop ,x ,y)]
[,pr (error who "invalid Pred ~s" pr)]))))
(define Effect
(lambda (env)
(lambda (ef)
(match ef
[(nop) '(nop)]
[(set! ,[(Var env) -> x]
(,binop ,[(Triv env) -> y] ,[(Triv env) -> z]))
`(set! ,x (,binop ,y ,z))]
[(set! ,[(Var env) -> x] ,[(Triv env) -> y])
(if (eq? y x) `(nop) `(set! ,x ,y))]
[(mset! ,[(Var env) -> base] ,[(Var env) -> offset] ,[(Var env) -> val])
`(mset! ,base ,offset ,val)]
[(begin ,[ef] ,[ef*] ...) `(begin ,ef ,ef* ...)]
[(if ,[(Pred env) -> test] ,[conseq] ,[altern])
`(if ,test ,conseq ,altern)]
[(return-point ,rplab ,[(Tail env) -> tail])
`(return-point ,rplab ,tail)]
[,ef (error who "invalid Effect ~s" ef)]))))
(define Tail
(lambda (env)
(lambda (tail)
(match tail
[(begin ,[(Effect env) -> ef*] ... ,[tail]) `(begin ,ef* ... ,tail)]
[(if ,[(Pred env) -> test] ,[conseq] ,[altern])
`(if ,test ,conseq ,altern)]
[(,[(Triv env) -> t]) `(,t)]
[,tail (error who "invalid Tail ~s" tail)]))))
(define Body
(lambda (bd)
(match bd
[(locate ([,uvar* ,loc*] ...) ,tail) ((Tail (map cons uvar* loc*)) tail)]
[,bd (error who "invalid Body ~s" bd)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Body -> bd*])] ...) ,[Body -> bd])
`(letrec ([,label* (lambda () ,bd*)] ...) ,bd)]
[,x (error who "invalid Program ~s" x)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;The triv function checks to see if a frame var has been encountered and accordingly makes the displacement operand
;; To each function we pass the offset on return from a tail expression offset must be set to zero
;;; Finally we get rid of the mref and mset! expressions here
;;; (mset! x y z) means x[y] = z
;;; if x is assigned a register and y a int then I make a displacement operand
;;; if x and y are assigned registers then I make an index operands
;;; otherwise I simply swap x and y and make a displacement operand ditto while handling the mrefs
;;; otherwise the pass remains identical to last weeks pass
(define-who expose-frame-var
(define Triv
(lambda (fp-offset)
(lambda (t)
(if (frame-var? t)
(make-disp-opnd frame-pointer-register
(- (ash (frame-var->index t) align-shift) fp-offset))
t))))
(define Pred
(lambda (pr fp-offset)
(match pr
[(true) (values '(true) fp-offset)]
[(false) (values '(false) fp-offset)]
[(begin ,ef* ... ,pr)
(let-values ([(ef* fp-offset) (Effect* ef* fp-offset)])
(let-values ([(pr fp-offset) (Pred pr fp-offset)])
(values (make-begin `(,ef* ... ,pr)) fp-offset)))]
[(if ,test ,conseq ,altern)
(let-values ([(test fp-offset) (Pred test fp-offset)])
(let-values ([(conseq c-fp-offset) (Pred conseq fp-offset)]
[(altern a-fp-offset) (Pred altern fp-offset)])
(values `(if ,test ,conseq ,altern) c-fp-offset)))]
[(,predop ,[(Triv fp-offset) -> tr1] ,[(Triv fp-offset) -> tr2])
(values `(,predop ,tr1 ,tr2) fp-offset)]
[,pr (error who "invalid Pred ~s" pr)])))
(define Effect*
(lambda (ef* fp-offset)
(if (null? ef*)
(values '() fp-offset)
(let-values ([(ef fp-offset) (Effect (car ef*) fp-offset)])
(let-values ([(ef* fp-offset) (Effect* (cdr ef*) fp-offset)])
(values (cons ef ef*) fp-offset))))))
(define Effect
(lambda (st fp-offset)
(match st
[(nop) (values '(nop) fp-offset)]
[(mset! ,[(Triv fp-offset) -> base] ,[(Triv fp-offset) -> offset] ,[(Triv fp-offset) -> value])
(cond
[(and (int32? base) (register? offset)) (values `(set! ,(make-disp-opnd offset base) ,value) fp-offset)]
[(and (int32? offset) (register? base)) (values `(set! ,(make-disp-opnd base offset) ,value) fp-offset)]
[else (values `(set! ,(make-index-opnd base offset) ,value) fp-offset)])]
[(set! ,fp (+ ,fp ,n))
(guard (eq? fp frame-pointer-register))
(values st (+ fp-offset n))] ;;send the new offset as incoming offset + n
[(set! ,fp (- ,fp ,n))
(guard (eq? fp frame-pointer-register))
(values st (- fp-offset n))] ;;send the new offset as incoming offset - n
[ (set! ,[(Triv fp-offset) -> var]
(mref ,[(Triv fp-offset) -> t1] ,[(Triv fp-offset) -> t2]))
(cond
[(and (register? t1) (register? t2)) (values `(set! ,var ,(make-index-opnd t1 t2)) fp-offset)]
[(and (register? t1) (int32? t2)) (values `(set! ,var ,(make-disp-opnd t1 t2)) fp-offset)]
[(and (int32? t1) (register? t2)) (values `(set! ,var ,(make-disp-opnd t2 t1)) fp-offset)])]
[(set! ,[(Triv fp-offset) -> var]
(,binop ,[(Triv fp-offset) -> t1] ,[(Triv fp-offset) -> t2]))
(values `(set! ,var (,binop ,t1 ,t2)) fp-offset)]
[(set! ,[(Triv fp-offset) -> var] ,[(Triv fp-offset) -> t])
(values `(set! ,var ,t) fp-offset)]
[(begin ,ef* ... ,ef)
(let-values ([(ef* fp-offset) (Effect* ef* fp-offset)])
(let-values ([(ef fp-offset) (Effect ef fp-offset)])
(values (make-begin `(,ef* ... ,ef)) fp-offset)))]
[(if ,test ,conseq ,altern)
(let-values ([(test fp-offset) (Pred test fp-offset)])
(let-values ([(conseq c-fp-offset) (Effect conseq fp-offset)]
[(altern a-fp-offset) (Effect altern fp-offset)])
(values `(if ,test ,conseq ,altern) c-fp-offset)))]
[(return-point ,rplab ,[(Tail fp-offset) -> tail fp-offset]) ;; Process the tail expression, get the same offset and return it
(values `(return-point ,rplab ,tail) fp-offset)]
[,st (error who "invalid syntax for Effect ~s" st)])))
(define Tail
(lambda (fp-offset)
(lambda (tail)
(match tail
[(begin ,ef* ... ,tail)
(let-values ([(ef* fp-offset) (Effect* ef* fp-offset)])
(let-values ([(tl fp-offset) ((Tail fp-offset) tail)])
(values (make-begin `(,ef* ... ,tl)) fp-offset)))]
[(if ,test ,conseq ,altern)
(let-values ([(test fp-offset) (Pred test fp-offset)])
(let-values ([(conseq c-fp-offset) ((Tail fp-offset) conseq)]
[(altern a-fp-offset) ((Tail fp-offset) altern)])
(values `(if ,test ,conseq ,altern) c-fp-offset)))]
[(,[(Triv fp-offset) -> t]) (values `(,t) fp-offset)]
[,tail (error who "invalid syntax for Tail ~s" tail)]))))
(define Body
(lambda (x)
(let-values ([(x fp-offset) ((Tail 0) x)])
(unless (= fp-offset 0)
(error who "nonzero final fp-offset ~s" fp-offset))
x)))
(lambda (program)
(match program
[(letrec ([,label* (lambda () ,[Body -> body*])] ...) ,[Body -> body])
`(letrec ([,label* (lambda () ,body*)] ...) ,body)]
[,program (error who "invalid syntax for Program: ~s" program)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;; Doesnot change from previous assignment
(define-who expose-basic-blocks
(define Tail
(lambda (x)
(match x
[(if ,pred ,[conseq cb*] ,[altern ab*])
(let ([clab (unique-label 'c)] [alab (unique-label 'a)])
(let-values ([(tail xb*) (Pred pred clab alab)])
(values tail
`(,xb* ...
[,clab (lambda () ,conseq)]
[,alab (lambda () ,altern)]
,cb* ...
,ab* ...))))]
[(begin ,effect* ... ,[tail tb*])
(let-values ([(expr eb*) (Effect* effect* `(,tail))])
(values expr `(,eb* ... ,tb* ...)))]
[(,triv) (values `(,triv) '())]
[,x (error who "invalid Tail ~s" x)])))
(define (Pred x tlab flab)
(match x
[(true) (values `(,tlab) '())]
[(false) (values `(,flab) '())]
[(if ,pred ,[conseq cb*] ,[altern ab*])
(let ([clab (unique-label 'c)] [alab (unique-label 'a)])
(let-values ([(expr xb*) (Pred pred clab alab)])
(values expr
`(,xb* ...
[,clab (lambda () ,conseq)]
[,alab (lambda () ,altern)]
,cb* ...
,ab* ...))))]
[(begin ,effect* ... ,[expr xb*])
(let-values ([(expr eb*) (Effect* effect* `(,expr))])
(values expr `(,eb* ... ,xb* ...)))]
[(,relop ,triv1 ,triv2)
(values `(if (,relop ,triv1 ,triv2) (,tlab) (,flab)) '())]
[,x (error who "invalid Tail ~s" x)]))
(define (Effect* x* rest*)
(match x*
[() (values (make-begin rest*) '())]
[(,x* ... ,x) (Effect x* x rest*)]))
(define Effect
(lambda (x* x rest*)
(match x
[(nop) (Effect* x* rest*)]
[(set! ,lhs ,rhs) (Effect* x* `((set! ,lhs ,rhs) ,rest* ...))]
[(if ,pred ,conseq ,altern)
(let ([clab (unique-label 'c)]
[alab (unique-label 'a)]
[jlab (unique-label 'j)])
(let-values ([(conseq cb*) (Effect '() conseq `((,jlab)))]
[(altern ab*) (Effect '() altern `((,jlab)))]
[(expr xb*) (Pred pred clab alab)])
(let-values ([(expr eb*) (Effect* x* `(,expr))])
(values expr
`(,eb* ...
,xb* ...
[,clab (lambda () ,conseq)]
[,alab (lambda () ,altern)]
[,jlab (lambda () ,(make-begin rest*))]
,cb* ...
,ab* ...)))))]
[(begin ,effect* ...) (Effect* `(,x* ... ,effect* ...) rest*)]
[(return-point ,rplab ,tail)
(let*-values ([(tail tail-label*) (Tail tail)] [(ef* ef-label*) (Effect* x* (cdr tail))])
(values (make-begin `(,ef*))
`(,ef-label* ... ,tail-label* ... [,rplab (lambda () ,(make-begin rest*))])))]
[,x (error who "invalid Effect ~s" x)])))
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,[Tail -> tail* b**])] ...) ,[Tail -> tail b*])
`(letrec ([,label* (lambda () ,tail*)] ... ,b** ... ... ,b* ...) ,tail)]
[,x (error who "invalid Program ~s" x)])))
;(optimize-jumps `(letrec ([,label* (lambda () ,tail*)] ... ,b** ... ... ,b* ...) ,tail))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;; Doesnot change from previous assignment
(define flatten-program
(lambda (prog)
(define build-exp
(lambda (label* tail*)
(match label*
[() '()]
[(,current ,rest* ...)
(let ((current-exp (append (list current) (Tail rest* (car tail*)))))
(append current-exp (build-exp rest* (cdr tail*))))])))
(define Prog
(lambda (x)
(match x
[(letrec ([,label* (lambda () ,tail*)] ...) ,tail)
(let ((tail-exp (Tail label* tail)) (rest-of-exp (build-exp label* tail*)))
(append '(code) tail-exp rest-of-exp))])))
(define Tail
(lambda (label* x)
(match x
[(if ,pred (,conseq) (,alt))
(if (null? label*) `((if ,pred (jump ,conseq)) (jump ,alt))
(let ((next-label (car label*)))
(cond
[(eq? next-label conseq) `((if (not ,pred) (jump ,alt)))]
[(eq? next-label alt) `((if ,pred (jump ,conseq)))]
[else `((if ,pred (jump ,conseq)) (jump ,alt))])))]
[(begin ,effect* ...,tail) (append effect* (Tail label* tail))]
[(,triv) `((jump ,triv))])))
(Prog prog)))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;; Doesnot change from previous assignment
(define-who generate-x86-64
(lambda (x)
(define Program
(lambda (x)
(match x
[(code ,st* ...)
(emit-program (for-each Stmt st*))])))
(define Stmt
(lambda (x)
(match x
[(jump ,target) (emit-jump 'jmp target)]
[(if (,op ,x ,y) (jump ,lbl)) (begin (emit 'cmpq y x) (emit-jump (op->inst op) lbl))]
[(if (not (,op ,x ,y)) (jump ,lbl)) (begin (emit 'cmpq y x) (emit-jump (inst->inst^ (op->inst op)) lbl))]
[(set! ,v1 (,op ,v1 ,v2)) (emit (op->inst op) v2 v1)]
[(set! ,v1 ,v2) (guard (label? v2)) (emit 'leaq v2 v1)]
[(set! ,v1 ,v2) (emit 'movq v2 v1)]
[,label (emit-label label)])))
(Program x)))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
(define op->inst
(lambda (op)
(case op
[(+) 'addq]
[(-) 'subq]
[(*) 'imulq]
[(logand) 'andq]
[(logor) 'orq]
[(sra) 'sarq]
[(=) 'je]
[(<) 'jl]
[(<=) 'jle]
[(>) 'jg]
[(>=) 'jge]
[else (error who "unexpected binop ~s" op)])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
(define inst->inst^
(lambda (inst)
(case inst
[(je) 'jne]
[(jl) 'jge]
[(jle) 'jg]
[(jg) 'jle]
[(jge) 'jl]
)))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
(define relop^
(lambda (op)
(case op
['> '<]
['< '>]
['<= '>=]
['= '=])))
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
;;--------------------------------------------------------------------------------------------------------------------------------------------------------
(define enable-optimize-self-reference #f) ;;; set only if optimize-known-call is not called
(define move-bias-enabled #f)
(compiler-passes '(
parse-scheme
convert-complex-datum
uncover-assigned
purify-letrec
convert-assignments
;optimize-direct-call ;;; optimization
remove-anonymous-lambda
sanitize-binding-forms
uncover-free
convert-closures
;optimize-known-call ;;; optimization
;optimize-self-reference ;;; optimization
introduce-procedure-primitives
lift-letrec
normalize-context
specify-representation
uncover-locals
remove-let
verify-uil
remove-complex-opera*
flatten-set!
impose-calling-conventions
uncover-frame-conflict
pre-assign-frame
assign-new-frame
(iterate
finalize-frame-locations
select-instructions
uncover-register-conflict
assign-registers
(break when everybody-home?)
assign-frame)
discard-call-live
finalize-locations
expose-frame-var
expose-basic-blocks
flatten-program
generate-x86-64
))
| false |
8b768594bd1f155fbfd6bfab821e35d03ce4dff7
|
0855447c3321a493efa9861b3713209e37c03a4c
|
/g-point/ffi/encrypt.ss
|
20fa20121770a39c89c2a6e2dac11142b4343235
|
[] |
no_license
|
dasheng523/sicp
|
d04f30c50076f36928728ad2fe0da392dd0ae414
|
1c40c01e16853ad83b8b82130c2c95a5533875fe
|
refs/heads/master
| 2021-06-16T20:15:08.281249 | 2021-04-02T04:09:01 | 2021-04-02T04:09:01 | 190,505,284 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 483 |
ss
|
encrypt.ss
|
(library (ffi encrypt)
(export sha1-ffi SHA_DIGEST_LENGTH
md5-ffi MD5_DIGEST_LENGTH)
(import (ffi ffi-utils)
(chezscheme))
(define _init
(load-shared-object (string-append "libssl" (machine-lib-suffix))))
(define sha1-ffi
(foreign-procedure
"SHA1"
(string int u8*)
int))
(define md5-ffi
(foreign-procedure
"MD5"
(string int u8*)
int))
(define SHA_DIGEST_LENGTH 20)
(define MD5_DIGEST_LENGTH 16)
)
| false |
dcad934c7a1e19db4345086041dd72a492511793
|
defeada37d39bca09ef76f66f38683754c0a6aa0
|
/System/system/net/http-listener-response.sls
|
926d87a0fce30634bc5db5351ef74b94f95b4eaf
|
[] |
no_license
|
futsuki/ironscheme-port
|
2dbac82c0bda4f4ff509208f7f00a5211d1f7cd5
|
4e7a81b0fbeac9a47440464988e53fb118286c54
|
refs/heads/master
| 2016-09-06T17:13:11.462593 | 2015-09-26T18:20:40 | 2015-09-26T18:20:40 | 42,757,369 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 4,632 |
sls
|
http-listener-response.sls
|
(library (system net http-listener-response)
(export is?
http-listener-response?
set-cookie
redirect
add-header
append-cookie
append-header
abort
copy-from
close
content-encoding-get
content-encoding-set!
content-encoding-update!
content-length64-get
content-length64-set!
content-length64-update!
content-type-get
content-type-set!
content-type-update!
cookies-get
cookies-set!
cookies-update!
headers-get
headers-set!
headers-update!
keep-alive?-get
keep-alive?-set!
keep-alive?-update!
output-stream
protocol-version-get
protocol-version-set!
protocol-version-update!
redirect-location-get
redirect-location-set!
redirect-location-update!
send-chunked?-get
send-chunked?-set!
send-chunked?-update!
status-code-get
status-code-set!
status-code-update!
status-description-get
status-description-set!
status-description-update!)
(import (ironscheme-clr-port))
(define (is? a) (clr-is System.Net.HttpListenerResponse a))
(define (http-listener-response? a)
(clr-is System.Net.HttpListenerResponse a))
(define-method-port
set-cookie
System.Net.HttpListenerResponse
SetCookie
(System.Void System.Net.Cookie))
(define-method-port
redirect
System.Net.HttpListenerResponse
Redirect
(System.Void System.String))
(define-method-port
add-header
System.Net.HttpListenerResponse
AddHeader
(System.Void System.String System.String))
(define-method-port
append-cookie
System.Net.HttpListenerResponse
AppendCookie
(System.Void System.Net.Cookie))
(define-method-port
append-header
System.Net.HttpListenerResponse
AppendHeader
(System.Void System.String System.String))
(define-method-port
abort
System.Net.HttpListenerResponse
Abort
(System.Void))
(define-method-port
copy-from
System.Net.HttpListenerResponse
CopyFrom
(System.Void System.Net.HttpListenerResponse))
(define-method-port
close
System.Net.HttpListenerResponse
Close
(System.Void System.Byte[] System.Boolean)
(System.Void))
(define-field-port
content-encoding-get
content-encoding-set!
content-encoding-update!
(property:)
System.Net.HttpListenerResponse
ContentEncoding
System.Text.Encoding)
(define-field-port
content-length64-get
content-length64-set!
content-length64-update!
(property:)
System.Net.HttpListenerResponse
ContentLength64
System.Int64)
(define-field-port
content-type-get
content-type-set!
content-type-update!
(property:)
System.Net.HttpListenerResponse
ContentType
System.String)
(define-field-port
cookies-get
cookies-set!
cookies-update!
(property:)
System.Net.HttpListenerResponse
Cookies
System.Net.CookieCollection)
(define-field-port
headers-get
headers-set!
headers-update!
(property:)
System.Net.HttpListenerResponse
Headers
System.Net.WebHeaderCollection)
(define-field-port
keep-alive?-get
keep-alive?-set!
keep-alive?-update!
(property:)
System.Net.HttpListenerResponse
KeepAlive
System.Boolean)
(define-field-port
output-stream
#f
#f
(property:)
System.Net.HttpListenerResponse
OutputStream
System.IO.Stream)
(define-field-port
protocol-version-get
protocol-version-set!
protocol-version-update!
(property:)
System.Net.HttpListenerResponse
ProtocolVersion
System.Version)
(define-field-port
redirect-location-get
redirect-location-set!
redirect-location-update!
(property:)
System.Net.HttpListenerResponse
RedirectLocation
System.String)
(define-field-port
send-chunked?-get
send-chunked?-set!
send-chunked?-update!
(property:)
System.Net.HttpListenerResponse
SendChunked
System.Boolean)
(define-field-port
status-code-get
status-code-set!
status-code-update!
(property:)
System.Net.HttpListenerResponse
StatusCode
System.Int32)
(define-field-port
status-description-get
status-description-set!
status-description-update!
(property:)
System.Net.HttpListenerResponse
StatusDescription
System.String))
| false |
bd822ca91c8c30e3b42baf520ec66c497aa50e0e
|
87b5179843c54c7f755476e0e3fd4597a3319fef
|
/interpret.scm
|
b1287c14e545cd8a8cad0b2d8181bdf1133afcaf
|
[] |
no_license
|
Marti2203/Guile-SiCP
|
cd87186cce4b1ba471fbab2d6d66af903785129c
|
bf511564eb3db7407baf6e6ab8867de3b94bcc47
|
refs/heads/master
| 2021-01-19T21:21:47.998024 | 2017-07-24T12:59:21 | 2017-07-24T12:59:21 | 88,643,407 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 8,247 |
scm
|
interpret.scm
|
(define (square x) (* x x))
(define (cube x) (* x x x))
(define (require p) (if (not p) (amb)))
(define (for-each proc items) (if (null? items) 'done (begin (proc (car items)) (for-each proc (cdr items)))))
;(define (cons x y) (lambda (m) 12 (m x y))) ; C(hex)=12(dec)
;(define (car z) (z (lambda (p q) p)) )
;(define (cdr z) (z (lambda (p q) q)))
(define (list-ref items n) (if (= n 0) (car items) (list-ref (cdr items) (- n 1))))
(define (map proc items) (if (null? items) '() (cons (proc (car items)) (map proc (cdr items)))))
(define (filter proc items) (if (null? items) '() (if (proc (car items)) (cons (car items) (filter proc (cdr items))) (filter proc (cdr items)))))
(define (scale-list items factor) (map (lambda (x) (* x factor)) items))
(define (add-lists list1 list2) (cond ((null? list1) list2) ((null? list2) list1) (else (cons (+ (car list1) (car list2)) (add-lists (cdr list1) (cdr list2))))))
;(define ones (cons 1 ones))
;(define integers (cons 1 (add-lists ones integers)))
;(define (integral integrand initial-value dt)(define int (cons initial-value (add-lists (scale-list integrand dt) int))) int)
;(define (solve f y0 dt)(define y (integral dy y0 dt))(define dy (map f y)) y)
(define (an-integer-starting-from n)
(amb n (an-integer-starting-from (+ n 1))))
(define (an-integer-between low high) (let ((a (an-integer-starting-from low))) (require (< a high)) a))
(define (an-element-of items)
(require (not (null? items)))
(amb (car items) (an-element-of (cdr items))))
(define (a-random-element-of l)
(require (not (null? l)))
(ramb (car l) (a-random-element-of (cdr l))))
(define (prime-sum-pair list1 list2)
(let ((a (an-element-of list1))
(b (an-element-of list2)))
(require (prime? (+ a b)))
(list a b)))
(define (a-pythagorean-triple-between low high)
(let ((i (an-integer-between low high)))
(let ((j (an-integer-between i high)))
(let ((k (an-integer-between j high)))
(require (and (< k (+ i j)) (= (+ (* i i) (* j j)) (* k k))))
(list i j k)))))
(define (a-pythagorean-triple-all)
(let ((i (an-integer-starting-from 2)))
(let ((j (an-integer-between 1 i)))
(let ((k (an-integer-between i (+ i j))))
(require (= (+ (* i i) (* j j)) (* k k)))
(list i j k)))))
(define (a-pythagorean-triple-between-Ben low high)
(let ((i (an-integer-between low high))
(hsq (* high high)))
(let ((j (an-integer-between i high)))
(let ((ksq (+ (* i i) (* j j))))
(require (>= hsq ksq))
(let ((k (sqrt ksq)))
(require (integer? k))
(list i j k))))))
(define (distinct? items)
(cond ((null? items) true)
((null? (cdr items)) true)
((member (car items) (cdr items)) false)
(else (distinct? (cdr items)))))
(define (multiple-dwelling)
(let ((baker (amb 1 2 3 4 5))
(cooper (amb 1 2 3 4 5))
(fletcher (amb 1 2 3 4 5))
(miller (amb 1 2 3 4 5))
(smith (amb 1 2 3 4 5)))
(require
(distinct? (list baker cooper fletcher miller smith)))
(require (not (= baker 5)))
(require (not (= cooper 1)))
(require (not (= fletcher 5)))
(require (not (= fletcher 1)))
(require (> miller cooper))
(require (not (= (abs (- smith fletcher)) 1)))
(require (not (= (abs (- fletcher cooper)) 1)))
(list (list 'baker baker)
(list 'cooper cooper)
(list 'fletcher fletcher)
(list 'miller miller)
(list 'smith smith))))
(define (multiple-dwelling-asmith)
(let ((baker (amb 1 2 3 4 5))
(cooper (amb 1 2 3 4 5))
(fletcher (amb 1 2 3 4 5))
(miller (amb 1 2 3 4 5))
(smith (amb 1 2 3 4 5)))
(require
(distinct? (list baker cooper fletcher miller smith)))
(require (not (= baker 5)))
(require (not (= cooper 1)))
(require (not (= fletcher 5)))
(require (not (= fletcher 1)))
(require (> miller cooper))
(require (not (= (abs (- fletcher cooper)) 1)))
(list (list 'baker baker)
(list 'cooper cooper)
(list 'fletcher fletcher)
(list 'miller miller)
(list 'smith smith))))
(define (multiple-dwelling-fast)
(let (
(fletcher (amb 2 4))
(baker (amb 1 2 3 4))
(miller (amb 3 4 5))
(cooper (amb 2 3 4))
(smith (amb 1 2 3 4 5)))
(require
(distinct? (list baker cooper fletcher miller smith)))
(require (> miller cooper))
(require (not (= (abs (- smith fletcher)) 1)))
(require (not (= (abs (- fletcher cooper)) 1)))
(list (list 'baker baker)
(list 'cooper cooper)
(list 'fletcher fletcher)
(list 'miller miller)
(list 'smith smith))))
(define adjectives '(adjective big old orange huge fat boring))
(define adverbs '(adverb slowly fast loudly lightly))
(define nouns '(noun student professor cat class))
(define verbs '(verb studies lectures eats sleeps))
(define articles '(article the a))
(define prepositions '(prep for to in by with))
(define connectors '(connector and or while but whereas))
(define (parse-word word-list)
(require (not (null? *unparsed*)))
(require (memq (car *unparsed*) (cdr word-list)))
(let ((found-word (car *unparsed*)))
(set! *unparsed* (cdr *unparsed*))
(list (car word-list) found-word)))
(define (parse-prepositional-phrase)
(list 'prep-phrase
(parse-word prepositions)
(parse-noun-phrase)))
(define (parse-sentence)
(list 'sentence
(parse-noun-phrase)
(parse-verb-phrase)))
(define (parse-simple-noun-phrase)
(define (loop input)
(amb (loop (list input (parse-word adjectives)))
input))
(list 'noun-phrase
(parse-word articles)
(amb (list 'adjective-phrase (loop (parse-word adjectives)) (parse-word nouns))
(parse-word nouns))))
;for a noun - preposition adjectives noun
(define (parse-noun-phrase)
(define (maybe-extend noun-phrase)
(amb noun-phrase
(maybe-extend (list 'noun-phrase
noun-phrase
(parse-prepositional-phrase)))))
(maybe-extend (parse-simple-noun-phrase)))
(define (parse-simple-verb-phrase)
(amb (list 'verb-phrase
(parse-word adverbs)
(parse-word verbs))
(parse-word verbs)))
(define (parse-verb-phrase)
(define (maybe-extend verb-phrase)
(amb verb-phrase
(maybe-extend (list 'verb-phrase
verb-phrase
(parse-prepositional-phrase)))))
(maybe-extend (parse-simple-verb-phrase)))
(define (parse-compound-sentence)
(define (maybe-extend-sentence sentence)
(amb
(maybe-extend-sentence (list 'compound-sentence
sentence
(parse-word connectors)
(parse-sentence)))
sentence))
(maybe-extend-sentence (parse-sentence)))
(define *unparsed* '())
(define (parse input) (set! *unparsed* input)
(let ((sent (parse-sentence))) (require (null? *unparsed*)) sent))
(define (parse-compound input) (set! *unparsed* input)
(let ((sent (parse-compound-sentence))) (require (null? *unparsed*)) sent))
(define (generate-word word-list) (a-random-element-of (cdr word-list)))
(define (generate-prepositional-phrase)
(list (generate-word prepositions)
(generate-noun-phrase)))
(define (generate-sentence)
(list (generate-noun-phrase)
(generate-verb-phrase)))
(define (generate-compound-sentence)
(define (maybe-extend-sentence sentence)
(ramb sentence
(maybe-extend-sentence
(list
sentence
(generate-word connectors)
(generate-sentence)))))
(maybe-extend-sentence (generate-sentence)))
(define (generate-verb-phrase)
(define (generate-adverbs-verb-phrase)
(ramb (list (generate-word adverbs)
(generate-word verbs))
(generate-word verbs)))
(define (maybe-extend-prepositions verb-phrase)
(ramb verb-phrase
(maybe-extend-prepositions (list verb-phrase
(generate-prepositional-phrase)))))
(maybe-extend-prepositions (generate-adverbs-verb-phrase)))
(define (generate-noun-phrase)
(define (maybe-extend-adjectives input)
(ramb (list input (generate-word adjectives))
input))
(list (maybe-extend-adjectives (generate-word articles))
(generate-word nouns)))
(define (work-test-permanent-set)
(define count 0)
(let ((x (an-element-of '(a b c)))
(y (an-element-of '(a b c))))
(permanent-set! count (+ count 1))
(require (not (eq? x y)))
(list x y count)))
(define (work-test-if-fail)
(let ((pairs '()))
(if-fail (let ((p (prime-sum-pair '(1 3 5 8) '(20 35 110))))
(permanent-set! pairs (cons p pairs))
(amb))
pairs)))
| false |
2add1d17c5ee8456fb4bbd7efd556d3f2d251624
|
8a0660bd8d588f94aa429050bb8d32c9cd4290d5
|
/sitelib/rfc/base64.scm
|
43215ba0657f8111187bef3e5e7d565fe6e89bcb
|
[
"BSD-2-Clause"
] |
permissive
|
david135/sagittarius-scheme
|
dbec76f6b227f79713169985fc16ce763c889472
|
2fbd9d153c82e2aa342bfddd59ed54d43c5a7506
|
refs/heads/master
| 2016-09-02T02:44:31.668025 | 2013-12-21T07:24:08 | 2013-12-21T07:24:08 | 32,497,456 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 6,455 |
scm
|
base64.scm
|
;;; -*- Scheme -*-
;;;
;;; base64.scm - base64 encoding/decoding routine
;;;
;;; Copyright (c) 2010-2012 Takashi Kato <[email protected]>
;;;
;;; Redistribution and use in source and binary forms, with or without
;;; modification, are permitted provided that the following conditions
;;; are met:
;;;
;;; 1. Redistributions of source code must retain the above copyright
;;; notice, this list of conditions and the following disclaimer.
;;;
;;; 2. Redistributions in binary form must reproduce the above copyright
;;; notice, this list of conditions and the following disclaimer in the
;;; documentation and/or other materials provided with the distribution.
;;;
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;
#!compatible
(library (rfc base64)
(export base64-encode base64-encode-string
base64-decode base64-decode-string)
(import (rnrs) (rnrs r5rs)
(sagittarius)
(sagittarius control))
(define *decode-table*
;; ! " # $ % & ' ( ) * + , - . /
#(#f #f #f #f #f #f #f #f #f #f #f 62 #f #f #f 63
;;0 1 2 3 4 5 6 7 8 9 : ; < = > ?
52 53 54 55 56 57 58 59 60 61 #f #f #f #f #f #f
;;@ A B C D E F G H I J K L M N O
#f 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
;;P Q R S T U V W X Y Z [ \ ] ^ _
15 16 17 18 19 20 21 22 23 24 25 #f #f #f #f #f
;;` a b c d e f g h i j k l m n o
#f 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
;;p q r s t u v w x y z { | } ~
41 42 43 44 45 46 47 48 49 50 51 #f #f #f #f #f
))
(define *encode-table*
;;0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#(#\A #\B #\C #\D #\E #\F #\G #\H #\I #\J #\K #\L #\M #\N #\O #\P
;;16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#\Q #\R #\S #\T #\U #\V #\W #\X #\Y #\Z #\a #\b #\c #\d #\e #\f
;;32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#\g #\h #\i #\j #\k #\l #\m #\n #\o #\p #\q #\r #\s #\t #\u #\v
;;48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
#\w #\x #\y #\z #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\+ #\/
;;pad
#\=
))
(define (base64-decode-string string
:key (transcoder (make-transcoder
(utf-8-codec) 'none)))
(or (string? string)
(assertion-violation 'base64-decode-string
(format "string required, but got ~s" string)
string))
(let ((bv (base64-decode (string->utf8 string))))
(if transcoder
(bytevector->string bv transcoder)
bv)))
(define (base64-decode in)
(if (bytevector? in)
(base64-decode (open-bytevector-input-port in))
(call-with-bytevector-output-port
(lambda (out)
(base64-decode-impl in out)))))
(define (base64-decode-impl in out)
(let-syntax ((lookup (syntax-rules ()
((_ b)
(and (< 32 b 128)
(vector-ref *decode-table* (- b 32)))))))
(define (d0 b)
(cond ((eof-object? b))
((= b #x1d)) ;; =
((lookup b) => (lambda (v) (d1 (get-u8 in) v)))
(else (d0 (get-u8 in)))))
(define (d1 b hi)
(cond ((eof-object? b))
((= b #x1d)) ;; =
((lookup b) => (lambda (lo)
(put-u8 out (+ (* hi 4) (quotient lo 16)))
(d2 (get-u8 in) (modulo lo 16))))
(else (d1 (get-u8 in) hi))))
(define (d2 b hi)
(cond ((eof-object? b))
((= b #x1d)) ;; =
((lookup b) => (lambda (lo)
(put-u8 out (+ (* hi 16) (quotient lo 4)))
(d3 (get-u8 in) (modulo lo 4))))
(else (d2 (get-u8 in) hi))))
(define (d3 b hi)
(cond ((eof-object? b))
((= b #x1d)) ;; =
((lookup b) => (lambda (lo)
(put-u8 out (+ (* hi 64) lo))
(d0 (get-u8 in))))
(else (d2 (get-u8 in) hi))))
(d0 (get-u8 in))))
(define (base64-encode-string string :key
(transcoder (make-transcoder
(utf-8-codec) 'none))
(line-width 76))
(or (string? string)
(assertion-violation 'base64-encode-string
(format "string required, but got ~s" string)
string))
(utf8->string
(base64-encode (string->bytevector string transcoder)
:line-width line-width)))
(define (base64-encode in :key (line-width 76))
(if (bytevector? in)
(base64-encode (open-bytevector-input-port in) :line-width line-width)
(call-with-bytevector-output-port
(lambda (out)
(base64-encode-impl in out line-width)))))
(define (base64-encode-impl in out line-width)
(define max-col (and line-width
(> line-width 0)
(- line-width 1)))
(letrec-syntax ((emit* (syntax-rules ()
((_ col) col)
((_ col idx idx2 ...)
(begin
(put-u8 out (char->integer (vector-ref *encode-table* idx)))
(let ((col2 (cond ((eqv? col max-col)
(put-u8 out #x0a) 0) ;; newline
(else (+ col 1)))))
(emit* col2 idx2 ...)))))))
(define (e0 c col)
(cond ((eof-object? c))
(else
(e1 (get-u8 in) (modulo c 4) (emit* col (quotient c 4))))))
(define (e1 c hi col)
(cond ((eof-object? c)
(emit* col (* hi 16) 64 64))
(else
(e2 (get-u8 in) (modulo c 16)
(emit* col (+ (* hi 16) (quotient c 16)))))))
(define (e2 c hi col)
(cond ((eof-object? c)
(emit* col (* hi 4) 64))
(else
(e0 (get-u8 in)
(emit* col (+ (* hi 4) (quotient c 64)) (modulo c 64))))))
(e0 (get-u8 in) 0)))
)
| false |
d8f0f7c5dd832791924962c46358a543ee774e1c
|
ec0f122fdcf4ceaf5e9e183575a460006c19ebe0
|
/src/misc/ktr
|
310b879b17f77376c0f9abba216f6161b866efe1
|
[] |
no_license
|
ThomasHintz/keep-the-records
|
d96e6253ebc3d2e11ee37277a6293c7365b25f9b
|
c20e648e831bed2ced3f2f74bfc590dc06b5f076
|
refs/heads/master
| 2021-01-13T02:37:41.053488 | 2013-07-19T04:18:44 | 2013-07-19T04:18:44 | 1,272,038 | 2 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 210 |
ktr
|
#!/usr/local/bin/csi -script
;; -*- scheme -*-
(declare (uses chicken-syntax))
(use awful spiffy)
(trusted-proxies '("127.0.0.1"))
(awful-start
(lambda ()
(load-apps '("keep-the-records")))
port: 12000)
| false |
|
f327d942b5d31294339f96c00e02f7c77682ba56
|
4f30ba37cfe5ec9f5defe52a29e879cf92f183ee
|
/src/tests/badsslo.scm
|
1b00e90b81d58b44d9993fa64989fba776e65227
|
[
"MIT"
] |
permissive
|
rtrusso/scp
|
e31ecae62adb372b0886909c8108d109407bcd62
|
d647639ecb8e5a87c0a31a7c9d4b6a26208fbc53
|
refs/heads/master
| 2021-07-20T00:46:52.889648 | 2021-06-14T00:31:07 | 2021-06-14T00:31:07 | 167,993,024 | 8 | 1 |
MIT
| 2021-06-14T00:31:07 | 2019-01-28T16:17:18 |
Scheme
|
UTF-8
|
Scheme
| false | false | 77 |
scm
|
badsslo.scm
|
(define x (make-string 3 #\a))
(display (string-set! x -1 #\b))
(newline)
| false |
5935718188f342968f9e911fb1fbbaf795a2b58a
|
5c4964460d5d9fcb190a35457ace51ab914ef3ff
|
/section-4.1.6.scm
|
045964eeac90329d816ef7a2e6117c0c55295383
|
[] |
no_license
|
lmcchun/sicp-solutions
|
0636333c65cfba35197c9c4939977d5bb0117aed
|
3beb68aeeb3b1cabb7b55a27fd67a289693a64f1
|
refs/heads/master
| 2021-01-17T19:08:49.028304 | 2016-06-12T16:11:20 | 2016-06-12T16:11:20 | 60,976,032 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,648 |
scm
|
section-4.1.6.scm
|
; ex 4.17
(define (lookup-variable-value var env)
(define (env-loop env)
(define (scan vars vals)
(cond ((null? vars)
(env-loop (enclosing-environment env)))
((eq? var (car vars))
(car vals))
(else (scan (cdr vars) (cdr vals)))))
(if (eq? env the-empty-environment)
(error "Unbound variable" var)
(let ((frame (first-frame env)))
(let ((val
(scan (frame-variables frame)
(frame-values frame))))
(if (eq? val '*unassigned*)
(error "Using an unassigned variable" var)
val)))))
(env-loop env))
(define (get-defines-and-non-defines sexp)
(letrec ((iter
(lambda (sexp defines non-defines)
(if (null? sexp)
(cons defines non-defines)
(let ((head (car sexp))
(rest (cdr sexp)))
(if (definition? head)
(iter rest (cons head defines) non-defines)
(iter rest defines (cons head non-defines))))))))
(iter sexp '() '())))
(define (reverse-list list)
(letrec ((iter
(lambda (list acc)
(if (null? list)
acc
(iter (cdr list)
(cons (car list) acc))))))
(iter list '())))
(define (scan-out-defines original-body)
(let ((defines-and-non-defines
(get-defines-and-non-defines original-body)))
(let ((defines (car defines-and-non-defines))
(non-defines (cdr defines-and-non-defines)))
(let ((make-body
(lambda (defines initforms body)
(if (null? defines)
(make-let initforms body)
(let ((head (car defines)))
(let ((name (definition-variable head))
(value (definition-value head)))
(make-body (cdr defines)
(cons (list name (quote '*unassigned*)) initforms)
(cons (list 'set! name value) body))))))))
(make-body defines '() (reverse-list non-defines))))))
(define (make-procedure parameters body env)
(list 'procedure parameters (scan-out-defines body) env))
; ex 4.20
(define (letrec? exp)
(tagged-list? exp 'letrec))
(define (letrec->let exp)
(let ((initforms (let-inits exp))
(body (let-body exp)))
(make-let
(map (lambda (initform)
(list (car initform)
(quote '*unassigned*)))
initforms)
(append
(map (lambda (initform)
(list 'set! (car initform) (cadr initform)))
initforms)
body))))
; ex 4.21
(define fib
(lambda (n)
((lambda (fib)
(fib fib n))
(lambda (f k)
(if (= k 1)
1
(if (= k 2)
1
(+ (f f (- k 1))
(f f (- k 2)))))))))
(define (f x)
((lambda (even? odd?)
(even? even? odd? x))
(lambda (ev? od? n)
(if (= n 0)
#t
(od? ev? od? (- n 1))))
(lambda (ev? od? n)
(if (= n 0)
#f
(ev? ev? od? (- n 1))))))
| false |
4e0df288bb642760de5cb75113fc99158b601d3d
|
710e486f87b70e57cc3c2a411d12c30644544b75
|
/hash-table.sld
|
555f909f7c645f22b059c2d7632f556a90ea8d1c
|
[
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"BlueOak-1.0.0"
] |
permissive
|
ar-nelson/schemepunk
|
6236a3200343257a9ce15a6e3f4bda1dd450c729
|
249bf057b256bbb9212f60345a84d84615c61893
|
refs/heads/master
| 2021-05-18T07:47:36.721609 | 2021-04-24T17:05:48 | 2021-04-24T17:05:48 | 251,185,680 | 92 | 7 |
NOASSERTION
| 2021-05-12T14:07:38 | 2020-03-30T02:53:33 |
Scheme
|
UTF-8
|
Scheme
| false | false | 4,282 |
sld
|
hash-table.sld
|
;; R7RS-Large hash tables (SRFI 125), with a polyfill implementation for Kawa,
;; which only has SRFI 69.
;;
;; The polyfill implementation is copied from Chibi Scheme.
;;
;; string-hash and string-ci-hash are omitted because Kawa can't handle
;; overlapping imports.
(define-library (schemepunk hash-table)
(export
;; Constructors:
make-hash-table hash-table hash-table-unfold alist->hash-table
;; Predicates:
hash-table? hash-table-contains? hash-table-exists?
hash-table-empty? hash-table=? hash-table-mutable?
;; Accessors:
hash-table-ref hash-table-ref/default
;; Mutators:
hash-table-set! hash-table-delete! hash-table-intern!
hash-table-update! hash-table-update!/default hash-table-pop!
hash-table-clear!
;; The whole hash table:
hash-table-size hash-table-keys hash-table-values
hash-table-entries hash-table-find hash-table-count
;; Mapping and folding:
hash-table-map hash-table-for-each hash-table-walk
hash-table-map! hash-table-map->list hash-table-fold hash-table-prune!
;; Copying and conversion:
hash-table-copy hash-table-empty-copy hash-table->alist
;; Hash tables as sets:
hash-table-union! hash-table-merge!
hash-table-intersection! hash-table-difference! hash-table-xor!
;; Hash functions and reflectivity:
hash hash-by-identity
hash-table-equivalence-function hash-table-hash-function)
(import (scheme base)
(schemepunk syntax)
(schemepunk list)
(schemepunk show span)
(schemepunk show block)
(schemepunk show block datum))
(cond-expand
(gauche
; Gauche's alist->hash-table in (scheme hash-table) has a bug,
; but the bug is not present in the built-in (gauche base) library.
(import (except (scheme hash-table) alist->hash-table)
(only (gauche base) alist->hash-table)))
((and (not chicken) (or (library (scheme hash-table))
(library (srfi 125))
(library (std srfi 125))))
(cond-expand
((library (scheme hash-table)) (import (scheme hash-table)))
((library (srfi 125)) (import (srfi 125)))
((library (std srfi 125)) (import (std srfi 125)))))
(else
(import (scheme case-lambda)
(except (schemepunk comparator) string-hash string-ci-hash)
(rename
(only (srfi 69)
make-hash-table hash-table? alist->hash-table
hash-table-equivalence-function hash-table-hash-function
hash-table-ref hash-table-ref/default hash-table-set!
hash-table-delete! hash-table-exists? hash-table-update!
hash-table-update!/default
hash-table-size hash-table-keys hash-table-values
hash-table-walk hash-table-fold hash-table->alist
hash-table-copy hash-table-merge!
hash string-hash string-ci-hash hash-by-identity)
(hash-table-ref %hash-table-ref)
(make-hash-table %make-hash-table)
(alist->hash-table %alist->hash-table)
(hash-table-copy %hash-table-copy)
(hash-table-set! %hash-table-set!)
(hash-table-delete! %hash-table-delete!)
(hash-table-fold %hash-table-fold)))
(include "polyfills/hash.scm")))
(begin
(define (hash-table->block ht)
(define color (datum-color-record))
(if (hash-table-empty? ht)
(make-block (list (text-span "#,(hash-table)" color)))
(make-block
(list
(text-span "#,(hash-table" color)
(whitespace-span))
(intercalate (whitespace-span)
(map
(λ((k . v))
(make-block
(list
(text-span "(" color)
(datum->block k)
(whitespace-span))
(list
(datum->block v))
(list
(text-span ")" color))))
(hash-table->alist ht)))
(list
(text-span ")" color)))))
(register-datum-writer! hash-table? hash-table->block)))
| false |
8a29ef28e34bc9f6a163c3a124a4217807f14e6d
|
961ccc58c2ed4ed1d84a78614bedf0d57a2f2174
|
/scheme/chapter1/tan.scm
|
8df1c541bd0ce85c9fb9d19a8a1d939b76cc3f7d
|
[] |
no_license
|
huangjs/mostly-lisp-code
|
96483b566b8fa72ab0b73bf0e21f48cdb80dab0d
|
9fe862dbb64f2a28be62bb1bd996238de018f549
|
refs/heads/master
| 2021-01-10T10:11:50.121705 | 2015-11-01T08:53:22 | 2015-11-01T08:53:22 | 45,328,850 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 588 |
scm
|
tan.scm
|
;:*=======================
;:* a continued fraction representation by J.H.Lambert
(define (tan-cf x count)
(define (tan-cf-recur k)
(if (> k count)
0
(/ x
(- (- (* 2 k) 1.0)
(* x
(tan-cf-recur (+ k 1)))))))
(tan-cf-recur 1))
;:*=======================
;:* iterative
(define (tan-cf-iter x count result)
(let ((new-result (/ x
(- (- (* 2 count) 1)
(* x result)))))
(if (= count 0)
result
(tan-cf-iter x (- count 1) new-result))))
| false |
27be644b96e556920593ae999e4d25d9aad63f37
|
86c001154e57121157873d0f1348c540ecea6675
|
/srfi/cut.scm
|
b9966eb8c98c7d8f2a372f886fe49719c3250f91
|
[] |
no_license
|
Memorytaco/melt-core
|
d9d3cd2d38cf4154bd9544a87a02ee0c3d6f765a
|
e6cf20ae881b33523f17959019d66499ae74c667
|
refs/heads/master
| 2020-04-30T02:00:16.058976 | 2019-04-18T13:24:50 | 2019-04-18T13:24:50 | 176,546,164 | 1 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 195 |
scm
|
cut.scm
|
(library (melt srfi cut)
(export cut)
(import (scheme))
(define-syntax cut
(syntax-rules (<>)
[(_ procedure )]))
)
| true |
998a210a22c77aaf86a4e81c7db1eab905d4a9a7
|
a5cff5beae635b13a1d67cb707856212fbbe32a5
|
/chapter4-yong.scm
|
ff99903e47e08e0c60d6f793f7bab06e367f60d5
|
[] |
no_license
|
abelard2008/plai
|
f6c1b2fa17d224579e8ec6e08d74e5f6fa80d5ed
|
b7de61a647a555f0355fc1d9617e80d6af27907d
|
refs/heads/master
| 2020-12-10T21:26:24.032181 | 2020-01-16T10:47:20 | 2020-01-16T10:47:20 | 233,715,673 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 4,418 |
scm
|
chapter4-yong.scm
|
#lang plai
;; 1 + 1
;; + 1 1
;; 1 1 +
;(define-struct num (the-number))
;(define-struct add (the-lhs the-rhs))
;; abstract syntax
(define-type AE
[num (n number?)]
[add (lhs AE?)
(rhs AE?)]
[mult (lhs AE?)
(rhs AE?)]
[id (s symbol?)]
[with (name symbol?)
(named-thing AE?)
(body AE?)]
[app (fun-name symbol?)
(arg AE?)])
;; abstract data type for functions
(define-type FunDef
[fundef (fun-name symbol?)
(arg-name symbol?)
(body AE?)])
;; abstract program
(add (num 1)
(num 1))
;; concrete program
(define e '(+ 1 1))
e
(empty? e)
(cons? e)
(first e)
(second e)
(third e)
;; concrete syntax
#|
AE = <number>
| (* <AE> <AE>)
| (+ <AE> <AE>)
| (with (<id> <AE>) <AE>)
| <id>
| (<id> <AE>)
|#
;; parse : concrete -> abstract
(define (parse c)
(cond
[(number? c)
(num c)]
[(and (list? c)
(= 3 (length c))
(equal? '+ (first c)))
(add (parse (second c))
(parse (third c)))]
[(and (list? c)
(= 3 (length c))
(equal? '* (first c)))
(mult (parse (second c))
(parse (third c)))]
[(and (list? c)
(= 3 (length c))
(equal? 'with (first c)))
(with (first (second c))
(parse (second (second c)))
(parse (third c)))]
[(and (list? c)
(= 2 (length c))
(symbol? (first c)))
(app (first c) (parse (second c)))]
[(symbol? c)
(id c)]
[else
(error 'parse "Bd programmer, no cake ~e" c)]))
(parse e)
;; paren'd thing is an s-expression, abbrv'd sexpr
;; <xml><a>stupid</a><way>of writing</way><sexpr /></xml>
;; (xml (a stupid) (way of writing) (sexpr))
(test (parse '(+ 1 1))
(add (num 1) (num 1)))
(test/exn (parse '(+ 1 1 1))
"no cake")
(test (parse '(* 3 1))
(mult (num 3) (num 1)))
;; subst : id AE AE -> AE
(define (subst i v e)
(type-case
AE e
[num (n)
(num n)]
[add (lhs rhs)
(add
(subst i v lhs)
(subst i v rhs))]
[mult (lhs rhs)
(mult
(subst i v lhs)
(subst i v rhs))]
[id (s)
(if (equal? s i)
v
(id s))]
[with (i* v* e*)
(if (equal? i i*)
(with i*
(subst i v v*)
e*)
(with i*
(subst i v v*)
(subst i v e*)))]
[app (fun-name arg-expr)
(app fun-name (subst i v arg-expr))]))
;; lookup-fundef : symbol? (listof FunDef) -> FunDef
(define (lookup-fundef name fun-defs)
(cond
[(empty? fun-defs)
(error name "function not found")]
[else
(if (symbol=? name (fundef-fun-name (first fun-defs)))
(first fun-defs)
(lookup-fundef name (rest fun-defs)))]))
;; interp : AE (listof FunDef) -> meaning
(define (interp some-ae fun-defs)
(type-case
AE some-ae
[num (n)
n]
[add (lhs rhs)
(+ (interp lhs fun-defs)
(interp rhs fun-defs))]
[mult (lhs rhs)
(* (interp lhs fun-defs)
(interp rhs fun-defs))]
[id (s)
(error 'interp "Unbound undiscovery infinite: ~e" s)]
[with (i v e)
;(interp (subst i v e))
(interp (subst i (num (interp v fun-defs)) e) fun-defs)
]
[app (fun-name arg-expr)
;; ('double (num 3))
;; (fundef 'double 'x (add (id 'x) (id 'x)))
(local [(define fun-def (lookup-fundef fun-name fun-defs))]
(interp (subst (fundef-arg-name fun-def)
(num (interp arg-expr fun-defs))
(fundef-body fun-def))
fun-defs))]))
(test (parse '(with (n 5)
(f 10)))
(with 'n (num 5) (app 'f (num 10))))
;;steps
;;i: 'n v: (num 5) e: (app 'f (num 10))
(test (interp (num 5) (list (fundef 'f 'p (id 'n))))
5)
(test (subst 'n (num 5) (app 'f (num 10)))
(app 'f (num 10)))
(test/exn (interp (app 'f (num 10)) (list (fundef 'f 'p (id 'n))))
"Unbound undiscovery infinite:")
(test (interp (num 10) (list (fundef 'f 'p (id 'n))))
10)
(test (subst 'p (num 10) (id 'n))
(id 'n))
(test/exn (interp (id 'n) (list (fundef 'f 'p (id 'n))))
"Unbound undiscovery infinite:")
(test/exn (interp (parse '(with (n 5)
(f 10))) (list (fundef 'f 'p (id 'n))))
"Unbound undiscovery infinite:")
| false |
daf4bfb4aabff20996b8a002f2dc2c60060c864a
|
ba84b1d8a13e6ad26f4a1c11f4d46437d900746c
|
/src/compiler/inference/pp.ss
|
6e4fbb9e4fc58abcc8c81cbef8abe855b94d01e8
|
[] |
no_license
|
tufty/scheme--llvm
|
57d51e0857058b4e05a897a0b8197d9d0826d1fa
|
c00d133c3fc49f6564150c5db15855c29b0d4d6c
|
refs/heads/master
| 2020-05-27T18:48:26.453551 | 2013-11-20T08:24:32 | 2013-11-20T08:24:32 | 14,452,546 | 4 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,460 |
ss
|
pp.ss
|
(library
(compiler inference pp)
(export pp)
(import (except (chezscheme) assoc filter find fold-right for-each map member partition remove remove! append! make-list list-copy break reverse! last-pair iota)
(srfi :1)
(compiler inference terms)
(compiler inference lang)
(compiler inference constraints))
(define (pp l)
(cond
[(list? l) (map pp l)]
[(pair? l) `(,(pp (car l)) : ,(pp (cdr l)))]
[(box? l) (pp (unbox l))]
[(L0? l) (unparse-L0 l)]
[(ei-constraint? l) `(,(pp (constraint-lhs l)) ≼ ,(pp (constraint-rhs l)))]
[(ii-constraint? l) `(,(pp (constraint-lhs l)) ≤ ,(pp (constraint-rhs l)))]
[(eq-constraint? l) `(,(pp (constraint-lhs l)) ≣ ,(pp (constraint-rhs l)))]
[(expr-term? l) (pp (expr-term-expr l))]
[(typevar-term? l) (pp (typevar-term-name l))]
[(atomic-type-term? l) (pp (atomic-type-term-type l))]
[(arrow-term? l) `(,(pp (arrow-term-lhs l)) ,(string->symbol (string #\x21fe)) ,(pp (arrow-term-rhs l)))]
[(union-type-term? l)
(fold (lambda (x l) (if (null? l) `(,(pp x)) `(,(pp x) ∪ ,@l))) '() (constructed-type-term-termlist l))]
[(intersection-type-term? l)
(fold (lambda (x l) (if (null? l) `(,(pp x)) `(,(pp x) ∩ ,@l))) '() (constructed-type-term-termlist l))]
[(constructed-type-term? l)
(fold (lambda (x l) `(,@l ,(pp x))) `(,(constructed-type-term-tag l)) (constructed-type-term-termlist l))]
[else l]))
)
| false |
c1eee8dc71adeec49c9a015ca242351bc1f03745
|
6b288a71553cf3d8701fe7179701d100c656a53c
|
/examples/queue.ss
|
389611a163d0ec17b7959b7908ad1617d3476ebf
|
[
"Apache-2.0"
] |
permissive
|
cisco/ChezScheme
|
03e2edb655f8f686630f31ba2574f47f29853b6f
|
c048ad8423791de4bf650fca00519d5c2059d66e
|
refs/heads/main
| 2023-08-26T16:11:15.338552 | 2023-08-25T14:17:54 | 2023-08-25T14:17:54 | 56,263,501 | 7,763 | 1,410 |
Apache-2.0
| 2023-08-28T22:45:52 | 2016-04-14T19:10:25 |
Scheme
|
UTF-8
|
Scheme
| false | false | 1,823 |
ss
|
queue.ss
|
;;; queue
;;; an abstract datatype
;;; operations:
;;; (queue) ;create a queue object
;;; if 'q' is a queue object:
;;; (q 'type?) ;return the type (queue), useful if there are other
;;; ;abstract datatypes floating around.
;;; (q 'empty?) ;returns true iff q is empty
;;; (q 'put val) ;adds val to end of q; returns val
;;; (q 'get) ;removes first element of q and returns it
;;; Examples
;;; (define! q (queue))
;;; (q 'type?) => queue
;;; (q 'empty?) => #!true
;;; (q 'put 3)
;;; (q 'put 4)
;;; (q 'put 5)
;;; (q 'empty?) => ()
;;; (q 'get) => 3
;;; (q 'get) => 4
;;; (q 'put 7)
;;; (q 'get) => 5
;;; (q 'get) => 7
;;; (q 'empty?) => #!true
(define queue
(lambda ()
(let ([head '()] [tail '()])
(lambda (request . args)
(case request
[type? 'queue]
[empty? (null? head)]
[put
(let ([v (car args)])
(if (null? head)
(let ([p (cons v '())])
(set! tail p)
(set! head p))
(let ([quebit (cons v '())])
(set-cdr! tail quebit)
(set! tail quebit)))
v)]
[get
(if (null? head)
(error 'queue "queue is empty")
(let ([v (car head)])
(set! head (cdr head))
(when (null? head) (set! tail '()))
v))]
[else
(error 'queue "~s is not a valid request" request)])))))
| false |
17a7c0243a1668a3177c3f4da5d9f1a538dc531f
|
e82d67e647096e56cb6bf1daef08552429284737
|
/ex3-22.scm
|
5fce7156e31e4f7d26e0e73d43c634a4641d808a
|
[] |
no_license
|
ashishmax31/sicp-exercises
|
97dfe101dd5c91208763dcc4eaac2c17977d1dc1
|
097f76a5637ccb1fba055839d389541a1a103e0f
|
refs/heads/master
| 2020-03-28T11:16:28.197294 | 2019-06-30T20:25:18 | 2019-06-30T20:25:18 | 148,195,859 | 6 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,400 |
scm
|
ex3-22.scm
|
(define (make-queue)
(define front-ptr '())
(define rear-ptr '())
(define (empty-queue?) (null? front-ptr))
(define (set-front-ptr! item) (set! front-ptr item))
(define (set-rear-ptr! item) (set! rear-ptr item))
(define (insert-queue! item)
(let ((new-pair (cons item '())))
(cond ((empty-queue?)
(set-front-ptr! new-pair)
(set-rear-ptr! new-pair)
dispatch)
(else
(set-cdr! rear-ptr new-pair)
(set-rear-ptr! new-pair)
dispatch))))
(define (delete-queue!)
(if (empty-queue?)
(error "Delete queue called on an empty queue!")
(set-front-ptr! (cdr front-ptr))))
(define (front-queue)
(if (empty-queue?)
(error "front queue called on an empty queue!")
(car front-ptr)))
(define (dispatch message)
(cond ((eq? message 'insert-queue! ) insert-queue! )
((eq? message 'delete-queue! ) (delete-queue!))
((eq? message 'front-queue ) (front-queue))
(else (error "Unknown operation!"))))
dispatch)
(define (insert-queue! item queue) ((queue 'insert-queue! ) item ))
(define (delete-queue! queue) (queue 'delete-queue! ))
(define (front-queue queue) (queue 'front-queue ))
| false |
5985a70e7f1684276e6ed8abb65cd084ca1eda0c
|
dae624fc36a9d8f4df26f2f787ddce942b030139
|
/chapter-08/cond.scm
|
424620c71870117cd40be60ab4790341dc1ad471
|
[
"MIT"
] |
permissive
|
hshiozawa/gauche-book
|
67dcd238c2edeeacb1032ce4b7345560b959b243
|
2f899be8a68aee64b6a9844f9cbe83eef324abb5
|
refs/heads/master
| 2020-05-30T20:58:40.752116 | 2019-10-01T08:11:59 | 2019-10-01T08:11:59 | 189,961,787 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 208 |
scm
|
cond.scm
|
(define (odd lis)
(cond [(find odd? lis) => (lambda (val) (* val 2))]
[else 0]))
(define (odd lis)
(cond [(find odd? lis) => (cut * <> 2)]
[else 0]))
(odd '(1 2 3))
(find odd? '(2 2 3))
| false |
0bcd0bebcfbda88027b00732ee1635bc87a134eb
|
3686e1a62c9668df4282e769220e2bb72e3f9902
|
/graphics.scm
|
b0602365b0e12c86cbb12c06dc40206be20b8a05
|
[] |
no_license
|
rasuldev/sicp
|
a4e4a79354495639ddfaa04ece3ddf42749276b5
|
71fe0554ea91994822db00521224b7e265235ff3
|
refs/heads/master
| 2020-05-21T17:43:00.967221 | 2017-05-02T20:32:06 | 2017-05-02T20:32:06 | 65,855,266 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 3,217 |
scm
|
graphics.scm
|
(define (cross)
(graphics-draw-line device -1 -1 1 1)
(graphics-draw-line device 1 -1 -1 1)
(graphics-draw-line device -1 -1 -1 1)
(graphics-draw-line device -1 1 1 1)
(graphics-draw-line device 1 1 1 -1)
(graphics-draw-line device 1 -1 -1 -1)
(graphics-draw-line device -0.05 0.45 0 0.5)
(graphics-draw-line device 0 0.5 0.05 0.45)
(graphics-draw-line device 0.45 -0.05 0.5 0)
(graphics-draw-line device 0.5 0 0.45 0.05)
)
(graphics-clear device)
(graphics-set-coordinate-limits device -1 -1 1 1)
(define (draw painter)
(painter)
)
(define (display-coords)
((get-coords) (lambda (x0 y0 x1 y1)
(display (list x0 y0 x1 y1))
)
)
)
(define (get-coords)
(graphics-coordinate-limits device)
)
(define (restore-coords coords)
(coords (lambda (x0 y0 x1 y1)
(graphics-set-coordinate-limits device x0 y0 x1 y1)
)
)
)
(define (painter-operation action)
(lambda ()
(let ((coords (get-coords)))
(coords action)
(restore-coords coords)
)
)
)
(define (beside left right)
(painter-operation (lambda (x0 y0 x1 y1)
;(display-coords)
(graphics-set-coordinate-limits device (+ (* 2 x0) 1) y0 (+ (* 2 x1) 1) y1)
;(display-coords)
(left)
;(display-coords)
(graphics-set-coordinate-limits device (- (* 2 x0) 1) y0 (- (* 2 x1) 1) y1)
;(display-coords)
(right)
)
)
)
(define (below bottom top)
(painter-operation (lambda (x0 y0 x1 y1)
(display (list x0 y0 x1 y1))
(graphics-set-coordinate-limits device x0 (- (* 2 y0) 1) x1 (- (* 2 y1) 1))
(top)
(graphics-set-coordinate-limits device x0 (+ (* 2 y0) 1) x1 (+ (* 2 y1) 1))
(bottom)
)
)
)
(define (flip-vert painter)
(painter-operation (lambda (x0 y0 x1 y1)
(display (list x0 y0 x1 y1))
(graphics-set-coordinate-limits device x0 (* -1 y0) x1 (* -1 y1))
(painter)
)
)
)
(define (flip-horiz painter)
(painter-operation (lambda (x0 y0 x1 y1)
(graphics-set-coordinate-limits device (* -1 x0) y0 (* -1 x1) y1)
(painter)
)
)
)
(define (flipped-pairs painter)
(let ((painter2 (beside painter (flip-vert painter))))
(below painter2 painter2)))
;(draw (below cross cross))
;(draw (beside cross (below cross (flip-vert cross))))
;(draw (flipped-pairs cross))
(define (right-split painter n)
(if (= n 0)
painter
(let ((smaller (right-split painter (- n 1))))
(beside painter (below smaller smaller)))))
;(draw (right-split cross 10))
;(draw (beside cross (beside cross (beside cross cross))))
;(draw (below cross (beside cross (below cross (flip-vert cross)))))
;(draw (flipped-pairs cross))
(define (up-split painter n)
(if (= n 0)
painter
(let ((smaller (up-split painter (- n 1))))
(below painter
(beside smaller smaller)
)
)
)
)
;(draw (up-split cross 10))
(define (split bigOp smallOp)
(define (splitter painter n)
(if (= n 0)
painter
(let (
(smaller (splitter painter (- n 1))))
(bigOp painter
(smallOp smaller smaller)
)
)
)
)
splitter
)
(draw ((split beside below) cross 4))
| false |
1042276f9333c46088cbc26f3c4fb71c0ea5d1a8
|
ec0f122fdcf4ceaf5e9e183575a460006c19ebe0
|
/rest.scm
|
26bcec86870f139917c6a73325bb0af1ec637e4f
|
[] |
no_license
|
ThomasHintz/keep-the-records
|
d96e6253ebc3d2e11ee37277a6293c7365b25f9b
|
c20e648e831bed2ced3f2f74bfc590dc06b5f076
|
refs/heads/master
| 2021-01-13T02:37:41.053488 | 2013-07-19T04:18:44 | 2013-07-19T04:18:44 | 1,272,038 | 2 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,054 |
scm
|
rest.scm
|
(use http-client uri-common intarweb json srfi-1 srfi-18)
(load "src/utils/misc-utils")
(import misc-utils)
(define *api-user* (insert-file "config/send-grid-user"))
(define *api-key* (insert-file "config/send-grid-key"))
(define (rest-action url method parameters)
(vector->list (with-input-from-request
(make-request method: method uri: (uri-reference url)) parameters json-read)))
(define (send-mail #!key (subject #f) (text #f) (html #f) (from #f) (from-name #f) (to #f) (reply-to #f))
(if (and subject (or text html) from from-name to reply-to)
(rest-action "https://sendgrid.com/api/mail.send.json" 'POST
`((api_user . ,*api-user*)
(api_key . ,*api-key*)
(subject . ,subject)
(to . ,to)
(replyto . ,reply-to)
,(if html `(html . ,html) `(text . ,text))
(from . ,from)
(fromname . ,from-name)))
(abort "You must specify all keyword parameters!")))
| false |
54ae2b967f2081490eb995828a07d5cb2d00ea47
|
140a499a12332fa8b77fb738463ef58de56f6cb9
|
/worlds/core/verbcode/12/joinlist-3.scm
|
7ab4ed2024e55ca3a1b070337de24541098818ea
|
[
"MIT"
] |
permissive
|
sid-code/nmoo
|
2a5546621ee8c247d4f2610f9aa04d115aa41c5b
|
cf504f28ab473fd70f2c60cda4d109c33b600727
|
refs/heads/master
| 2023-08-19T09:16:37.488546 | 2023-08-15T16:57:39 | 2023-08-15T16:57:39 | 31,146,820 | 10 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 384 |
scm
|
joinlist-3.scm
|
(let
((lst (get args 0))
(last-sep (get args 1))
(if-empty (get args 2 "")))
(cond
((= 0 (len lst)) if-empty)
((= 1 (len lst)) (get lst 0))
((= 2 (len lst)) (cat ($ (get lst 0)) " " last-sep " " (get lst 1)))
((let
((last (get lst -1))
(mod-lst (set lst -1 (cat last-sep " " last))))
($strutils:join mod-lst ", ")))))
| false |
885d25708d6a904543907522798f91a5c615ac7a
|
d9cb7af1bdc28925fd749260d5d643925185b084
|
/src/2.02.scm
|
8150ec1655ee377888431dae94366de2149a6df8
|
[] |
no_license
|
akerber47/sicp
|
19e0629df360e40fd2ea9ba34bf7bd92be562c3e
|
9e3d72b3923777e2a66091d4d3f3bfa96f1536e0
|
refs/heads/master
| 2021-07-16T19:36:31.635537 | 2020-07-19T21:10:54 | 2020-07-19T21:10:54 | 14,405,303 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 536 |
scm
|
2.02.scm
|
; Point constructor and selectors
(define (make-point x y) (cons x y))
(define (x-point p) (car p))
(define (y-point p) (cdr p))
; Segment constructor and selectors
(define (make-segment p q) (cons p q))
(define (start-segment s) (car s))
(define (end-segment s) (cdr s))
(define (midpoint-segment s)
(make-point (/ (+ (x-point (start-segment s))
(x-point (end-segment s)))
2)
(/ (+ (y-point (start-segment s))
(y-point (end-segment s)))
2)))
| false |
fed487182a9c3e71fdd3cbbd4f130ce18a847b90
|
b85062eadba845bd0e607f92f3d6f58707c3030c
|
/src/swish/web-mats/include/absolute.ss
|
d9353ecf4e45f8c02c4969bf51108082bc3f3b88
|
[
"MIT",
"LicenseRef-scancode-public-domain"
] |
permissive
|
guenchi/swish-win
|
a0bc94a0121bc3c69fe2ac79d312b7c953040f68
|
bab98dfa757dfd851d8cf5176fb3e88115f311f4
|
refs/heads/master
| 2020-06-04T17:45:00.654922 | 2018-04-02T18:40:46 | 2018-04-02T18:40:46 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 39 |
ss
|
absolute.ss
|
(http:include "C:\\does-not-exist.ss")
| false |
460cdf9967c2a3c232920cd30d992708aef6e5cf
|
121be116a5b8b741c3d2955efab3c2a1c3dbdd78
|
/tests/run.scm
|
9a6e4b46bbfc9f5d83640c2b15d4b148167b716c
|
[
"LicenseRef-scancode-public-domain"
] |
permissive
|
iconmaster5326/CSDoc
|
4b57abeb72f88dbc45d4e48d8997dd92026b0cd0
|
be4f1d5fa2b7dd26e7d0dd2ad2abe8145248f826
|
refs/heads/master
| 2020-03-19T02:33:52.763765 | 2018-06-02T13:56:38 | 2018-06-02T13:56:38 | 135,639,585 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 569 |
scm
|
run.scm
|
(use csdoc)
; test basic documentation
(printf "TEST 1: ")
(document procedure (+ . numbers) "Adds numbers.")
(printf "~s\n" (docs-for +))
(assert (docs-for +))
; test that "@(...)" is getting expanded properly
(printf "TEST 2: ")
(document procedure (add . numbers) "A synonym for the proc @(ref add), which does addition.")
(let ((desc (cdr (assv 'desc (cdr (docs-for add))))))
(printf "~s\n" desc)
(assert (= (length desc) 3))
(assert (string? (first desc)))
(assert (equal? (second desc) '(ref add)))
(assert (string? (third desc)))
)
| false |
06d3bfbb82ed15336697321c6e4216493de85220
|
4b480cab3426c89e3e49554d05d1b36aad8aeef4
|
/chapter-02/ex2.45-falsetru.scm
|
59e75e0f30750fc294ee5231ebb4773516723412
|
[] |
no_license
|
tuestudy/study-sicp
|
a5dc423719ca30a30ae685e1686534a2c9183b31
|
a2d5d65e711ac5fee3914e45be7d5c2a62bfc20f
|
refs/heads/master
| 2021-01-12T13:37:56.874455 | 2016-10-04T12:26:45 | 2016-10-04T12:26:45 | 69,962,129 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 622 |
scm
|
ex2.45-falsetru.scm
|
(require paint/painters)
; 1
(define (split join1 join2)
(lambda (painter n)
(if (= n 0)
painter
(let ((smaller ((split join1 join2) painter (- n 1))))
(join1 painter (join2 smaller smaller))))))
; 2
(define (split join1 join2)
(define (f painter n)
(if (= n 0)
painter
(let ((smaller (f painter (- n 1))))
(join1 painter (join2 smaller smaller)))))
(lambda (painter n)
(f painter n)))
(define right-split (split beside below))
(define up-split (split below beside))
; test
(paint-hires (right-split einstein 2))
(paint-hires (up-split einstein 2))
| false |
aec7643050eb646a6a917cec30b6504e23a1b149
|
f08220a13ec5095557a3132d563a152e718c412f
|
/logrotate/skel/usr/share/guile/2.0/texinfo/serialize.scm
|
f3840c49cd5020612f0e4d66de374d0e902c95b4
|
[
"Apache-2.0"
] |
permissive
|
sroettger/35c3ctf_chals
|
f9808c060da8bf2731e98b559babd4bf698244ac
|
3d64486e6adddb3a3f3d2c041242b88b50abdb8d
|
refs/heads/master
| 2020-04-16T07:02:50.739155 | 2020-01-15T13:50:29 | 2020-01-15T13:50:29 | 165,371,623 | 15 | 5 |
Apache-2.0
| 2020-01-18T11:19:05 | 2019-01-12T09:47:33 |
Python
|
UTF-8
|
Scheme
| false | false | 9,844 |
scm
|
serialize.scm
|
;;;; (texinfo serialize) -- rendering stexinfo as texinfo
;;;;
;;;; Copyright (C) 2009, 2012, 2013 Free Software Foundation, Inc.
;;;; Copyright (C) 2003,2004,2009 Andy Wingo <wingo at pobox dot com>
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 3 of the License, or (at your option) any later version.
;;;;
;;;; This library is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;;; Lesser General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;;;;
;;; Commentary:
;;
;;Serialization of @code{stexi} to plain texinfo.
;;
;;; Code:
(define-module (texinfo serialize)
#:use-module (texinfo)
#:use-module (texinfo string-utils)
#:use-module (sxml transform)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-13)
#:export (stexi->texi))
(define (list-intersperse src-l elem)
(if (null? src-l) src-l
(let loop ((l (cdr src-l)) (dest (cons (car src-l) '())))
(if (null? l) (reverse dest)
(loop (cdr l) (cons (car l) (cons elem dest)))))))
;; converts improper lists to proper lists.
(define (filter* pred l)
(let lp ((in l) (out '()))
(cond ((null? in)
(reverse! out))
((pair? in)
(lp (cdr in) (if (pred (car in)) (cons (car in) out) out)))
(else
(lp '() (if (pred in) (cons in out) out))))))
;; (list* 'a '(b c) 'd '(e f g)) => '(a b c d e f g)
(define (list* . args)
(let* ((args (reverse args))
(tail (car args)))
(let lp ((in (cdr args)) (out tail))
(cond ((null? in) out)
((pair? (car in)) (lp (cdr in) (append (car in) out)))
((null? (car in)) (lp (cdr in) out))
(else (lp (cdr in) (cons (car in) out)))))))
;; Why? Well, because syntax-case defines `include', and carps about its
;; wrong usage below...
(eval-when (expand load eval)
(define (include exp lp command type formals args accum)
(list* "\n"
(list-intersperse
args
" ")
" " command "@" accum)))
(define (empty-command exp lp command type formals args accum)
(list* " " command "@" accum))
(define (inline-text exp lp command type formals args accum)
(if (not (string=? command "*braces*")) ;; fixme :(
(list* "}"
(append-map (lambda (x) (lp x '())) (reverse (cdr exp)))
"{" command "@" accum)
(list* "@}"
(append-map (lambda (x) (lp x '())) (reverse (cdr exp)))
"@{" accum)))
(define (inline-args exp lp command type formals args accum)
(list* "}"
(if (not args) ""
(list-intersperse
(map
(lambda (x)
(cond ((not x) "")
((pair? x)
(if (pair? (cdr x))
(warn "Strange inline-args!" args))
(car x))
(else (error "Invalid inline-args" args))))
(drop-while not
(map (lambda (x) (assq-ref args x))
(reverse formals))))
","))
"{" command "@" accum))
(define (inline-text-args exp lp command type formals args accum)
(list* "}"
(if (not args) ""
(apply
append
(list-intersperse
(map
(lambda (x) (append-map (lambda (x) (lp x '())) (reverse x)))
(drop-while not
(map (lambda (x) (assq-ref args x))
(reverse formals))))
'(","))))
"{" command "@" accum))
(define (serialize-text-args lp formals args)
(apply
append
(list-intersperse
(map (lambda (arg) (append-map (lambda (x) (lp x '())) arg))
(map
reverse
(drop-while
not (map (lambda (x) (assq-ref args x))
(reverse formals)))))
'(" "))))
(define (eol-text-args exp lp command type formals args accum)
(list* "\n"
(serialize-text-args lp formals args)
" " command "@" accum))
(define (eol-text exp lp command type formals args accum)
(list* "\n"
(append-map (lambda (x) (lp x '()))
(reverse (if args (cddr exp) (cdr exp))))
" " command "@" accum))
(define (eol-args exp lp command type formals args accum)
(list* "\n"
(list-intersperse
(apply append
(drop-while not
(map (lambda (x) (assq-ref args x))
(reverse formals))))
", ")
" " command "@" accum))
(define (environ exp lp command type formals args accum)
(case (car exp)
((texinfo)
(list* "@bye\n"
(append-map (lambda (x) (lp x '())) (reverse (cddr exp)))
"\n@c %**end of header\n\n"
(reverse (assq-ref args 'title)) "@settitle "
(or (and=> (assq-ref args 'filename)
(lambda (filename)
(cons "\n" (reverse (cons "@setfilename " filename)))))
"")
"\\input texinfo @c -*-texinfo-*-\n@c %**start of header\n"
accum))
(else
(list* "\n\n" command "@end "
(let ((body (append-map (lambda (x) (lp x '()))
(reverse (if args (cddr exp) (cdr exp))))))
(if (or (null? body)
(eqv? (string-ref (car body)
(1- (string-length (car body))))
#\newline))
body
(cons "\n" body)))
"\n"
(serialize-text-args lp formals args)
" " command "@" accum))))
(define (table-environ exp lp command type formals args accum)
(list* "\n\n" command "@end "
(append-map (lambda (x) (lp x '()))
(reverse (if args (cddr exp) (cdr exp))))
"\n"
(let* ((arg (if args (cadar args) ""))) ;; zero or one args
(if (pair? arg)
(list (symbol->string (car arg)) "@")
arg))
" " command "@" accum))
(define (wrap strings)
(fill-string (string-concatenate strings)
#:line-width 72
#:break-long-words? #f))
(define (paragraph exp lp command type formals args accum)
(list* "\n\n"
(wrap
(reverse
(append-map (lambda (x) (lp x '())) (reverse (cdr exp)))))
accum))
(define (item exp lp command type formals args accum)
(list* (append-map (lambda (x) (lp x '())) (reverse (cdr exp)))
"@item\n"
accum))
(define (entry exp lp command type formals args accum)
(list* (append-map (lambda (x) (lp x '())) (reverse (cddr exp)))
"\n"
(append-map (lambda (x) (lp x '())) (reverse (cdar args)))
"@item "
accum))
(define (fragment exp lp command type formals args accum)
(list* "\n@c %end of fragment\n"
(append-map (lambda (x) (lp x '())) (reverse (cdr exp)))
"\n@c %start of fragment\n\n"
accum))
(define serializers
`((EMPTY-COMMAND . ,empty-command)
(INLINE-TEXT . ,inline-text)
(INLINE-ARGS . ,inline-args)
(INLINE-TEXT-ARGS . ,inline-text-args)
(EOL-TEXT . ,eol-text)
(EOL-TEXT-ARGS . ,eol-text-args)
(INDEX . ,eol-text-args)
(EOL-ARGS . ,eol-args)
(ENVIRON . ,environ)
(TABLE-ENVIRON . ,table-environ)
(ENTRY . ,entry)
(ITEM . ,item)
(PARAGRAPH . ,paragraph)
(FRAGMENT . ,fragment)
(#f . ,include))) ; support writing include statements
(define (serialize exp lp command type formals args accum)
((or (assq-ref serializers type)
(error "Unknown command type" exp type))
exp lp command type formals args accum))
(define escaped-chars '(#\} #\{ #\@))
(define (escape str)
"Escapes any illegal texinfo characters (currently @{, @}, and @@)."
(let loop ((in (string->list str)) (out '()))
(if (null? in)
(apply string (reverse out))
(if (memq (car in) escaped-chars)
(loop (cdr in) (cons* (car in) #\@ out))
(loop (cdr in) (cons (car in) out))))))
(define (stexi->texi tree)
"Serialize the stexi @var{tree} into plain texinfo."
(string-concatenate-reverse
(let lp ((in tree) (out '()))
(cond
((or (not in) (null? in)) out)
((string? in) (cons (escape in) out))
((pair? in)
(let ((command-spec (assq (car in) texi-command-specs)))
(if (not command-spec)
(begin
(warn "Unknown stexi command, not rendering" in)
out)
(serialize in
lp
(symbol->string (car in))
(cadr command-spec)
(filter* symbol? (cddr command-spec))
(cond
((and (pair? (cdr in)) (pair? (cadr in))
(eq? (caadr in) '%))
(cdadr in))
((not (cadr command-spec))
;; include
(cdr in))
(else
#f))
out))))
(else
(error "Invalid stexi" in))))))
;;; arch-tag: d3fa16ea-0bf7-4ec5-ab9f-3f08490f77f5
| false |
2728a5da3ce28e941044daab9dcbc1168bb943ed
|
483a1c3d153edd17f637ad1c304062776651fb33
|
/fib-auto.scm
|
342f156dc2b9b2d6421bd2fc7327c339640f21e0
|
[] |
no_license
|
namin/lambdajam
|
c4fb047044676ba52c800c1343ffd4360afeb085
|
1ea7b3e424551c3d389199f392abb83ea27b046c
|
refs/heads/master
| 2023-08-30T19:54:06.203073 | 2023-08-12T19:56:36 | 2023-08-12T19:56:36 | 11,259,139 | 10 | 4 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 157 |
scm
|
fib-auto.scm
|
(define fib
(lambda (n)
(begin
(show n)
(if (or (= n 0) (= n 1))
n
(+ (fib (- n 1)) (fib (- n 2)))))))
(show (fib 5))
| false |
c18ead2527ccf41e931aa66a36a8ebb71fcdd39b
|
33f464f68e3403929b115402eb13e46241b84892
|
/jatkumot.scm
|
c9f19df96d02c4bfe8e3f30fc4b75c653b89d025
|
[] |
no_license
|
aoh/fp-mothly
|
68b1eb648f6bdc12bc2b7fb5b87e855428c7a635
|
64baa14ab939cbf6bc151d3de32924daf2da71b4
|
refs/heads/master
| 2021-01-10T13:53:09.531863 | 2017-04-18T08:56:08 | 2017-04-18T08:56:08 | 49,959,154 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 5,882 |
scm
|
jatkumot.scm
|
;; Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary.
; monadit kategoriateoria kontinuaatiot tyyppiteoria
(define (fakt x)
(if (= x 0)
1
(* x (fakt (- x 1)))))
(fakt 60)
;;; -----------------------------------------------
(define id (lambda (x) x))
(define (fakt x k)
(if (= x 0)
(k 1)
(fakt (- x 1)
(lambda (v)
(k (* x v))))))
(fakt 50 id)
;;; -----------------------------------------------
(define cps* (lambda (a b k) (k (* a b))))
(define cps- (lambda (a b k) (k (- a b))))
(define cps= (lambda (a b k) (k (= a b))))
(define cps-fakt
(lambda (x k)
(cps= x 0
(lambda (res)
(if (eq? res #t)
(k 1)
(cps- x 1
(lambda (p)
(cps-fakt p
(lambda (t)
(cps* t x
(lambda (res)
(k res))))))))))))
(cps-fakt 60 id)
;;; ---------------------------------------------
(define-syntax CPS
(syntax-rules (if quote)
((CPS k (lambda (arg ...) body))
(k (lambda (x arg ...) (CPS x body))))
((CPS k (x ... (op . args) y ...))
(CPS
(lambda (r)
(CPS k (x ... r y ...)))
(op . args)))
((CPS k (quote val))
(k (quote val)))
((CPS k (if (op . args) a b))
(CPS
(lambda (test) (CPS k (if test a b)))
(op . args)))
((CPS k (if test a b))
(if test
(CPS k a)
(CPS k b)))
((CPS k (rator rand ...))
(rator k rand ...))
((CPS k x)
(k x))
((CPS value)
(lambda (k) (CPS k value)))))
,expand (CPS 42)
,expand (CPS (+ 1 2))
,expand (CPS (+ 1 (+ 2 3)))
,expand (CPS (lambda (x) (x x)))
(define (add-cps k a b) (k (+ a b)))
((CPS (add-cps 111 222)) (lambda (x) x))
;;; ---------------------------------------------
(call/cc
(lambda (k)
(print "hello")
(k "goodbye")
(print "world")))
;;; ----------------------------------------------
(fold (lambda (s a) (* s a)) 1 '(1 2 3 4 5))
(fold (lambda (s a) (* s a)) 1 '(1 2 3 4 5 x))
(call/cc (lambda (ret) (fold (lambda (s a) (* s a)) 1 '(1 2 3 4 5))))
(call/cc (lambda (ret) (fold (lambda (s a) (if (not (number? a)) (ret a)) (* s a)) 1 '(1 2 3 4 5))))
;;; ----------------------------------------------
(define oma-callcc ('_sans_cps (λ (k f) (f k (λ (r a) (k a))))))
(oma-callcc
(lambda (k)
(print "hello")
(k "BYE")
(print "world")))
;;; ----------------------------------------------
(define foo 42)
(define k (call/cc (lambda (x) x)))
k
(define bar 100)
(k 'hello)
k bar?
;;; ----------------------------------------------
;;; SWITCH TO SCHEME
(define (print . args)
(for-each display args)
(newline))
(define (fail x)
(display "bug: no handler"))
(define-syntax try
(syntax-rules ()
((try . exps)
(call-with-current-continuation
(lambda (k)
(let ((old fail))
(set! fail
(lambda (x)
(set! fail old)
(k x))))
. exps)))))
(try
(print 1)
(fail "nope")
(print 2))
(define (tsekkaa a)
(if (< a 0) (fail "liian pieni"))
(if (> a 100) (fail "liian iso"))
a)
(define (add-safely a b)
(+ (tsekkaa a) (tsekkaa b)))
(try
(print ""
(add-safely 0
(add-safely 40
(add-safely 50 -60)))))
;;; -------------------------------------------------
(define (print . args)
(for-each display args)
(newline))
(define (ei) #f)
(define (joku . args)
(call-with-current-continuation
(lambda (k)
(let ((old-back ei))
(set! ei
(lambda ()
(if (null? args)
(begin
(set! ei old-back)
(ei))
(let ((a (car args)))
(set! args (cdr args))
(k a)))))
(ei)))))
(let*
((a (joku 2 4 6 8 ))
(b (joku 1 (joku 0.6 1.2 5.6) 5 7 9)))
(if (< (* a b) 20)
(ei))
(if (>= (* a b) 30)
(ei))
(print a " * " b " = " (* a b))
(ei))
;; ---------------------------------------------------------------------
;; scheme
(define (print . args)
(for-each display args)
(newline))
(define (tc x) x)
(define threads '())
(define (start!)
(call-with-current-continuation
(lambda (exit)
(set! tc exit)
(go!))))
(define (go!)
(if (null? threads)
(tc 'done)
(let ((fst (car threads)))
(set! threads (cdr threads))
(fst 'resumed))))
(define (next-thread!)
(call-with-current-continuation
(lambda (continue)
(set! threads (append threads (list continue)))
(go!))))
(define-syntax fork
(syntax-rules ()
((fork exp)
(set! threads (cons (lambda (x) exp (go!)) threads)))))
(define (counter message n)
(next-thread!)
(print message n)
(if (= n 0)
'done
(counter message (- n 1))))
(fork (counter "aaaa at " 4))
(fork (counter "bbb at " 3))
(fork (counter "cc at " 2))
(fork (counter "d at " 1))
(start!)
(define-syntax pdefine
(syntax-rules ()
((pdefine (var . args) . body)
(define (var . args)
(next-thread!)
. body))))
(pdefine (laskuri nimi n)
(if (= n 0)
(print nimi "bling!")
(laskuri nimi (- n 1))))
(fork (laskuri "pitkä " 100000))
(fork (laskuri "lyhyt " 10))
(fork (laskuri "keski " 100))
(start!)
;; räntit
; try/catch
; generaattorit
; threadit
; callbackit
| true |
960fe1028a6213db3053a6bd03d6ce0d7dc2126c
|
53e7f5c820c2a19c98d50e2ba5341fee5f45a08b
|
/testing2-stk.scm
|
8cb34fab25ef8b5844b5c80a454e5e1984723c96
|
[] |
no_license
|
lambdaloop/cs61as-extras
|
d5822b483d5035f1e943a363fc25f277b1f38b1d
|
a124c8ded7285aa93324b21e9d3608cc6321385c
|
refs/heads/master
| 2021-01-16T18:03:03.770884 | 2012-12-08T19:05:20 | 2012-12-08T19:05:20 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 8,628 |
scm
|
testing2-stk.scm
|
;; Berkeley STK Test Framework Additions
;; by Pierre Karashchuk
;; To use, save code into some file, say "tests-named.scm".
;; then load the file: (load "tests-named.scm")
;; ------------------------
;; What can you do with it?
;; add tests to test database:
;; (add-tests-named <name> <test1> <test2> ...)
;; where <name> is some symbol, string, or number which names this group of tests.
;; and <test1>,<test2>, ... are of the format (<expression> <expected result>)
;;
;; NOTE: If a test group with name <name> has already been added, add-tests-named will neither
;; override nor modify it. Rather, it will do nothing.
;; then run the tests:
;;
;; (run-tests-named <name>)
;; where <name> is a name of some group of tests added earlier
;;
;; (run-tests-named <name1> <name2> ...)
;; will run group of tests with <name1> or <name2> and so on...
;;
;; (run-tests-named)
;; will run ALL groups of tests added
;; if you wish to clear tests
;; (need to clear to re-add tests with same name):
;;
;; (clear-tests-name <name1> <name2> ...)
;; will clear tests groups with names <name1>, <name2>, etc...
;;
;; (clear-test-cases)
;; will clear all test cases.
;; sample usage:
;; > (add-tests-named 'arithmetic-test
;; ((+ 1 2) 3)
;; ((* 3 5) 15)
;; ((/ 6 2) (/ 12 4))
;; ((+ 1 1) 5)
;; )
;; => arithmetic-test
;; > (run-tests-named 'arithmetic-test)
;; (TESTS NAMED: arithmetic-test)
;; (----- Running 4 tests... Failure output below. -----)
;; ((+ 1 1) Expected: 5 Actual: 2)
;; (----- Done. 1 failed test(s). 0 error(s). -----)
;;
;; (good: 3 failed: 1 errors: 0)
;; -----------------------------------------
;; use for Stk scheme
(define (to-string . args)
(define (one-string x)
(cond ((symbol? x) (symbol->string x))
((number? x) (number->string x))
((string? x) x)
(else x)))
(apply string-append (map one-string args)))
(define-macro (add-tests-named . tests)
(let ((name (gensym)))
`(let ((,name ,(car tests)))
(if (member (to-string ,name) (map car *test-groups*))
(show (list "WARNING: duplicate test group" ,name "detected. Ignoring it."))
(begin
(add-tests-named-helper ,name (quote ,(cdr tests)))
,name)))))
(define-macro (add-test-cases . tests)
(cons 'begin
(map (lambda (a) (cons 'add-test-case a))
tests)))
;; use for MIT scheme
;; (define to-string string)
;; (define-syntax catch
;; (syntax-rules ()
;; ((catch expr)
;; (condition? (ignore-errors (lambda () expr))))))
;; (define-syntax add-tests-named
;; (syntax-rules ()
;; ((add-tests-named name (expr val) ...)
;; (if (member (to-string name) (map car *test-groups*))
;; (show (list "WARNING: duplicate test group" name "detected. Ignoring it."))
;; (begin
;; (add-tests-named-helper name '((expr val) ...))
;; name)))))
;; (define-syntax add-test-cases
;; (syntax-rules ()
;; ((add-test-cases (name expr val))
;; (add-test-case name val expr))
;; ((add-test-cases (name expr val) t ...)
;; (begin (add-test-case name val expr)
;; (add-test-cases t ...)))))
(define (good-test-name? name)
(or (symbol? name) (number? name) (string? name)))
(define *test-groups* '())
(define (clear-test-cases)
(set! *xx-test-case-store* '())
(set! *test-groups* '()))
(define (clear-tests test-names)
(set! *xx-test-case-store*
(filter (lambda (x) (not (member (car x) test-names)))
*xx-test-case-store*)))
(define (clear-tests-named . names)
(let ((namestrs (map to-string names)))
(define (clear groups)
(cond ((empty? groups) '())
((member (caar groups) namestrs)
(clear-tests (map car (cdar groups)))
(clear (cdr groups)))
(else (cons (car groups)
(clear (cdr groups))))))
(set! *test-groups* (clear *test-groups*))
'ok))
(define (add-test-case-quoted name expected expr)
(if (not (good-test-name? name))
(show (list "WARNING: badly named test case:" name
"Ignoring it."))
(let ((namestr (to-string name)))
(if (assoc namestr *xx-test-case-store*)
(show (list "WARNING: duplicate test case" namestr "detected."
"Ignoring it."))
(set! *xx-test-case-store*
(append *xx-test-case-store*
(list (list namestr expected expr))))))))
(define (add-tests-named-helper name tests)
(define (format-tests i tests)
(cond ((empty? tests) '())
(else (let ((t (car tests)))
(cons (list (to-string name "-" i) (cadr t) (car t))
(format-tests (+ i 1) (cdr tests)))))))
(let ((formatted-tests (format-tests 0 tests)))
(for-each (lambda (x) (apply add-test-case-quoted x))
formatted-tests)
(set! *test-groups*
(cons (cons (to-string name) formatted-tests)
*test-groups*))
))
(define (run-single-case case)
(let* ((get-name car)
(get-expected cadr)
(get-expression caddr)
(expected (eval (get-expected case)))
(actual '()))
(cond
((catch (set! actual (eval (get-expression case))))
(show (list (get-expression case)
"\t Expected:" expected
"\tActual:" "ERROR!!!"))
(list 1 0)) ;; 1 error, 0 failures
((not (equal? actual expected))
(show (list (get-expression case)
"\tExpected:" expected
"\tActual:" actual))
(list 0 1)) ;; 0 errors, 1 failure
(else (list 0 0)) ;; 0 errors, 0 failures
) ) )
(define (run-test-group-named name)
(let ((test-cases-to-run '())
(err-fail (list 0 0)))
(let ((a (assoc (to-string name) *test-groups*)))
(if a (set! test-cases-to-run (cdr a))))
(show (list "TESTS NAMED:" name))
(show (list "----- Running" (length test-cases-to-run)
"tests... Failure output below. -----"))
(set! err-fail
(reduce (lambda (a b) (map + a b))
(map run-single-case test-cases-to-run)))
(show (list "----- Done. "
(car err-fail) "failed test(s). "
(cadr err-fail) "error(s). -----" ))
(newline)
(cons (length test-cases-to-run) err-fail)
))
(define (run-tests-named . names)
(if (empty? names)
(apply run-tests-named
(reverse (map car *test-groups*)))
(let ((count-err-fail
(reduce (lambda (a b) (map + a b))
(map run-test-group-named names))))
(show (list "good:" (- (car count-err-fail)
(cadr count-err-fail)
(caddr count-err-fail))
"\tfailed:" (caddr count-err-fail)
"\terrors:" (cadr count-err-fail))))))
(define (run-test-cases2 . input)
(let ((test-cases-to-run '())
(get-name car)
(get-expected cadr)
(get-function caaddr)
(get-expression caddr)
(err-fail (list 0 0))
)
(define (string-starts-with? start full)
(equal? (substring full 0 (string-length start))
start))
(cond ((null? input)
(set! test-cases-to-run *xx-test-case-store*))
((procedure? (car input))
(set! test-cases-to-run
(filter (lambda (case)
(and (list? (get-expression case))
(equal? (eval (get-function case))
(car input))))
*xx-test-case-store*) )
)
(else ; check names
(let ((argstr (if (good-test-name? (car input))
(to-string (car input))
(error "Bad input to run-test-cases:"
"not a procedure, symbol, number, or string!"))))
(set! test-cases-to-run
(filter (lambda (case)
(string-starts-with? argstr (get-name case)))
*xx-test-case-store*) ) )) )
(show (list "----- Running"
(length test-cases-to-run)
"tests... Failure output below. -----"))
(set! err-fail
(reduce (lambda (a b) (map + a b))
(map run-single-case test-cases-to-run)))
(show (list "----- Done. "
(car err-fail) "failed test(s). "
(cadr err-fail) "error(s). -----" ))
(newline)
))
| true |
d627b794260fab342dffa8fe00db9e6b63c5caef
|
b9eb119317d72a6742dce6db5be8c1f78c7275ad
|
/random-scheme-stuff/mapatoms.scm
|
541b037efb39dd9a73fcf517f3babf902e731d9f
|
[] |
no_license
|
offby1/doodles
|
be811b1004b262f69365d645a9ae837d87d7f707
|
316c4a0dedb8e4fde2da351a8de98a5725367901
|
refs/heads/master
| 2023-02-21T05:07:52.295903 | 2022-05-15T18:08:58 | 2022-05-15T18:08:58 | 512,608 | 2 | 1 | null | 2023-02-14T22:19:40 | 2010-02-11T04:24:52 |
Scheme
|
UTF-8
|
Scheme
| false | false | 192 |
scm
|
mapatoms.scm
|
(define (atoms x)
(cond
((null? x)
'())
((vector? x)
(atoms (vector->list x)))
((pair? x)
(append (atoms (car x) )
(atoms (cdr x) )))
(else
(list x))))
| false |
7f750ea83a1f86c7ecd2fb66c0e94ee36faa64e7
|
d8bdd07d7fff442a028ca9edbb4d66660621442d
|
/scam/tests/00-syntax/assign/undefine.scm
|
f376a266d3a240012a6a64b37bed83b50d7f8ac2
|
[] |
no_license
|
xprime480/scam
|
0257dc2eae4aede8594b3a3adf0a109e230aae7d
|
a567d7a3a981979d929be53fce0a5fb5669ab294
|
refs/heads/master
| 2020-03-31T23:03:19.143250 | 2020-02-10T20:58:59 | 2020-02-10T20:58:59 | 152,641,151 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 184 |
scm
|
undefine.scm
|
(import (only (scam misc) undefine)
(test narc))
(narc-label "Undefine")
(define test 1)
(narc-expect
(1 test))
(undefine test)
(narc-catch
(:eval test))
(narc-report)
| false |
7493904cdbee9149fc67292ef2c51a369f58c95b
|
02dc91f3985e81cc9c17ae31bd09dacb7fd7c1d0
|
/src/prototype1/pp.scm
|
c2cc47fbb6c25bf704f2296cf0c4ae9f19a25143
|
[] |
no_license
|
edechter/probprog
|
1db3c49b545c032ec2a507179169ba35b6eb36d1
|
702f00022fcb73dcb80863b0a3cd66b59428e387
|
refs/heads/master
| 2021-01-10T21:19:48.446719 | 2013-05-20T18:07:58 | 2013-05-20T18:07:58 | 9,099,925 | 1 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 5,832 |
scm
|
pp.scm
|
(declare (usual-integrations))
(load "pp-records")
(load "constants")
(load "eq-properties")
(load "generic-rv")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Globals and initialization ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define DEFAULT-MH-STEPS 100)
(define *niter-left*)
(define *current-ptrace*)
(define *alternative-ptrace*)
(define *forward-score*)
(define *backward-score*)
(define *common-ptrace-prefix-length*)
(define *top-level* #f) ;; should only be rebound dynamically (i.e. should stay #f in global scope)
(define *niter-done* 0) ;; only interesting when resuming runs
(define (reset)
(set! *niter-left* DEFAULT-MH-STEPS)
(set! *current-ptrace* (ptrace:new))
(set! *alternative-ptrace* #f))
(reset)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Forward-sampling with bookkeeping ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (sample name sampler log-likelihood parameters proposer)
(if (default-object? proposer)
(set! proposer (proposals:prior-proposer sampler log-likelihood parameters)))
(let ((val (call-with-current-continuation
(lambda (k)
(ptrace:add-choice! (choice:new name parameters log-likelihood proposer k))
(sampler parameters)))))
(let ((choice (car (ptrace:choices *current-ptrace*))))
(define (doer) (choice:set-val! choice val))
(ptrace:set-doer-hook! *current-ptrace* doer)
(doer)
choice)))
;; TODO move this to pp-interface
;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
;; Emit and MH over traces ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
(define emit
(make-generic-procedure (make-procedure-arity 2 3)
'emit))
;; by default, we emit with the mh:emit which backtracks randomly to a
;; ptrace continuation
(set-generic-procedure-default-generator!
emit (lambda (proc tags) mh:emit))
(define (mh:emit var observed-value #!optional likelihood-function)
(if (default-object? likelihood-function)
(set! likelihood-function likelihood:exact))
(ptrace:set-likelihood-score! *current-ptrace* (likelihood-function var observed-value))
(call-with-current-continuation
(lambda (k)
(ptrace:set-emit-continuation! *current-ptrace* k)
(choose-ptrace (MH-sample-ptrace))))
(set! *niter-done* (+ *niter-done* 1))
(if (> *niter-left* 0)
(try-another)
(if (not *top-level*)
(reset))))
(define (MH-sample-ptrace)
(if (not *alternative-ptrace*)
(begin (set! *alternative-ptrace* (ptrace:new)) *current-ptrace*)
(let ((forward-choice-prob (flo:negate (flo:log (exact->inexact (ptrace:length *alternative-ptrace*)))))
(backward-choice-prob (flo:negate (flo:log (exact->inexact (ptrace:length *current-ptrace*)))))
(current-prior (prior-score *current-ptrace*))
(alternative-prior (prior-score *alternative-ptrace*))
(current-likelihood (ptrace:likelihood-score *current-ptrace*))
(alternative-likelihood (ptrace:likelihood-score *alternative-ptrace*)))
(cond ((flo:= alternative-likelihood neginf) *current-ptrace*)
((flo:= current-likelihood neginf) *alternative-ptrace*)
(else (let ((accept-current-probability
(flo:sum (flo:- current-prior alternative-prior)
(flo:- current-likelihood alternative-likelihood)
(exact->inexact (- backward-choice-prob forward-choice-prob))
(flo:- *backward-score* *forward-score*))))
(if (flo:< (flo:log (random 1.0)) accept-current-probability)
*current-ptrace*
*alternative-ptrace*)))))))
(define (prior-score ptrace)
(let ((choice (list-ref (ptrace:choices ptrace) (- (ptrace:length ptrace)
(+ 1 *common-ptrace-prefix-length*)))))
((choice:log-likelihood choice) (choice:val choice) (choice:parameters choice))))
(define (choose-ptrace ptrace)
((ptrace:doer-hook ptrace))
(ptrace:set-all! *current-ptrace* ptrace)
(within-continuation (ptrace:emit-continuation ptrace) (lambda () #!unspecific)))
(define (try-another)
(set! *niter-left* (- *niter-left* 1))
(ptrace:set-all! *alternative-ptrace* *current-ptrace*)
(let* ((len (ptrace:length *current-ptrace*))
(proposal-index (random len))
(choice (list-ref (ptrace:choices *current-ptrace*) (- len (+ 1 proposal-index))))
(k (choice:continuation choice)))
(set! *common-ptrace-prefix-length* proposal-index)
(ptrace:head! *current-ptrace* proposal-index)
(within-continuation k (lambda () (propose choice)))))
(define (propose choice)
(let ((new-val ((choice:proposer choice) choice)))
(ptrace:add-choice! (choice:copy choice))
new-val))
;;;;;;;;;;;;;;;;;;;;
;; Resumable runs ;;
;;;;;;;;;;;;;;;;;;;;
(define (run thunk niter)
(fluid-let ((*niter-left* niter)
(*niter-done* 0)
(*current-ptrace* (ptrace:new))
(*alternative-ptrace* #f)
(*backward-score* #f)
(*forward-score* #f)
(*backward-score* #f)
(*common-ptrace-prefix-length* #f))
(call-with-current-continuation
(lambda (k)
(fluid-let ((*top-level* k))
(let ((val (thunk)))
(eq-put! thunk 'last-ptrace *current-ptrace*)
(eq-put! thunk 'total-iterations *niter-done*)
(*top-level* val)))))))
(define (resume thunk niter)
(call-with-current-continuation
(lambda (k)
(within-continuation
(ptrace:emit-continuation (eq-get thunk 'last-ptrace))
(lambda () (set! *niter-left* niter) (set! *top-level* k) #!unspecific)))))
| false |
da7bae83866e873b0a766db1959dfb46e0291cea
|
c74dcb1facbd920d762017345171f47f8e41d0c5
|
/chapter_3/3.17.scm
|
bba80952f52f5062f3598990fc9b99fe41eba8b5
|
[] |
no_license
|
akash-akya/sicp-exercises
|
5125c1118c7f0e4400cb823508797fb67c745592
|
c28f73719740c2c495b7bc38ee8b790219482b67
|
refs/heads/master
| 2021-06-15T19:12:47.679967 | 2019-08-03T14:03:20 | 2019-08-03T14:03:20 | 136,158,517 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 647 |
scm
|
3.17.scm
|
#lang sicp
(#%require "utils.scm")
;; Exercise 3.17: Devise a correct version of the count-pairs
;; procedure of Exercise 3.16 that returns the number of distinct
;; pairs in any structure. (Hint: Traverse the structure, maintaining
;; an auxiliary data structure that is used to keep track of which
;; pairs have already been counted.)
(define (count-pairs x)
(define visited '())
(define (iter a)
(cond ((not (pair? x)) 0)
((not (member x visited))
(set! visited (cons x visited))
(+ (count-pairs (car x))
(count-pairs (cdr x))
1))
(else 0)))
(iter x))
;; test
| false |
aad0e30da4d5adea977db5df2bf778c24d5fed2e
|
1ed47579ca9136f3f2b25bda1610c834ab12a386
|
/sec4/q4.68.scm
|
4f2d468bcac5307b2aa402bd3c3a9948550c1a56
|
[] |
no_license
|
thash/sicp
|
7e89cf020e2bf5ca50543d10fa89eb1440f700fb
|
3fc7a87d06eccbe4dcd634406e3b400d9405e9c4
|
refs/heads/master
| 2021-05-28T16:29:26.617617 | 2014-09-15T21:19:23 | 2014-09-15T21:19:23 | 3,238,591 | 0 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,057 |
scm
|
q4.68.scm
|
(load "./sec4.4-Serendip")
(query-driver-loop)
;; reverse演算を実装せよ.
;; 想定される使い方
(reverse (1 2 3) ?x)
(reverse ?x (1 2 3))
;; append-to-form -> sec4.4-Logic-Programming.scm "プログラムとしての論理" より抽出
(assert! (rule (append-to-form () ?y ?y)))
(assert! (rule (append-to-form (?u . ?v) ?y (?u . ?z))
(append-to-form ?v ?y ?z)))
;;; 実装 ;;;
(assert! (rule (reverse (?x) (?x)))) ;; 最終防御用pattern match
(assert! (rule (reverse (?head . ?tail) ?z)
(and (reverse ?tail ?w)
(append-to-form ?w (?head) ?z))))
;; 動いた.
;; が, これだと (reverse (1 2 3) ?x) しか対応できない.
;; この段階の(テキスト上想定してる)実装力では, それでいいらしい.
;; 解答例(動かない...)
;(assert! (rule (reverse () ()))) ??
(assert! (rule (reverse ?x ?y)
(and
(append-to-form (?car) ?cdr ?x)
(append-to-form ?rev-cdr (?car) ?y)
(reverse ?cdr ?rev-cdr))))
| false |
ef2ec731c1fefc0d38644025861fdcf2bfddcbc6
|
4e64a8ed146a67f0d35d34a3c2d7af266d35e1eb
|
/scheme/scheme_files/gabriel/dderiv.scm
|
109443c7458195b6bd2f6a56d6ea58b0c522effd
|
[] |
permissive
|
svenkeidel/sturdy
|
0900f427f8df1731be009ee4f18051e1e93356b4
|
4962b9fbe0dab0a7b07f79fe843f4265c782e007
|
refs/heads/master
| 2023-07-05T22:00:22.524391 | 2023-06-23T04:05:50 | 2023-06-23T04:06:14 | 126,147,527 | 55 | 8 |
BSD-3-Clause
| 2023-05-22T10:18:35 | 2018-03-21T08:34:54 |
Pascal
|
UTF-8
|
Scheme
| false | false | 2,539 |
scm
|
dderiv.scm
|
(include-equals)
(define (map f l)
(if (null? l)
l
(if (pair? l)
(cons (f (car l)) (map f (cdr l)))
(error "Cannot map over a non-list"))))
(define (lookup key table)
(letrec ((loop (lambda (x)
(if (null? x)
#f
(let ((pair (car x)))
(if (eq? (car pair) key)
pair
(loop (cdr x))))))))
(loop table)))
(define properties '())
(define (get key1 key2)
(let ((x (lookup key1 properties)))
(if x
(let ((y (lookup key2 (cdr x))))
(if y
(cdr y)
#f))
#f)))
(define (put key1 key2 val)
(let ((x (lookup key1 properties)))
(if x
(let ((y (lookup key2 (cdr x))))
(if y
(set-cdr! y val)
(set-cdr! x (cons (cons key2 val) (cdr x)))))
(set! properties
(cons (cons key1 (cons (cons key2 val) '())) properties)))))
(define (dderiv a)
(if (not (pair? a))
(if (eq? a 'x) 1 0)
(let ((f (get (car a) 'dderiv)))
(if f
(f a)
(error "No derivation method available")))))
(define (my+dderiv a)
(cons '+
(map dderiv (cdr a))))
(define (my-dderiv a)
(cons '-
(map dderiv (cdr a))))
(define (*dderiv a)
(cons '*
(cons a
(cons (cons '+
(map (lambda (a) (cons '/ (cons (dderiv a) (cons a '())))) (cdr a)))
'()))))
(define (/dderiv a)
(cons '-
(cons (cons '/
(cons (dderiv (cadr a))
(cons (caddr a) '())))
(cons (cons '/
(cons (cadr a)
(cons (cons '*
(cons (caddr a)
(cons (caddr a)
(cons (dderiv (caddr a))
'()))))
'())))
'()))))
(put '+ 'dderiv my+dderiv)
(put '- 'dderiv my-dderiv)
(put '* 'dderiv *dderiv)
(put '/ 'dderiv /dderiv)
(let ((arg '(+ (* 3 x x) (* a x x) (* b x) 5))
(result '(+ (* (* 3 x x) (+ (/ 0 3) (/ 1 x) (/ 1 x)))
(* (* a x x) (+ (/ 0 a) (/ 1 x) (/ 1 x)))
(* (* b x) (+ (/ 0 b) (/ 1 x)))
0)))
(equal? (dderiv arg) result))
| false |
e3e3ac87615f308bbc6cc3f0a7d8e5c73a7bc6b5
|
79955bb9083a947c38d202cfa5a7fa2c7ef5f2cf
|
/ch3.scm
|
5d54549cd6ebb281a605a64cdbe56384b8bb47e1
|
[] |
no_license
|
vujadetech/YASR
|
feba5cc9573ff45f55054f874eede1c9a88608d7
|
31ee98e4a8f168fce20261e07987a8d1a704e73b
|
refs/heads/master
| 2020-05-02T17:34:33.405727 | 2019-05-26T02:42:16 | 2019-05-26T02:42:16 | 178,103,249 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 18,914 |
scm
|
ch3.scm
|
#lang racket
; For set-car! etc:
;(require r5rs) ; This threw an error - conflicts with srfi/1?
(require rnrs/mutable-pairs-6)
(require srfi/1)
(require "utils-vujadeTech.rkt")
; *******************************************
; Sec 3.1 Assignment and local state
(define (make-withdraw balance)
(lambda (amount)
(if (>= balance amount)
(begin (set! balance (- balance amount))
balance)
"Insufficient funds")))
(define W1 (make-withdraw 100))
(define W2 (make-withdraw 100))
; We can also create objects that handle deposits as well as withdrawals, and
; thus we can represent simple bank accounts. Here is a procedure that returns
; a ``bank-account object'' with a specified initial balance:
(define (make-account balance)
(define (withdraw amount) ; This appears to behave like an OO member function. Ditto for deposit.
(if (>= balance amount)
(begin (set! balance (- balance amount))
balance)
"Insufficient funds"))
(define (deposit amount)
(set! balance (+ balance amount))
balance)
;(define (current-balance) balance)
(define (dispatch m) ; This appears to function like an OO virtual lookup table. And m means "member"?
(cond ((eq? m 'withdraw) withdraw)
((eq? m 'deposit) deposit)
((eq? m 'current-balance) balance)
(else (error "Unknown request -- MAKE-ACCOUNT"
m))))
dispatch)
(define acc (make-account 100)) ; Same as C++ constructor with member variable balance = 100?
;((acc 'withdraw) 50) ; Same as C++ acc->withdraw(50)?
;((acc 'withdraw) 60)
;((acc 'deposit) 40)
;((acc 'withdraw) 60)
; *******************************************
; Ex 3.1
(define (make-accumulator current) ; Start with current, add delta when calling the function each time.
(λ (delta)
; (+=! current delta)
(set! current (+ current delta))
current))
(define A (make-accumulator 5))
; *******************************************
; Ex 3.2
(define (make-monitored f)
(let ([count (make-accumulator 0)])
(λ (x)
(if (number? x)
(begin
(count 1) ; add 1 to count
(f x)) ; and return f(x)
(count 0)) ; return current count
)))
(define s (make-monitored sqrt))
; *******************************************
; Ex 3.3
(define (make-account-with-password balance password)
(let ([acc (make-account balance)])
(λ (pass-given m) ; Must provide both a pass and m so acc will know whether to dispatch on
; withdraw or deposit.
(if (eq? pass-given password)
(acc m)
(λ (_) "Incorrect password.") ; constant function "Incorrect password."
))))
#;(define make-account-with-password-curried
(λ (password)
(λ (balance)
(let ([acc (make-account balance)])
(λ (pass-given)
(if (eq? pass-given password)
acc
(error "Incorrect password.")
))))))
;(define mawph make-account-with-password-h)
#;(define mawpc make-account-with-password-curried)
#;(define (make-account-with-password balance password)
((make-account-with-password-curried password) balance))
#;(define (mawp b p)
((mawpc p) b))
(define acc-pass (make-account-with-password 100 'secret-password))
;;((acc-pass 'secret-password 'withdraw) 40) ; => 60
;;((acc-pass 'some-other-password 'deposit) 50) ; => "Incorrect password."
; *******************************************
; Ex 3.4
(define (reset-accumulator a) (a (- (a 0))))
(define call-the-cops (λ (_) "Quick! What's the number for 911!?!?!"))
(define (make-account-with-password-limit balance password)
(let ([acc (make-account balance)][failed-pass (make-accumulator 0)][fail-pass-limit 7])
(λ (pass-given m) ; Must provide both a pass and m so acc will know whether to dispatch on
; withdraw or deposit.
(if (eq? pass-given password)
(begin ; correct pass
(reset-accumulator failed-pass)
(acc m))
(begin ; wrong pass
(failed-pass 1)
; (display (failed-pass 0))
(if (<= (failed-pass 0) fail-pass-limit)
(λ (_) "Incorrect password.")
call-the-cops))))))
(define acc-pass-limit (make-account-with-password-limit 100 'secret-password))
;; (map (λ (pass) ((acc-pass-limit pass 'deposit) 50)) (repeat 'some-other-password 8))
; => '("Incorrect password."
; "Incorrect password."
; "Incorrect password."
; "Incorrect password."
; "Incorrect password."
; "Incorrect password."
; "Incorrect password."
; "Quick! What's the number for 911!?!?!")
; *******************************************
; Sec 3.1.2 The benefits of introducing assignment,
; the importance of being earnest, and the politics of dancing*.
; I mean just the first one, sorry for that hilarious joke interruption!
; * One of the best 80s songs from the 20th century: https://www.youtube.com/watch?v=sRrSwLHyxGc
; rand-update is from pscholz's github, https://github.com/psholtz/MIT-SICP/tree/master/Section-3.1:
(define m (expt 2 32))
(define a 1664525)
(define b 1013904423)
(define (rand-update x) ; Could also think of this is (next-rand x)
(let ((m (expt 2 32))
(a 1664525)
(b 1013904423))
(remainder (+ (* a x) b) m)))
; The book didn't say what value to use for random-init.
(define random-init 42)
(define rand
(let ((x random-init)) ; x is like a C++ member variable here? Not sure but this is interesting.
(lambda ()
(set! x (rand-update x))
x)))
(define (estimate-pi-mc trials)
(sqrt (/ 6 (monte-carlo trials cesaro-test))))
(define (cesaro-test)
(= (gcd (rand) (rand)) 1))
(define (monte-carlo trials experiment)
(define (iter trials-remaining trials-passed)
(cond ((= trials-remaining 0)
(/ trials-passed trials))
((experiment)
(iter (- trials-remaining 1) (+ trials-passed 1)))
(else
(iter (- trials-remaining 1) trials-passed))))
(iter trials 0))
; [book] Now let us try the same computation using rand-update directly rather than rand, the way we would be forced to proceed if we did not use assignment to model local state:
(define (estimate-pi trials)
(sqrt (/ 6 (random-gcd-test trials random-init))))
(define (random-gcd-test trials initial-x)
(define (iter trials-remaining trials-passed x)
(let ((x1 (rand-update x)))
(let ((x2 (rand-update x1)))
(cond ((= trials-remaining 0)
(/ trials-passed trials))
((= (gcd x1 x2) 1)
(iter (- trials-remaining 1)
(+ trials-passed 1)
x2))
(else
(iter (- trials-remaining 1)
trials-passed
x2))))))
(iter trials 0 initial-x))
; *******************************************
; Ex 3.5 Monte Carlo integration, which is not to be confused with
; Atlantic City integration, Jersey style. HEY-oh!
; Apparently an Atlantic City algorithm is an actual thing, though my joke
; is still a great idea and I stand by: https://en.wikipedia.org/wiki/Atlantic_City_algorithm.
; The last sentence was inspired by "Focus group" by Tim Robinson: https://www.youtube.com/watch?v=8YDpvMYk5jA
(define (random-in-range low high)
(let ((range (- high low)))
(+ low (random range))))
(define (random-pair-in-range x1 x2 y1 y2) ; random pair in R2, that is 2D space
(cons (random-in-range x1 x2) (random-in-range y1 y2)))
(define (hyp^2 x1 x2 y1 y2) ; (x2 - x1)^2 + (y2 - y1)^2
(+ (sq (- x2 x1)) (sq (- y2 y1))))
(define (in-circle-radius-R? R)
(λ (x y)
(< (+ (sq x) (sq y)) (sq R))))
(define icr10? (in-circle-radius-R? 10))
(define square-radius-10 (list -10 10 -10 10))
#;(define (exp10)
(let ([X1 -10] [X2 10] [Y1 -10] [Y2 10] [P icr10?])
(let ([x (random-in-range X1 X2)] [y (random-in-range Y1 Y2)])
(icr10? x y))))
(define (experiment-pi R) ; assume circle is radius R at (0,0), region is square bounding the circle
; experiment is to pick a random (x,y) coordinate in [-R,R] x [-R,R]
; and see if it's in the circle of radius R at (0,0).
(let* ([X1 (negative R)][X2 R][Y1 X1][Y2 X2][P (in-circle-radius-R? R)])
(let ([x (random-in-range X1 X2)] [y (random-in-range Y1 Y2)])
(P x y))))
(define exp10 (experiment-pi 10))
(define (estimate-integral P X1 X2 Y1 Y2 N) ; P = predicate, N = # trials
(let ([total-area (* (- X2 X1) (- Y2 Y1))])
(monte-carlo N P)))
; (let ratio (exact->inexact (monte-carlo N P)))
(define (Pi-ei N [R 10]) ; Pi using estimate-integral, N = # trials
(let* ([X1 (negative R)][X2 R][Y1 X1][Y2 X2][P (in-circle-radius-R? R)])
; (estimate-integral (in-circle-radius-R? R) X1 X2 Y1 Y2 N)))
(estimate-integral
(λ () (experiment-pi R)) ; experiment must be a function of 0 arguments
X1 X2 Y1 Y2 N)))
; (define PI (exact->inexact (* 4 (monte-carlo 100 exp10))))
;; PI ; => 3.24 Answer is unfluenced by randomness, so YMMV :)
; *******************************************
; Ex 3.6, let's call it rand-with-reset to avoid clobbering rand which is in namespace
(define rand-with-reset
(let ([x random-init])
(λ (m)
(cond
[(eq? m 'generate)
(begin
(set! x (rand-update x))
x)]
[(eq? m 'reset)
(λ (new-seed) (set! x new-seed) new-seed)]
))))
;;(map (λ (_) (rand-with-reset 'generate)) (range 1 5))
;;(map (λ (_) (rand-with-reset 'generate)) (range 1 5))
;;((rand-with-reset 'reset) random-init)
;;(map (λ (_) (rand-with-reset 'generate)) (range 1 5))
; Last and first "random" lists should be the same: '(1083814473 711399388 3416838739 1642706014)
; *******************************************
; Ex 3.7
(define bad-pass-response (λ (_) "Incorrect password.")) ; constant function "Incorrect password."
(define (make-joint acc1 pass1 pass2) ; (acc 'pass1) account must already exist and
; is pass protected. That is, it needs a pass as well as member function to work.
(λ (pass2-given m)
(if (eq? pass2-given pass2)
(acc1 pass1 m) ; acc1 needs pass1 to work
bad-pass-response)))
(define peter-acc (make-account-with-password 100 'open-sesame))
(define paul-acc (make-joint peter-acc 'open-sesame 'rosebud))
;;(paul-acc 'rosebud 'current-balance) ; => 100
;;((paul-acc 'rosebud 'deposit) 25) ; => 125
;;(peter-acc 'open-sesame 'current-balance) ; 125, so peter has 125 b/c paul put in 25
; *******************************************
; Ex 3.8
(define (f x)
(mod (apply + (flatten (idt x))) 2))
; +_lr is like plus but forces evaluation of e1 first
(define (+_lr e1 e2) ; e1 and e2 are quoted to delay evaluation so they can be ordered.
(let ([x1 (eval e1)]) ; eval e1 first
(let ([x2 (eval e2)])
(+ x1 x2))))
(define (+_rl e1 e2) ; e1 and e2 are quoted to delay evaluation so they can be ordered.
(let ([x2 (eval e2)]) ; eval e2 first
(let ([x1 (eval e1)])
(+ x1 x2))))
(define (make-list-acc xs)
(λ (ys)
(set! xs (append ys xs))
xs))
(define (g x)
(let ([xs (make-list-acc '())][count (make-accumulator 0)])
(list (count 1) (xs x))))
(define id (λ (x) x))
(define (make-historied f [starting-history '()]) ; if a number x is sent to f, returns f(x), otherwise all values previously sent to f
(let ([history (make-list-acc starting-history)])
(λ (x)
(if (number? x) ; if x is a num, add x to history and return f(x)
(begin
(history (list x))
(f x))
(history '()))))) ; else just return history for any input that's not a number, like say the symbol 'get-history
(define (f2 x)
(let* ([idh (make-historied id)][curr (idh '())])
(let ([answer (if (empty? (idh '())) 0 (car (idh '())))])
(begin
(idh x)
(list answer (idh '()))))))
(define (f3 x)
(let ([f3-trail (f-trail id)])
; (let ([trail (f3-trail x)])
; trail)))
(f3-trail x)))
#;(define (f-trail f)
(let ([f-hist (make-historied f)])
(λ (x)
(let ([curr (f-hist x)])
(list curr (f-hist '()))))))
(define (f-trail f)
(let ([f-hist (make-historied f)])
(λ (x)
(f-hist x))))
(define idt (f-trail id))
(define (sq* x)
(let ([xs '()])
(set! xs (cons (sq x) xs))
xs))
;;(+_lr '(f 0) '(f 1)) ; => 0
;;(+_rl '(f 0) '(f 1)) ; => 1
;; (+ (f 0) (f 1)) ; => 0, so + is behaving like it evaluates it's arguments left to right.
; NB: This was failing sometimes b/c it needed the environment reevaluated. See below for more experiments.
(define (f4 x)
(let* ([curr (idt x)][hist (cdr curr)][prev-hist (if (empty? hist) '() (cdr hist))])
; (list hist prev-hist)))
(let ([prev-x (cond
[(empty? (cdr hist)) 0]
[else (cadr hist)])])
(list prev-x hist))))
(define (f5 x)
(let* ([curr (idt x)][hist (cdr curr)])
(let ([prev-hist (if (empty? hist) '() (cdr hist))])
(list hist prev-hist))))
(define (f6 x)
(let* ([prev (idt '())][curr (idt x)])
(list prev curr)))
(define f7
(let ([xs-hist (make-historied id)])
(λ (x)
(let ([has-prev-x? (not (empty? (xs-hist 'hist)))])
(let ([prev-x (if has-prev-x? (car (xs-hist 'hist)) 0)]) ; set prev-x to 0 if no history yet
(xs-hist x) ; add x to history
(if (not has-prev-x?)
x ; if no history, it's identity
(if (zero? x)
(++ (negative (f7 1)))
(negative (f7 0)))))))))
(define f8
(let ([idm (make-historied id '(-1))])
(λ (x)
(idm x)
(idm 'hist))))
(define f9
(let ([idm (make-monitored id)])
(λ (x)
(idm x)
(if (zero? x)
(++ (idm 'num-calls))
(negative (idm 'num-calls))))))
(define (f10 x) (/ (f9 x) 2))
; Finally got one that works regardless of function history:
;; (+ (f10 0) (f10 1)) ; => 0
;; (+ (f10 1) (f10 0)) ; => 1 This is like a + that evaluates right to left on the above inputs above.
; *******************************************
; 3.2 The environment model of evaluation
; TL;DR: An ENV is seq of FRAMES what are tables of (possibly empty) BINDINGS (var of num, proc, etc => value)
; and a pointer to its enclosing ENV (unless it's the global ENV). BINDINGS are searched bottum up.
; [From book]
; When we introduced compound procedures in chapter 1, we used the substitution model of evaluation
; (section 1.1.5) to define what is meant by applying a procedure to arguments:
; To apply a compound procedure to arguments, evaluate the body of the procedure with each
; formal parameter replaced by the corresponding argument.
; Once we admit assignment into our programming language, such a definition is no longer adequate.
; In particular, section 3.1.3 argued that, in the presence of assignment, a variable can no longer
; be considered to be merely a name for a value. Rather, a variable must somehow designate a ``place''
; in which values can be stored. In our new model of evaluation, these places will be maintained in
; structures called environments.
; An environment is a sequence of frames. Each frame is a table (possibly empty) of bindings,
; which associate variable names with their corresponding values. (A single frame may contain at most
; one binding for any variable.) Each frame also has a pointer to its enclosing environment,
; unless, for the purposes of discussion, the frame is considered to be global.
; The value of a variable with respect to an environment is the value given by the binding of the
; variable in the first frame in the environment that contains a binding for that variable.
; If no frame in the sequence specifies a binding for the variable, then the variable is said
; to be unbound in the environment.
; *******************************************
; Ex 3.9, NA show environment structures created
; *******************************************
; Ex 3.10 NA show ENVs
; Recall from section 1.3.2 that let is simply syntactic sugar for a procedure call:
; (let ([<var> <exp>])
; <body>) is interpreted as an alternate syntax for
; ((λ (<var>) <body>) <exp>)
; *******************************************
; Ex 3.11 NA show ENVs
; *******************************************
; Ex 3.12 See ch3-lang-sicp.scm.
; *******************************************
; *******************************************
; Representing Tables
(define (lookup key table)
(let ((record (assoc key (cdr table))))
(if record
(cdr record)
false)))
(define (assoc key records [pred equal?])
(cond ((null? records) false)
((equal? key (caar records)) (car records))
(else (assoc key (cdr records)))))
; To insert a value in a table under a specified key, we first use assoc to see if there is already a record in the table with this key. If not, we form a new record by consing the key with the value, and insert this at the head of the table's list of records, after the dummy record. If there already is a record with this key, we set the cdr of this record to the designated new value. The header of the table provides us with a fixed location to modify in order to insert the new record.25
(define (insert! key value table)
(let ((record (assoc key (cdr table))))
(if record
(set-cdr! record value)
(set-cdr! table
(cons (cons key value) (cdr table)))))
'ok)
; To construct a new table, we simply create a list containing the symbol *table*:
(define (make-table) (list '*table*))
(define t (make-table))
;(insert! 'a 1 t)
;(insert! 'b 2 t)
;(insert! 'c 3 t)
;(assoc 'b (cdr t))
; *******************************************
; Ex 3.24
(define (make-table-g same-key?) ; Generic version of make-table
(let ([foo 42])
; member functions
; dispatch
0))
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
; *******************************************
| false |
9d83d3590609a2ab9ab504e533c9dfe9d090ae3d
|
eaa28dbef6926d67307a4dc8bae385f78acf70f9
|
/lib/pikkukivi/command/ääliö/main.sld
|
36d0549e1e3157f5d1d121d9eb2942ff4862e491
|
[
"Unlicense"
] |
permissive
|
mytoh/pikkukivi
|
d792a3c20db4738d99d5cee0530401a144027f1f
|
d3d77df71f4267b9629c3fc21a49be77940bf8ad
|
refs/heads/master
| 2016-09-01T18:42:53.979557 | 2015-09-04T08:32:08 | 2015-09-04T08:32:08 | 5,688,224 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 6,902 |
sld
|
main.sld
|
(define-library (pikkukivi command ääliö main)
(export
ääliö)
(import
(scheme base)
(scheme write)
(scheme process-context)
(gauche base)
(gauche process) ; run-process
(gauche parseopt)
(srfi 13)
(srfi 37)
(util match)
(file util) ; directory-list, current-directory
(maali)
(clojure)
(kirjasto merkkijono)
(kirjasto list)
(kirjasto tiedosto)
(rename (prefix (kirjasto tiedosto polku) path:)))
(begin
(define *ääliöpath*
(let ((ääliöpath (get-environment-variable "ääliöpath")))
(if ääliöpath
ääliöpath
(expand-path "~/huone/git/"))))
(define (do-root)
(println *ääliöpath*))
;; update git repository
(define (do-update)
(let ((repos (find-git-repository *ääliöpath*)))
(for-each
(lambda (r)
(update-git-repository r))
repos)
(println "update finished!")))
(define (update-git-repository dir)
(message-update dir)
(run-process `(git -C ,dir pull --ff --ff-only) ':wait #true)
(newline))
(define (message-update dir)
(display (paint "=> " 4))
(display (paint (path:child dir) 3))
(display " ")
(println (paint (string-drop dir (string-length *ääliöpath*))
39)))
(define (git-repository? directory)
(file-exists? (path:join directory ".git")))
(define (find-git-repository directory)
(flatten
(map
(lambda (d)
(if (git-repository? d)
d
(find-git-repository d)))
(directory-list2 directory
':children? #true
':add-path? #true))))
;; clean git repository with "git gc"
(define (do-clean)
(let ((dirs (list (directory-list (expand-path *ääliöpath*)
':children? #true
':add-path? #true))))
(let loop ((dirs (car dirs)))
(cond
((null? dirs)
(display "cleaning finished!\n"))
(else
(cond
((file-is-directory? (car dirs))
(display (paint "=> " 4))
(println (paint (path:child (car dirs)) 3))
(run-process '(git gc)
':wait #true
':directory (car dirs))
(newline))
(else #true))
(loop (cdr dirs)))))))
(define (do-list args)
(receive (full-path?)
(args-fold (cdr args)
options-list
(lambda (option name arg . seeds)
(error "Unrecognized option: " name))
(lambda (operand full-path)
(values full-path))
#false)
(let ((repos (find-git-repository *ääliöpath*)))
(if full-path?
(map
println
repos)
(map
(lambda (r)
(println (string-drop r (string-length *ääliöpath*))))
repos)))))
(define (do-usage status)
(exit status "usage: ~a <command> <package-name>\n" "ääliö"))
(define (do-get args)
(receive (branch-name rest)
(args-fold (cdr args)
options-get
(lambda (opt name arg branch . seeds)
(error "Unrecognized option: " name))
(lambda (operand branch rest)
(values branch (reverse (cons operand rest))))
#false
'())
(let* ((path (format-url->path (car rest)))
(git-url (format-url->git (car rest))))
(println git-url)
(if branch-name
(run-process `(git clone --depth 1 -b ,branch-name ,git-url ,path)
':wait #true)
(run-process `(git clone --depth 1 ,git-url ,path)
':wait #true)))))
(define options-get
(list (option '(#\b "branch") 'required-arg? (not 'optional-arg?)
(lambda (opt name arg branch rest)
(values arg rest)))))
(define (url-is-github-short? url)
(= 1 (string-count url #\/)))
(define (url-is-github? url)
(and (= 2 (string-count url #\/))
(string-prefix? "github.com" url)))
(define (format-url->path url)
(cond
;; user/repo
((url-is-github-short? url)
(string-append "github.com/" url))
;; github.com/user/repo
((url-is-github? url)
url)
(else
(trim-url-prefix url))))
(define (format-url->git url)
(cond
((url-is-github-short? url)
(string-append "git://github.com/" url))
((url-is-github? url)
(string-append "git://" url))
(else
url)))
(define (trim-url-prefix url)
(define (drop-prefix u prefix)
(string-drop u (string-length prefix)))
(cond ((url-protocol=? "http" url)
(drop-prefix url "http://"))
((url-protocol=? "https" url)
(drop-prefix url "https://"))
((url-protocol=? "git" url)
(drop-prefix url "git://"))))
(define (url-protocol=? p url)
(let ((proto (string-append p "://")))
(string= proto
(string-take url (string-length proto)))))
(define options
(list (option '(#\h "help") (not 'required-arg?) (not 'optional-arg?)
(lambda (opt name arg help)
(values (or arg #true))))))
(define options-list
(list (option '(#\p "full-path") (not 'required-arg?) (not 'optional-arg?)
(lambda (opt name arg full-path)
(values #true)))))
(define (ääliö args)
(receive (help)
(args-fold args
options
(lambda (opt name arg . seeds)
(values #false))
(lambda (operand help)
(values help))
#false ; default help
)
(cond
(help
(do-usage 0))
(else
(with-cwd *ääliöpath*
(match (car args)
;; commands
((or "update" "up")
(begin
(print (string-append (paint "updating " 8) "repositories"))
(do-update)))
("clean"
(do-clean))
("list"
(do-list args))
("get"
(do-get args))
("root"
(do-root))
(_ (do-usage 1)))))))
0)
))
| false |
072b2469f0427061299fd2a42f5cdc59e27f43d8
|
aa3c0aed788687ccc10a85d9cb8dd77a8ffbd5e9
|
/sql-de-lite.egg
|
22fa6e8fc7de4d47c3892b8fc6c082983840a0e7
|
[] |
no_license
|
ursetto/sql-de-lite
|
22c3cc76127fe2d20f577c638e81b83ab6c3ba2d
|
0f974749d5caa0a34e2a7d6dcc4163f2cb4beac3
|
refs/heads/master
| 2023-03-06T16:12:22.018124 | 2023-02-13T04:11:01 | 2023-02-13T04:11:01 | 157,043,421 | 4 | 7 | null | 2023-02-13T04:11:02 | 2018-11-11T03:19:36 |
C
|
UTF-8
|
Scheme
| false | false | 2,447 |
egg
|
sql-de-lite.egg
|
;; -*- scheme -*-
;; Builds with internal SQLite library, or external system library if
;; -feature sql-de-lite-external-lib is defined.
((synopsis "SQLite 3 interface")
(author "Jim Ursetto")
(category db)
(license "BSD")
(dependencies foreigners object-evict srfi-1 srfi-18 srfi-69) ;; And bind if you want to update sqlite3-api
(test-dependencies test compile-file)
(version "0.10.0")
(components (extension sql-de-lite
(types-file)
(cond-expand
(sql-de-lite-external-lib
(link-options -L -lsqlite3))
(else
(objects sqlite3)
(csc-options -C -Isqlite3)))
(csc-options -O2 -d2 -inline -local
-types sql-de-lite-cache.types)
(component-dependencies sql-de-lite-cache)
(source-dependencies "sqlite3-api.scm"))
(extension sql-de-lite-cache
(types-file)
(csc-options -O2 -d0 -inline -local))
(cond-expand
(sql-de-lite-external-lib)
(else
(c-object sqlite3
(source "sqlite3/sqlite3.c")
(source-dependencies "sqlite3/sqlite3.h"
"sqlite3/sqlite3ext.h")
(csc-options -C -Isqlite3
-C -DSQLITE_THREADSAFE=0 ;; avoid linking in pthreads
-C -DSQLITE_ENABLE_FTS3
-C -DSQLITE_ENABLE_FTS3_PARENTHESIS
-C -DSQLITE_ENABLE_FTS4
-C -DSQLITE_ENABLE_FTS5
-C -DSQLITE_ENABLE_JSON1
-C -DSQLITE_USE_URI
))))
(program chicken-sqlite3
(cond-expand
((and windows sql-de-lite-external-lib)) ; skip
(sql-de-lite-external-lib
(source "chicken-sqlite3.sh")
(custom-build build-chicken-sqlite3))
(else
(source "sqlite3/shell.c")
(objects sqlite3))))))
| false |
97f9ed0fc16f05efd3bfb0adedb40ac5b246ab83
|
acc632afe0d8d8b94b781beb1442bbf3b1488d22
|
/deps/sdl2/lib/sdl2-internals/helpers/foreign-lambda-with-dynamic-body.scm
|
977beac960f6db12fa70579f3e89e16ccaa01718
|
[
"BSD-2-Clause",
"BSD-3-Clause"
] |
permissive
|
kdltr/life-is-so-pretty
|
6cc6e6c6e590dda30c40fdbfd42a5a3a23644794
|
5edccf86702a543d78f8c7e0f6ae544a1b9870cd
|
refs/heads/master
| 2021-01-20T21:12:00.963219 | 2016-05-13T12:19:02 | 2016-05-13T12:19:02 | 61,128,206 | 1 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,489 |
scm
|
foreign-lambda-with-dynamic-body.scm
|
;;
;; chicken-sdl2: CHICKEN Scheme bindings to Simple DirectMedia Layer 2
;;
;; Copyright © 2013, 2015-2016 John Croisant.
;; All rights reserved.
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions
;; are met:
;;
;; - Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;;
;; - Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in
;; the documentation and/or other materials provided with the
;; distribution.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
;; FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
;; COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
;; INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
;; STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
;; OF THE POSSIBILITY OF SUCH DAMAGE.
;;; Like foreign-lambda*, except the function body string is
;;; constructed dynamically (at macro expansion time) using sprintf.
;;;
;;; Usage:
;;;
;;; (foreign-lambda*-with-dynamic-body
;;; RETURN-TYPE
;;; (ARG-TYPE ...)
;;; (BODY-FORMATSTRING FORMAT-ARG ...))
;;;
;;; This macro is used within other macros to generate function bodies
;;; based on a template. For example, a type or field name within the
;;; function body can be filled in based on the arguments given to the
;;; high-level macro.
;;;
;;; Because the body string is constructed at macro expansion time,
;;; each FORMAT-ARG must be a literal value like a symbol, string, or
;;; number.
;;;
(define-syntax foreign-lambda*-with-dynamic-body
(ir-macro-transformer
(lambda (form inject compare?)
(let ((return-type (list-ref form 1))
(args (list-ref form 2))
(body (list-ref form 3)))
`(foreign-lambda*
,return-type
,args
,(apply sprintf (map strip-syntax body)))))))
| true |
f2909b282100bbec455b85f63c05b44f6f70df01
|
4b480cab3426c89e3e49554d05d1b36aad8aeef4
|
/misc/SpiralArray.scm
|
8936d85e8b6ec1c8bc31744c1d97b4a5371f84db
|
[] |
no_license
|
tuestudy/study-sicp
|
a5dc423719ca30a30ae685e1686534a2c9183b31
|
a2d5d65e711ac5fee3914e45be7d5c2a62bfc20f
|
refs/heads/master
| 2021-01-12T13:37:56.874455 | 2016-10-04T12:26:45 | 2016-10-04T12:26:45 | 69,962,129 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,627 |
scm
|
SpiralArray.scm
|
(load "../misc/scheme-test.scm")
(define nil ())
(define (back-direction x y size)
(let ((s-1 (- size 1))
(x+y (+ x y)))
(cond ((and (= x 0) (= y 0)) (cons 0 0))
((and (>= x y) (<= x+y s-1)) (cons -1 0))
((and (>= x y) (> x+y s-1)) (cons 0 -1))
((and (< x y) (>= x+y s-1)) (cons 1 0))
((and (< x y) (< x+y s-1)) (cons 0 1)))))
(define (number x y size)
(let ((d (back-direction x y size)))
(if (equal? d (cons 0 0))
0
(+ (number (+ x (car d)) (+ y (cdr d)) size) 1))))
(define (seq start end)
(if (> start end)
()
(cons start (seq (+ start 1) end))))
(define (solve size)
(let ((x (seq 0 (- size 1))))
;(map (lambda (a) (map (lambda (b) (cons a b)) x)) x)))
(map (lambda (a) (map (lambda (b) (number b a size)) x)) x)))
(define (print-it solution)
(display "\n")
(map (lambda (a) (display a) (display "\n") nil) solution))
(print-it (solve 6))
(run (make-testcase
'(assert-equal? (cons 0 0) (back-direction 0 0 6))
'(assert-equal? (cons -1 0) (back-direction 1 0 6))
'(assert-equal? (cons -1 0) (back-direction 5 0 6))
'(assert-equal? (cons 0 -1) (back-direction 5 1 6))
'(assert-equal? (cons 0 -1) (back-direction 3 3 6))
'(assert-equal? 0 (number 0 0 6))
'(assert-equal? 1 (number 1 0 6))
'(assert-equal? 2 (number 2 0 6))
'(assert-equal? 5 (number 5 0 6))
'(assert-equal? 6 (number 5 1 6))
'(assert-equal? 10 (number 5 5 6))
'(assert-equal? 11 (number 4 5 6))
'(assert-equal? 15 (number 0 5 6))
'(assert-equal? 16 (number 0 4 6))
'(assert-equal? 17 (number 0 3 6))
'(assert-equal? 19 (number 0 1 6))
'(assert-equal? 20 (number 1 1 6))))
| false |
4b652074a84b98fece8e48938208633b7b3cd52d
|
000dbfe5d1df2f18e29a76ea7e2a9556cff5e866
|
/lib/sagittarius/mop/immutable.scm
|
a3a0f3c2112e0d9d2917c129c294b9c33dbbd14b
|
[
"BSD-3-Clause",
"LicenseRef-scancode-other-permissive",
"MIT",
"BSD-2-Clause"
] |
permissive
|
ktakashi/sagittarius-scheme
|
0a6d23a9004e8775792ebe27a395366457daba81
|
285e84f7c48b65d6594ff4fbbe47a1b499c9fec0
|
refs/heads/master
| 2023-09-01T23:45:52.702741 | 2023-08-31T10:36:08 | 2023-08-31T10:36:08 | 41,153,733 | 48 | 7 |
NOASSERTION
| 2022-07-13T18:04:42 | 2015-08-21T12:07:54 |
Scheme
|
UTF-8
|
Scheme
| false | false | 2,458 |
scm
|
immutable.scm
|
;;; -*- mode:scheme; coding:utf-8 -*-
;;;
;;; immutable.scm - metaclass to support immutable object
;;;
;;; Copyright (c) 2022 Takashi Kato <[email protected]>
;;;
;;; Redistribution and use in source and binary forms, with or without
;;; modification, are permitted provided that the following conditions
;;; are met:
;;;
;;; 1. Redistributions of source code must retain the above copyright
;;; notice, this list of conditions and the following disclaimer.
;;;
;;; 2. Redistributions in binary form must reproduce the above copyright
;;; notice, this list of conditions and the following disclaimer in the
;;; documentation and/or other materials provided with the distribution.
;;;
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;;
#!nounbound
(library (sagittarius mop immutable)
(export <immutable> <immutable-meta>)
(import (rnrs)
(clos core)
(clos user))
(define-class <immutable-meta> (<class>) ())
(define-class <immutable> () () :metaclass <immutable-meta>)
;; copy&paste of <record-meta>
;; This is needed due to the record inspection, <record-meta>
;; is treated during record inspection and this would ignore object-equal?
;; Might be better to revisit the implementation to adjust
;; as this means, record can't be specialised with object-equal? method.
(define-method compute-getter-and-setter ((c <immutable-meta>) slot)
(let ((mutability (slot-definition-option slot :mutable #f))
(accessors (call-next-method)))
(if mutability
accessors
(list (car accessors)
(lambda (o v)
(error 'slot-setter "field is immutable"
(slot-definition-name slot) o))
(caddr accessors)))))
)
| false |
2264e52f6078a52d6bbc2b69ec9cdb8cf8334d3d
|
6488db22a3d849f94d56797297b2469a61ad22bf
|
/setup-helper/setup-helper.scm
|
5caa8ab9f3902757c0d3fd0a867ba7ce399ddedc
|
[] |
no_license
|
bazurbat/chicken-eggs
|
34d8707cecbbd4975a84ed9a0d7addb6e48899da
|
8e741148d6e0cd67a969513ce2a7fe23241df648
|
refs/heads/master
| 2020-05-18T05:06:02.090313 | 2015-11-18T16:07:12 | 2015-11-18T16:07:12 | 22,037,751 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 14,337 |
scm
|
setup-helper.scm
|
;;;; setup-helper.scm -*- Hen -*-
;;;; Kon Lovett, Mar '09
;;Issues
;;
;; - Accepts anything as a pathname component (see '->string' use).
;;
;; - Static support is limited.
;;; Release 4 Only!
(use
srfi-1
posix
extras
data-structures
files
setup-api)
(define *has-emit-inline* #f)
(define *has-emit-types* #f)
(when (version>=? (chicken-version) "4.0.0")
(set! *has-emit-inline* #t) )
(when (version>=? (chicken-version) "4.7.3")
(set! *has-emit-types* #t) )
;;; Extension Information
(define (verify-extension-name nam)
(let ((extnam (->string nam)))
(unless (string=? extnam (extension-name))
(error "unexpected extension-name" extnam (extension-name)) ) ) )
;;; Support
;; Simple type error report
(define (sh:error-type loc obj #!optional typmsg)
(let* ((msg "bad argument type")
(msg (if typmsg (string-append msg " - not a " typmsg))) )
(##sys#signal-hook #:type-error loc msg obj) ) )
;; Filename Support
(define CHICKEN-SOURCE-EXTENSION "scm")
(define CHICKEN-IMPORT-EXTENSION "import")
(define CHICKEN-INLINE-EXTENSION "inline")
(define CHICKEN-TYPES-EXTENSION "types")
(define HTML-EXTENSION "html")
(define STATIC-ARCHIVE-EXTENSION "a")
(define OBJECT-BINARY-EXTENSION "o")
(cond-expand
(windows
(define EXECUTABLE-EXTENSION "exe")
(define DIRECTORY-SEPARATOR "\\") )
(else
(define EXECUTABLE-EXTENSION #f)
(define DIRECTORY-SEPARATOR "/") ) )
(define (installation-chicken-home)
(if (not (installation-prefix)) (chicken-home)
(make-pathname `(,(installation-prefix) "share") "chicken") ) )
; from repo-path in setup-helper.scm
(define (installation-repository-path)
(if (deployment-mode)
(installation-prefix) ; deploy: copy directly into destdir
(let ((p (destination-prefix)))
(if p
; installation-prefix changed: use it
(make-pathname p (sprintf "lib/chicken/~a" (##sys#fudge 42)))
; otherwise use repo-path
(repository-path) ) ) ) )
(define (directory-separator? obj)
(string=? (->string obj) DIRECTORY-SEPARATOR) )
(define (filename bn #!optional en)
(make-pathname #f (->string bn) (and en (->string en))) )
(define (make-directory-name dir)
(let ((dir (if (symbol? dir) (symbol->string dir) dir)))
(cond
((string? dir)
(let ((end (sub1 (string-length dir))))
(if (not (directory-separator? (string-ref dir end))) dir
(substring dir 0 end) ) ) )
((pair? dir)
(let ((len (length dir)))
(if (= 1 len) (->string (car dir))
;Ensures no trailing directory separator.
(make-pathname
(map ->string (take dir (sub1 len)))
(->string (last dir))) ) ) )
(else
(sh:error-type 'make-directory-name dir) ) ) ) )
(define (document-filename bn)
(filename bn HTML-EXTENSION) )
(define (source-filename bn)
(filename bn CHICKEN-SOURCE-EXTENSION) )
(define (shared-library-filename bn)
(filename bn ##sys#load-library-extension) )
(define (shared-filename bn)
(filename bn ##sys#load-dynamic-extension) )
(define (static-library-filename bn)
(filename bn STATIC-ARCHIVE-EXTENSION) )
(define (static-filename bn)
(filename bn OBJECT-BINARY-EXTENSION) )
(define (import-filename bn)
(filename bn CHICKEN-IMPORT-EXTENSION) )
(define (source-import-filename bn)
(source-filename (import-filename bn)) )
(define (shared-import-filename bn)
(shared-filename (import-filename bn)) )
(define (inline-filename bn)
(filename bn CHICKEN-INLINE-EXTENSION) )
(define (types-filename bn)
(filename bn CHICKEN-TYPES-EXTENSION) )
(define (program-filename bn)
(filename bn EXECUTABLE-EXTENSION) )
(define (make-home-pathname bn)
(make-pathname (installation-chicken-home) bn) )
(define (make-repository-pathname bn)
(make-pathname (installation-repository-path) bn) )
;; File Support
;This subverts the "installation-prefix" relative insurance.
;(and uses the builtin to-path creation "feature").
(define (copy-file-relative fn dn)
(copy-file `(,fn ,fn) dn #t dn) )
;Keeps the "installation-prefix" relative insurance.
;(and uses the builtin to-path creation "feature").
(define (copy-file-absolute fn dn)
(copy-file `(,fn ,fn) dn) )
(define (copy-file-to-directory fn dn)
(copy-file-relative fn dn) )
(define (copy-to-installation-repository fn)
(copy-file-relative fn (installation-repository-path)) )
(define (copy-to-repository fn)
(copy-to-installation-repository fn) )
(define (copy-to-home fn)
(copy-file-relative fn (installation-chicken-home)) )
(define (built-filename nam knd)
(cond
((symbol? knd)
(case knd
((static) (static-filename nam))
((shared) (shared-filename nam))
((inline) (inline-filename nam))
((types) (types-filename nam))
((import) (shared-import-filename nam))
((document) (document-filename nam))
(else
(sh:error-type 'built-filename knd "symbolic kind" ) ) ) )
((procedure? knd)
(knd nam) )
(else
(sh:error-type 'built-filename knd "symbol or procedure") ) ) )
(define (built-file nam . knds)
(let loop ((knds (if (and (null? (cdr knds)) (list? (car knds))) (car knds) knds))
(ls '()))
(if (null? knds) (reverse ls)
(let ((gnflnm (built-filename nam (car knds))))
(loop (cdr knds)
(if (file-exists? gnflnm) (cons gnflnm ls) ls))) ) ) )
;; Single File Install Support
(define (install-in-repository fn)
(when (setup-install-mode)
(copy-to-repository fn) ) )
(define (install-in-home fn)
(when (setup-install-mode)
(copy-to-home fn) ) )
;; SRFI-29 Bundle Support
(define (srfi-29-bundles-home)
(make-repository-pathname "srfi-29-bundles") )
(define (make-srfi-29-bundle-directory-name spec)
(if (null? spec) (srfi-29-bundles-home)
(make-directory-name
(append (list (srfi-29-bundles-home)) spec)) ) )
(define (install-srfi-29-bundle nam . spec)
(when (setup-install-mode)
(unless (directory? (srfi-29-bundles-home))
(error "missing SRFI-29 bundles directory; please install SRFI-29") )
(let* ((spec (map ->string spec))
(nam (->string nam))
(dir (make-srfi-29-bundle-directory-name spec)) )
;Explicit curdir ('.') because problems in the past.
(copy-file
(make-pathname (append '(".") spec) nam)
(make-pathname dir nam)
#t
dir) ) ) )
;; Compile Support
;FIXME -...o style!
(define (output-file-option compile-options)
(or (memq '-o compile-options)
(memq '-output-file compile-options)) )
(define (optional-output-file compile-options)
(let ((of (output-file-option compile-options)))
(if of (list (cadr of)) '()) ) )
;;; Compile
;; Default Options
#;
(define include-path-options
(make-parameter
(cond-expand
(macosx '(-I/opt/local/include -I/sw/include))
(else '()))))
#;
(define library-path-options
(make-parameter
(cond-expand
(macosx '(-L/opt/local/lib -L/sw/lib))
(else '()))))
;Bad idea to make `-local' the default for a module compile (but not an import
;compile) since it means something like `fluid-let' cannot be used on an
;exported binding.
;The import filename base must be the module name!
;The inline filename base must be the output name!
;So assume unused when explicit output name.
(define default-static-compile-options
(make-parameter '(
-c
-optimize-leaf-routines -inline)))
(define default-shared-compile-options
(make-parameter '(
-shared
-optimize-leaf-routines -inline)))
(define default-import-compile-options
(make-parameter '(
-shared
-optimize-leaf-routines -inline
-local
-no-trace -no-lambda-info)))
;; Compile Action
(define (has-emit-inline inline? nam)
(if (not (and *has-emit-inline* inline?)) '()
`(-emit-inline-file ,(inline-filename nam)) ) )
(define (has-emit-types types? nam)
(if (not (and *has-emit-types* types?)) '()
`(-emit-type-file ,(types-filename nam)) ) )
;compile expands using back-quote
(define (compile-static nam #!key (options '()) inline? types?)
(compile
,(source-filename nam)
,@(default-static-compile-options)
-unit ,nam
,@(if (output-file-option options) '() `(-output-file ,(static-filename nam)))
,@(has-emit-inline inline? nam)
,@(has-emit-types types? nam)
,@options) )
(define (compile-shared nam #!key (options '()) inline? types?)
(compile
,(source-filename nam)
,@(default-shared-compile-options)
,@(if (output-file-option options) '() `(-output-file ,(shared-filename nam)))
,@(has-emit-inline inline? nam)
,@(has-emit-types types? nam)
,@options) )
(define (compile-static-module nam #!key (options '()) inline? types?)
(compile
,(source-filename nam)
,@(default-static-compile-options)
-unit ,nam
,@(if (output-file-option options) '() `(-output-file ,(static-filename nam)))
-emit-import-library ,nam
,@(has-emit-inline inline? nam)
,@(has-emit-types types? nam)
,@options)
(compile
,(source-import-filename nam)
,@(default-import-compile-options)
-output-file ,(shared-import-filename nam)) )
(define (compile-shared-module nam #!key (options '()) inline? types?)
(compile
,(source-filename nam)
,@(default-shared-compile-options)
,@(if (output-file-option options) '() `(-output-file ,(shared-filename nam)))
-emit-import-library ,nam
,@(has-emit-inline inline? nam)
,@(has-emit-types types? nam)
,@options)
(compile
,(source-import-filename nam)
,@(default-import-compile-options)
-output-file ,(shared-import-filename nam)) )
;;; Install
(define default-static-install-options
(make-parameter '()))
(define default-shared-install-options
(make-parameter '()))
(define default-static-module-install-options
(make-parameter '()))
(define default-shared-module-install-options
(make-parameter '()))
(define default-shared+static-module-install-options
(make-parameter '()))
;;
(define (install-static-extension nam ver #!key (options '()) (files '()) output-file?)
(install-extension nam
`(,@(built-file nam 'static 'inline 'types)
,@files)
`(,@(default-static-install-options)
(version ,ver)
;FIXME what about explicit output file
(static ,(static-filename nam))
(documentation ,(document-filename nam))
,@options)) )
(define (install-shared-extension nam ver #!key (options '()) (files '()) output-file?)
(install-extension nam
`(,@(built-file nam 'shared 'inline 'types)
,@files)
`(,@(default-shared-install-options)
(version ,ver)
(documentation ,(document-filename nam))
,@options)) )
(define (install-static-extension-module nam ver #!key (options '()) (files '()) output-file?)
(install-extension nam
`(,@(built-file nam 'static 'import 'inline 'types)
,@files)
`(,@(default-static-module-install-options)
(version ,ver)
;FIXME what about explicit output file & .a
(static ,(static-filename nam))
(documentation ,(document-filename nam))
,@options)) )
(define (install-shared-extension-module nam ver #!key (options '()) (files '()) output-file?)
(install-extension nam
`(,@(built-file nam 'shared 'import 'inline 'types)
,@files)
`(,@(default-shared-module-install-options)
(version ,ver)
(documentation ,(document-filename nam))
,@options)) )
(define (install-shared+static-extension-module nam ver
#!key (options '()) (files '()) shared-output-file? static-output-file?)
(install-extension nam
`(,@(built-file nam 'shared 'import 'static 'inline 'types)
,@files)
`(,@(default-shared+static-module-install-options)
(version ,ver)
;FIXME what about explicit output file & .a
(static ,(static-filename nam))
(documentation ,(document-filename nam))
,@options)) )
;;; Setup
(define (setup-static-extension nam ver
#!key (compile-options '())
inline? types?
(install-options '()) (files '()))
(let ((files (append files (optional-output-file compile-options))))
(compile-static nam #:options compile-options #:inline? inline? #:types? types?)
(install-static-extension nam ver #:options install-options #:files files) ) )
(define (setup-shared-extension nam ver
#!key (compile-options '())
inline? types?
(install-options '()) (files '()))
(let ((files (append files (optional-output-file compile-options))))
(compile-shared nam #:options compile-options #:inline? inline? #:types? types?)
(install-shared-extension nam ver #:options install-options #:files files) ) )
(define (setup-static-extension-module nam ver
#!key (compile-options '())
inline? types?
(install-options '()) (files '()))
(let ((files (append files (optional-output-file compile-options))))
(compile-static-module nam #:options compile-options #:inline? inline? #:types? types?)
(install-static-extension-module nam ver #:options install-options #:files files) ) )
(define (setup-shared-extension-module nam ver
#!key (compile-options '())
inline? types?
(install-options '()) (files '()))
(let ((files (append files (optional-output-file compile-options))))
(compile-shared-module nam #:options compile-options #:inline? inline? #:types? types?)
(install-shared-extension-module nam ver #:options install-options #:files files) ) )
;cannot support -output-file option
(define (setup-shared+static-extension-module nam ver
#!key (shared-compile-options '())
(static-compile-options '())
(compile-options '())
inline? types?
(install-options '()) (files '()))
(compile-shared-module nam
#:options (append compile-options shared-compile-options)
#:inline? inline? #:types? types?)
(compile-static nam #:options (append compile-options static-compile-options))
(install-shared+static-extension-module nam ver #:options install-options #:files files) )
;; Empty "Conglomerate" Extension Support
(define (install-extension-tag nam ver) (install-extension nam '() `((version ,ver))))
| false |
a3983fb657bd342691312345c2012274598cbe3b
|
ee232691dcbaededacb0778247f895af992442dd
|
/kirjasto/lib/panna/komento/list.scm
|
b82f4d67694f38f103b990adcb76a726bdaa8571
|
[] |
no_license
|
mytoh/panna
|
c68ac6c6ef6a6fe79559e568d7a8262a7d626f9f
|
c6a193085117d12a2ddf26090cacb1c434e3ebf9
|
refs/heads/master
| 2020-05-17T02:45:56.542815 | 2013-02-13T19:18:38 | 2013-02-13T19:18:38 | null | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,185 |
scm
|
list.scm
|
":"; exec gosh -- $0 "$@"
(use file.util)
(use gauche.parameter)
(use panna)
(use maali)
(use kirjasto.pääte)
(define (list-packages)
(display (paint ":: " (colour-symbol1)))
(display (paint "installed packages" (colour-message)))
(newline)
(puts-columns (directory-list (kellari-kansio) :children? #t)))
(define (list-package-contents kaava)
(let* ((tynnyri (make-parameter (build-path (kellari-kansio) kaava))))
(print (string-append (paint ":: " (colour-symbol1))
(paint "files installed as " (colour-message))
(paint kaava (colour-package))))
(for-each print
(directory-fold (tynnyri) cons '()
:lister (lambda (path seed)
(values (directory-list path :add-path? #t :children? #t)
(cons path seed)))))))
(define (main args)
(cond
((not (file-exists? (kellari-kansio)))
(print (paint ":: " (colour-symbol1))
"no package found"))
(else
(if (<= 2 (length args))
(list-package-contents (cadr args))
(list-packages)) )))
| false |
9736422ae41e5cb0279ea2229448432f60c72b85
|
aa3c0aed788687ccc10a85d9cb8dd77a8ffbd5e9
|
/sqlite3-api.scm
|
9e9365f0c6fc5a4bca69517012947713e8cc6b60
|
[] |
no_license
|
ursetto/sql-de-lite
|
22c3cc76127fe2d20f577c638e81b83ab6c3ba2d
|
0f974749d5caa0a34e2a7d6dcc4163f2cb4beac3
|
refs/heads/master
| 2023-03-06T16:12:22.018124 | 2023-02-13T04:11:01 | 2023-02-13T04:11:01 | 157,043,421 | 4 | 7 | null | 2023-02-13T04:11:02 | 2018-11-11T03:19:36 |
C
|
UTF-8
|
Scheme
| false | false | 12,448 |
scm
|
sqlite3-api.scm
|
;;; GENERATED BY CHICKEN-BIND FROM sqlite3-api.h
(begin
(begin
(define sqlite3_close
(foreign-lambda integer "sqlite3_close" (c-pointer "sqlite3"))))
(begin
(define sqlite3_exec
(foreign-lambda
integer
"sqlite3_exec"
(c-pointer "sqlite3")
c-string
(function
integer
((c-pointer void)
integer
(c-pointer (c-pointer char))
(c-pointer (c-pointer char))))
(c-pointer void)
(c-pointer (c-pointer char)))))
(begin
(define sqlite3_open
(foreign-lambda
integer
"sqlite3_open"
c-string
(c-pointer (c-pointer "sqlite3")))))
(begin
(define sqlite3_errcode
(foreign-lambda integer "sqlite3_errcode" (c-pointer "sqlite3"))))
(begin
(define sqlite3_errmsg
(foreign-lambda c-string "sqlite3_errmsg" (c-pointer "sqlite3"))))
(begin
(define sqlite3_extended_errcode
(foreign-lambda
integer
"sqlite3_extended_errcode"
(c-pointer "sqlite3"))))
(begin
(define sqlite3_prepare_v2
(foreign-lambda
integer
"sqlite3_prepare_v2"
(c-pointer "sqlite3")
c-string
integer
(c-pointer (c-pointer "sqlite3_stmt"))
(c-pointer (c-pointer (const char))))))
(begin
(define sqlite3_next_stmt
(foreign-lambda
(c-pointer "sqlite3_stmt")
"sqlite3_next_stmt"
(c-pointer "sqlite3")
(c-pointer "sqlite3_stmt"))))
(begin
(define sqlite3_step
(foreign-lambda integer "sqlite3_step" (c-pointer "sqlite3_stmt"))))
(begin
(define sqlite3_step_safe
(foreign-safe-lambda
integer
"sqlite3_step_safe"
(c-pointer "sqlite3_stmt"))))
(begin
(define sqlite3_reset
(foreign-lambda integer "sqlite3_reset" (c-pointer "sqlite3_stmt"))))
(begin
(define sqlite3_finalize
(foreign-lambda integer "sqlite3_finalize" (c-pointer "sqlite3_stmt"))))
(begin
(define sqlite3_changes
(foreign-lambda integer "sqlite3_changes" (c-pointer "sqlite3"))))
(begin
(define sqlite3_total_changes
(foreign-lambda integer "sqlite3_total_changes" (c-pointer "sqlite3"))))
(begin
(define sqlite3_last_insert_rowid
(foreign-lambda
integer64
"sqlite3_last_insert_rowid"
(c-pointer "sqlite3"))))
(begin
(define sqlite3_sql
(foreign-lambda c-string "sqlite3_sql" (c-pointer "sqlite3_stmt"))))
(begin
(define sqlite3_get_autocommit
(foreign-lambda bool "sqlite3_get_autocommit" (c-pointer "sqlite3"))))
(begin
(define sqlite3_bind_parameter_count
(foreign-lambda
integer
"sqlite3_bind_parameter_count"
(c-pointer "sqlite3_stmt"))))
(begin
(define sqlite3_bind_parameter_index
(foreign-lambda
integer
"sqlite3_bind_parameter_index"
(c-pointer "sqlite3_stmt")
c-string)))
(begin
(define sqlite3_bind_parameter_name
(foreign-lambda
c-string
"sqlite3_bind_parameter_name"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_bind_blob
(foreign-lambda
integer
"sqlite3_bind_blob"
(c-pointer "sqlite3_stmt")
integer
blob
integer
(function void ((c-pointer void))))))
(begin
(define sqlite3_bind_double
(foreign-lambda
integer
"sqlite3_bind_double"
(c-pointer "sqlite3_stmt")
integer
double)))
(begin
(define sqlite3_bind_int
(foreign-lambda
integer
"sqlite3_bind_int"
(c-pointer "sqlite3_stmt")
integer
integer)))
(begin
(define sqlite3_bind_int64
(foreign-lambda
integer
"sqlite3_bind_int64"
(c-pointer "sqlite3_stmt")
integer
integer64)))
(begin
(define sqlite3_bind_null
(foreign-lambda
integer
"sqlite3_bind_null"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_bind_text
(foreign-lambda
integer
"sqlite3_bind_text"
(c-pointer "sqlite3_stmt")
integer
c-string
integer
(function void ((c-pointer void))))))
(begin
(define sqlite3_bind_zeroblob
(foreign-lambda
integer
"sqlite3_bind_zeroblob"
(c-pointer "sqlite3_stmt")
integer
integer)))
(begin
(define sqlite3_column_count
(foreign-lambda
integer
"sqlite3_column_count"
(c-pointer "sqlite3_stmt"))))
(begin
(define sqlite3_column_blob
(foreign-lambda
(c-pointer (const void))
"sqlite3_column_blob"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_column_bytes
(foreign-lambda
integer
"sqlite3_column_bytes"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_column_double
(foreign-lambda
double
"sqlite3_column_double"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_column_int
(foreign-lambda
integer
"sqlite3_column_int"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_column_int64
(foreign-lambda
integer64
"sqlite3_column_int64"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_column_text
(foreign-lambda
c-string
"sqlite3_column_text"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_column_type
(foreign-lambda
integer
"sqlite3_column_type"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_column_name
(foreign-lambda
c-string
"sqlite3_column_name"
(c-pointer "sqlite3_stmt")
integer)))
(begin
(define sqlite3_busy_handler
(foreign-lambda
integer
"sqlite3_busy_handler"
(c-pointer "sqlite3")
(function integer ((c-pointer void) integer))
(c-pointer void))))
(begin
(define sqlite3_busy_timeout
(foreign-lambda
integer
"sqlite3_busy_timeout"
(c-pointer "sqlite3")
integer)))
(begin
(define sqlite3_create_function_v2
(foreign-lambda
integer
"sqlite3_create_function_v2"
(c-pointer "sqlite3")
c-string
integer
integer
(c-pointer void)
(function
void
((c-pointer "sqlite3_context")
integer
(c-pointer (c-pointer "sqlite3_value"))))
(function
void
((c-pointer "sqlite3_context")
integer
(c-pointer (c-pointer "sqlite3_value"))))
(function void ((c-pointer "sqlite3_context")))
(function void ((c-pointer void))))))
(begin
(define sqlite3_result_blob
(foreign-lambda
void
"sqlite3_result_blob"
(c-pointer "sqlite3_context")
blob
integer
(function void ((c-pointer void))))))
(begin
(define sqlite3_result_double
(foreign-lambda
void
"sqlite3_result_double"
(c-pointer "sqlite3_context")
double)))
(begin
(define sqlite3_result_error
(foreign-lambda
void
"sqlite3_result_error"
(c-pointer "sqlite3_context")
c-string
integer)))
(begin
(define sqlite3_result_error16
(foreign-lambda
void
"sqlite3_result_error16"
(c-pointer "sqlite3_context")
(c-pointer void)
integer)))
(begin
(define sqlite3_result_error_toobig
(foreign-lambda
void
"sqlite3_result_error_toobig"
(c-pointer "sqlite3_context"))))
(begin
(define sqlite3_result_error_nomem
(foreign-lambda
void
"sqlite3_result_error_nomem"
(c-pointer "sqlite3_context"))))
(begin
(define sqlite3_result_error_code
(foreign-lambda
void
"sqlite3_result_error_code"
(c-pointer "sqlite3_context")
integer)))
(begin
(define sqlite3_result_int
(foreign-lambda
void
"sqlite3_result_int"
(c-pointer "sqlite3_context")
integer)))
(begin
(define sqlite3_result_int64
(foreign-lambda
void
"sqlite3_result_int64"
(c-pointer "sqlite3_context")
integer64)))
(begin
(define sqlite3_result_null
(foreign-lambda
void
"sqlite3_result_null"
(c-pointer "sqlite3_context"))))
(begin
(define sqlite3_result_text
(foreign-lambda
void
"sqlite3_result_text"
(c-pointer "sqlite3_context")
c-string
integer
(function void ((c-pointer void))))))
(begin
(define sqlite3_result_text16
(foreign-lambda
void
"sqlite3_result_text16"
(c-pointer "sqlite3_context")
(c-pointer void)
integer
(function void ((c-pointer void))))))
(begin
(define sqlite3_result_text16le
(foreign-lambda
void
"sqlite3_result_text16le"
(c-pointer "sqlite3_context")
(c-pointer void)
integer
(function void ((c-pointer void))))))
(begin
(define sqlite3_result_text16be
(foreign-lambda
void
"sqlite3_result_text16be"
(c-pointer "sqlite3_context")
(c-pointer void)
integer
(function void ((c-pointer void))))))
(begin
(define sqlite3_result_value
(foreign-lambda
void
"sqlite3_result_value"
(c-pointer "sqlite3_context")
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_result_zeroblob
(foreign-lambda
void
"sqlite3_result_zeroblob"
(c-pointer "sqlite3_context")
integer)))
(begin
(define sqlite3_value_blob
(foreign-lambda
(c-pointer (const void))
"sqlite3_value_blob"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_bytes
(foreign-lambda
integer
"sqlite3_value_bytes"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_bytes16
(foreign-lambda
integer
"sqlite3_value_bytes16"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_double
(foreign-lambda
double
"sqlite3_value_double"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_int
(foreign-lambda
integer
"sqlite3_value_int"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_int64
(foreign-lambda
integer64
"sqlite3_value_int64"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_text
(foreign-lambda
c-string
"sqlite3_value_text"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_text16
(foreign-lambda
(c-pointer (const void))
"sqlite3_value_text16"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_text16le
(foreign-lambda
(c-pointer (const void))
"sqlite3_value_text16le"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_text16be
(foreign-lambda
(c-pointer (const void))
"sqlite3_value_text16be"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_type
(foreign-lambda
integer
"sqlite3_value_type"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_value_numeric_type
(foreign-lambda
integer
"sqlite3_value_numeric_type"
(c-pointer "sqlite3_value"))))
(begin
(define sqlite3_user_data
(foreign-lambda
(c-pointer void)
"sqlite3_user_data"
(c-pointer "sqlite3_context"))))
(begin
(define sqlite3_aggregate_context
(foreign-lambda
(c-pointer void)
"sqlite3_aggregate_context"
(c-pointer "sqlite3_context")
integer)))
(begin
(define sqlite3_load_extension
(foreign-lambda
integer
"sqlite3_load_extension"
(c-pointer "sqlite3")
c-string
c-string
(c-pointer (c-pointer char))))))
;;; END OF FILE
| false |
729d82473e7bcaa51df34cecbb6375abc6925a0d
|
895daaa3a466ec7f61773b892920dfbe8d78780e
|
/schemes/kawa-demo/vector.scm
|
37887fc92d1ad0eeb7fda5f6655837484e1020d2
|
[] |
no_license
|
jwalsh/scheme-workshop-2014
|
feac007278a4255ccdb6c82814ea18bbf646d8fa
|
32718dbdc3a83d0508f7b6110c59e7e960db7b62
|
refs/heads/master
| 2016-09-05T16:18:50.247061 | 2015-03-25T19:17:42 | 2015-03-25T19:17:42 | 26,870,183 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 73 |
scm
|
vector.scm
|
(define (dot u v) (for/sum ([x u] [y v]) (* x y)))
(define x 12)
(def)
| false |
da43c4cbc9c694912ee8c154564bbd3b62ec015b
|
296dfef11631624a5b2f59601bc7656e499425a4
|
/seth/seth/message-digest/primitive.sld
|
38cbd031f0d0237fd37f5942c765ceed929099ab
|
[] |
no_license
|
sethalves/snow2-packages
|
f4dc7d746cbf06eb22c69c8521ec38791ae32235
|
4cc1a33d994bfeeb26c49f8a02c76bc99dc5dcda
|
refs/heads/master
| 2021-01-22T16:37:51.427423 | 2019-06-10T01:51:42 | 2019-06-10T01:51:42 | 17,272,935 | 1 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,147 |
sld
|
primitive.sld
|
(define-library (seth message-digest primitive)
(export make-message-digest-primitive
message-digest-primitive?
;; check-message-digest-primitive
;; error-message-digest-primitive
message-digest-primitive-name
message-digest-primitive-context-info
message-digest-primitive-digest-length
message-digest-primitive-init
message-digest-primitive-update
message-digest-primitive-final)
(import (scheme base)
(seth gensym)
)
(begin
;;; Support
;;
;; (define (positive-fixnum? obj)
;; (and (fixnum? obj) (positive? obj)) )
;;; Message Digest Algorithm API
;;
;; (define (check-message-digest-arguments loc ctx-info digest-len init update final)
;; (unless (or (procedure? ctx-info) (positive-fixnum? ctx-info))
;; (error-argument-type loc ctx-info "positive-fixnum or procedure" 'context-info) )
;; (check-positive-fixnum loc digest-len 'digest-length)
;; (check-procedure loc init 'digest-initializer)
;; (check-procedure loc update 'digest-updater)
;; (check-procedure loc final 'digest-finalizer) )
;;
(define-record-type message-digest-primitive
(*make-message-digest-primitive ctxi digest-len init update final name)
message-digest-primitive?
(ctxi message-digest-primitive-context-info)
(digest-len message-digest-primitive-digest-length)
(init message-digest-primitive-init)
(update message-digest-primitive-update)
(final message-digest-primitive-final)
(name message-digest-primitive-name) )
;; (define-check+error-type message-digest-primitive)
(define (make-message-digest-primitive ctx-info digest-len init update final
;; #!optional (name (gensym "mdp"))
. maybe-name
)
(let ((name (if (pair? maybe-name) (car maybe-name) (gensym "mdp"))))
;; (check-message-digest-arguments 'make-message-digest-primitive
;; ctx-info digest-len init update final)
(*make-message-digest-primitive
ctx-info
digest-len
init update final
name) ) )
))
| false |
1a9d80d868052273c4e96eb0c3c25fa172f6c891
|
0bb7631745a274104b084f6684671c3ee9a7b804
|
/lib/_test/_test.sld
|
7f8ec89c25011a5d1a3aece0c8ae50d76834573d
|
[
"Apache-2.0",
"LGPL-2.1-only",
"LicenseRef-scancode-free-unknown",
"GPL-3.0-or-later",
"LicenseRef-scancode-autoconf-simple-exception"
] |
permissive
|
feeley/gambit
|
f87fd33034403713ad8f6a16d3ef0290c57a77d5
|
7438e002c7a41a5b1de7f51e3254168b7d13e8ba
|
refs/heads/master
| 2023-03-17T06:19:15.652170 | 2022-09-05T14:31:53 | 2022-09-05T14:31:53 | 220,799,690 | 0 | 1 |
Apache-2.0
| 2019-11-10T15:09:28 | 2019-11-10T14:14:16 | null |
UTF-8
|
Scheme
| false | false | 916 |
sld
|
_test.sld
|
;;;============================================================================
;;; File: "_test.sld"
;;; Copyright (c) 2013-2020 by Marc Feeley, All Rights Reserved.
;;;============================================================================
;;; Testing framework.
(define-library (_test)
(export test-assert
test-equal
test-eqv
test-eq
test-approximate
test-error
test-error-tail
test-begin
test-end
test-group
test-msg
test-all?-set!
test-quiet?-set!
test-verbose?-set!
%test-predicate
%test-relation
%test-approximate
%test-error
%test-begin
%test-end
%test-group)
(include "_test#.scm")
(include "_test.scm"))
;;;============================================================================
| false |
0a155ba5b76128b3ad03a2b8d796ff227268f3d9
|
c2603f0d6c6e523342deaa1e284b7855a450a6f7
|
/autoload/vgen/compiler/erase.scm
|
7b2219c307880132e40e629673afaf7026bad610
|
[] |
no_license
|
aharisu/vise
|
5d35a085e6b1070920e9a4e035339050091b2be0
|
6d0f54b0fe28e7d2c3b2b91cb3ef5ff847a11484
|
refs/heads/master
| 2020-06-02T10:48:42.822204 | 2013-02-21T09:42:59 | 2013-02-21T09:42:59 | 7,975,231 | 1 | 1 | null | 2013-02-20T12:26:45 | 2013-02-02T11:53:18 | null |
UTF-8
|
Scheme
| false | false | 6,726 |
scm
|
erase.scm
|
(define-module vgen.compiler.erase
(use srfi-1)
(use gauche.parameter)
(use vgen.util)
(use vgen.common)
(export vise-phase-erase
))
(select-module vgen.compiler.erase)
(define (vise-phase-erase form-list)
(sexp-traverse
form-list
`((defvar . ,erase-sym-bind-defvar)
(let . ,erase-sym-bind-let)))
(parameterize ([erased-flag #f])
(let1 form-list (filter-map
(erase-filter 'toplevel #f)
form-list)
(if (erased-flag)
(vise-phase-erase form-list)
form-list))))
(define (erase-sym-bind-defvar form ctx loop)
(erase-sym-bind (cadr form) (caddr form))
(loop 'expr (caddr form)))
(define (erase-sym-bind-let form ctx loop)
(for-each
(lambda (clause)
(erase-sym-bind (car clause) (cadr clause))
(list (car clause) (loop 'expr (cadr clause))))
(cadr form))
(for-each (pa$ loop (if (eq? ctx 'toplevel) 'toplevel 'stmt)) (cddr form)))
(define (decrement-ref-count exp)
(cond
[(list? exp)
(for-each decrement-ref-count exp)]
[(vsymbol? exp)
(if-let1 d (env-find-data exp)
(@dec! d.ref-count))]))
(define (erase-sym-bind sym exp)
(let1 d (and (vsymbol? sym) (env-find-data sym))
(when (and (not (is-function-call? exp))
d (env-data-ref-only? d))
(@! d.value exp))))
(define-constant exp-erased (gensym))
(define erased-flag (make-parameter #f))
(define (mark-erase exp)
(erased-flag #t)
exp)
(define (erase-filter ctx parent)
(lambda (exp)
(let1 e (erase-expression ctx parent exp)
(if (eq? exp-erased e)
#f
e))))
(define (erase-expression ctx parent form)
(cond
[(list? form)
(case (vexp (car form))
[(quote) form]
[(defun) (erase-defun ctx parent form)]
[(defvar) (erase-defvar ctx parent form)]
[(lambda) (erase-lambda ctx parent form)]
[(if) (erase-if ctx parent form)]
[(set!) (erase-set! ctx parent form)]
[(return) (erase-return ctx parent form)]
[(let) (erase-let ctx parent form)]
[(dolist) (erase-dolist ctx parent form)]
[(while) (erase-while ctx parent form)]
[(begin and or) (erase-begin-or-and ctx parent form)]
[(augroup) (erase-augroup ctx parent form)]
[(list-func) (erase-list-func ctx parent form)]
[(array) (erase-array ctx parent form)]
[(dict) (erase-dict ctx parent form)]
[(try) (erase-try ctx parent form)]
[(autocmd) (erase-autocmd ctx parent form)]
[else (erase-apply ctx parent form)])]
[(vsymbol? form) (erase-refer-symbol ctx parent form)]
[else form]))
(define (erase-defun ctx parent form)
`(,(car form);defun
,(cadr form);name
,(caddr form);args
,(cadddr form);modifier
,@(filter-map
(erase-filter 'stmt form)
(cddddr form))))
(define (erase-defvar ctx parent form)
(list
(car form);defvar
(cadr form);name
(erase-expression 'expr form (caddr form))))
(define (erase-lambda ctx parent form)
`(,(car form);lambda
,(cadr form);args
,@(filter-map (erase-filter 'stmt form) (cddr form))))
(define (erase-if ctx parent form)
(let1 frm (filter-obj
exp-erased
(lambda (e)
(if (eq? exp-erased e)
(mark-erase e)
e))
(let1 cctx (if (eq? ctx 'expr) 'expr ctx)
(if (null? (cdddr form))
(list
(car form)
(erase-expression 'expr form (cadr form))
(erase-expression cctx form (caddr form)))
(list
(car form)
(erase-expression 'expr form (cadr form))
(erase-expression cctx form (caddr form))
(erase-expression cctx form (cadddr form))))))
(if (exp-is-literal? (cadr frm))
(mark-erase
(begin
(decrement-ref-count (cadr frm))
(if (or* eq? (get-evaluated-exp (cadr frm)) #f 0)
(if (null? (cdddr frm)) exp-erased (cadddr frm)) ;;get else
(caddr frm)))) ;;get then
frm)))
(define (erase-set! ctx parent form)
(list
(car form);set!
(cadr form) ;name
(erase-expression 'expr form (caddr form))))
(define (erase-return ctx parent form)
(if (null? (cdr form))
form
(list
(car form) ;return
(erase-expression 'expr form (cadr form)))))
(define (erase-dolist ctx parent form)
`(,(car form)
,(list
(caadr form)
(erase-expression 'expr form (cadadr form)))
,@(filter-map (erase-filter 'stmt form) (cddr form))))
(define (erase-while ctx parent form)
`(,(car form) ;name
,(erase-expression 'expr form (cadr form))
,@(filter-map (erase-filter 'stmt form) (cddr form))))
(define (erase-begin-or-and ctx parent form)
`(,(car form) ;name
,@(filter-map
(pa$ erase-expression (if (or* eq? (vexp (car form)) 'and 'or) 'expr ctx) form)
(cdr form))))
(define (erase-augroup ctx parent form)
form)
(define (erase-list-func ctx parent form)
(list
(car form) ;list
(cadr form) ;function
(erase-expression 'expr form (caddr form))
(erase-expression 'expr form (cadddr form))))
(define (erase-let ctx parent form)
`(,(car form)
,(let loop ([vars (cadr form)]
[acc '()])
(if (null? vars)
(reverse! acc)
(let1 d (and (vsymbol? (caar vars)) (env-find-data (caar vars)))
(loop (cdr vars)
(if (and d (env-data-not-use? d) (exp-is-literal? (cadar vars)))
(mark-erase acc) ;erase var decl
(cons
(list
(caar vars)
(erase-expression 'expr (car vars) (cadar vars)))
acc))))))
,@(filter-map
(erase-filter (if (eq? ctx 'toplevel) 'toplevel 'stmt) form)
(cddr form))))
(define (erase-array ctx parent form)
`(,(car form)
,@(map
(pa$ erase-expression 'expr form)
(cdr form))))
(define (erase-dict ctx parent form)
`(,(car form)
,@(map
(lambda (pair) (list (car pair) (erase-expression 'expr form (cadr pair))))
(cdr form))))
(define (erase-try ctx parent form)
form)
(define (erase-autocmd ctx parent form)
(list
(car form) ;autocmd
(cadr form);group
(caddr form) ;events
(cadddr form) ;pat
(car (cddddr form)) ;nest
(erase-expression 'stmt form (cadr (cddddr form)))))
(define (erase-apply ctx parent form)
(map (pa$ erase-expression 'expr form) form))
(define (erase-refer-symbol ctx parent form)
form)
| false |
a1a9541f65fb0af9d1bd44d19afc0e83cb87c544
|
2ff77aed2df384e78c210ef28f607c23352e5b8d
|
/examples/08-gps/gpsbutton.scm
|
0677cabc0237812d8382e88c2a1afa76b786e8fd
|
[
"Apache-2.0"
] |
permissive
|
rafleon/KawaDroid
|
14d65fb74686c421cab4ca9785266daa321ffacc
|
5b218826146320f442a55e20171875cb208c7b56
|
refs/heads/master
| 2020-12-24T15:58:15.249818 | 2015-05-12T05:07:51 | 2015-05-12T05:07:51 | 33,094,259 | 18 | 3 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,541 |
scm
|
gpsbutton.scm
|
;; define some useful things.
;; These all use view Id's which are set below.
(define scrolldown
(lambda ()
(let* ((act::android.app.Activity *activity*)
(sv::ScrollView (act:findViewById 0)))
;; This sleep is needed for it to stop appending before we scroll.
(sleep 0.1)
(rout (sv:fullScroll android.view.View:FOCUS_DOWN))
)))
(define disablebutton
(lambda ()
(let* ((act::android.app.Activity *activity*)
(b::Button (act:findViewById 2)))
(rout (b:setEnabled #f))
)))
(define enablebutton
(lambda ()
(let* ((act::android.app.Activity *activity*)
(b::Button (act:findViewById 2)))
(rout (b:setEnabled #t))
)))
;; this is the app.
(let* ((act::android.app.Activity *activity*)
(ll::LinearLayout (LinearLayout act))
(but::Button
(Button act text: "Click here!"))
(tv::TextView
(TextView act text: "Not clicked yet.\n"))
(sv::ScrollView (ScrollView act))
)
;; set some settings.
(ll:setOrientation ll:VERTICAL)
(sv:setId 0)
(tv:setId 1)
(but:setId 2)
;; dynamically build the layout
(ll:addView but)
(sv:addView tv)
(ll:addView sv)
(but:setOnClickListener
(lambda(v)
(future
(begin
(disablebutton)
(let ((latlon (getloc)))
(msg (format "Current latitude is: ~f\n" (car latlon)))
(msg (format "Current longitude is: ~f\n" (cadr latlon))))
(enablebutton)
(scrolldown)
))))
(rout (act:setContentView ll))
)
| false |
2c57e79c1a6b43e407c95637ccaaaed83c56e65b
|
18fb2e9f5ce1a5c876d9e0694ed001d8932b2fde
|
/profiling/profiling-scripts/extract.scm
|
7260dcae6762239f2c662443084fb5a1c1f07eeb
|
[
"MIT",
"X11"
] |
permissive
|
christoff-buerger/racr
|
0669a0ba537c6b6d7e4379dbb453c42ff8456d25
|
b83e18d751bb11f844e8face7a81770819f1a3a9
|
refs/heads/master
| 2023-09-04T05:25:04.113295 | 2023-08-19T22:29:23 | 2023-08-19T22:29:23 | 32,183,687 | 33 | 10 | null | 2017-02-13T20:38:03 | 2015-03-13T22:19:59 |
Scheme
|
UTF-8
|
Scheme
| false | false | 22,813 |
scm
|
extract.scm
|
; This program and the accompanying materials are made available under the
; terms of the MIT license (X11 license) which accompanies this distribution.
; Author: C. Bürger
#!r6rs
(library
(profiling-scripts extract)
(export filter-tables ps:< ps:> ps:<= ps:>= ps:== ps:!= ps:MIN ps:MAX ps:min ps:max)
(import (rnrs) (rnrs mutable-pairs))
; Find a string within a list of strings. Return its index if found and unique, otherwise #f.
(define (find-index s l)
(let loop ((l l) (i 0) (index -1))
(cond
((null? l)
(and (>= index 0) index))
((string=? (car l) s)
(if (>= index 0) #f (loop (cdr l) (+ i 1) i)))
(else
(loop (cdr l) (+ i 1) index)))))
; Apply a function on a port. The port is closed when terminating.
(define (process-stream port f)
(dynamic-wind
(lambda () #f)
(lambda () (f port))
(lambda () (close-port port))))
; Abort with an exception due to some error.
(define (raise-error . rationales)
(raise
(condition
(make-error)
(make-message-condition
(apply
string-append
"Extraction failed:"
(map
(lambda (rationale)
(string-append "\n " rationale))
rationales))))))
; Abort with an exception due to an extractor configuration error.
(define (raise-extractor-configuration-error . rationales)
(apply raise-error "The given extractor configuration is malformed." rationales))
; Abort with an exception due to a header configuration error.
(define (raise-header-configuration-error . rationales)
(apply raise-error "The given header configuration is malformed." rationales))
; Comparator functions for value comparison and extrema checking:
(define (ps:< s1 s2)
(string<? s1 s2))
(define (ps:> s1 s2)
(string>? s1 s2))
(define (ps:<= s1 s2)
(string<=? s1 s2))
(define (ps:>= s1 s2)
(string>=? s1 s2))
(define (ps:== s1 s2)
(string=? s1 s2))
(define (ps:!= s1 s2)
(not (ps:== s1 s2)))
(define (ps:MIN s1 s2)
(string<? s1 s2))
(define (ps:MAX s1 s2)
(string>? s1 s2))
(define (ps:min s1 s2)
(string<? s1 s2))
(define (ps:max s1 s2)
(string>? s1 s2))
; Is a given extraction operator a value comparator?
(define (value-comparator? e)
(memq e (list ps:!= ps:== ps:< ps:> ps:<= ps:>=)))
; Is a given extraction operator a row independent extrema?
(define (row-independent-extrema? e)
(memq e (list ps:MIN ps:MAX)))
; Is a given extraction operator a row specific extrema?
(define (row-specific-extrema? e)
(memq e (list ps:min ps:max)))
; Is a given extraction operator a row independent or specific extrema?
(define (extrema? e)
(or (row-independent-extrema? e) (row-specific-extrema? e)))
(define cell-size ; Length of columns.
21)
(define cell-delimeter ; Character separating adjacent cells of columns.
#\|)
(define min-cell-value ; Lexically smallest value a cell can have.
(make-string cell-size #\x0))
(define max-cell-value ; Lexically biggest value a cell can have.
(make-string cell-size #\xFFFFF))
(define header-separator-cell ; Content of cells separating table headers from actual data rows.
(make-string cell-size #\-))
; Construct a cell-content string matching the cell size of tables (#f if to big cell).
(define (make-padded-cell cell)
(define padding (- cell-size 1 (string-length cell)))
(and
(>= padding 0)
(string-append (make-string padding #\space) cell " ")))
; Construct a header-string matching the cell size of tables (#f if to big header).
(define (make-padded-header header)
(define padding (- cell-size 1 (string-length header)))
(and
(>= padding 0)
(string-append " " header (make-string padding #\space))))
; Value comparator extractor that accepts any input.
(define neutral-comparator-checker
(lambda _ #t))
; Given a list of extractors, construct a function checking if a cell satisfies the
; value comparators of the given list. Aborts with an exception in case of invalid extractors.
; Returns the neutral value comparator checker if the list contains no value comparators.
(define (make-column-comparator-checker extractors)
(define (make-column-comparator-checker extractors pending-comparator? continuation)
(if (null? extractors)
(if pending-comparator?
(raise-extractor-configuration-error
"Orphan comparision value missing value comparator:" pending-comparator?)
continuation)
(let ((elem (car extractors))
(rest (cdr extractors)))
(cond
(pending-comparator?
(when (not (value-comparator? elem))
(raise-extractor-configuration-error
"Orphan comparision value missing value comparator:" pending-comparator?))
(make-column-comparator-checker
rest
#f
(if (eq? continuation neutral-comparator-checker)
(lambda (cell-value) ; First value comparator of extractors defines whole...
(elem cell-value pending-comparator?)) ; ...checker for now,...
(lambda (cell-value) ; ...until further value comparators...
(and ; ...also...
(elem cell-value pending-comparator?) ; ...have to be checked...
(continuation cell-value)))))) ; ...and so on.
((string? elem)
(let ((comparison-value (make-padded-cell elem)))
(unless comparison-value
(raise-extractor-configuration-error "To big comparison value."))
(make-column-comparator-checker rest comparison-value continuation)))
(else
(when (value-comparator? elem)
(raise-extractor-configuration-error
"Orphan value comparator missing comparison value."))
(unless (extrema? elem)
(raise-extractor-configuration-error "Unknown extractor."))
(make-column-comparator-checker rest #f continuation))))))
(make-column-comparator-checker (reverse extractors) #f neutral-comparator-checker))
; Extrema extractor that discards any input (treats it as if no extrema).
(define neutral-extrema-checker
(lambda _ 0))
; Emit the data-cells of source tables considering row-extraction operators. Only data-rows
; selected by the given extraction operators will be printed cell-wise on the standard output,
; each cell terminated by a new line. Source tables are checked for structural integrity
; throughout processing. An exception is thrown in case of errors.
(define (filter-tables headers extractors . source-files)
;;; Initialize row-size and -structure metrics:
(define column-count ; Number of columns per row.
(length headers))
(define date-column ; Column number of measurement dates.
(find-index "Date" headers))
(define status-column ; Column number of measurement statuses.
(find-index "Status" headers))
(define header-title ; Column title string (first line of tables).
; Abort with exception in case of header configuration errors.
(if (and date-column status-column (= date-column 0))
(fold-left
(lambda (result header)
(define padded-header (make-padded-header header))
(unless padded-header
(raise-header-configuration-error "To big header cell."))
(if result
(string-append result (string cell-delimeter) padded-header)
padded-header))
#f
headers)
(raise-header-configuration-error "Date or Status column missing.")))
(define header-separator ; Colum title separator string (second line of tables).
(do ((i 1 (+ i 1))
(ruler header-separator-cell (string-append ruler "+" header-separator-cell)))
((>= i column-count) ruler)))
;;; Initialize table-size and -processing metrics:
(define row-count ; Total number of rows considering all source tables.
(fold-left
(lambda (counter file)
(+
counter
(process-stream
(open-input-file file)
(lambda (port)
(do ((i 0 (+ i 1)))
((eof-object? (get-line port)) i))))))
0
source-files))
(define rows ; Vector of table-rows. Each row is a vector of its cells or '#f' when unselected.
(make-vector row-count #f))
(define processed ; Total number of table-rows (header and data) processed so far.
0)
;;; Configure row pool allocator for fast row allocation:
(define row-length ; Size of row vectors (number of columns + extrema counter).
(+ column-count 1))
(define row-pool-size ; Size of row pool allocator.
(if (>= row-count 3)
(if (< (* row-count row-length) 65535)
(floor (/ row-count 3)) ; About 1/3 of rows to process...
(floor (/ 65535 row-length))) ; ...but maximal (2^16)-1 (-1: consider vector-tagging).
1)) ; Ensure there is at least a single row allocated.
(define row-pool ; Row pool allocator: list of unused, but already allocated, rows.
(make-vector row-pool-size #f))
(define row-pool-next-free ; Index of next available unused row in pool.
row-pool-size)
; Get a new row, preferred without reallocation.
(define make-row
(let ((reallocation-start (floor (/ (* 2 row-pool-size) 3))))
(lambda ()
(when (= row-pool-next-free row-pool-size) ; If the pool is exhausted...
(do ((i reallocation-start (+ i 1))) ; ...allocate new rows within last third of pool.
((>= i row-pool-size))
(vector-set! row-pool i (make-vector row-length)))
(set! row-pool-next-free reallocation-start))
(let ((row (vector-ref row-pool row-pool-next-free)))
(set! row-pool-next-free (+ row-pool-next-free 1))
row))))
; Add row to the pool of unused rows so it can be reused by later allocations.
(define (free-row row)
(when (> row-pool-next-free 0)
(do ((i 0 (+ i 1))) ((>= i column-count))
(vector-set! row i #f))
(set! row-pool-next-free (- row-pool-next-free 1))
(vector-set! row-pool row-pool-next-free row)))
; Reduce the number of extrema a row satisfies. Discard and free the row if no extrema is left.
(define (discard-extremum row-index)
(define row (vector-ref rows row-index))
(define new-extrema-count (- (vector-ref row column-count) 1))
(if (= new-extrema-count 0)
(begin (vector-set! rows row-index #f) (free-row row))
(vector-set! row column-count new-extrema-count)))
;;; Value comparators processing:
; Satisfies a given row all value comparators defined for all its columns?
; Abort with exception in case of extractor configuration errors.
(define value-comparator-checker
(if (= (length extractors) column-count)
(let loop ((i (- (length extractors) 1))
(continuation neutral-comparator-checker)
(extractors (reverse extractors)))
(if (null? extractors)
continuation
(let ((column-checker (make-column-comparator-checker (car extractors))))
(loop
(- i 1)
(cond
((eq? column-checker neutral-comparator-checker) ; Column has no comparators,...
continuation) ; ...thus do nothing for it.
((eq? continuation neutral-comparator-checker) ; First comparators,...
(lambda (row) ; ...define whole extractor (replace neutral checker) for now...
(column-checker (vector-ref row i))))
(else ; ...until further columns with comparators...
(lambda (row)
(and ; ...also...
(column-checker (vector-ref row i)) ; ...have to be checked,...
(continuation row))))) ; ...and so on.
(cdr extractors)))))
(raise-extractor-configuration-error
"Wrong number of extractor configurations."
"Expected one extractor configuration per column.")))
;;; Row independent extrema processing:
; Check if a certain cell of a row is a certain row independent extrema (updates extrema caches).
(define (check-XXX-extrema row column ps:XXX XXX-values XXX-indices)
(define extrema-value (vector-ref XXX-values column))
(define extrema-indices (vector-ref XXX-indices column))
(define cell (vector-ref row column))
(cond
((ps:== cell extrema-value)
(vector-set! XXX-indices column (cons processed extrema-indices))
1)
((ps:XXX cell extrema-value)
(for-each discard-extremum extrema-indices)
(vector-set! XXX-values column cell)
(vector-set! XXX-indices column (list processed))
1)
(else
0)))
; Check if a certain cell of a row is a row independent minimum (updates extrema caches).
(define check-MIN-extrema
(let ((MIN-values (make-vector column-count max-cell-value))
(MIN-indices (make-vector column-count (list))))
(lambda (row column)
(check-XXX-extrema row column ps:MIN MIN-values MIN-indices))))
; Check if a certain cell of a row is a row independent maximum (updates extrema caches).
(define check-MAX-extrema
(let ((MAX-values (make-vector column-count min-cell-value))
(MAX-indices (make-vector column-count (list))))
(lambda (row column)
(check-XXX-extrema row column ps:MAX MAX-values MAX-indices))))
;;; Row specific extrema processing:
; Check if a certain cell of a row is a certain row specific extrema (updates extrema caches).
(define (check-xxx-extrema row column ps:xxx row-key->xxx-value/indices)
(define cell (vector-ref row column))
(define result 1)
(hashtable-update!
row-key->xxx-value/indices
(let ((row-key (vector-map (lambda (e) e) row)))
(vector-set! row-key date-column #f) ; Ignore the date column.
(vector-set! row-key column #f) ; Ignore the column checked for a row specific extrema.
(vector-set! row-key column-count #f) ; Ignore the row's extrema count.
row-key)
(lambda (hashed)
(if (eq? hashed #f)
(cons cell (list processed))
(let ((extrema-value (car hashed))
(extrema-indices (cdr hashed)))
(cond
((ps:== cell extrema-value)
(set-cdr! hashed (cons processed extrema-indices))
hashed)
((ps:xxx cell extrema-value)
(for-each discard-extremum extrema-indices)
(cons cell (list processed)))
(else
(set! result 0)
hashed)))))
#f)
result)
; Check if a certain cell of a row is a row specific minimum (updates extrema caches).
(define check-min-extrema
(let ((min-value/indices (make-vector column-count)))
(do ((i (- column-count 1) (- i 1))) ((< i 0))
(vector-set! min-value/indices i (make-hashtable equal-hash equal?)))
(lambda (row column)
(check-xxx-extrema row column ps:min (vector-ref min-value/indices column)))))
; Check if a certain cell of a row is a row specific maximum (updates extrema caches).
(define check-max-extrema
(let ((max-value/indices (make-vector column-count)))
(do ((i (- column-count 1) (- i 1))) ((< i 0))
(vector-set! max-value/indices i (make-hashtable equal-hash equal?)))
(lambda (row column)
(check-xxx-extrema row column ps:max (vector-ref max-value/indices column)))))
; Check a given row for row independent and specific extrema, return how many the row has and
; update the respective extrema caches accordingly (if the row introduces new extrema or
; satisfies existing). Respective updates also discard rows with outdated extrema as required.
(define row-extrema-checker
(let ((ps:???/checker-list
(list
(cons ps:MIN check-MIN-extrema)
(cons ps:MAX check-MAX-extrema)
(cons ps:min check-min-extrema)
(cons ps:max check-max-extrema))))
(let loop ((i 0)
(continuation neutral-extrema-checker)
(extractors extractors))
(if (null? extractors)
continuation
(let ((column-extrema-checker
(let loop ((continuation continuation)
(ps:???/checker-list ps:???/checker-list))
(if (null? ps:???/checker-list)
continuation
(loop
(if (memq (car (car ps:???/checker-list)) (car extractors))
(let ((checker (cdr (car ps:???/checker-list))))
(lambda (row)
(+ (checker row i)
(continuation row))))
continuation)
(cdr ps:???/checker-list))))))
(loop (+ i 1) column-extrema-checker (cdr extractors)))))))
;;; Row processing:
; Check given row if it should be kept or discarded and incorporate it accordingly, including
; any required maintenance of the given and previously processed rows (like updating extrema
; caches, discarding outdated rows, setting the given row's extrema counter etc).
(define process-row
(let ((no-extrema-extractors? (not (find (lambda (l) (memp extrema? l)) extractors))))
(lambda (row)
(define keep-row?
(and
(value-comparator-checker row)
(or no-extrema-extractors?
(let ((extrema (row-extrema-checker row)))
(and (> extrema 0) extrema)))))
(if keep-row?
(begin
(vector-set! row column-count keep-row?)
(vector-set! rows processed row))
(free-row row))
(set! processed (+ processed 1)))))
;;; Read in source tables. While doing so, check their structure and apply extraction operators:
(fold-left ; Process each source table and track...
(lambda (previously-processed source-file) ; ...number of lines proceeding the current table.
; Abort with an exception due to a source table error.
(define (raise-table-error . rationales)
(apply
raise-error
(string-append
"Source table ["
source-file
"] is malformed on line ["
(number->string (+ (- processed previously-processed) 1))
"].")
rationales))
;;; Open input stream for the current source table and process it:
(process-stream
(open-input-file source-file)
(lambda (port)
;;; Process table header (check existence and structure):
(when (or (port-eof? port) (not (string=? (get-line port) header-title)))
(raise-table-error "Malformed header."))
(set! processed (+ processed 1))
(when (or (port-eof? port) (not (string=? (get-line port) header-separator)))
(raise-table-error "Malformed header separator."))
(set! processed (+ processed 1))
;;; Process table rows (check structure, apply extraction operators and store extracted):
(let loop ((row-position 0) (row (make-row)))
(cond
((port-eof? port)
(unless (= row-position 0)
(raise-table-error "Preemtive end of table.")))
((= row-position column-count)
(unless (char=? (read-char port) #\newline)
(raise-table-error "Overlong table row."))
(process-row row)
(loop 0 (make-row)))
(else
(let* ((cell (get-string-n port cell-size))
(cell-length (string-length cell)))
(when ; Check cell structure, i.e., ensure...
(or
(not (= cell-length cell-size)) ; ...a complete cell was read,...
(do ((cell-position 0 (+ cell-position 1)))
((or
(= cell-position cell-size)
(let ((char (string-ref cell cell-position)))
(or
(char=? char #\tab) ; ...free of tabulators and...
(char=? char #\newline) ; ...unexpected row and...
(char=? char cell-delimeter)))) ; ...cell delimeters...
(< cell-position cell-size))) ; ...within its content.
(and ; Also ensure, that it is followed by the cell-delimeter if...
(< row-position (- column-count 1)) ; ...it is not the last cell of the row.
(not (char=? (read-char port) cell-delimeter))))
(raise-table-error
(string-append
"Malformed cell (cell number "
(number->string (+ row-position 1))
").")))
(vector-set! row row-position cell)
(loop (+ row-position 1) row)))))))
processed)
0
source-files)
;;; Sort all rows and mark duplicates:
(vector-sort!
(lambda (row-1 row-2) ; Return #t if, and only if, row-1 has to be moved before row-2.
(cond
((not row-1)
#f)
((not row-2)
#t)
(else
(let ((date-1 (vector-ref row-1 0))
(date-2 (vector-ref row-2 0)))
(or
(ps:< date-1 date-2)
(and
(ps:== date-1 date-2)
(let loop ((i 1))
(cond
((>= i column-count)
(vector-set! row-1 column-count #f) ; Mark as duplicate.
#f)
((ps:< (vector-ref row-1 i) (vector-ref row-2 i))
#t)
((ps:> (vector-ref row-1 i) (vector-ref row-2 i))
#f)
(else (loop (+ i 1)))))))))))
rows)
;;; Emit extracted rows to the standard output, each cell on a new line (stream of cells):
(process-stream
(current-output-port)
(lambda (port)
(vector-for-each
(lambda (row)
(when (and row (vector-ref row column-count))
(do ((i 0 (+ i 1)))
((= i column-count))
(put-string port (vector-ref row i))
(newline port))))
rows)))))
| false |
84d6daad787670fe4872499dc2a05773d58799c5
|
6ac5c268b4d11421993d6ee22325643219eebf98
|
/Example--Assn/Test Files/After Generating Tests/test.0/in/7/options.ss
|
3643d13f572ba2fd25a0d6282d0778c21f2c7fa2
|
[] |
no_license
|
trsong/AutotestGenerator
|
ee5f1f1a55a481dac3ffd8a0c637b8c81466598e
|
7fb6566de32455e8f773c0e4262595bffca20906
|
refs/heads/master
| 2021-01-11T10:50:06.170051 | 2016-12-11T14:34:08 | 2016-12-11T14:34:08 | 76,160,341 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 47 |
ss
|
options.ss
|
(modules "my-gcd.rkt")
(loadcode "my-lcm.rkt" )
| false |
0392f19510161ee5fd3228af1dfdd678f7ed7ac0
|
ae4938300d7eea07cbcb32ea4a7b0ead9ac18e82
|
/parser/csv/main.ss
|
606dc28c4a3f8bd3f84074c736f22105e83e5d98
|
[] |
no_license
|
keenbug/imi-libs
|
05eb294190be6f612d5020d510e194392e268421
|
b78a238f03f31e10420ea27c3ea67c077ea951bc
|
refs/heads/master
| 2021-01-01T19:19:45.036035 | 2012-03-04T21:46:28 | 2012-03-04T21:46:28 | 1,900,111 | 0 | 1 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,402 |
ss
|
main.ss
|
(library (imi parser csv)
(export read-csv
csv-delimiter)
(import (rnrs)
(imi proc construct)
(imi proc predicate logic)
(imi sugar cut)
(imi utils tester)
(imi utils parameter))
;;; reads a csv (comma seperated values) line
;;; from standard input, the delimiters are
;;; defined by csv-delimiter, additionally
;;; the newline character
;;;
;;; -> (listof/c string?)
(define (read-csv)
(construct-list*
read-csv-token
(lambda (token)
(not (or (eof-object? (peek-char))
(char=? #\newline (peek-char)))))))
;;; the delimiters for the values, standard
;;; is comma and semicolon
;;;
;;; (parameter/c (listof/c char?))
(define csv-delimiter
(make-parameter
'(#\, #\;)))
;;; reads an token of a csv, that is the
;;; text until an delimiter, except it
;;; is in an string; the delimiter is
;;; a newline or the characters given
;;; in the csv-delimiter parameter
;;;
;;; -> string?
(define (read-csv-token)
(if (char=? (peek-char)
#\")
(read)
(list->string
(construct-list*
(cut read-char)
(or/p eof-object?
(cut char=? <> #\newline)
(tester exists
char=?
(csv-delimiter)))))))
)
| false |
e559acf5347310d688a90ed07bf68ccb589d9892
|
6e359a216e1e435de5d39bc64e75998945940a8c
|
/ex2.54.scm
|
7832d95211bf12a68b4b7b7abc2885a419458482
|
[] |
no_license
|
GuoDangLang/SICP
|
03a774dd4470624165010f65c27acc35d844a93d
|
f81b7281fa779a9d8ef03997214e47397af1a016
|
refs/heads/master
| 2021-01-19T04:48:22.891605 | 2016-09-24T15:26:57 | 2016-09-24T15:26:57 | 69,106,376 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 159 |
scm
|
ex2.54.scm
|
(define (equall? a b)
(let ((na (cdr a))
(nb (cdr b)))
(if (and (null? na) (null? nb)) true
(if (eq? (car a) (car b)) (equall? na nb)
false))))
| false |
e869016767170605ab82c49d246e6dfbafc37a11
|
d074b9a2169d667227f0642c76d332c6d517f1ba
|
/sicp/ch_5/exercise.5.11.scm
|
6600238afc0b4fde6ede5635647b66941c945217
|
[] |
no_license
|
zenspider/schemers
|
4d0390553dda5f46bd486d146ad5eac0ba74cbb4
|
2939ca553ac79013a4c3aaaec812c1bad3933b16
|
refs/heads/master
| 2020-12-02T18:27:37.261206 | 2019-07-14T15:27:42 | 2019-07-14T15:27:42 | 26,163,837 | 7 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,428 |
scm
|
exercise.5.11.scm
|
#!/usr/bin/env csi -s
(require rackunit)
;;; Exercise 5.11
;; When we introduced `save' and `restore' in section *Note 5-1-4::,
;; we didn't specify what would happen if you tried to restore a
;; register that was not the last one saved, as in the sequence
;;
;; (save y)
;; (save x)
;; (restore y)
;;
;; There are several reasonable possibilities for the meaning of
;; `restore':
;;
;; a. `(restore y)' puts into `y' the last value saved on the stack,
;; regardless of what register that value came from. This is the
;; way our simulator behaves. Show how to take advantage of this
;; behavior to eliminate one instruction from the Fibonacci
;; machine of section *Note 5-1-4:: (*Note Figure 5-12::).
;;
;; b. `(restore y)' puts into `y' the last value saved on the stack,
;; but only if that value was saved from `y'; otherwise, it
;; signals an error. Modify the simulator to behave this way. You
;; will have to change `save' to put the register name on the
;; stack along with the value.
;;
;; c. `(restore y)' puts into `y' the last value saved from `y'
;; regardless of what other registers were saved after `y' and
;; not restored. Modify the simulator to behave this way. You
;; will have to associate a separate stack with each register.
;; You should make the `initialize-stack' operation initialize
;; all the register stacks.
| false |
ce2e0e5fa75b3b07623ff1764f9671bd1d325b21
|
2bcf33718a53f5a938fd82bd0d484a423ff308d3
|
/programming/sicp/ch2/ex-2.22.scm
|
44430a335a41513a58654e36e5b1f800b00ffc65
|
[] |
no_license
|
prurph/teach-yourself-cs
|
50e598a0c781d79ff294434db0430f7f2c12ff53
|
4ce98ebab5a905ea1808b8785949ecb52eee0736
|
refs/heads/main
| 2023-08-30T06:28:22.247659 | 2021-10-17T18:27:26 | 2021-10-17T18:27:26 | 345,412,092 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,093 |
scm
|
ex-2.22.scm
|
#lang scheme
;; https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-15.html#%_thm_2.22
;; This iterative definition reverses the list because the list is iterated
;; through from head to tail, but each successive square is prepended to the
;; accumulator, so the first processed element (the original head) ends up as
;; the last element in the accumulator, and vice versa.
(define (square-list items)
(define (iter things answer)
(if (null? things)
answer
(iter (cdr things)
(cons (square (car things)) answer))))
(iter items nil))
;; This iterative definition is all kinds of weird because the answer is created
;; with a flipped argument order from the usual: in this case cons is called
;; with a pair as its first value, and the second is a primitive value:
;; (square-list (list 1 2 3))
;; => (cons (cons (cons '() 1) 4) 9)
(define (square-list items)
(define (iter things answer)
(if (null? things)
answer
(iter (cdr things)
(cons answer (square (car things))))))
(iter items nil))
| false |
b6c26e93322ac928fa895fac06e8ee8d571e2641
|
025c71211d8c0b4cf40c65d5add4c3d1fe10fa59
|
/mk-misc/mk/stuff.scm
|
34cc5449262c503343bfd7deb8a4b94cb1083793
|
[
"MIT"
] |
permissive
|
gregr/experiments
|
5ce58d6ac6ae034d3955a96a434272ab3671bf6f
|
a6c5461bda9f8e221225a403f21d61ad4673c57a
|
refs/heads/master
| 2023-08-10T23:48:05.730805 | 2023-08-01T18:58:56 | 2023-08-01T18:58:56 | 4,839,336 | 9 | 2 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,134 |
scm
|
stuff.scm
|
(load "mk.scm")
(load "evalo.scm")
;(1 2 3)
;(1 . (2 . (3 . ())))
;(1 2 3 . 4)
;(1 . (2 . (3 . 4)))
;(cond (T1 E1)
;(T2 E2)
;...
;(else ...))
;(define (employee-jobo name job)
;(conde
;((== name 'Billy) (== job 'Janitor))
;((== name 'Bob) (== job 'Farmer))
;((== name 'Rob) (== job 'Programmer))
;((== name 'Robby) (== job 'Cook))
;((== name 'Robert) (== job 'Janitor))
;((== name 'Bobby) (== job 'Programmer))
;))
;(define (job-salaryo job salary)
;(conde
;((== job 'Farmer) (== salary 2))
;((== job 'Janitor) (== salary 8))
;((== job 'Programmer) (== salary 1))
;))
;(define (my-append xs ys)
;(if (null? xs)
;ys
;(cons (car xs) (my-append (cdr xs) ys))))
;(define (multiple-answers-please x y)
;(list (cons x 1) (cons y 2)))
;(define (multiple-answers-pleaseo x y answer1 answer2)
;(== (cons y 2) answer2)
;(== answer1 (cons x 1)))
;(display (my-append '(a b c) '(d e f)))
(define (my-append xs ys)
(cond
((null? xs) ys)
(else (let* ((x (car xs))
(xs-rest (cdr xs))
(zs (my-append xs-rest ys)))
(cons x zs)))))
(define (appendo xs ys xsys)
(conde
((== '() xs) (== ys xsys))
((fresh (x xs-rest zs)
(== `(,x . ,xs-rest) xs)
(== `(,x . ,zs) xsys)
(appendo xs-rest ys zs)))))
;(display (run 30 (q)
;;(evalo (quote (quote 5)) q)
;(evalo q 5)
;;(appendo q r '(1 2 3 4 5 6))
;;(employee-jobo name job)
;;(job-salaryo job salary)
;;(== salary 8)
;;(conde
;;((== q 1) (== r 2))
;;((== q s) (== r 3)))
;;(== s 2)
;;(numbero s)
;;(=/= `(,t . 4) `(3 . ,u))
;;(== `(,q 4 ,r 5 . ,u) `(3 ,s 6 ,t))
;;(== `(,t . (4 . ())) `(3 ,u))
;;(== (cons t (cons 4 '())) `(3 ,u))
;;(== u 4)
;;(== t 3)
;;(=/= 5 s)
;;(== s t)
;;(== 1 q)
;;(== r 2)
;))
;(newline)
| false |
5ecd7cab0ef28a979119047cefd7cd6d76f36265
|
000dbfe5d1df2f18e29a76ea7e2a9556cff5e866
|
/sitelib/srfi/%3a64.scm
|
f7eb6075371a35dedf2a85b8880483bef49c2f22
|
[
"BSD-3-Clause",
"LicenseRef-scancode-other-permissive",
"MIT",
"BSD-2-Clause"
] |
permissive
|
ktakashi/sagittarius-scheme
|
0a6d23a9004e8775792ebe27a395366457daba81
|
285e84f7c48b65d6594ff4fbbe47a1b499c9fec0
|
refs/heads/master
| 2023-09-01T23:45:52.702741 | 2023-08-31T10:36:08 | 2023-08-31T10:36:08 | 41,153,733 | 48 | 7 |
NOASSERTION
| 2022-07-13T18:04:42 | 2015-08-21T12:07:54 |
Scheme
|
UTF-8
|
Scheme
| false | false | 74 |
scm
|
%3a64.scm
|
#!core
(library (srfi :64)
(export :all)
(import (srfi :64 testing)))
| false |
d8a2e85ceb35b0b4900b038211da336b0b37b00f
|
23ff9f52226c27bd848a6382de15edf5b4b2c460
|
/prooftree-tests.scm
|
92974bd1a2e40e176f9599b5463b3fb8772dd80c
|
[] |
no_license
|
namin/metamk
|
db4c10bf297289345b84b9934b5767b79a73c585
|
8bc90b222987294baaf8464fccaa6a12c47005b0
|
refs/heads/master
| 2023-09-02T03:11:46.571987 | 2023-08-27T10:13:43 | 2023-08-27T10:13:43 | 14,932,255 | 27 | 3 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 2,576 |
scm
|
prooftree-tests.scm
|
(load "mk.scm")
(load "utils.scm")
(load "prooftree.scm")
(load "meta.scm")
(load "matche.scm")
(load "ex-peano.scm")
(load "ex-stlc.scm")
(load "test-check.scm")
(test-check "pluso-prooftree"
(run 3 (q)
(fresh (a b c proof)
(== q `((,a ,b ,c) ,proof))
((prooftree pluso-clause-case)
`(pluso ,a ,b ,c) proof)))
'(((z _.0 _.0) (((pluso z _.0 _.0) () <-- ())))
(((s z) _.0 (s _.0))
(((pluso (s z) _.0 (s _.0))
() <--
(((pluso z _.0 _.0) () <-- ())))))
(((s (s z)) _.0 (s (s _.0)))
(((pluso (s (s z)) _.0 (s (s _.0)))
() <--
(((pluso (s z) _.0 (s _.0))
() <--
(((pluso z _.0 _.0) () <-- ())))))))))
(test-check "stlc-prooftree-no-eigen"
(run 2 (q)
(fresh (term proof)
(== q `(,term ,proof))
((prooftree !-o-clause-case)
`(!-o () ,term (A -> A))
proof)))
'((((lambda (_.0) _.0)
(((!-o () (lambda (_.0) _.0) (A -> A))
abs <--
(((!-o ((_.0 : A)) _.0 A) var <-- ())))))
(sym _.0))
(((lambda (_.0) ((lambda (_.1) _.1) _.0))
(((!-o () (lambda (_.0) ((lambda (_.1) _.1) _.0)) (A -> A))
abs <--
(((!-o ((_.0 : A)) ((lambda (_.1) _.1) _.0) A)
app <--
(((!-o ((_.0 : A)) (lambda (_.1) _.1) (A -> A))
abs <--
(((!-o ((_.1 : A) (_.0 : A)) _.1 A) var <-- ())))
((!-o ((_.0 : A)) _.0 A) var <-- ())))))))
(sym _.0 _.1))))
(test-check "stlc-prooftree-if"
(run* (q)
(fresh (term ty proof)
(== term '(lambda (x) (if x (lambda (y) x) (lambda (y) y))))
(== q `(,term ,ty ,proof))
((prooftree !!-o-clause-case)
`(!!-o () ,term ,ty)
proof)))
'(((lambda (x) (if x (lambda (y) x) (lambda (y) y)))
(boolean -> (boolean -> boolean))
(((!!-o
()
(lambda (x) (if x (lambda (y) x) (lambda (y) y)))
(boolean -> (boolean -> boolean)))
abs
<--
(((!!-o
((x : boolean))
(if x (lambda (y) x) (lambda (y) y))
(boolean -> boolean))
if
<--
(((!!-o ((x : boolean)) x boolean) var <-- ())
((!!-o ((x : boolean)) (lambda (y) x) (boolean -> boolean))
abs
<--
(((!!-o ((y : boolean) (x : boolean)) x boolean)
var
<--
())))
((!!-o ((x : boolean)) (lambda (y) y) (boolean -> boolean))
abs
<--
(((!!-o ((y : boolean) (x : boolean)) y boolean)
var
<--
())))))))))))
| false |
9ec9c391fe16cb5ddf0a55aa0e4aae82e6122cee
|
defeada37d39bca09ef76f66f38683754c0a6aa0
|
/mscorlib/system/security/cryptography/dsasignature-formatter.sls
|
f2c2bbcd10e95b3fd298adc28823e84a80f4cd8d
|
[] |
no_license
|
futsuki/ironscheme-port
|
2dbac82c0bda4f4ff509208f7f00a5211d1f7cd5
|
4e7a81b0fbeac9a47440464988e53fb118286c54
|
refs/heads/master
| 2016-09-06T17:13:11.462593 | 2015-09-26T18:20:40 | 2015-09-26T18:20:40 | 42,757,369 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 1,100 |
sls
|
dsasignature-formatter.sls
|
(library (system security cryptography dsasignature-formatter)
(export new
is?
dsasignature-formatter?
set-hash-algorithm
create-signature
set-key)
(import (ironscheme-clr-port))
(define-syntax new
(lambda (e)
(syntax-case e ()
((_ a ...)
#'(clr-new
System.Security.Cryptography.DSASignatureFormatter
a
...)))))
(define (is? a)
(clr-is System.Security.Cryptography.DSASignatureFormatter a))
(define (dsasignature-formatter? a)
(clr-is System.Security.Cryptography.DSASignatureFormatter a))
(define-method-port
set-hash-algorithm
System.Security.Cryptography.DSASignatureFormatter
SetHashAlgorithm
(System.Void System.String))
(define-method-port
create-signature
System.Security.Cryptography.DSASignatureFormatter
CreateSignature
(System.Byte[] System.Byte[]))
(define-method-port
set-key
System.Security.Cryptography.DSASignatureFormatter
SetKey
(System.Void System.Security.Cryptography.AsymmetricAlgorithm)))
| true |
cdf3f42363761bf89dcad47caacd70f88d658a87
|
c872e91f18e48b8571293d27469284199a4877fc
|
/day27.ss
|
9aace17cd005c0c60a77f9b906fc2d443e8ab82a
|
[] |
no_license
|
lamberce/Programming-Language-Concepts-GitHub
|
95afc0d0237a57c78a1d0aae1085ef4af3479256
|
585b78bbf6e3d4c8006badb9b376c6fa88d62ce4
|
refs/heads/master
| 2021-01-10T20:36:52.841958 | 2015-01-18T18:53:29 | 2015-01-18T18:53:29 | 29,436,770 | 0 | 0 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 22 |
ss
|
day27.ss
|
;;Day 27 class notes
| false |
baa0d88a6603c9eab089618eb565d08d551b9a3a
|
b9eb119317d72a6742dce6db5be8c1f78c7275ad
|
/random-scheme-stuff/enum.scm
|
153406dc6a8ddcb5ebe403a91417f5071a18c687
|
[] |
no_license
|
offby1/doodles
|
be811b1004b262f69365d645a9ae837d87d7f707
|
316c4a0dedb8e4fde2da351a8de98a5725367901
|
refs/heads/master
| 2023-02-21T05:07:52.295903 | 2022-05-15T18:08:58 | 2022-05-15T18:08:58 | 512,608 | 2 | 1 | null | 2023-02-14T22:19:40 | 2010-02-11T04:24:52 |
Scheme
|
UTF-8
|
Scheme
| false | false | 288 |
scm
|
enum.scm
|
(define (enumerate-interval start how-many)
(let loop ((result '())
(start start)
(how-many how-many))
(if (zero? how-many)
result
(loop (append result (list start))
(+ 1 start)
(- how-many 1)))))
(provide 'interval)
| false |
9433326261121133b682a47db7ab666e351f8717
|
eef5f68873f7d5658c7c500846ce7752a6f45f69
|
/spheres/os/arguments.scm
|
f21bae6ef2fd6acb547db3747ef280e61fb2f869
|
[
"MIT"
] |
permissive
|
alvatar/spheres
|
c0601a157ddce270c06b7b58473b20b7417a08d9
|
568836f234a469ef70c69f4a2d9b56d41c3fc5bd
|
refs/heads/master
| 2021-06-01T15:59:32.277602 | 2021-03-18T21:21:43 | 2021-03-18T21:21:43 | 25,094,121 | 13 | 3 | null | null | null | null |
UTF-8
|
Scheme
| false | false | 5,525 |
scm
|
arguments.scm
|
;;!!! Argument processing for command-line programs
;; .author Per Eckerdal, for the Blackhole module system
;; .author Alvaro Castro-Castilla, 2013-2015
(define (arguments/error . args)
(let ((err (current-error-port)))
(display "Program argument error: " err)
(for-each
(lambda (arg)
(display arg err)
(display " " err))
args)
(display "\n") err)
(exit 1))
;;!! Parse arguments
;; .parameter args List of arguments to process
;; .parameter options List of options following this structure:
;; '((#\g 0 "global")
;; (#\f 1 "file"))
;; 1 means that takes an argument, 0 it doesn't
;; Example:
;; (define (main . args)
;; (let ((commands
;; `(("install" ,@install-cmd)
;; ("uninstall" ,@uninstall-cmd)
;; ("help" ,@help-cmd)
;; ("update" ,@update-cmd)
;; ("search" ,@search-cmd)
;; ("set" ,@set-cmd)
;; ("unknown-command" ,@unknown-cmd))))
;; (parse-arguments
;; args
;; (lambda (actual-args-sans-opts opts)
;; (let* ((args-sans-opts (if (null? actual-args-sans-opts)
;; '("help")
;; actual-args-sans-opts))
;; (cmd-pair (assoc (car args-sans-opts) commands))
;; (cmd (if cmd-pair
;; (cdr cmd-pair)
;; (cdr (assoc "unknown-command" commands)))))
;; (cmd (car args-sans-opts)
;; opts
;; (cdr args-sans-opts))))
;; *options*)))
;; (apply main (cdr (command-line)))
(define (parse-arguments args kont options)
(define (string-contains haystack chr)
(call/cc
(lambda (ret)
(let ((strlen (string-length haystack)))
(let loop ((i 0))
(if (>= i strlen)
(ret #f)
(let ((c (string-ref haystack i)))
(if (eq? c chr)
(ret i)
(loop (+ i 1))))))))))
(define (opt? str)
(and (> (string-length str) 1)
(char=? #\- (string-ref str 0))))
(define (long-opt? str)
(and (> (string-length str) 2)
(char=? #\- (string-ref str 0))
(char=? #\- (string-ref str 1))))
(define (short-opt? str)
(and (opt? str)
(not (long-opt? str))))
(let loop ((args args)
(args-sans-opts '())
(opts '()))
(define (consume-next-argument!)
(if (or (null? (cdr args))
(equal? "--" (cadr args)))
(arguments/error "Expected an argument to" (car args)))
(let ((val (cadr args)))
(set-cdr! args (cddr args))
val))
(cond
((null? args)
(kont (reverse args-sans-opts)
(reverse opts)))
((equal? "--" (car args))
(kont (append (reverse args-sans-opts)
(cdr args))
(reverse opts)))
((long-opt? (car args))
(let* ((=-pos (string-contains (car args) #\=))
(opt-name
(substring (car args)
2
(or =-pos
(string-length (car args)))))
(opt-val
(and =-pos
(substring (car args)
(+ 1 =-pos)
(string-length (car args))))))
(loop (cdr args)
args-sans-opts
(cons (list opt-name
(string-append "--" opt-name)
opt-val)
opts))))
((short-opt? (car args))
(let* ((str (car args))
(len (string-length str)))
(let inner-loop ((idx 1) (opts opts))
(cond
((= len idx)
(loop (cdr args)
args-sans-opts
opts))
(else
(let* ((opt-chr (string-ref str idx))
(opt (assq opt-chr options)))
(if (not opt)
(arguments/error "Unrecognized option" (car args)))
(let ((val
(cond
((zero? (cadr opt))
#f)
((not (= 2 len))
(arguments/error "Option that takes an argument must not be grouped"
(car args)))
(else
(consume-next-argument!)))))
(inner-loop (+ 1 idx)
(cons (list (caddr opt)
(string #\- opt-chr)
val)
opts)))))))))
(else
(loop (cdr args)
(cons (car args) args-sans-opts)
opts)))))
(define (handle-opts! opts handlers)
(for-each
(lambda (opt)
(let ((handler (assoc (car opt) handlers)))
(if handler
((cdr handler) (caddr opt))
(arguments/error "Option is not valid in this context:"
(cadr opt)))))
opts))
(define (ensure-no-args! args)
(if (not (null? args))
(apply
arguments/error
(cons "Did not expect arguments:" args))))
(define (ensure-args! args)
(if (null? args)
(apply
arguments/error
(list "At least one argument is required."))))
(define (ensure-one-arg! args)
(if (not (and (list? args)
(= 1 (length args))))
(apply
arguments/error
(cons "Expected exactly one argument:" args))))
| false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.