美文网首页
Scala 柯里化

Scala 柯里化

作者: 小样do | 来源:发表于2019-01-30 16:42 被阅读0次

    柯里化

    
    class MyCurry {
    
      def curry(f: (Apple, Pear) => Peach): Pear => Peach = {
    
        def c(pear: Pear): Peach = {
          val apple = new Apple
          f(apple, pear)
        }
    
        return c
      }
    }
    
    class Apple
    
    class Pear
    
    class Peach
    
    
    object Main extends App {
    
      val myCurry = new MyCurry
      val pear = new Pear
    
      def f(apple: Apple, pear: Pear): Peach = new Peach
    
      println(myCurry.curry(f)(pear))
    
    }
    

    相关文章

      网友评论

          本文标题:Scala 柯里化

          本文链接:https://www.haomeiwen.com/subject/hujcsqtx.html