摘要: #if INTERACTIVE#r @"C:\Users\v-shuzhu\Desktop\HtmlAgilityPack.dll"#endifopen Systemopen System.Diagnosticsopen System.Netopen System.Xmlopen System.IOopen HtmlAgilityPack let asyncGrapUrl(newUrl : string) = async{ let fileNameXml = @"D:\" + newUrl.Replace('.','0') 阅读全文
posted @ 2013-01-05 17:55 ZackZhou 阅读(268) 评论(0) 推荐(0) 编辑
摘要: open Systemopen System.Diagnosticsopen System.Netopen System.Xmlopen System.IO//open HtmlAgilityPack let asyncGrapUrl(newUrl : string) = async{ let fileName = @"D:\" + newUrl.Replace('.','0').Replace('/','0').Replace(':','0') + ".xml&quo 阅读全文
posted @ 2013-01-04 18:13 ZackZhou 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 当有很多数据要显示的时候,一次显示完可能比较不合实际,我们有时候可以使用分页显示的形式来处理这种情况。Razor代码:@model RunInfoMVC.Controllers.Post@{ ViewBag.Title = "Runs"; }@{ int count = ViewData.Model.runSet.Count<RunsDB.Run>(); int pageSize = 20; int pageCounts = (int)Math.Ceiling(count / (double)pageSize); int currPage = Vie... 阅读全文
posted @ 2012-12-29 13:08 ZackZhou 阅读(498) 评论(0) 推荐(0) 编辑
摘要: 下面是服务器端代码:// Learn more about F# at http://fsharp.net// See the 'F# Tutorial' project for more help.open System.Net.Socketsopen System.Netopen System.IOopen Systemopen System.Collections.Generictype System.Net.Sockets.TcpListener with member this.AsyncAcceptTcpClient() = Async.FromBeginEnd(. 阅读全文
posted @ 2012-12-28 15:36 ZackZhou 阅读(526) 评论(0) 推荐(0) 编辑
摘要: 下面我们看看如何将F# 中的Quotation表达式转为LINQ表达式, 这个也就是上一篇中说说的第三个功能。在实现此功能前,我们学要从Codeplex上将F# 的一个扩展包下在到本地,此扩展为FSharp.PowerPack. 这个扩展包对F#作了很大的扩展,其中包括很多新的不可变类型, 以及一些数学中常常用到的矩阵,实数复数等等的相关类型及操作。值得注意的是此扩展包以前版本中的一些功能已经被内置到F#3.0中了。下面我们看看代码:#if INTERACITVE#r @"C:\Users\v-shuzhu\Desktop\bin\gac\FSharp.PowerPack.dll&q 阅读全文
posted @ 2012-12-24 16:24 ZackZhou 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 下面介绍了如何从SQL 2008R2 中的数据库获取数据,并将数据通过View呈现出来:Step 1: 创建一个MVC4.0 的Internet App,选择 Razor作为View engine.Step 2: 在创建好的Project的Models文件夹上 右键-〉Add-> LINQ to SQL Classes ->命名(StudentCourseSelection)Step 3: 在VS的Server Explorer上连接自己的数据库,展开数据库中的Tables文件夹,将需要的表 都拖到上一步新建的LINQ to SQL class中,如:保存此文件Step 4: 察看 阅读全文
posted @ 2012-12-07 13:06 ZackZhou 阅读(423) 评论(0) 推荐(0) 编辑
摘要: 发如果你看过我前面的一篇关于自定义Type Provide的博客的话,或许你还记得在当时我使用了Quotation表达式来定义TP 中的成员函数。那么Quotation表达式具体有什么作用,有什么用途呢,下面我们来瞧瞧。 由于Quotation表达式在编译时,并不会被编译成IL代码,所以在当前程序运行时,Quotation表达式会被忽略。这是第一种情况。 你可以利用F#中的Pattern match分析上面的AST,从而生成新的代码。正如上面的说得一样,Quotation表达式不会被编译成IL代码,但是它会被编译成一个树型的数据结构。此结构类似于语法树(AST),因此对此语法树可以进 行分析, 阅读全文
posted @ 2012-12-04 13:52 ZackZhou 阅读(1320) 评论(2) 推荐(3) 编辑
摘要: 或许你对这个词有点陌生,但是如果说到F#中的Sequence表达式,Async结构时,你或许会有点印象。其实这两种表达式均可以理解为Computation Expression.如果你对Sequence表达式这个名词感觉很陌生的话,那先弄些代码来看看:let seqExpr = seq{ for i in [1..10] do yield i }相信看到上面的代码你应该知道神马叫Sequence表达式了。。。下面是Async的代码片断:let asyncExpr path = async{ let fileStr ... 阅读全文
posted @ 2012-11-22 21:55 ZackZhou 阅读(1272) 评论(4) 推荐(1) 编辑
摘要: F# 的快排实现起来很简单,因为集合类List里面的方法帮用户实现了大部分的代码。下面就是就是代码:let rec quickSort (list : int list) = match list with | [] -> [] | [single] -> [single] | head :: tail -> let leftList = tail |> List.choose(fun item -> if item <= head then Some(item) else No... 阅读全文
posted @ 2012-11-21 15:25 ZackZhou 阅读(373) 评论(0) 推荐(0) 编辑
摘要: 本文转自: Prbert Pickering的博客。原文链接:http://strangelights.com/blog/archive/2011/09/18/first-example-of-a-very-simple-type-provider.aspx原文内容:I have an idea for a type provider, so now that the type provider bits are finally publicly available I set to work building it. However it turns out just implementin 阅读全文
posted @ 2012-11-20 15:17 ZackZhou 阅读(309) 评论(0) 推荐(0) 编辑