Re: converting a string to a list
Thanks for the answsers! Jay's last answer is just what I was looking for. thanks, Sam 2012/1/14 Jay Fields j...@jayfields.com this seems easier... user= (map str abc) (a b c) Though the original question says a list to a string and the example shows a string to a list (of symbols) user= (apply str [a b c]) abc' But, the example is looks like it wants user= (map (comp symbol str) abc) (a b c) Hopefully one of those is what you're looking for. Cheers, Jay On Jan 14, 2012, at 1:01 PM, dennis zhuang wrote: You can do this ((comp #(map str %) seq) abcdef) (a b c d e f) 2012/1/15 Bruce Durling b...@otfrom.com Sam, Strings can be turned into sequences with seq. (seq foo) (\f \o \o) The backslashes are because f o and o are character literals. cheers, Bruce On Sat, Jan 14, 2012 at 10:13, Samuel Lê samuel...@gmail.com wrote: Hi, I was wondering if there was a function to convert a list into a string, something like: (string-to-list abcde) ;; (a b c d e) thanks! Sam -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 庄晓丹 Email:killme2...@gmail.com 伯岩(花名) bo...@taobao.com Site: http://fnil.net 淘宝(中国)软件有限公司 / 产品技术部 / Java中间件 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
converting a string to a list
Hi, I was wondering if there was a function to convert a list into a string, something like: (string-to-list abcde) ;; (a b c d e) thanks! Sam -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: converting a string to a list
Sam, Strings can be turned into sequences with seq. (seq foo) (\f \o \o) The backslashes are because f o and o are character literals. cheers, Bruce On Sat, Jan 14, 2012 at 10:13, Samuel Lê samuel...@gmail.com wrote: Hi, I was wondering if there was a function to convert a list into a string, something like: (string-to-list abcde) ;; (a b c d e) thanks! Sam -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: converting a string to a list
You can do this ((comp #(map str %) seq) abcdef) (a b c d e f) 2012/1/15 Bruce Durling b...@otfrom.com Sam, Strings can be turned into sequences with seq. (seq foo) (\f \o \o) The backslashes are because f o and o are character literals. cheers, Bruce On Sat, Jan 14, 2012 at 10:13, Samuel Lê samuel...@gmail.com wrote: Hi, I was wondering if there was a function to convert a list into a string, something like: (string-to-list abcde) ;; (a b c d e) thanks! Sam -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 庄晓丹 Email:killme2...@gmail.com 伯岩(花名) bo...@taobao.com Site: http://fnil.net 淘宝(中国)软件有限公司 / 产品技术部 / Java中间件 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: converting a string to a list
this seems easier... user= (map str abc) (a b c) Though the original question says a list to a string and the example shows a string to a list (of symbols) user= (apply str [a b c]) abc' But, the example is looks like it wants user= (map (comp symbol str) abc) (a b c) Hopefully one of those is what you're looking for. Cheers, Jay On Jan 14, 2012, at 1:01 PM, dennis zhuang wrote: You can do this ((comp #(map str %) seq) abcdef) (a b c d e f) 2012/1/15 Bruce Durling b...@otfrom.com Sam, Strings can be turned into sequences with seq. (seq foo) (\f \o \o) The backslashes are because f o and o are character literals. cheers, Bruce On Sat, Jan 14, 2012 at 10:13, Samuel Lê samuel...@gmail.com wrote: Hi, I was wondering if there was a function to convert a list into a string, something like: (string-to-list abcde) ;; (a b c d e) thanks! Sam -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 庄晓丹 Email:killme2...@gmail.com 伯岩(花名) bo...@taobao.com Site: http://fnil.net 淘宝(中国)软件有限公司 / 产品技术部 / Java中间件 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: converting a string to a list
This may not be important for your application, but if what you want in the returned sequence are strings, and if you expect to deal with Unicode characters that are not in the Basic Multilingual Plane (BMP) set, then note the following differences. (map str s) will return a separate string for each UTF-16 code unit, so any supplementary characters will result in 2 strings in the result, not one. Those 2 resulting strings won't be complete Unicode strings by themselves, since they each only contain one surrogate character. [1] has more info on UTF-16 encoding if you are curious. e.g. (map str smile \ud83d\ude03) will contain two strings \ud83d and \ude03 at the end of the resulting sequence (re-seq #. s) will return a separate string for each Unicode code point, so BMP or supplementary characters will each result in one string in the output sequence, where supplementary characters become strings with 2 Java chars in them. e.g. (re-seq #'. smile \ud83d\ude03) will contain one string \ud83d\ude03 at the end of the resulting sequence, since those two are a surrogate pair representing a single Unicode character Similarly, there is the notion of combining characters in Unicode [2], e.g. a with a grave accent can be represented either with a single Unicode code point, or it can be represented by the Unicode character for a followed by the Unicode character for a combining grave accent, U+0300. (re-seq #'. s) would return separate strings for the a and the combining character in that case. If you want each non-combining character plus any following combining characters to be kept together, you can use: (re-seq #\PM\pM* s) \pM matches any Unicode combining character (whether it is in the BMP or supplementary), and \PM matches any other Unicode character. Andy [1] http://en.wikipedia.org/wiki/UTF-16 [2] http://en.wikipedia.org/wiki/Unicode#Ready-made_versus_composite_characters On Sat, Jan 14, 2012 at 10:13 AM, Jay Fields j...@jayfields.com wrote: this seems easier... user= (map str abc) (a b c) Though the original question says a list to a string and the example shows a string to a list (of symbols) user= (apply str [a b c]) abc' But, the example is looks like it wants user= (map (comp symbol str) abc) (a b c) Hopefully one of those is what you're looking for. Cheers, Jay On Jan 14, 2012, at 1:01 PM, dennis zhuang wrote: You can do this ((comp #(map str %) seq) abcdef) (a b c d e f) 2012/1/15 Bruce Durling b...@otfrom.com Sam, Strings can be turned into sequences with seq. (seq foo) (\f \o \o) The backslashes are because f o and o are character literals. cheers, Bruce On Sat, Jan 14, 2012 at 10:13, Samuel Lê samuel...@gmail.com wrote: Hi, I was wondering if there was a function to convert a list into a string, something like: (string-to-list abcde) ;; (a b c d e) thanks! Sam -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 庄晓丹 Email:killme2...@gmail.com 伯岩(花名) bo...@taobao.com Site: http://fnil.net 淘宝(中国)软件有限公司 / 产品技术部 / Java中间件 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe