Forked from ronaiza-cardoso/negative-number-matrix.js
Last active
March 21, 2017 00:09
-
-
Save lubien/662c9e2e474b123f77420dde3a38a35b to your computer and use it in GitHub Desktop.
Count Negative Integers in Matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const | |
composeN = (...fs) => y => | |
fs.reduceRight((x, f) => f(x), y) | |
, flatten = xs => | |
xs.reduce((acc, x) => acc.concat(x)) | |
, filter = pred => xs => | |
xs.filter(pred) | |
, negative = x => | |
x < 0 | |
, prop = p => o => | |
o[p] | |
, M = | |
[ [-1, 3, 4, 1] | |
, [ 2, 2, 4, 9] | |
, [ 4, 5, -7, 9] | |
] | |
composeN( | |
prop('length'), | |
filter(negative), | |
flatten | |
)(M) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment