r/programmingchallenges • • Sep 10 '11

Challenge: Hello, world!

I'm kind of interested in running xmonad and learning Haskell. Should we all tackle learning about a new programming paradigm?

9 Upvotes

21 comments sorted by

View all comments

Show parent comment

1

u/dmwit Sep 10 '11

Yep, it's very unintuitive. Nobody would write the function this way the first time -- this was mostly a cute demonstration of very, very short code. If you weren't going for very short code, I would expect something like this instead:

import Data.List
x `divides` y = x `mod` y == 0
main = print $ nubBy divides [2..]

2

u/HigherFive Sep 10 '11

Oh I'm all for short code that makes no sense!

Have you seen matrix transposition in Scheme?

(apply map list m)

(A matrix is a list of lists - the matrix's rows. Transposing is the process of transforming it to a list of its columns)