Create a cond
function that takes 2 arguments:
- An matrix in the format:
[
[firstCondition, firstCallback],
[secondCondition, secondCallback],
...
]
Create a cond
function that takes 2 arguments:
[
[firstCondition, firstCallback],
[secondCondition, secondCallback],
...
]
const R = new LaRamda() | |
/** | |
* A subset of custom implementations of functions from | |
* the Ramda library. (all in Lamda form) | |
* - thanks to @xgrommx for uniq, intersection, where, evolve, | |
* applySpec, defaultTo, both, either, cond, zipWith | |
*/ | |
function LaRamda () { | |
const I = x => x |
CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.
In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.
First, let's illustrate the 3 styles by implementing
Given a number of people N and an array of integers, each one representing the amount of people a type of umbrella can handle, output the minimum number of umbrellas needed to handle N people.
No umbrella could have left spaces. Which means if a umbrella can handle 2 people, there should be 2 people under it.
If there's no solution, return -1
.
http://idea.imsxm.com/ |
const Latinise={};Latinise.latin_map={"Á":"A","Ă":"A","Ắ":"A","Ặ":"A","Ằ":"A","Ẳ":"A","Ẵ":"A","Ǎ":"A","Â":"A","Ấ":"A","Ậ":"A","Ầ":"A","Ẩ":"A","Ẫ":"A","Ä":"A","Ǟ":"A","Ȧ":"A","Ǡ":"A","Ạ":"A","Ȁ":"A","À":"A","Ả":"A","Ȃ":"A","Ā":"A","Ą":"A","Å":"A","Ǻ":"A","Ḁ":"A","Ⱥ":"A","Ã":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ḃ":"B","Ḅ":"B","Ɓ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ć":"C","Č":"C","Ç":"C","Ḉ":"C","Ĉ":"C","Ċ":"C","Ƈ":"C","Ȼ":"C","Ď":"D","Ḑ":"D","Ḓ":"D","Ḋ":"D","Ḍ":"D","Ɗ":"D","Ḏ":"D","Dz":"D","Dž":"D","Đ":"D","Ƌ":"D","DZ":"DZ","DŽ":"DZ","É":"E","Ĕ":"E","Ě":"E","Ȩ":"E","Ḝ":"E","Ê":"E","Ế":"E","Ệ":"E","Ề":"E","Ể":"E","Ễ":"E","Ḙ":"E","Ë":"E","Ė":"E","Ẹ":"E","Ȅ":"E","È":"E","Ẻ":"E","Ȇ":"E","Ē":"E","Ḗ":"E","Ḕ":"E","Ę":"E","Ɇ":"E","Ẽ":"E","Ḛ":"E","Ꝫ":"ET","Ḟ":"F","Ƒ":"F","Ǵ":"G","Ğ":"G","Ǧ":"G","Ģ":"G","Ĝ":"G","Ġ":"G","Ɠ":"G","Ḡ":"G","Ǥ":"G","Ḫ":"H","Ȟ":"H","Ḩ":"H","Ĥ":"H","Ⱨ":"H","Ḧ":"H","Ḣ":"H","Ḥ":"H","Ħ":"H","Í":"I","Ĭ":"I","Ǐ":"I","Î":"I","Ï":"I","Ḯ":"I","İ":"I","Ị":"I","Ȉ":"I |
// -------------------------------------------------------- | |
// "No javascript qualquer variável pode ser uma função ou o resultado de uma função" | |
function umaFuncao () { | |
console.log('faz coisas aqui dentro') | |
return 'e sempre deveria retornar alguma coisa' | |
} | |
const funcao = umaFuncao |
Transformar uma string em outra na qual cada letra do alfabeto deve ser a proxima mantendo o resto igual. ex: a -> b, z -> a, f -> g. | |
Após a transformação gerar uma nova string onde toda vogal deve ser maiúscula. | |
exemplos: | |
Input:"hello*3" | |
Output:"Ifmmp*3" | |
Input:"fun times!" |
const | |
id = x => | |
x | |
, always = x => () => | |
x | |
, not = prop => | |
!prop | |
"use strict"; | |
const arr = [[-1, 3, 4, 1], [2, 2, 4, 9], [4, 5, -7, 9]]; | |
const flatten = [].concat(...arr); | |
const find = () => flatten.filter(_a => _a < 0).length; | |
console.log(find()) //2 |