[plt-scheme] Trying to use match.ss

From: Dan Schmidt (dfan at dfan.org)
Date: Wed May 28 11:10:30 EDT 2003

I'm having trouble understanding how ... works in match patterns.

Here are a couple of pairs of calls to match; in each case I don't
understand why the first one works and the second one doesn't.

  Welcome to MzScheme version 204, Copyright (c) 1995-2003 PLT
  > (require (lib "match.ss"))

  > (match '(2 2 2 3) ((a ... 3 ...) #t))
  #t
  > (match '(2 2 2 3) ((a ... 3) #t))
  match: no matching clause for (2 2 2 3):
  (match (quote (2 2 2 3)) ((a ... 3) #t))

  > (match '(2 2 2 3) (((and (not 3) a) ... 3) a))
  (2 2 2)
  > (match '(2 2 2 3) ((a ... 3) a))
  match: no matching clause for (2 2 2 3):
  (match (quote (2 2 2 3)) ((a ... 3) a))

The actual problem I'm trying to solve is to pattern match on an xml
tree where I want to find an A node with a B child who in turn has a
C child, but I don't know what position B and C come in in their
respective lists.  Perhaps I should grab Bruce's latest sources and
try using list-no-order.

Dan

-- 
http://www.dfan.org



Posted on the users mailing list.