Closed Dakkers closed 9 years ago
Shouldn't this be called a "map" function?
Yes you're correct. I was struggling to come up with a name. Will fix in a bit On Jun 6, 2015 5:51 PM, "Philip I. Thomas" notifications@github.com wrote:
Shouldn't this be called a "map" function?
— Reply to this email directly or view it on GitHub https://github.com/numbers/numbers.js/pull/147#issuecomment-109653311.
@KartikTalwar mind reviewing this? should only take a minute :hamburger:
Mostly lgtm :hamburger:
looking at some benchmarks, doing a direct call is faster. I think doing this for a single argument is okay, but if we want to generalize it we can use apply
.
Cool, feel free to merge
On Sunday, June 7, 2015, Dakota St. Laurent notifications@github.com wrote:
looking at some benchmarks https://jsperf.com/function-calls-direct-vs-apply-vs-call-vs-bind/6, doing a direct call is faster. I think doing this for a single argument is okay, but if we want to generalize it we can use apply.
— Reply to this email directly or view it on GitHub https://github.com/numbers/numbers.js/pull/147#issuecomment-109809159.
anyone have a suggestion for the name of the second version of matrix.map
?
140 wasn't broken, per se, but an in-place operation is deceiving. as mentioned in that issue, it would be nice to have a separate function for an in-place operation, in case it's needed. perhaps a suffix of
IP
would be suitable.matrix.map
takes a matrix (or vector) and applies a function to every element to a copy of the matrix (not in-place!). the purpose behind this function is to imitate how some of Numpy's functions operate element-by-element on Numpy arrays. so instead of writingmatrix.sin
,matrix.cos
... etc. the user can just pass any function tomatrix.map
.the catch: the function passed can only take one parameter, so it would be nice (and pretty simple, methinks) to create something that would behave like so:
so that any additional parameters passed to
matrix.mapNEW
(name is a work in progress) are passed tof
too.