Map (higher-order function): Difference between revisions

Content deleted Content added
Optimizations: «"optimizations" → "optimizations", "Maps can be" → "Map functions can and often are"»
Optimizations: «+" xs"» forgot the list the map would be operating on
Line 16:
 
==Optimizations==
The mathematical basis of maps allow for a number of [[optimization]]s. If one has <code>map f . map g</code> ('.' is function application; <code>map f (map g xs)</code> is equivalent) then it is the same as the simpler <code>map (f . g) xs</code>; this particular simplification and optimization is a "map fusion". Map functions can and often are defined in terms of a [[Fold (higher-order function)|fold]] such as <code>foldr</code>, which means one can do a "map-fold fusion": <code>f z . map g</code> is equivalent to <code>foldr (f . g) z</code>.
 
==Haskell's Functor class==