DEV Community

Discussion on: Writing a Functional Programming-Style map Function

Collapse
 
brentc profile image
Brent C

but since calling map(x => x.id) already returns a function

Yes, that example works if map is returning a function, but I guess my read at that point in the article was that map wasn't returning a function.

  • it takes a function (fn) and then some datum (m2)3
  • it returns the datum as transformed by said function

In which case the example that follows that presupposes it's already a curried implementation was confusing.

Thread Thread
 
rpearce profile image
Robert Pearce • Edited

...aaaaand I feel like an idiot. I totally see it now! We're still working with (fn, m) => ... and not fn => m => ..., so that doesn't make sense yet. I'll update ASAP. Thanks for your patience, and nice 👀!

Thread Thread
 
rpearce profile image
Robert Pearce

Quick fix was to change it to:

const mapId = map.bind(null, x => x.id)

Thanks again.