The first rule looks for a list that contains exactly 3 numbers then prints them out. The second rule matches any list non empty list and removes the head of the list then searches the remaining list by recursively calling the findSequence function. This means that any list with more that 3 items will be searched until only three items remain.

The last rule says if you find an empty list do nothing. () is a value of type "unit", which is used to mean do nothing.

By on 11/12/2007 4:36 AM ()

So it is actually recursively hitting the second rule until there is only 3 items left and then it hits the first rule. I think I get it now.

By on 11/12/2007 6:03 AM ()

I think this example is in the book "Foundations Of F Sharp" by Robert. Great book by the way!

By on 11/12/2007 6:02 AM ()

It is modified from the book. I couldn't get the full example to work when I include the 'Found sequence ...' rule on pg 41 so I removed it to make it clearer for posters to help me with what I wanted to know.

By on 11/12/2007 6:07 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper