From 0.19 Elm introduced 4 ways to boot an app:
- sandbox (no outside interaction)
- element (simple outside interaction - side effect, flags, subscriptions)
- document (same as above but with title tag control)
- application (whole SPA features)
function invariant(condition, message, a, b, c, d, e, f) { | |
if (!condition) { | |
var error; | |
var args = [a, b, c, d, e, f]; | |
var argIndex = 0; | |
error = new Error( | |
message.replace(/%s/g, function () { | |
return args[argIndex++]; | |
}) |
{ | |
"val": 1, | |
"left": { | |
"val": 2, | |
"left": { | |
"val": 4, | |
"left": null, | |
"right": null | |
}, | |
"right": { |
/** | |
* The input string can contain any of: -, *, ^ alongside any valid numerical number (including decimals). | |
* Standard operator precedence applies with ^ being higher than * higher than - . | |
An example program input might be 5 * 4 - 3 - 5 ^ 3 which should output -108 | |
For the purposes of this program you can assume that negative numbers and parenthesis are not allowed. Additionally, | |
we are not concerned about floating point precision or numbers that would exceed the float type size. | |
While some languages have built in support for eval-ing expressions, we ask you don’t use these features when designing | |
a solution. | |
*/ |
/** | |
* Observe dom mutation and return a promise with the element when element is either present or appear on the page | |
*/ | |
function waitForElm(selector) { | |
return new Promise(resolve => { | |
if (document.querySelector(selector)) { | |
return resolve(document.querySelector(selector)); | |
} | |
const observer = new MutationObserver(mutations => { | |
if (document.querySelector(selector)) { |
type NumberRange<Min extends number, Max extends number> = _Range<Max, _Range1<Min,[Min]>>; | |
type _Range1<Min extends number, Acc extends unknown[]> = Acc['length'] extends Min ? Acc : _Range1<Min, [Min, ...Acc]> | |
type _Range<Max extends number, Range extends unknown[]> = Range['length'] extends Max | |
? Range['length'] | |
: Range['length'] | _Range<Max, [Max, ...Range]>; | |
type FiveTo7 = NumberRange<5,7> | |
// 5 | 6 | 7 | |
type OneTo7 = NumberRange<1,7> |
module Debug.Extra exposing (viewModel) | |
import Html exposing (Html, p, pre, text) | |
import Html.Attributes exposing (style) | |
quote = | |
"\"" | |
isLeapYear : Int -> Bool | |
isLeapYear year = | |
Bitwise.and year 3 == 0 && (not (modBy year 25 == 0) || Bitwise.and year 15 == 0) |
From 0.19 Elm introduced 4 ways to boot an app:
I hereby claim:
To claim this, I am signing this object:
See https://performancejs.com/post/hde6d32/The-Best-Frontend-JavaScript-Interview-Questions-(Written-by-a-Frontend-Engineer) and https://en.wikipedia.org/wiki/Sorting_algorithm