Skip to content

Instantly share code, notes, and snippets.

@saralilyb
Last active February 2, 2025 18:37
Show Gist options
  • Save saralilyb/f704f09b9c66628550d9 to your computer and use it in GitHub Desktop.
Save saralilyb/f704f09b9c66628550d9 to your computer and use it in GitHub Desktop.
The following are done up to dig into nested arrays and find the max or min values in them. In CoffeeScript. From http://stackoverflow.com/questions/10564441/how-to-find-the-max-min-of-a-nested-array-in-javascript.
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