Select all elements in a
that are greater than 5 and multiply them by 2.
Ruby
a.select { |x| x > 5 }.map { |x| x * 2 }
a.find_all { |x| x > 5 }.collect { |x| x * 2 }
a.inject([]) { |b, x| x > 5 ? (b << x * 2) : b }
Python
map(lambda x: x * 2, filter(lambda x: x > 5, a))
Clojure
(map #(* 2 %1) (filter #(> %1 5) a))
Haskell
map (*2) (filter (>5) a)
map (*2) $ filter (>5) a
[ x * 2 | x <- a, x > 5 ]
MATLAB
a(a > 5) * 2