Assembling lists start-to-end

Wolfgang Jeltsch wolfgang@jeltsch.net
Sat, 21 Jun 2003 14:47:22 +0200


On Saturday, 2003-06-21, 14:38, CEST, Mark Carroll wrote:
> I am assembling a list from start to end. I can add elements to the end with
> "previous ++ [current]" or I can add them with "current : previous" and
> reverse it when I'm done. Or, maybe I should use some other data structure.
> (I don't know the length in advance.) Any thoughts?
>
> -- Mark

Hi,

adding with "current : previous" and finally reversing the list seems good 
since the whole process takes linear time whereas adding to the end with 
"previous ++ [current]" would take quadratic time.

Wolfgang