I have a simple string (or list of characters to be precise) in a form of: "1234<5678<<9".
I want to parse this string and end up with: "123569". The "<" is essentially the same as a "backspace". I managed to implement this fairly simply using the reduce function - source: http://gist.github.com/489019. Although it can be implemented easily using the reduce function, I was concerned with the performance (especially with large inputs). As the reduce function invokes the provided function with the previous result, this list that is getting built is being passed around a huge amount. I'm not too sure as to what will be going on under the hood in this sample. Whether the previous result of the function application is really being passed around or not clear to me. For the program, I know that when processing a character, I do not need the previous result. All I need is the current character, and I can return a function that acts on the result. I'm not sure if this is simple to implement in a functional way. So, I have 2 questions: 1) Is this a correct use of the reduce function? (I know there is a clue in the word "reduce", but it's also called "inject" and else in other languages.) 2) Is there a more efficient way of solving this? I appreciate any replies (for such a trivial topic). Answers to this will hopefully enlighten me to using functional languages more effectively, or possibly to a more suitable high-order function. -- 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