Non-answer: You don't really want to do that. (What are you trying to do? Or just experimenting?)

By on 1/21/2010 11:31 AM ()

Hi,
Just do some testing. I saw a web site saying there is a function called "Array.Combine", but this function is gone, as the article on that web site was more than 1 year ago, so I think F# has changed and the function "Array.Combine" is gone.
But if I want to have similar function, what I can do?
Thanks,

By on 1/21/2010 11:55 AM ()

Do you happen to know the signature for 'Array.Combine'? Many library functions have been renamed, and knowing the original signature can be helpful in determining if the function was removed -- or just renamed.

By on 1/21/2010 12:31 PM ()

Hi,
Unfortunately, I don't know. I know there are a lot of functions are removed or renamed.
But if some one knows how to write one using the existing functions, then it is OK.
Right?

By on 1/21/2010 12:48 PM ()

Well, I am hard-pressed to imagine why you want to do this, but the right-hand-side of 'combination' below shows how.

1
2
3
4
5
6
7
8
9
10
11
12
 

let A = [|(1.0, 1, "AAAA");(2.0, 2, "BBBB");(4.0, 5, "XXXX");(5.0, 10, "YYYY")|]

let B = [|(1.0, 1.0, 1.0);(2.0, 2.0, 2.0);(3.0, 3.0, 3.0);(4.0, 4.0, 4.0)|]

let C = [|(1.0, 1, "AAAA",1.0, 1.0, 1.0);(2.0, 2, "BBBB", 2.0, 2.0, 2.0);(4.0, 5, "XXXX",3.0, 3.0, 3.0);(5.0, 10, "YYYY",4.0, 4.0, 4.0)|]

let combination = (A,B) ||> Array.map2 (fun (a,b,c) (x,y,z) -> a,b,c,x,y,z)

assert(combination=C)
By on 1/21/2010 1:23 PM ()

Hello, Brianmcn:
Thank you very much. Your code works.
One question: I have no idea about "||>", could you please explain what is "||>"?
I think pipe forward is "|>", and logical OR is "||", but really have no idea about "||>", could you tell me something about it?
Thanks!

By on 1/21/2010 2:43 PM ()

It's in the docs

[link:msdn.microsoft.com]

It's definition is probably

let (||>) (x,y) f = f x y

By on 1/21/2010 4:46 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper