[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ELISP] How do you turn an array of chars into a string?
From: |
Joseph Brenner |
Subject: |
Re: [ELISP] How do you turn an array of chars into a string? |
Date: |
Wed, 08 Dec 2010 15:22:38 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> What if you want to convert an array-of-chars into a string?
>
> A string *is* an array of chars.
Yes, I've heard that, but:
(let ((mah-array [?c ?a ?t])
(mah-string "cat"))
(equal mah-array mah-string)) ;; ==> nil
(let ((mah-array [?c ?a ?t])
(mah-string "cat"))
(string= mah-array mah-string))
;; Lisp error: (wrong-type-argument stringp [99 97 116])
Though on the other hand:
(equal
(aref [?c ?a ?t] 2)
(aref "cat" 2)) ;; ==> t
In any case, it doesn't exactly make sense to me to just say
that "a string is an array of chars".
I suppose you might say "a string is an array of chars, with a type
of 'string'".