mercredi 11 mars 2015

How to mix Function input parameter with output


Vote count:

0




What is the best way to mix a function input parameter with the output.


Here is my current code :



def zip[A,B](f: A => B) : A => (A, B) = (a: A) => (a, f(a))
def zip[A,B](pf: PartialFunction[A,B]) : PartialFunction[A, (A, B)] = { case a if pf.isDefinedAt(a) => (a, pf(a)) }


Is there a better way ? Is there a better naming for that ?



asked 39 secs ago







How to mix Function input parameter with output

Aucun commentaire:

Enregistrer un commentaire