cfchou 積分 0

是指在 iteration 中 break 嗎?

我也想知道 fp 的 idiom

好像 for..loop 本身就是很 imperative, 可是 fp 偏愛 declarative

或許簡單的情況下可以:

collection.takeWhile(predicate).foreach(foo)

複雜的 看過一種做法:

collection.toStream 後每個 iteration returns Either<Success, Fail> 然後 lazily evaluate, stop when getting Fail

這是文章的子討論串,你可以回到上層查看所有討論和文章