Here's how I'd outline lang/reader.rkt, assuming the API from
advent7/main.rkt in comments below.
(If I write a full solution, I'll come back & post that)
#lang racket/base
(provide (rename-out
[advent7-read read]
[advent7-read-syntax read-syntax]))
(require racket/port
syntax/strip-context (only-in advent7 ;; ASSUMPTION: parse-line
;; (-> String Gate) solve ;; (-> (Listof Gate) Solution)))
;; =============================================================================
(define (advent7-read in)
(syntax->datum (advent7-read-syntax #f in)))
(define (advent7-read-syntax src-path in)
(let* ([gate* (map parse-line (port->lines in))] [sol (solve
gate*)]) (strip-context #`(module advent7-program racket/base
(define input #,gate*) (define solution '#,sol)
(printf "Input:\n~a\n\nSolution:\n~a\n" input solution)))))
On Sat, Dec 19, 2015 at 6:01 AM, Daniel Prager <[email protected]>
wrote:
> I'm having a bit of fun working through the puzzles on adventofcode.com using
> Racket, and of course trying to use it to improve my Racket skills along
> the way.
>
> I've just solved Day 7 (adventofcode.com/day/7) for which the input
> "data" starts with:
>
> lf AND lq -> ls
>> iu RSHIFT 1 -> jn
>> bo OR bu -> bv
>> gj RSHIFT 1 -> hc
>> et RSHIFT 2 -> eu
>> bv AND bx -> by
>> is OR it -> iu
>> b OR n -> o
>
>
> and continues for a few hundred lines, ostensibly describing a system of
> wires and logic gates.
>
> Could this make a good example of how to make a one-off #lang in order to
> write a single program?
>
> I didn't make a #lang, but I'd love to see a solution that turns the data
> into input for #lang advent-day-7 (or whatever).
>
> Any takers?
>
> Dan
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.