Re: Strings
From: Hannah Schroeter (hannah_at_schlund.de)
Date: 01/14/04
- Next message: Anton van Straaten: "Re: Programming languages for the very young"
- Previous message: Henrik Motakef: "Re: SOT: GUI design"
- In reply to: Kristof: "Strings"
- Next in thread: Kenny Tilton: "Re: Strings"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 14 Jan 2004 20:45:47 GMT
Hello!
Kristof <kristof_jebens@hotmail.com> wrote:
>Can anyone tell me how to convert e.g. a list into a string like the
>print function in lisp does?
There are functions print-to-string, prin1-to-string and
princ-to-string. Or you can use string output streams. In this case,
you can format to the string stream or build the output with multiple
output function calls.
(with-output-to-string (stream)
(format stream "Hello world! ")
(princ '(1 2 3) stream))
=>
"Hello world! (1 2 3)"
>Is there a way to add characters/strings to a string?
It depends. In principle strings are one-dimensional arrays
containing characters. Arrays can be adjustable or not
(i.e. you can change the size of the dimensions), and
have a fill-pointer (a concept that only a part of a one-dimensional
array is really "valid").
So if the string is adjustable, you can destructively append to it
(change the original string).
You can, of course, also do it in a functional way, creating a
new string which is the concatenation of two or more old ones,
using (concatenate 'string a-string another-string)
>Thank you
>Kristof
Kind regards,
Hannah.
- Next message: Anton van Straaten: "Re: Programming languages for the very young"
- Previous message: Henrik Motakef: "Re: SOT: GUI design"
- In reply to: Kristof: "Strings"
- Next in thread: Kenny Tilton: "Re: Strings"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|