Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about simple methods such as min and max #67

Open
chanansh opened this issue Jul 8, 2015 · 1 comment
Open

How about simple methods such as min and max #67

chanansh opened this issue Jul 8, 2015 · 1 comment

Comments

@chanansh
Copy link

chanansh commented Jul 8, 2015

It seems like the library doesn't support these.

@saralilyb
Copy link

Edit: Here. Works in JavaScript or CoffeeScript or whatever. No error checking or anything.

arrmax = numeric.mapreduce('if(xi > accum) accum=xi;','-Infinity');
arrmin = numeric.mapreduce('if(xi < accum) accum=xi;','Infinity');

Older:

Not efficient at all, but here's what I'm using. I'm sure there's a clever way to do this with mapreduce.

The following are done up to dig into nested arrays and find the max or min values in them. From StackOverflow. This is CoffeeScript.

arrmax = (arrs) ->
    toplevel = []
    i = 0
    l = arrs.length
    while i < l
        toplevel.push Math.max.apply(window, arrs[i])
        i++
    Math.max.apply window, toplevel
arrmin = (arrs) ->
    toplevel = []
    i = 0
    l = arrs.length
    while i < l
        toplevel.push Math.min.apply(window, arrs[i])
        i++
    Math.min.apply window, toplevel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants