This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) | |
(ice-9 match) (ice-9 peg) | |
(ice-9 textual-ports) | |
(ice-9 pretty-print) | |
(srfi srfi-43)) | |
(define-peg-string-patterns | |
"top <-- entry entry entry NL entry !. | |
entry <-- name COLON SPACE (number COMMA?)* NL | |
name <-- [A-Za-z ]+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (ice-9 textual-ports) (ice-9 peg) | |
(ice-9 match) (ice-9 pretty-print) (srfi srfi-26) | |
(ice-9 string-fun)) | |
(define-peg-string-patterns | |
"top <-- grid insns !.* | |
grid <-- (nnl+ CNL)+ NL | |
insns <-- (nnl* NL)+ | |
nnl <- !NL . | |
CNL <- '\n' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (srfi srfi-26) | |
(ice-9 match) (ice-9 peg) | |
(ice-9 textual-ports) | |
(ice-9 pretty-print) | |
(ice-9 threads) (ice-9 atomic)) | |
(define-peg-string-patterns | |
"top <-- (entry NL)* !. | |
entry <-- var SPACE var | |
var <-- ('p'/'v') EQUAL number COMMA number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) | |
(ice-9 match) (ice-9 peg) | |
(ice-9 textual-ports) | |
(ice-9 pretty-print)) | |
(define-peg-string-patterns | |
"top <-- (entry NL?)* !. | |
entry <-- button NL button NL prize NL | |
prize <-- PRIZE vec | |
button <-- BUTTON ('A'/'B') COLON vec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (srfi srfi-26) | |
(ice-9 pretty-print) (ice-9 textual-ports) (ice-9 hash-table)) | |
(define (%read-input) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons (string->list line) (%read-input))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (srfi srfi-26) (ice-9 pretty-print) (ice-9 textual-ports) (ice-9 match)) | |
(define (char->digit ch) | |
(match ch | |
[#\0 0] | |
[#\1 1] | |
[#\2 2] | |
[#\3 3] | |
[#\4 4] | |
[#\5 5] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 textual-ports) (ice-9 pretty-print) | |
(srfi srfi-1) (ice-9 match) (srfi srfi-43)) | |
(define (char->digit ch) | |
(match ch | |
[#\0 0] | |
[#\1 1] | |
[#\2 2] | |
[#\3 3] | |
[#\4 4] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (srfi srfi-26) (ice-9 pretty-print) (ice-9 textual-ports)) | |
(define (%read-input) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons (string->list line) (%read-input))))) | |
(define (read-input) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (srfi srfi-1) (srfi srfi-26) (ice-9 match) (ice-9 arrays) | |
(ice-9 receive) (ice-9 pretty-print) (ice-9 textual-ports)) | |
(define (%read-input) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons (string->list line) (%read-input))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 textual-ports) (ice-9 pretty-print) (srfi srfi-1) (ice-9 receive) (srfi srfi-26)) | |
(define (read-input) | |
(let ([line (get-line (current-input-port))]) | |
(if (eof-object? line) | |
'() | |
(cons (filter identity (map string->number (string-split line #\space))) | |
(read-input))))) | |
(define (abs- a b) (abs (- a b))) |
NewerOlder