F# applying Seq.map using 2 sequences to a method which takes 2 parameters?

You can use Seq. Map2 : Seq. Map2 measureSelectTimes ids cmds Or (ids, cmds) ||> Seq.

Map2 measureSelectTimes.

You can use Seq. Map2: Seq. Map2 measureSelectTimes ids cmds Or (ids, cmds) ||> Seq.

Map2 measureSelectTimes.

1 let partial = Seq. Map2 measureSelectTimes ids, indeed. It's so obvious and easy... when you see the solution.

But before I saw it it did'n even crossed my mind. :-( +1 – Dmitry May 25 at 18:42 This is what I was looking for; I didn't see how Seq. Map2 worked, but this cleared it up.

Thanks also @Dmitry for how to express the result as a partial to apply, which is what I was ultimately thinking of. +1 – codekaizen May 25 at 19:54 1 +1 for teaching me a new operator - where did "||>" come from!? It's not on the MSDN page.

– Sam May 25 at 23:48 2 @Sam - see msdn.microsoft. Com/en-us/library/ee340237. Aspx – kvb May 250 at 1:29.

Your measureSelectTimes function takes two arguments as separate arguments, but you instead need a function that takes them as a tuple. One option is to just change the function to take a tuple (if it is logical for the arguments to be tupled). Alternative, you can write a cobinator that turns a function taking two arguments into a function taking tuple.

This is usually called uncurry and it exists in some functional language: let uncurry f (a, b) = f a be Then you can write: input |> Seq. Map (uncurry measureSelectTimes) This looks okay for a simple use like this, but I think that using combinators too much in F# is not a good idea as it makes code difficult to read for less experienced functional programmers. I would probably write something like this (because I find that more readable): for (time1, time2) in input -> measureSelectTimes time1 time2 .

Thanks for the answer and the 2 new tools of using an uncurry function and a list comprehension to solve it. Also, thanks for the book. – codekaizen May 25 at 19:56.

One approach is to change the signature of measureSelectTimes to (Guid list * Guid list) * IDbCommand -> TimeSpan * TimeSpan Then you can change the map call to let results = input |> Seq. Map measureSelectTimes // or let results = Seq. Map measureSelectTimes input.

Yea, I thought of this, but I knew there must be another approach than to need to change the method sig. – codekaizen May 25 at 19:29.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions