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
/** | |
* Show Me the Evens - Show me the Odds | |
* Diana is learning to count and she just learned the difference between odds and even numbers. | |
* She wants to have some fun, so she picks a random number. | |
* If that number is even, she decides to count all the even numbers up to it starting from 0 up to (but not including) the input. | |
* If not, she decides to count all the odd numbers up to that number starting from 1 (but not including) the input. | |
**/ | |
const | |
range = x => y => |
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) | |
, concat = ys => xs => | |
xs.concat(ys) | |
, flatten = xs => | |
reduce(uncurry2(concat))(xs) |
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 | |
id = x => | |
x | |
, always = x => () => | |
x | |
, not = prop => | |
!prop | |
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 clamp = l => h => x => | |
x > h | |
? h | |
: x < l | |
? l | |
: x | |
const | |
ascend = i => xs => { | |
let |
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 max = (x, y) => x > y ? x : y | |
console.log([1, 2, 3, 4, 5, 6].reduce(max)) |
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 len = x => x.length | |
const maxBy = fn => (x, y) => fn(x) > fn(y) ? x : y | |
console.log(['a', 'ab', 'abc'].reduce(maxBy(len))) |
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
crie uma função chamada MaiorPalavra(str) que recebe um parâmetro do tipo string e retorna a maior palavra. | |
tenha como casos de entrada os exemplos abaixo: | |
"Olá mundo" | |
"Letra após letra" | |
"uma confusa /:cadeia de caracteres:/[ isso não é!!!!!!!~" | |
"uma bonita sequência^&" |
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) | |
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 Poller = (time, callback) => { | |
const queue = []; | |
const add = op => { | |
queue.push(op) | |
} | |
const exec = () => { | |
callback(queue.shift()) | |