This file contains hidden or 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 arrayInstanceHandler = { | |
get(target, property, receiver) { | |
if (property < 0) { | |
property = target.length + parseInt(property); | |
} | |
return target[property]; | |
}, | |
}; | |
const arrayConstructorHandler = { |
This file contains hidden or 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
class Sheep: | |
def __init__(self, name: str): | |
self.name = name | |
self.naked = False | |
def is_naked(self) -> bool: | |
return self.naked | |
def shear(self): | |
if self.is_naked(): |
This file contains hidden or 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
use std::fmt; | |
enum Node<T> { | |
Add { left: T, right: T }, | |
Mul { left: T, right: T }, | |
Num { value: i64 }, | |
} | |
struct Arena { | |
nodes: Vec<Node<usize>>, |
This file contains hidden or 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
Machine({ | |
id: "light", | |
initial: "green", | |
states: { | |
red: { | |
initial: "no_cars", | |
states: { | |
no_cars: { | |
on: { | |
SENSE_CAR: "cars", |
This file contains hidden or 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 existingTransitions = { | |
EXISTING_PASSWORD: [ | |
{ | |
target: "check_existing", | |
actions: assign({ existing: (ctx, evt) => evt.value }), | |
}, | |
], | |
}; | |
const passwordTransitions = { |
This file contains hidden or 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 ZERO = 0; | |
const ONE = 1; | |
export const add = (a, b) => a + b; | |
export const mul = (a, b) => a * b; | |
export const sum = (...args) => args.reduce(add, ZERO); | |
export const product = (...args) => args.reduce(mul, ONE); |
This file contains hidden or 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
// @flow | |
import type {Expr, ExprF} from "./ast.js"; | |
const fmap = <A, B>(fn: A => B, expr: ExprF<A>): ExprF<B> => { | |
switch (expr.type) { | |
case "number": | |
return expr; | |
case "variable": | |
return expr; | |
case "apply": |
This file contains hidden or 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 moment = require("moment"); | |
module.exports = "bar"; |
This file contains hidden or 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 path = require("path"); | |
const webpack = require("webpack"); | |
const includeEditor = process.env.INCLUDE_EDITORS === "true"; | |
const prod = process.env.NODE_ENV === "production"; | |
module.exports = { | |
entry: "./src/" + (includeEditor ? "editor-" : "") + "perseus.js", | |
output: { | |
path: "./build", |
This file contains hidden or 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
console.log(''); | |
`Number | String`; // what about chaining? | |
`{ type: String }`; | |
`{ type: 'FunctionDeclaration' | 'FunctionExpression' }`; | |
// etc. | |
// what if... we provide definitions for combining two functions or two literals to provide pattern matching |
NewerOlder