Andrew's blog is good; e.g.

[link:blogs.msdn.com]

By on 10/10/2008 3:47 PM ()

in fact, it is from that website that i got the idea, but it says

"Next time, we'll write types that are generic in units-of-measure. This makes the feature extensible: if floats with units aren't what you want, just define your own types!"

i am looking for that exact example.

-f

By on 10/10/2008 10:41 PM ()

Actually, Andrew has posted a quick example of such a type in his very first blog post on units in comments:

[link:blogs.msdn.com]

The syntax is fairly obvious. I'll reproduce it here for convenience:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[<Measure>] type m

[<Measure>] type s

type Vector< [<Measure>] 'a> = struct

 val X:float<'a>

 val Y:float<'a>

 val Z:float<'a>

 new(x,y,z) = {X=x;Y=y;Z=z}

end

let v = Vector(2.0<m/s>,3.0<m/s>,4.0<m/s>)
By on 10/10/2008 11:49 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