You could also use pattern matching on this one:

1
2
3
4
5
6
7
8
let rem x y = x % y;; 

let rec hcf x y = 
    match (x, y) with 
    | (0, y) -> y
    | (x, 0) -> x
    | (x, y) when x < y -> hcf x (rem y x) 
    | (x, y) -> hcf (rem x y) y

Thanks,

FZSharp

By on 5/18/2011 10:45 AM ()

Thank you ... very nice.

You have done a +1 to my liking of F#

By on 5/20/2011 11:25 AM ()

Just split it into lines. Like 'test' fuction here:

Conditional Expressions: if... then...else (F#)

By on 5/14/2011 6:18 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