Talk:How to work on lists

From HaskellWiki
Revision as of 11:38, 22 January 2007 by MathematicalOrchid (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

on the topic of slower operations: it should be noted that filter, map, zip, etc. are only O(n) if the whole list is evaluated. since these are lazy functions any of these will be O(1):

head $ map (+1) [0..]
(filter even [0..])!!5
take 5 $ zip [0..] [5..]

--Johannes Ahlmann 23:44, 21 January 2007 (UTC)

Ah yes, quite right. All of the complexity descriptions only apply if you actually use all of the list. I should probably mention that somewhere...

MathematicalOrchid 11:38, 22 January 2007 (UTC)