[racket] Lunch choosing program ported from Haskell to Racket

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Mon Jul 7 21:24:47 EDT 2014

On Mon, Jul 7, 2014 at 9:17 PM, Brian Adkins <racketusers at lojic.com> wrote:
>
> The various match-lambdas got me closer. I haven't found one w/o an extra set of [ ] or ( ) yet, but if I don't, I think I can make a macro for it after gaining some experience to allow the following:
>
> (define foo
>   (my-match-lambda ((arg1 _ arg2) arg3)
>     (bar arg1 arg2 arg3)))
>
> instead of:
>
> (define foo
>   (match-lambda* [(list (list arg1 _ arg2) arg3)
>                   (bar arg1 arg2 arg3)]))


You may want to take a look at `define/match`:

(define/match (foo a b)
  [((arg1 _ arg2) arg3) (bar arg1 arg2 arg3)])

Sam

Posted on the users mailing list.