What is your favourite cleverly written functional code?

Posted by sdcvvc on Stack Overflow See other posts from Stack Overflow or by sdcvvc
Published on 2009-10-06T10:22:48Z Indexed on 2010/05/20 2:50 UTC
Read the original article Hit count: 304

What are your favourite short, mind-blowing snippets in functional languages?

My two favourite ones are (Haskell):

powerset = filterM (const [True, False]) 

foldl f v xs = foldr (\x g a -> g (f a x)) id xs v -- from Hutton's tutorial

(I tagged the question as Haskell, but examples in all languages - including non-FP ones - are welcome as long as they are in functional spirit.)

© Stack Overflow or respective owner

Related posts about subjective

Related posts about functional-programming