随笔分类 -  F#

摘要:这是在工作之余弄了些这个,做的也不太好,留个纪念,今后要用可以做个笔记:)namespace FSharp.Graph#if INTERACTIVE#r "System.Xml.dll"#r "System.Xml.Linq"#endifopen Systemopen System.Xml.Linqopen System.Xmltype Graph() = let mutable nodes = [] let mutable edges = [] member this.Nodes with get() = nodes member this.Edges 阅读全文
posted @ 2012-11-08 10:14 ZackZhou 阅读(671) 评论(0) 推荐(1)
摘要:前段时间实现了下这个算法,写的太复杂了,虽然有更简单的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 阅读(381) 评论(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 阅读(223) 评论(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 阅读(165) 评论(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 阅读(192) 评论(0) 推荐(0)