摘要: 前段时间实现了下这个算法,写的太复杂了,虽然有更简单的F# 版本,不过还是写下来留个纪念:): let rec quickSort (intArray : int array )= match intArray with | empty when empty |> Array.isEmpty -> async {return [||]} | singleValue when (singleValue |> Array.length = 1) -> ... 阅读全文
posted @ 2012-11-07 14:44 ZackZhou 阅读(375) 评论(0) 推荐(0) 编辑
摘要: It's not convenient to get the memory address of object in F#, and the following code will illustrate how to get the memory of given index item of an array://Define your arraylet arr = [|1;23|]//Get the nativeint of arr.[0]let nativeint = System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinned 阅读全文
posted @ 2012-11-07 14:36 ZackZhou 阅读(214) 评论(0) 推荐(0) 编辑
摘要: it's quite easy to define a modifiable static property in C# , but in F#,a defined static filed is required first when the class want to define a static property. type StacitMemberCls() = //A static filed should be defined first static let mutable staticFiled = "" static member St... 阅读全文
posted @ 2012-11-07 14:33 ZackZhou 阅读(184) 评论(0) 推荐(0) 编辑
摘要: When we define an F# class in explicit way, it's easy for new F# programmers to make this kind of mistakes when they define mult constructors: people will forget to initliza the class first before use it.type myCls() = //This this a new feature in VS2012,define a property is much easier than bef 阅读全文
posted @ 2012-11-07 14:32 ZackZhou 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Sometimes, we may run into this kind of situation that we want to check if the given method/function has been initialized. We all know this is fairly easy in C#, since we can use delegate to invoke the function , then verify if the value of delegate is null. But in F# , delegate is rarely needed b.. 阅读全文
posted @ 2012-11-07 14:30 ZackZhou 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Because a constant value never changes, constants are always considered to be part of the defining type. In other words, constants are always considered to be static members, not instance members. Defining a constant causes the creation of metadata. When code refers to a constant symbol, compiler... 阅读全文
posted @ 2012-11-07 14:22 ZackZhou 阅读(190) 评论(1) 推荐(0) 编辑