[plt-scheme] match-lambda question

From: harsha (harsha.v.r at gmail.com)
Date: Sat Mar 22 16:13:57 EDT 2008

  i've been using define-syntax to define some of my functions as
macros because  the pattern matching is so convenient
i am trying to use match-lambda instead.
my qn is that when something like
x ...
is used in a pattern, match-lambda binds x to a list,
but is there some way ... to destructure the list again,
in other words, i am trying to define a macro define-fn, such that
        (m (n1 ...) ...)
        (+ (* n1 ...) ...))
(m '(1 2 3) '(4 5)) should evaluate to 26, the sum of the products

match-lambda doesn't seem to allow ... in the body of the lamda
expression, so one need's to write something like,
(define m (match-lambda*
            [((a ...) ...) (apply + (map (λ(x) (apply * x)) a))]))
is there some way to get around that, (pheraps, some-one has already
written a macro to convert the ...'s into apply's?)

right now i use define-stx (a custom macro which is just define-syntax
& syntax-rules specialised to the case where there is only one pattern
and no keywords)
so that after
(define-stx (m (n1 ...) ...) (+ (* n1 ...) ...))
(m (1 2 3) (4 5)) does evaluate to 26
the problem with this is that a macro is created instead of a fn and
in particular, the arguments are  not evaluated like a fns arguments,

Posted on the users mailing list.