I hereby claim:
- I am trygvea on github.
- I am trygvea (https://keybase.io/trygvea) on keybase.
- I have a public key whose fingerprint is 61DF 261E E636 2555 75C0 0143 EBC0 F71B D423 9905
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
// pureStatefulComputation: (state) => [result, newState] | |
// push & pop as pure stateful computations | |
const push = elem => stack => [undefined, [elem, ...stack]] | |
const pop = ([head, ...tail]) => [head, tail] | |
// ------------------------------------------------------------ | |
// stackManip, version 1. | |
// The passing of state through computations is tedious |
// push & pop as pure stateful computations | |
const push = elem => stack => [null, [elem, ...stack]] | |
const pop = ([head, ...tail]) => [head, tail] | |
// ---------------------------------------------------------- | |
// Let's do a simple stack manipulation popping the first two | |
// elements and pushing their product back on to the stack. | |
// The boring way to do it: Note how we manually must lift | |
// the stack through computations. | |
// (compare that to stackManipM below) |
const curry = f => (...args) => | |
args.length >= f.length | |
? f(...args) | |
: (...more) => curry(f)(...args, ...more) | |
// Test it. If | |
const f = (a,b,c) => a+b+c | |
const g = curry(f) | |
// then the following holds true: |
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import { createStore } from 'redux' | |
import { Provider, connect } from 'react-redux' | |
const reducer = (state = {counter:0}, action = {}) => { | |
switch (action.type) { | |
case 'INCREMENT': | |
return {counter: state.counter+1} | |
default: |
function * Numbers () { | |
let number = 0; | |
while (true) { | |
yield ++number; | |
} | |
} | |
function * take (numberToTake, iterable) { | |
const iterator = iterable[Symbol.iterator](); |
import java.nio.ByteBuffer | |
public static byte[] bytes(long l) { | |
ByteBuffer.allocate(Long.BYTES).putLong(l).array(); | |
} | |
def pretty(byte[] b) { | |
def sb = new StringBuilder() | |
for(i=0;i<b.length;i++){ | |
sb.append(String.format("\\x%02X", b[i])) |
package shapeless.examples | |
import shapeless._ | |
import poly._ | |
import labelled._ | |
sealed trait Message | |
case class Ping(id: Long, sender: String) extends Message | |
case class Pong(id: Long, receiver: String) extends Message |
// Tested in groovy 2.4.3 | |
import groovy.transform.TypeChecked | |
@TypeChecked | |
interface F1<A, B> { // Function1 | |
abstract B f(A a); | |
} | |
@TypeChecked | |
interface Functor<T, A> { // Egentlig Functor<T<A>> men det går ikke i java/groovy | |
abstract <A,B> T<B> map(F1<A, B> f) |
UTF-8: æøåÆØÅ | |
ISO-8859-1: ʯÂ∆ÿ≈ | |
MacRoman: æøåÆØÅ | |
I korthet: | |
* non-UTF-8 aapnet i UTF8 gir svarte spoersmaalstegn | |
* non-ISO aaapnet i ISO: UTF8: diverse A-tegn, MacRoman: 3/4 (R) E etc | |
* non-Mac aapnet i Mac: UTF-8: Kvadratrot, ISO: E, delta Y mattesymboler |