emacs-devel
[Top][All Lists]
Advanced

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

Re: Why (substring "abc" 0 4) does not return "abc" instead of an error?


From: Pascal J. Bourguignon
Subject: Re: Why (substring "abc" 0 4) does not return "abc" instead of an error?
Date: Mon, 16 Jul 2012 22:20:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Lars Magne Ingebrigtsen <address@hidden> writes:

> Tassilo Horn <address@hidden> writes:
>
>> I'm not even able to come up with some concrete use-case where I'd
>> like to have the suggested behavior.
>
> It's a very common use case for me.  I know that a string can't be
> longer than X for some particular use, so I have to say
>
> (insert (if (> (length string) 4)
>             (substring string 0 4)
>           string))

(insert (substring string 0 (min 4 (length string))))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




reply via email to

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