How can I use concatenation in scheme without spaces

11,988

Solution 1

append returns a list, and the evaluator prints the result like (a b c), where spaces are inserted to make the representation clear. If you need %procedure:+%, you may create a new symbol or use strings instead of symbols.

Solution 2

You're trying to use symbols, which aren't the same thing as strings in Scheme. If you want to have control over your printed output, you should use strings, which are arrays of characters.

> (append '(hello) '(world))
(hello world)
> (string-append "hello " "world")
"hello world"
> (symbol->string 'hello)
"hello"
> (apply string-append (map symbol->string '(a b c d e f g)))
"abcdefg"
Share:
11,988
jacky brown
Author by

jacky brown

Updated on June 05, 2022

Comments

  • jacky brown
    jacky brown over 1 year

    I have a problem with concatenation and spaces in Scheme. The result of the command:

    (append '(%procedure:) (list '+) '(%))**     //with spaces
    

    is:

    %procedure: + %      //without spaces
    

    How can I make the same result without space between the lists, so the result will be:

    %procedure:+%
    
    • John Clements
      John Clements almost 12 years
      Are you trying to produce a symbol, a string, or something else?