# Using Fold[ or Map[ Better?

I'm working through MMA Cookbook by Mangano, page 54. He shows Map is a compact form of Fold function. Is using Fold function important?

myMap3[f_, l_] := Fold[Prepend[#1, f[#2]]&, {}, l]
myMap3[Sqrt, {1, 2, 3}]
(* Out: {Sqrt[3], Sqrt[2], 1} *)



I value writing better MMA code. Mastering Functional forms, then moving into Rewrite-rules. Thanks in advance.

• Sure. Fold solves problems that Map does not (at least not without uncomfortable contortions). Map is perhaps more intuitive to me and certainly very convenient. It also has a nice infix form (/@), which is handy. You would certainly want to be aware of both to write idiomatic MMA code. May 15, 2020 at 21:36
• As @MarcoB notes, Fold can solve problems that Map cannot. I have not read Mangano's book, but to me, the more interesting comparison is between Fold and recursive functions. Understanding why recursion is more powerful than Fold is valuable exercise. May 15, 2020 at 22:17
• Thank you, now I get it. @Shredderroy May 15, 2020 at 23:35
• Magnano's point was, "so you can understand" what is happening inside of the Map[ command, by a drawn out equivalent. I'm really enjoying trying to get inside MMA head. Just everything is so abstract & full of symbols. May 16, 2020 at 3:06