Reputation: 27373
I have a function
f : Point2D => Point2D = ???
I want to convert it to a function of tuples :
(Double,Double) => (Double,Double)
I know how to map Point2D
to Tuple2
:
implicit def pointToTuple(p : Point2D) = (p.x,p.y)
but I have no idea how to map the function itself :
def convertFunction(f : Point2D => Point2D) : (Double,Double) => (Double,Double) = {
???
}
Upvotes: 0
Views: 55
Reputation: 40500
You also need tupleToPoint
, not just pointToTuple
.
Now, provided you have that, you can just do:
def convertFunction(f: Point2D => Point2D) =
tupleToPoint andThen f andThen pointToTuple
Upvotes: 1