For instance, i have a list like ['a','b','c','d','e'].
I want to do something like this:
First do something with the first two elements, f 'a' 'b'
Then do the same thing with the return value of f and next element in the list, result = f 'a' 'b', lets say like f result 'c'. Then f resultof(result 'c') 'd' and so on.
How can i do something like this?
Recursion over lists in Haskell

Best Answer
First let's consider that function
Now we want to create a folding function that uses
What should it return? It should yield something of the resultant type
Now one thing's missing. How do you get the very first
So...how do we implement it? It'll be recursive, so let's start with the base cases.
If we hit the end of the list, then we've accumulated enough, right? That was easy. So how about the recursive case? From what you said, at each step we should apply
Easy, right? But...what if we want to do like you said and start the function by taking the first two values of the list? Also easy. Just take the first element, and call it the original "base" accumulator!
Notice that since
In real code, you should actually use 

comments:

Other Answer1
Sounds like homework. Take a look at folds. 

comments:

Other Answer2
In this case, the problem with a fold is, that it usually processes on element at a time. You could try to manually roll a fold. Assume, you have your function
Try to understand this. 

comments:

Relate
 Recursion using lists  Haskell
 Recursion Haskell
 Scheme: recursion and lists
 recursion in prolog (on lists)
 Erlang: Recursion vs Lists
 SML  lists and recursion
 Recursion and lists in Prolog
 Recursion and lists in Python
 Prolog: Recursion and splitting lists
 Lists in Haskell
 Haskell Lists within lists
 Struggling with lists of lists in Haskell
 Tail Recursion in Haskell
 haskell beginner  recursive recursion
 Haskell: problem with recursion
f
look like? Take the example['a','b','c']
: can you write out exactly what the end result should look like? Is it going to be(f (f 'a' 'b') 'c')
or something different? What does this imply for the signature forf
, and once you know that, can you adapt the fold answers below to help you finish it up?