: ====================== 我是 Scala 程式分隔線 =========================
: val xs = List(-1, -2, -3, 0, 1, 2, 3)
: val square = (n: Int) => n * n
: val isGreaterThan5 = (n: Int) => n > 5
: val result = xs.map(square).filter(isGreaterThan5).length
: // 上面那行和下面這行等價
: // val result = xs.map(n => n * n).filter(n => n > 5).length
: println (result1)
: ======================================================================
最近在學 haskell ,發現 haskell 也可以寫成像上面的型式,分享一下
let x -: f = f x
let xs = [-3..3]
let square = (^2)
let isGreaterThan5 = (>5)
let result = xs -: map square -: filter isGreaterThan5 -: length