【发布时间】:2012-02-12 20:15:20
【问题描述】:
我有时会发现自己在编写这样的代码:
someFunc :: Foo -> Int
someFunc foo = length $ do
x <- someList
guard someGuard
return ()
或等价:
someFunc foo = length [() | x <- someList, someGuard]
有没有更好的方法来执行这种计算?更高效?更具可读性?更地道?
【问题讨论】: