开发者

F# TupleGet ActivePattern usage

I would like to know how to extract values out of a tuple Expression in F# when using 开发者_如何学Goquotations. If for example, I have a quotation <@ fst(sample_tuple) @>, how do I deconstruct the tuple quotation to get out the values?


The unquote library [1] contains an eval function that is reported as being faster than the FSharp.PowerPack.

[1] http://code.google.com/p/unquote


As you can see from the output of sending a quotation like that to FSI, your quotation doesn't use TupleGet, it uses a Call to the generic Fst method, so you can't destructure it using TupleGet.

A quotation like <@ match sample_tuple with | a, _ -> a @> would use TupleGet to extract the first element.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜