F#: any way to use member functions as unbound functions?

Posted by gatoatigrado on Stack Overflow See other posts from Stack Overflow or by gatoatigrado
Published on 2010-06-11T20:01:34Z Indexed on 2010/06/11 20:23 UTC
Read the original article Hit count: 328

Filed under:
|
|

Is there a way to extract member functions, and use them as F# functions? I'd like to be able to write the following:

mystring |> string.Split '\n' |> Array.filter (string.Length >> (=) 0 >> not)

The code above works if you [let]

let mystring = "a c\nb\n"
let stringSplit (y:char) (x:string) = x.Split(y)
let stringLength (x:string) = x.Length
mystring |> stringSplit '\n' |> Array.filter (stringLength >> (=) 0 >> not)

© Stack Overflow or respective owner

Related posts about F#

Related posts about functions