[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Global change to strings...
- To: CXEA@MCGILLA.BITNET, email@example.com
- Subject: Global change to strings...
- From: firstname.lastname@example.org (Darryn Kozak)
- Date: Mon, 24 Jun 91 08:40:47 CDT
- In-reply-to: CXEA000's message of Sun, 23 Jun 91 20:28:36 EDT <23JUN91.22115082.0155.MUSIC@MUSICA.MCGILL.CA>
Date: Sun, 23 Jun 91 20:28:36 EDT
From: CXEA000 <CXEA%MCGILLA.BITNET@cunyvm.cuny.edu>
I have a rather embarrasingly simple question. I suspect it is a Common
Lisp rather than a specifically MACL question- and apologize if it is.
I have spent all afternoon with Franz's 'Common Lisp: The Language' and
with 'Common Lisp: The Reference' AND with the MACL docs, and I still
can not figure out how to do a global change in a Lisp string. I need to
be able to replace every instance of (say) 'x' with (say) 'a different
word'. Surely Lisp and/or MACl provide some means to do this with
different length keys...but I have tried various combinations of
'REPLACE' and 'SUBSTITUTE' and I can see that I can write a function
which copies character by character...but surely this must be built-in
to the language! The problem isn't doing the replacing per se; it's
doing it so that no other part of the string is overwritten or left
hanging after the new insertion.
I do apologize in adding to the heavy mail with this question which must
have a trivial answer...but I'm at my rope's end over this idiocy.
You'd think it would be built into the language, but... String
maniputlation seems like such a simple thing to do, but not nearly as
simple as you might like in CL. I think it has mostly to do with the
fact that strings are a type of vector, and if you want to change the
size of a string you need to add or remove some of the vector elements
or create a new string (vector).
Maybe what we really need is a new class of strings that includes
methods from string manipulation and patterm matching (like
Sorry, I seem to have drifted from MACL,
Darryn J Kozak
Cray Research Park
655F Lone Oak Drive
Eagan, MN 55121
ISS (Integrated Support System) Project