langs on my langs

2017
Matthew Butterick 7 years ago
parent 0bdbd84aef
commit 30a2928e99

@ -0,0 +1,22 @@
#lang s-exp syntax/module-reader
#:read read
#:read-syntax read-syntax
#:language `(submod ,aoc-lang expander)
(require racket/runtime-path)
(define-runtime-path aoc-lang "aoc-lang.rkt")
(module expander br/quicklang
(require "helper.rkt")
(provide (except-out (all-from-out br/quicklang "helper.rkt") #%module-begin)
(rename-out [#%mb #%module-begin]))
(define-macro (#%mb . ARGS)
(with-pattern ([MODULE-PATH (syntax-source caller-stx)])
#'(#%module-begin
(provide read-syntax)
(define (read-syntax path port)
(strip-context #`(module mod MODULE-PATH
#,@(for/list ([line (in-lines port)])
(for/list ([datums (in-port read (open-input-string line))])
datums)))))
. ARGS))))

@ -1,12 +1,7 @@
#lang br/quicklang
(require "../helper.rkt")
(provide read-syntax)
(define (read-syntax path port)
(strip-context #`(module mod "main.rkt" #,@(port->datums port))))
#lang reader "../aoc-lang.rkt"
(provide (rename-out [#%mb #%module-begin]))
(define-macro (#%mb STARS NUMBER ...)
(define-macro (#%mb (STARS) (NUMBER) ...)
#'(#%module-begin (captcha-sum 'STARS NUMBER) ...))
(define (captcha-sum stars num)

@ -1,2 +1,2 @@
#lang reader "main.rkt"
#lang reader "main.rkt" ; 1343
9513446799636685297929646689682997114316733445451534532351778534251427172168183621874641711534917291674333857423799375512628489423332297538215855176592633692631974822259161766238385922277893623911332569448978771948316155868781496698895492971356383996932885518732997624253678694279666572149831616312497994856288871586777793459926952491318336997159553714584541897294117487641872629796825583725975692264125865827534677223541484795877371955124463989228886498682421539667224963783616245646832154384756663251487668681425754536722827563651327524674183443696227523828832466473538347472991998913211857749878157579176457395375632995576569388455888156465451723693767887681392547189273391948632726499868313747261828186732986628365773728583387184112323696592536446536231376615949825166773536471531487969852535699774113163667286537193767515119362865141925612849443983484245268194842563154567638354645735331855896155142741664246715666899824364722914296492444672653852387389477634257768229772399416521198625393426443499223611843766134883441223328256883497423324753229392393974622181429913535973327323952241674979677481518733692544535323219895684629719868384266425386835539719237716339198485163916562434854579365958111931354576991558771236977242668756782139961638347251644828724786827751748399123668854393894787851872256667336215726674348886747128237416273154988619267824361227888751562445622387695218161341884756795223464751862965655559143779425283154533252573949165492138175581615176611845489857169132936848668646319955661492488428427435269169173654812114842568381636982389224236455633316898178163297452453296667661849622174541778669494388167451186352488555379581934999276412919598411422973399319799937518713422398874326665375216437246445791623283898584648278989674418242112957668397484671119761553847275799873495363759266296477844157237423239163559391553961176475377151369399646747881452252547741718734949967752564774161341784833521492494243662658471121369649641815562327698395293573991648351369767162642763475561544795982183714447737149239846151871434656618825566387329765118727515699213962477996399781652131918996434125559698427945714572488376342126989157872118279163127742349

@ -1,2 +1,2 @@
#lang reader "main.rkt" ★★
#lang reader "main.rkt" ★★ ; 1274
9513446799636685297929646689682997114316733445451534532351778534251427172168183621874641711534917291674333857423799375512628489423332297538215855176592633692631974822259161766238385922277893623911332569448978771948316155868781496698895492971356383996932885518732997624253678694279666572149831616312497994856288871586777793459926952491318336997159553714584541897294117487641872629796825583725975692264125865827534677223541484795877371955124463989228886498682421539667224963783616245646832154384756663251487668681425754536722827563651327524674183443696227523828832466473538347472991998913211857749878157579176457395375632995576569388455888156465451723693767887681392547189273391948632726499868313747261828186732986628365773728583387184112323696592536446536231376615949825166773536471531487969852535699774113163667286537193767515119362865141925612849443983484245268194842563154567638354645735331855896155142741664246715666899824364722914296492444672653852387389477634257768229772399416521198625393426443499223611843766134883441223328256883497423324753229392393974622181429913535973327323952241674979677481518733692544535323219895684629719868384266425386835539719237716339198485163916562434854579365958111931354576991558771236977242668756782139961638347251644828724786827751748399123668854393894787851872256667336215726674348886747128237416273154988619267824361227888751562445622387695218161341884756795223464751862965655559143779425283154533252573949165492138175581615176611845489857169132936848668646319955661492488428427435269169173654812114842568381636982389224236455633316898178163297452453296667661849622174541778669494388167451186352488555379581934999276412919598411422973399319799937518713422398874326665375216437246445791623283898584648278989674418242112957668397484671119761553847275799873495363759266296477844157237423239163559391553961176475377151369399646747881452252547741718734949967752564774161341784833521492494243662658471121369649641815562327698395293573991648351369767162642763475561544795982183714447737149239846151871434656618825566387329765118727515699213962477996399781652131918996434125559698427945714572488376342126989157872118279163127742349

@ -1,13 +1,4 @@
#lang br/quicklang
(require "../helper.rkt")
(provide read-syntax)
(define (read-syntax path port)
(strip-context #`(module mod "main.rkt"
#,@(for/list ([line (in-lines port)])
(with-input-from-string line (λ ()
(for/list ([datums (in-port)])
datums)))))))
#lang reader "../aoc-lang.rkt"
(provide (rename-out [#%mb #%module-begin]))
(define-macro (#%mb (STARS) (NUMBER ...) ...)

@ -1,4 +1,4 @@
#lang reader "main.rkt"
#lang reader "main.rkt" ; 53978
1919 2959 82 507 3219 239 3494 1440 3107 259 3544 683 207 562 276 2963
587 878 229 2465 2575 1367 2017 154 152 157 2420 2480 138 2512 2605 876
744 6916 1853 1044 2831 4797 213 4874 187 6051 6086 7768 5571 6203 247 285

@ -1,4 +1,4 @@
#lang reader "main.rkt" ★★
#lang reader "main.rkt" ★★ ; 314
1919 2959 82 507 3219 239 3494 1440 3107 259 3544 683 207 562 276 2963
587 878 229 2465 2575 1367 2017 154 152 157 2420 2480 138 2512 2605 876
744 6916 1853 1044 2831 4797 213 4874 187 6051 6086 7768 5571 6203 247 285

@ -1,14 +1,7 @@
#lang sugar/debug br/quicklang
(require "../helper.rkt" sugar/cache)
(provide read-syntax)
(define (read-syntax path port)
(strip-context #`(module mod "main.rkt"
#,@(for/list ([datums (in-port read port)])
datums))))
#lang reader "../aoc-lang.rkt"
(provide (rename-out [#%mb #%module-begin]))
(define-macro (#%mb STARS NUMBER ...)
(define-macro (#%mb (STARS) (NUMBER) ...)
#'(#%module-begin ((if (eq? 'STARS ') dist larger-sum) NUMBER) ...))
(define (ring-side r) (* 2 r))

@ -1,2 +1,2 @@
#lang reader "main.rkt"
#lang reader "main.rkt" ; 480
347991

@ -1,2 +1,2 @@
#lang reader "main.rkt" ★★
#lang reader "main.rkt" ★★ ; 349975
347991

@ -1,13 +1,4 @@
#lang br/quicklang
(require "../helper.rkt")
(provide read-syntax)
(define (read-syntax path port)
(strip-context #`(module mod "main.rkt"
#,@(for/list ([line (in-lines port)])
(with-input-from-string line (λ ()
(for/list ([datums (in-port)])
datums)))))))
#lang reader "../aoc-lang.rkt"
(provide (rename-out [#%mb #%module-begin]))
(define-macro (#%mb (STARS) (WORD ...) ...)
@ -22,5 +13,3 @@
(define (no-duplicates? ws #:anagrams? [anagrams #f])
(let ([ws (if anagrams (map sort-chars ws) ws)])
(= (length ws) (length (remove-duplicates ws)))))

@ -1,4 +1,4 @@
#lang reader "main.rkt"
#lang reader "main.rkt" ; 337
kvvfl kvvfl olud wjqsqa olud frc
slhm rdfm yxb rsobyt rdfm
pib wzfr xyoakcu zoapeze rtdxt rikc jyeps wdyo hawr xyoakcu hawr

@ -1,4 +1,4 @@
#lang reader "main.rkt" ★★
#lang reader "main.rkt" ★★ ; 231
kvvfl kvvfl olud wjqsqa olud frc
slhm rdfm yxb rsobyt rdfm
pib wzfr xyoakcu zoapeze rtdxt rikc jyeps wdyo hawr xyoakcu hawr

@ -1,17 +1,11 @@
#lang sugar/debug br/quicklang
(require "../helper.rkt")
(provide read-syntax)
(define (read-syntax path port)
(strip-context #`(module mod "main.rkt"
#,@(for/list ([datum (in-port read port)])
datum))))
#lang reader "../aoc-lang.rkt"
(provide (rename-out [#%mb #%module-begin]))
(define-macro (#%mb STARS JMP ...)
#'(#%module-begin (escape 'STARS (list->vector '(JMP ...)))))
(define-macro (#%mb (STARS) (JMP) ...)
#`(#%module-begin
(escape (list->vector '(JMP ...)) 'STARS)))
(define (escape stars vec)
(define (escape vec stars)
(let/ec exit
(for/fold ([pos 0])
([i (in-naturals)])

@ -1,4 +1,4 @@
#lang reader "main.rkt"
#lang reader "main.rkt" ; 360603
2
2
1

@ -1,4 +1,4 @@
#lang reader "main.rkt" ★★
#lang reader "main.rkt" ★★ ; 25347697
2
2
1

@ -11,3 +11,7 @@
(define (number->digits num)
(for/list ([c (in-string (number->string num))])
(string->number (string c))))
(define (dirname path)
(define-values (dir name _) (split-path path))
dir)