Page 1 of 1

Embedded lists with match?

Posted: Wed Dec 16, 2009 6:27 pm
by methodic
Is something like this possible:

Code: Select all

(set 'lst '("key ("this one" "that one" "other one")))
(match '(? ("that one")) lst)
Basically I need to go backwards in referencing the key with one of it's elements.

Thanks in advance!

Re: Embedded lists with match?

Posted: Wed Dec 16, 2009 7:52 pm
by cormullion
Possibly:

Code: Select all

> (match '(? (* "that one" *)) lst)
;-> ("key" ("this one") ("other one"))

Re: Embedded lists with match?

Posted: Thu Dec 17, 2009 8:15 am
by Lutz
... and this same pattern would work for the others too, as the * star stands for 0, 1 or more:

Code: Select all

(match '(? (* "this one" *)) lst)
(match '(? (* "other one" *)) lst)