Home:ALL Converter>Add character to string to get another string?

Add character to string to get another string?

Ask Time:2011-11-11T00:20:10         Author:Matt Fenwick

Json Formatter

I want to add a character to a string, and get another string with the character added as a result.

This doesn't work:

(cons \a "abc")

Possible solutions, in order of preference:

  1. Clojure core function
  2. Clojure library function
  3. Clojure user-defined (me!) function (such as (apply str (cons \a "abc")))
  4. java.lang.String methods

Is there any category 1 solution before I roll-my-own?


Edit: this was a pretty dumb question. :(

Author:Matt Fenwick,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/8082706/add-character-to-string-to-get-another-string
Dan Filimon :

How about:\n\n(str \"abc\" \\a)\n\n\nThis returns \"abca\" on my machine.\n\nYou can also use it for any number of strings/chars: (str \"kl\" \\m \"abc\" \\a \\b).",
2011-11-10T16:31:01
yy