[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `compare-strings' style question

From: David Kastrup
Subject: Re: `compare-strings' style question
Date: Thu, 19 Nov 2009 12:39:33 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

address@hidden writes:

> Hi,
> In Elisp, I'm trying to test whether a string is a prefix of another.
> Poking around the documentation, I stumbled upon `compare-strings',
> which seems to do the job fairly well. The interface is a bit weird
> (at least as seen from Lisp) It feels more like C's strcmp.
> It returns t on exact match, and some numbers on mismatch. I understand
> that the result might be useful in some cases (it tells one by how many
> chars we miss a match), but then I can't just do
>   (when (compare-strings foo 0 5 bar 0 5)
>     ...)
> but must do
>   (when (eq (compare-strings foo 0 5 bar 0 5) t)
>     ...)
> which looks rather funny. My question: are there better idioms? Am I
> barking up the wrong function?

(unless (numberp ...


(if (symbolp ...

David Kastrup

reply via email to

[Prev in Thread] Current Thread [Next in Thread]