fanderlf (2) [Avatar] Offline
Hey there smilie

I'm new to F# and currently working through this book. I really like F# smilie

I've just got a little question. This function (Listing 6.4)

let mapSecond f (a, b) = (a, f(b))

I understand what it does, but I don't understand this usage:

oldPrague |> mapSecond ((+) 13195)

One chapter before the author wrote that I can use the pipeling operator to write the first parameter before the function name. But in this example the first parameter is the function.

((+) 13195) |> mapSecond oldPrague

didn't work. Does anybody have an explanation for me?

Thanks in advance!!!

fanderlf (2) [Avatar] Offline
Re: Why does pipelining work in Listing 6.5?
aaaaaaaaaaaaah smilie

After a little surfing on the INet I found this little link:

For my example this means:

basic function:
let mapSecond f (a, b) = (a, f(b))

oldPrague |> mapSecond ((+) 13195)

The principle here is currying, as you can read in the book. So I think one could rewrite it with:

let mapSecondCurried = mapSecond ((+) 13195)
let newPrague = oldPrague |> mapSecondCurried

I hope this is write and that I got the problem smilie Maybe this helps somebody else, too. Perhaps the author could drop a little comment on that in the book. It wasn't obvious to me.