newLISP Fan Club

Forum => newLISP in the real world => Topic started by: newdep on January 22, 2007, 01:41:36 AM

Title: push on strings
Post by: newdep on January 22, 2007, 01:41:36 AM
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.
Title:
Post by: newdep on January 22, 2007, 02:22:56 AM
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...