chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] matchable egg usage question


From: Alan Post
Subject: [Chicken-users] matchable egg usage question
Date: Thu, 27 Jan 2011 22:21:05 -0700

I'm trying to use the matchable egg to detect #!key parameters in
functions I've constructed.  I have functions that accept multiple
#!key parameters, and I'm not sure how to make the matchable egg
match |(func ... mykey: myvalue ...)|.  That is, how to get the
matchable egg to match two parameters anywhere in an input list.

This is what I've got so far.  I am interested in whether the
#!key paramater 'a' is set to #t:

  (use matchable)

  (pretty-print (map
    (match-lambda
      ((_ 'a: #t . _) '(0 #t))
      ((_ ... 'a: #t) '(1 #t))
      (_              #f))
    '((foo)
      (foo bar)
      (foo a: #f)
      (foo a: #f b: #t)
      (foo a: #f b: #t c: #t)
      (foo a: #f c: #t b: #t)
      (foo b: #t a: #f c: #t)
      (foo b: #t c: #t a: #f)
      (foo a: #t)
      (foo a: #t b: #t)
      (foo a: #t b: #t c: #t)
      (foo a: #t c: #t b: #t)
      (foo b: #t a: #t c: #t)
      (foo b: #t c: #t a: #t))))
  (exit)

This works for every case except when the #!key I want to match
appears in the middle of a list of arguments, as happens in the
second-to-last case I'm trying to match.

Is there a way to make match work in this case?  What pattern
should I add to match values anywhere in the list, not just the
front and end?

-Alan
-- 
.i ko djuno fi le do sevzi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]