some additional features / convenience funcs #441
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
i added _.sum() _.mean() _.median() to collections section and nrange() to arrays. tests are adjusted appropriately.
in further detail:
_.sum(obj): returns the sum of the elements objects.
_.mean(obj): returns the mean of the elements in the object.
_.median(obj): returns the median element (middle in sorted). works also with string / char elements (i.e. to split lists of names by alphabet)
_.nrange(n) adds convenience functions to _.range(n):
nrange(-3) -> [0, -1, -2];
nrange(0,3) -> [0, 1, 2];
nrnage(3,0) -> [3, 2, 1];
(might replace _.range(n) to reduce redundance)
do{}while() instead of while(){} speeds up the script slightly on FF4+ and Safari.
test suite and speed test is adjusted and tests passed.
Andreas