Help with understanding a function object or functor in Java

后端 未结 4 672
甜味超标
甜味超标 2020-12-01 00:28

Can someone explain what a functor is and provide a simple example?

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 01:00

    Take concept of function application

    f.apply(x)
    

    Inverse

    x.map(f)
    

    Call x a functor

    interface Functor {
        Functor map(Function f);
    }
    

提交回复
热议问题