https://www.slideshare.net/ScottWlaschin/fp-patterns-ndc-london2014 says
Bad news: Composition patterns only work for functions that have one parameter!
Good news! Every function is a one parameter function!
We can convert a function with two parameters into a function with one parameter, by partial application. For example
let add x y = x + y
let add x = (fun y -> x + y)
let add1 = (+) 1
let three = add1 2
How can we convert a function without a parameter into a one-parameter function?
Aucun commentaire:
Enregistrer un commentaire