Re: Page 76 of OCaml by John Whitington ???

"Douglas Lewit [email protected] [ocaml_beginners]" <[email protected]> Tue, 29 Mar 2016 10:16:48 -0500
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAM0XMJRbcNQr9-QpuQUnm2y7hksUGquRYpLkR==upuXoi_emNQ@mail.gmail.com>
Yes, tailOfTail is a list, but headOfTail is an element ( which could be a
list if we're dealing with a list of lists ).

So if I have something like:

*let rec practice_function list = match list with*
*|[ ] -> false*
*head :: tail -> match tail with*
*|[ ] -> false*
*|headOfTail :: tailOfTail -> if head = headOfTail then true else
practice_function tail ;;*

I should think that the above function would test the list for equal
elements that are right next to each other in the list.  I was trying to
base my packing function on similar logic, but my approach became horribly
convoluted and it just didn't work.  I think my logic is sound, but my
implementation was not effective.

On Tue, Mar 29, 2016 at 3:18 AM, 'Mr. Herr' [email protected]
[ocaml_beginners] <[email protected]> wrote:

>
>
>
>
> On 29.03.2016 06:41, Douglas Lewit [email protected] [ocaml_beginners]
> wrote:
>
>
> I also gave something like this a try, but I ended up with a couple of
> error messages:
>
> *let pack list = match list with*
> *|[ ] -> [ ]*
> *|head :: tail -> match tail with*
> *|[ ] -> [ ]*
> *headOfTail :: tailOfTail -> if head = headOfTail then..... ( more code )*
>
> I thought it was clever, but either I just ended up with an empty list, a
> one-element list, or the compiler just rejected it.  I'm starting to feel a
> little dumb!  But I'll keep at it.
>
> tailOfTail is a list, not an element!
>
> /Str.
>
> 
>