ends-with

Pondering the philosophy behind the language
Locked
Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

ends-with

Post by Kazimir Majorinc »

currently:

(ends-with "hiho" "ho") => true
(ends-with '(h i h o) 'o) => true

should it be:

(ends-with '(h i h o) '(o)) => true
(ends-with '(h i h o) '(h o)) => true ?

same for starts-with

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: ends-with

Post by Lutz »

I believe when using lists, you mostly look for the single element with 'starts/ends-with'.

But you could use 'match' for that case:

Code: Select all

> (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.

Locked