A Pen by Michael Salaverry on CodePen.
const axios = require('axios').default; | |
let callCounter = {}; | |
const displayCalls = () => { | |
console.log(callCounter); | |
}; | |
function makeInterceptor(keyName, returns) { | |
callCounter[keyName] = 0; | |
return (r) => { | |
callCounter[keyName]++; |
A Pen by Michael Salaverry on CodePen.
A Pen by Michael Salaverry on CodePen.
class Candle extends HTMLElement { | |
constructor() { | |
super(); | |
this.attachShadow({ mode: "open" }); | |
const wrapper = document.createElement("span"); | |
wrapper.setAttribute("class", "candle"); | |
const candleFlicker = document.createElement("img"); | |
candleFlicker.setAttribute( |
<div class="menorah"> | |
<candle-el lit></candle-el> | |
<candle-el lit></candle-el> | |
<candle-el lit></candle-el> | |
<candle-el></candle-el> | |
<candle-el lit shamesh></candle-el> | |
<candle-el></candle-el> | |
<candle-el></candle-el> | |
<candle-el></candle-el> | |
<candle-el></candle-el> |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
fmt.Println(Divisors_simple(10)) // should equal 4 | |
fmt.Println(Divisors_pointers(10)) // should equal 4 | |
fmt.Println(Divisors_channels(10)) // should equal 4 |
We want to approximate the length of a curve representing a function y = f(x) with a <= x <= b. First, we split the interval [a, b] into n sub-intervals with widths h1, h2, ... , hn by defining points x1, x2 , ... , xn-1 between a and b. This defines points P0, P1, P2, ... , Pn on the curve whose x-coordinates are a, x1, x2 , ... , xn-1, b and y-coordinates f(a), f(x1), ..., f(xn-1), f(b) . By connecting these points, we obtain a polygonal path approximating the curve.
Our task is to approximate the length of a parabolic arc representing the curve y = x * x with x in the interval [0, 1]. We will take a common step h between the points xi: h1, h2, ... , hn = h = 1/n and we will consider the points P0, P1, P2, ... , Pn on the curve. The coordinates of each Pi are (xi, yi = xi * xi).
The function len_curve (or similar in other languages) takes n as parameter (number of sub-intervals) and returns the length of the curve. You can truncate it to 9 decimal places.