Fun with sections

Submitted by boggle on Mon, 03/21/2005 - 6:14pm.

Still being quite a haskell newbie, I just got a lesson about sections and argument order. I wrote something like the following code in a small program for calculation the maximume queueing time of packets on a CAN bus system. Try out for a mild smile:

some_list = [0..5]

pifilter p i = filter (p (some_list !! i))

main = do
{ putStrLn $ show $ pifilter (<) i some_list;
putStrLn $ show $ filter (< si) some_list
} where i = 2; si = some_list !! i

While at first glance the two lines look like they should do the same, they include two inverse filter predicates (si <) and (< si).

BTW why does indentation get messed up inside <code></code> blocks?

Submitted by boggle on Mon, 03/21/2005 - 6:18pm.

Fixed the post.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.