[erlang-questions] how: Another library flatten function?

Dmitry Belayev <>
Sat Feb 27 14:39:22 CET 2010


It's kind of "handmade" stack.

黃耀賢 (Yau-Hsien Huang) wrote:
> The basic concept of flattening a list, similar to process a binary tree, is
> to flatten the head
> elements which may be a list or not, to flatten the tail which is a list,
> and to concatenate
> these two parts. How to make a flattening function tail-recursive?
>
>
> 2010/2/27 Dmitry Belayev <>
>
>   
>> Shame on me, my own version uses f(_, f(_)) so it is not-tail recursive
>> too.
>>
>>
>> Dmitry Belayev wrote:
>>
>>     
>>> It would be best solution in non-strict language like haskell, but in
>>> erlang it is not tail-recursive, so it will use more memory.
>>>
>>>
>>>       
>
>   



More information about the erlang-questions mailing list