Listlessness is better than laziness: an algorithm that transforms applicative programs to eliminate intermediate lists