newLISP Fan Club

Forum => newLISP in the real world => Topic started by: methodic on December 16, 2009, 10:27:01 AM

Title: Embedded lists with match?
Post by: methodic on December 16, 2009, 10:27:01 AM
Is something like this possible:
(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!
Title: Re: Embedded lists with match?
Post by: cormullion on December 16, 2009, 11:52:58 AM
Possibly:


> (match '(? (* "that one" *)) lst)
;-> ("key" ("this one") ("other one"))
Title: Re: Embedded lists with match?
Post by: Lutz on December 17, 2009, 12:15:10 AM
... and this same pattern would work for the others too, as the * star stands for 0, 1 or more:


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