Others have given good reasons to take alternate approaches, but if I were writing your define-lookup-function macro, I would avoid using a dictionary type and have the macro expand to `case`, like this: (define-syntax define-lookup-function (syntax-parser [(_ name:id [lhs:expr rhs:expr] ...) #'(define (name arg) (case arg [(lhs) rhs] ... [else (error 'name (format "no matching clause for ~e" arg))]))]))
For a pre-made solution, I'd look at match-lambda. I'm interested to see what you're doing with this code! (I'm a musicology student when I'm not playing with Racket.) -Philip On Mon, Aug 7, 2017 at 1:01 PM, Luis Sanjuán <luisj.sanj...@gmail.com> wrote: > On Monday, August 7, 2017 at 6:39:58 PM UTC+2, Luis Sanjuán wrote: > > EDIT. > > > > In the description of the 'Interval' data type, replace 'notes' with > 'pitch-classes' > > > > In the signature of the function `interval`, replace 'Nat' with > 'Interval' > > Another one: > > In the signature of `fifths-from-to` replace the returned type `Nat` with > `Integer` > > -- > 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 racket-users+unsubscr...@googlegroups.com. > 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 racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.