type basicColor =
| Red
| Green
| Blue;
let basicColorToInt = color => {
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 lastIndex = list => ( | |
list && list.length > 0 ? list.length - 1 : 0); | |
const isNone = val => val === null || typeof val === 'undefined'; | |
const asList = list => (isNone(list) ? [] : list); | |
const isEmptyList = list => list && list.length <= 0; | |
const isLastIndex = (lst, index) => (asList(lst).length - 1) === index; |
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 bt = (value, left, right) => { | |
return { | |
value: value, | |
left: left, | |
right: right | |
}; | |
} | |
const leaf = value => { | |
return bt(value, null, null); |
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
<script> | |
function execPolyfill() { | |
(function(){ | |
// CustomElementsV1.min.js v1 polyfill from https://github.com/webcomponents/webcomponentsjs/tree/v1/src/CustomElements/v1. | |
/* | |
Copyright (c) 2016 The Polymer Project Authors. All rights reserved. | |
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | |
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
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
package recfun | |
object Main { | |
def main(args: Array[String]) { | |
println("Pascal's Triangle") | |
for (row <- 0 to 10) { | |
for (col <- 0 to row) | |
print(pascal(col, row) + " ") | |
println() | |
} |
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
// If you use Redux Thunk... | |
import { createStore, applyMiddleware } from 'redux' | |
import thunk from 'redux-thunk' | |
const store = createStore(reducer, applyMiddleware(thunk)) | |
// You can define asynchronous action creators that return functions. | |
// We call such action creators "thunks": | |
export function getUser(id) { | |
// Redux Thunk will inject dispatch here: |
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 R = require('ramda'); | |
const { append, compose, filter, flatten, isArray, join, map, prepend } = R | |
const { log } = console | |
// html markup functions | |
const UL = 'ul' | |
const LI = 'li' | |
const tagOpen = tag => `<${tag}>` |
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
function IsThisUndefined(props) { | |
return <div>{props.title} {this === undefined ? 'Yes' : 'No'}!</div> | |
} | |
ReactDOM.render( | |
<IsThisUndefined title='Is this undefined?' />, | |
document.getElementById('app') | |
) |
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 Counter extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {count: 0}; | |
this.incrementCounter = this.updateCounter.bind(this, 1); | |
this.decrementCounter = this.updateCounter.bind(this, -1); | |
} | |
render() { | |
return ( |
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
// preserved from my comment in this issue: https://github.com/Microsoft/TypeScript/issues/165#issuecomment-259598080 | |
interface Type<T> { new(...args): T } | |
interface CaseResult<R> { | |
success: boolean; | |
result: R; | |
} | |
interface CaseFn<R> { (value: any): CaseResult<R> } |