Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Common Lisp] String manipulation

13 views
Skip to first unread message

Edrad

unread,
Dec 16, 2001, 4:06:26 AM12/16/01
to
Hello

I already know the string-concat to concat 2 strings, but I need a function
which can copy a small part of a string

(function "this is a string" 1 4) => "this"
where 1 would be the beginning index
and 4 the ending index

It would be a function of the kind

function: string, integer, integer -> string
s, b, e -> substring of s
from indice b to indice e

The parameters can be different, but I need a function that allow me to
extract substring (even a char) from a string

Thank you a lot

--

Dark Skull Software
http://www.dark-skull.fr.st

A+


Knut Anders Hatlen

unread,
Dec 16, 2001, 4:39:12 AM12/16/01
to
ed...@wanadoo.fr wrote:
> Hello
>
> I already know the string-concat to concat 2 strings, but I need a
> function which can copy a small part of a string
>
> (function "this is a string" 1 4) => "this"
> where 1 would be the beginning index
> and 4 the ending index

(subseq "this is a string" 0 4) => "this"

--
Knut Anders

Edrad

unread,
Dec 16, 2001, 4:41:24 AM12/16/01
to
Hello

Thank you !!!!!!!!!!

--

Dark Skull Software
http://www.dark-skull.fr.st

Association d'entraide aux développeurs francophones
http://www.developpez.com

A+
"Knut Anders Hatlen" <kaha...@online.no> a écrit dans le message de news:
866677o...@stjernegris.hatlen.net...

Matt Curtin

unread,
Dec 16, 2001, 10:28:01 AM12/16/01
to
>>>>> "Knut" == Knut Anders Hatlen <kaha...@online.no> writes:

>> I already know the string-concat to concat 2 strings, but I need
>> a function which can copy a small part of a string

Knut> (subseq "this is a string" 0 4) => "this"

The original poster would do well to note that this solution uses a
function that applies not specifically to strings, but rather to
sequences.

This is a critical point that often needs to be underscored for folks
only recently enlightened. It seems to come up a lot with strings.

Strings are sequences. When working with the Common Lisp library,
you'll frequently find that there isn't a function that does what you
need on the precise type on which you need it to work (e.g., a string)
but there is one that works on a more general type of which your
specific type is a member (e.g., a sequence).

--
Matt Curtin, Founder Interhack Corporation http://web.interhack.com/
My new book, "Developing Trust: Online Privacy and Security," is now
available. See site for details. research | development | consulting

Edrad

unread,
Dec 16, 2001, 2:19:41 PM12/16/01
to
Hello

Ok, thanks you for these precisions

--

Dark Skull Software
http://www.dark-skull.fr.st

A+
"Matt Curtin" <cmcu...@interhack.net> a écrit dans le message de news:
86u1ur2...@rowlf.interhack.net...

0 new messages