Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    $\begingroup$ @@@ supplies a sequence to the function being applied, with n slots where n is the length of the sublists you're mapping over. Last takes a list as an argument, so you need Last/@m, for understanding, the way to make @@@ work is to do Last[List@##]&@@@m, but that's just tearing the list apart and putting it back together. $\endgroup$ Commented Aug 6, 2015 at 15:10
  • $\begingroup$ Notice the difference in Szabolcs explanation of @@@ and f/@{{x1,y1},{x2,y2}}, which gives {f[{x1,y1}],f[{x2,y2}]} $\endgroup$ Commented Aug 6, 2015 at 15:13
  • 1
    $\begingroup$ Some possible duplicates: 78240, 46238, 70201 $\endgroup$ Commented Aug 7, 2015 at 5:26
  • 1
    $\begingroup$ Actually many operations can be phrased either in terms of Apply or Map. I should have mentioned in my answer that Map tends to be quite a bit faster than Apply. I still use Apply a lot in the exact same way I described, but for the times when performance is important, you should know that Apply tends not to be as fast as Map. $\endgroup$ Commented Aug 7, 2015 at 8:56
  • 1
    $\begingroup$ To stir the pot a little, MapThread[f,{a,b}]===f@@@Transpose[{a,b}] when a and b are lists of equal length. I mentally think of MapThread as zipWith from Haskell. $\endgroup$ Commented Aug 7, 2015 at 12:34