On Sat, Jul 24, 2010 at 3:16 PM, samnardoni samnard...@googlemail.com wrote:
I have a simple string (or list of characters to be precise) in a form
of: 123456789.
I want to parse this string and end up with: 123569.
The is essentially the same as a backspace.
I think reduce(or fold/foldl'
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.
Actually my understanding says that you need
On Mon, Jul 26, 2010 at 08:13, ka sancha...@gmail.com wrote:
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
On 26 July 2010 09:25, B Smith-Mannschott bsmith.o...@gmail.com wrote:
[...]
That said, don't use my code. It's hideous. And by now, I'm sure
there's a cleaner solution possible for my approach:
The idea is to split the input string into a lazy list of substrings
alternating between strings
I have a simple string (or list of characters to be precise) in a form
of: 123456789.
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.
This is a wholly appropriate use of reduce; it's the obvious function
to use when you want to accumulate some calculation over a sequence.
As you say, you can just produce a function that acts on the result,
something like
(defn fstep [c] (if (= c \) pop #(conj % c))
However, the obvious way
Randy, thanks for the reply. This has certainly cleared things up for
me.
I was only concerned about performance for an order of magnitude or
more; just checking I was on the right track, so to speak.
It seems I'll have to do a little research on transients now.
On Jul 25, 4:23 pm, Randy Hudson
On Sun, Jul 25, 2010 at 00:16, samnardoni samnard...@googlemail.com wrote:
I have a simple string (or list of characters to be precise) in a form
of: 123456789.
I want to parse this string and end up with: 123569.
The is essentially the same as a backspace.
I managed to implement this