我怎么能够把一大批ool子带给F#的功能?
Thanks Maybettle
我怎么能够把一大批ool子带给F#的功能?
Thanks Maybettle
有两个选择,取决于您是否重新使用实际的2D阵列(硬体阵列)或阵列(其组成部分是阵列的阵列,其长度可能有所不同):
如果你不相信哪一个可以使用的话,那么,知道标记阵列较快,但与直径阵列合作可能比较容易(因为你可以肯定各个层面)。
let foo (ar:bool[,]) = ar.[0, 0] // Get element at specified coordinates
let bar (ar:bool[][]) = ar.[0].[0] // Get first array and then the element
To call the two functions, you can use the following syntax:
// Create array of arrays and call the function
bar [| [| true |] |]
// Creates array of arrays and converts it to multi-dimensional array
// You can also use plenty of functions from Array2D module
foo (array2D [| [| true |] |])
If you want to write function that will be more general, you can also use sequence of sequences. This will be compatible with jagged arrays only, but you can also use the function with e.g. F# lists of lists or any .NET collection types.
let woo (ar:seq<#seq<bool>>) = Seq.head (Seq.head ar)
The #seq<.>
类型是指它可以是顺序还是任何其他衍生类型。 由于F#自动投出外型(但并非部件),因此该元素类型需要这种处理,但不适用于外型。
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 ...
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 ...
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 ...
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 ...
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 (...
(Background: I ve been thinking about doing a presentation on F# and functional programming. From experience, I think that the wow factor of pattern matching and type inference is not necessarily ...
I recently began to read some F# related literature, speaking of "Real World Functional Programming" and "Expert F#" e. g.. At the beginning it s easy, because I have some background in Haskell, and ...
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 ...