string function

Q&A's, tips, howto's
Post Reply
cameyo
Posts: 165
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

string function

Post by cameyo »

Why this?

Code: Select all

(setq a 10)
(setq b 20)
(string "'"a" '"b"")
-> "'10 '20"

HPW
Posts: 1385
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Re: string function

Post by HPW »

Hello,

Whats the question: The integer in the both symbols are converted to string and all together is concatinated.

http://www.newlisp.org/downloads/newlis ... tml#string

Regards
Hans-Peter
Hans-Peter

cameyo
Posts: 165
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: string function

Post by cameyo »

This is normal:

Code: Select all

(string a b)
-> "1020"
(string "a""b")
-> "ab"
This is strange, but you just need to know:

Code: Select all

(string ""a""b"")
-> "1020"

ralph.ronnquist
Posts: 223
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: string function

Post by ralph.ronnquist »

I'm confused about why you appear confuse... of course (string ""a""b"") is the same as (string "" a "" b ""); the string function packs together the stringifying of its arguments ignoring any (optional) whitespace between them. No strangeness involved afaict.

cameyo
Posts: 165
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: string function

Post by cameyo »

Ok. I am old...and often confused.
Thanks HPW and Ralph.

Post Reply