push on strings

Started by newdep, January 22, 2007, 01:41:36 AM

Previous topic - Next topic

newdep

Hi Lutz,





> (setq t "")

""

> (push "a" t 0)

"a"

> t

"a"

> (push "b" t 1)

"b"

> t

"ba"

> (push "c" t 2)

"c"

> t

"bca"

>

> (push "d" t 3)

"d"

> t

"bcda"

>





This is odd...Why is "c" at position 1 and "d" at position 2?



This is only possible if the string-index does not start at 0

(as lists do start at 0, this is confusing..)



but thats not the case ->



> (setq t "")

""

> (length t)

0

> (push "a" t)

"a"

> (length t)

1

> (t 0)

"a"

>







Norman.
-- (define? (Cornflakes))

newdep

#1
It is confusing when the length to push is bigger then the string itself, then we

have to deal with an exeption.. a round-robbin counter in this case...
-- (define? (Cornflakes))