Scala performance question

后端 未结 7 1247
Happy的楠姐
Happy的楠姐 2021-02-03 11:45

In the article written by Daniel Korzekwa, he said that the performance of following code:

list.map(e => e*2).filter(e => e>10)

is muc

7条回答
  •  无人共我
    2021-02-03 12:01

    list.filter(e => e*2>10).map(e => e*2)

    This attempt reduces first the List. So the second traversing is on less elements.

提交回复
热议问题