Difference between revisions of "Talk:How to work on lists"

From HaskellWiki
Jump to navigation Jump to search
m
 
 
Line 8: Line 8:
   
 
--[[User:JohannesAhlmann|Johannes Ahlmann]] 23:44, 21 January 2007 (UTC)
 
--[[User:JohannesAhlmann|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...
  +
  +
[[User:MathematicalOrchid|MathematicalOrchid]] 11:38, 22 January 2007 (UTC)

Latest revision as of 11:38, 22 January 2007

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)