In React's terminology, there are five core types that are important to distinguish:
React Elements
// Inspired by https://github.com/Munksgaard/session-types | |
interface Chan<Env, Protocol> { | |
env_and_protocol: [Env, Protocol]; | |
} | |
class Eps implements HasDual { | |
readonly tag: 'Eps' = 'Eps'; | |
readonly dual!: Eps; | |
} |
const {useCallback, useEffect, useReducer, useRef} = require('react'); | |
let effectCapture = null; | |
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) { | |
let updateCounter = useRef(0); | |
let wrappedReducer = useCallback(function(oldWrappedState, action) { | |
effectCapture = []; | |
try { | |
let newState = reducer(oldWrappedState.state, action.action); |
#!/bin/bash | |
# script: time-docker-build.sh | |
# | |
# All command line arguments are passed to docker build command. | |
# | |
# usage: ./time-docker-build.sh | |
# | |
DATE_FORMAT="+%s" |
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
r := genericMap([]int{1, 2, 3, 4}, func(x int) string { | |
return "Hello" |
In React's terminology, there are five core types that are important to distinguish:
React Elements
package main | |
import "strconv" | |
import "fmt" | |
type Color string | |
type Make string | |
type Model string | |
const ( |
extern mod extra; | |
use std::vec; | |
use extra::test::BenchHarness; | |
pub fn crc32(bytes : &[u8]) -> u32 { | |
crc32_end(crc32_chunk(crc32_begin(), bytes)) | |
} | |
pub fn crc32_begin() -> u32 { | |
0xffffffff |
resolveURL: function (route, params, appendRoot) { | |
var appendRoot = (appendRoot == false) ? false : true; | |
var route, params; | |
var href = ""; | |
var regExpAllNormalParams = /(\(\?)?\/:\w+/g; | |
var regExpAllOptionalParams = /\((.*?)\)/g; | |
href = router.routes[route]; |
// This is *not* valid Go! | |
func Map(f func(A) B, xs []A) []B { | |
ys := make([]B, len(xs)) | |
for i, x := range xs { | |
ys[i] = f(x) | |
} | |
return ys | |
} | |
Map(func(x int) int { return x * x }, []int{1, 2, 3}) |
var Benchmark = require('benchmark'); | |
Benchmark.prototype.setup = function() { | |
a = ["test"]; | |
for (var i = 0; i < 10000; i++) { | |
a.push("some other stuff"); | |
} | |
s = a.join(); | |
re1 = new RegExp("^test"); | |
re2 = new RegExp("^not there"); | |
}; |