I hereby claim:
- I am marcoslhc on github.
- I am marcoslhc (https://keybase.io/marcoslhc) on keybase.
- I have a public key ASDLabcN5vXDb0S9oe_pdXN5_qQUj7PTUp3IEy0mhX6zIAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| const compose = | |
| (...funcs) => arg => funcs.reduceRight((composed, f) => f(composed), arg); | |
| const filterReduce = | |
| predicate => reducer => (accum, value) => (predicate(value)) ? reducer(accum, value) : accum; | |
| const mapReduce = | |
| morphism => reducer => (accum, value) => reducer(accum, morphism(value)); | |
| const transduce = |
| range = (start, end, step = 1) => { | |
| return { | |
| *[Symbol.iterator]() { | |
| let by = start >= end && step > 0 ? step*(-1) : step; | |
| let current = start; | |
| while ((start < end && current < end) || (start > end && current > end)) { | |
| yield current; | |
| current = current + by; | |
| } | |
| return end; |
| // Stripped straight from the good Dan Abramov | |
| // https://gist.github.com/gaearon/ffd88b0e4f00b22c3159 | |
| function compose(...functions) { | |
| return function (arg) { | |
| return functions.reduceRight(function (composed, f) { | |
| return f(composed); | |
| }, arg); | |
| }; | |
| }; |
| function filterReduce(predicate) { | |
| return function (accum, value) { | |
| if (predicate(value)) { | |
| return accum.concat(value); | |
| } else { | |
| return accum; | |
| } | |
| }; | |
| }; |
| // Utilities | |
| const compose = | |
| (...fns) => (arg) => fns.reduceRight((composed, func) => func(composed), arg); | |
| const map = | |
| fn => list => list.map(fn); | |
| const filter = | |
| predicate => list => list.filter(predicate); |
| var matrix1 = [ | |
| [1, 1, 4, 5], | |
| [0, 3, 3, 2], | |
| [3, 1, 1, 0] | |
| ] | |
| var coeficients = [0.3, 0.5, 0.2]; | |
| function weirdComputation(matrix) { | |
| var m = matrix; |
| var arr = ['The', 'simple', 'things', 'of', 'life'] | |
| arr.reduce(function (finalString, str) { | |
| return finalString.concat(' ').concat(str) | |
| }, ''); | |
| // " The simple things of life" | |
| // reduce folds the value from left to righ, we could also reduce from right to left: | |
| var arr = 'stressed'.split(''); |
| let arr = [1,2,3,4,5,6,7,8,9,10]; | |
| // Array.prototype.reduce takes a function (reducer) and an initial value of type B | |
| // and returns an value of type B | |
| let num = arr.reduce(function (accum, value) { | |
| // The reducer function takes a value of | |
| // type B and another value of the same type as the array (A) | |
| // returns a value of type B; | |
| return accum + value; |
| ClassList.prototype.concat = function (otherList) { | |
| return ClassList.of(this.getClasses().concat(otherList.getClasses())); | |
| } | |
| // We check if it's a value we can work on. There are some other | |
| // checks we need to make, but this is not the place to do it | |
| ClassList.prototype.addClass = function (classes) { | |
| const classesToAdd = Array.isArray(classes) ? classes | |
| : [classes]; | |
| return ClassList.of(this.getClasses()).concat(ClassList.of(classesToAdd)); |