Re: Struggling with flatten function.
"Manfred Lotz [email protected] [ocaml_beginners]" <[email protected]> Fri, 30 Sep 2016 06:29:20 +0200
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
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. -- Manfred