[plt-scheme] match-lambda question

From: Jos Koot (jos.koot at telefonica.net)
Date: Sat Mar 22 19:41:23 EDT 2008

May be something like:

(define-syntax macro->procedure
 (syntax-rules ()
  ((_ macro) (lambda x (macro x)))))

----- Original Message ----- 
From: "harsha" <harsha.v.r at gmail.com>
To: <plt-scheme at list.cs.brown.edu>
Sent: Saturday, March 22, 2008 9:13 PM
Subject: [plt-scheme] match-lambda question

  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,

  For list-related administrative tasks:

Posted on the users mailing list.