newLISP Fan Club

Forum => Whither newLISP? => Topic started by: Kazimir Majorinc on February 12, 2010, 01:52:59 PM

Title: ends-with
Post by: Kazimir Majorinc on February 12, 2010, 01:52:59 PM
currently]
Title: Re: ends-with
Post by: Lutz on February 12, 2010, 05:30:58 PM
I believe when using lists, you mostly look for the single element with 'starts/ends-with'.



But you could use 'match' for that case:


> (match '(* h o) '(h i h o))
((h i))
> (match '(h i *) '(h i h o))
((h o))
> (match '(x y *) '(h i h o))
nil
>


the first two cases are Boolean 'true'



Ps: there was a time when 'match' could also be used for strings, but it got deprecated for the more powerful regex string matching. Although less powerful, perhaps the string matching with 'match' had some attractiveness to it? It definitely was easier to grasp mentally.