English 中文(简体)
F# 前线管道从内向中转
原标题:F# forward pipe to convert from int to bigint
  • 时间:2010-07-01 14:08:15
  •  标签:
  • f#

我对“F#”说得很新,并贯穿这一设想,希望有人能够解释为什么我的汇编者像守则一样。

如果在F# I中做到:

let FloatToInt = 10.0 |> int
let IntToFloat = 10 |> float

一切都属于罚款,数字投到相关数据类别......

然而,如果我这样做的话......

let IntToBigInt = 10 |> bigint

I get a error "Invalid use of type name or object constructor." I assume that this is because there isnt an operator overload for the forward pipe for bigint?

如果我想要使这一守则成为可能,我会怎样这样做? 我知道,我可以使用不同的合成物。

let IntToBigInt = bigint(10)

但我真的喜欢“前进管道”,并想知道我是否能够做到这一点,以便......

let IntToBigInt = 10 |> bigint

......

最佳回答

它与超负荷无关。 <代码>10.0>>>;载于t 工作是因为有一个名为<代码>int的功能。 但是,没有名称为<条码>bigint的功能,因此,<条码>10 >>>;大标题不适用。

如果你界定其中一项,它就发挥了作用:

> let bigint (x:int) = bigint(x);; // looks recursive, but isn t
val bigint : int -> System.Numerics.BigInteger

> 42 |> bigint;;
val it : System.Numerics.BigInteger = 42I
问题回答

暂无回答




相关问题
F#: Storing and mapping a list of functions

I have a number of events that happen in a game. I want to control the time and order at which these events occur. For example: Event 1: Show some text on screen for N frames & play a sound ...

Creating Silverlight 3 applications with F#

Is there an easy way to create Silverlight 3 applications with F# (October CTP)? I have seen the F# for Silverlight, but that only works with the May CTP. I am using Visual Studio Integrated Shell ...

How To Change List of Chars To String?

In F# I want to transform a list of chars into a string. Consider the following code: let lChars = [ a ; b ; c ] If I simply do lChars.ToString, I get "[ a ; b ; c ]". I m trying to get "abc". I ...

Unzipping ZLIB compressed portions of a binary file

I m reading a file(a flash swf) from .Net 3.5 that has a header which states whether the body of the file/Stream is compressed or not. However, I m having problems-after I rewrap the basic File ...

Pretty print a tree

Let s say I have a binary tree data structure defined as follows type a tree = | Node of a tree * a * a tree | Nil I have an instance of a tree as follows: let x = Node (Node (...

F# String Pattern-Matching with Wildcards

As part of a project I have assigned myself as a way of improving my knowledge of F# and functional programming in general, I am attempting to write a string pattern-matching algorithm from scratch ...

热门标签