1
| [] -> 1

When xs = [5] you'll have 5 * SumList [], and you've defined SumList [] to be 0.

By on 2/28/2010 8:59 PM ()

well somethimes it is advisable to know syntax better and dig deep before pulling a help trigger.....

the solution is very simple if you know what the -> operator is...

this version works with the only drawback being that the [] set returns 1...could be ok since 0! = 1....

1
2
3
4
let rec SumList xs =
    match xs with
    | [] -> 1
    | y::ys -> y * SumList ys
By on 2/28/2010 8:56 PM ()
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