Re: Struggling with flatten function.

"Oliver Bandel [email protected] [ocaml_beginners]" <[email protected]> Fri, 30 Sep 2016 09:35:32 +0200
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <20160930093532.Horde.WbADXC9--XwqwJ2bIa5JpqY@webmail.in-berlin.de>
Zitat von "Manfred Lotz [email protected] [ocaml_beginners]"  
<[email protected]> (Fri, 30 Sep 2016 06:29:20 +0200)

> On Thu, 29 Sep 2016 23:38:59 +0200
> "Oliver Bandel [email protected] [ocaml_beginners]"
> <[email protected]> wrote:
>
>> Hello,
>>
>>
>> Zitat von "Douglas Lewit [email protected] [ocaml_beginners]"
>> <[email protected]> (Thu, 29 Sep 2016 15:10:56 -0500)
>>
>> > So I figured out the following:
>> >
>> > let rec flatten = function
>> >                          |[ ] -> [ ]
>> >                          |head :: tail -> head @ flatten tail ;;
>> >
>> > This mimics the builtin List.flatten function from the List
>> > module.
>> [...]
>>
>> So, you reinvented the wheel.
>>
>
> Perhaps, he simply wants to learn. As a learning experience it is a
> good thing to mimick library functions.
[...]

Ah, yes!


Ciao,
     Oliver