This file contains 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
incrementBy(1); |
This file contains 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
export const incrementBy = context.action( | |
(state, value) => ({someprop: state.someprop + value}) | |
); | |
export const asyncAction = context.asyncAction( | |
async (_, value1, value2) => ({ value1, value2}) | |
); |
This file contains 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 MyLitComponent extends LitElement { | |
static get properties() { | |
return { | |
somepropFromContext: { | |
type: Number, | |
fromContext: true | |
}, | |
renamedProp: { | |
type: String, |
This file contains 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
context.init({ | |
propName: someValue, | |
propName2: { nestedData: [] } | |
}); |
This file contains 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
/** Usage | |
* | |
* file: someAction.js | |
* | |
* export const SOMEVAR = 'SOMEVAR'; | |
* | |
* export function fetchSomething(callbackOnDone, ...args) { | |
* return actionCreator({ | |
* actionName: SOMEVAR, | |
* getResult(data) { return data.someProperty }, |
This file contains 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 fs = require('fs'); | |
const buffer = fs.readFileSync('input'); | |
const file = buffer.toString().split('\n'); | |
function calcConsumption(amount) { | |
const tmp = Math.floor(+amount / 3) - 2; | |
return (tmp > 0) ? tmp + calcConsumption(tmp) : 0; | |
} |
This file contains 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 obsxvv; | |
import java.util.*; | |
import java.util.concurrent.*; | |
/** An immutable board of non-attacking queens. */ | |
class Board { | |
/** An immutable linked list of int values. */ | |
protected static class Node { | |
protected final int value; |
This file contains 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 obsxvv; | |
import java.util.concurrent.*; | |
/** Game of Life. */ | |
public class Life { | |
/** Invariant: <code> | |
from != null & to != null & | |
from.length == to.length != 0 & |
This file contains 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
import scalaz.Functor | |
object FunctorExample extends App{ | |
implicit val optionFunctor: Functor[Option] = new Functor[Option] { | |
override def map[A, B](fa: Option[A])(f: A => B): Option[B] = fa match { | |
case None => None | |
case _ => Some(f (fa.get)) | |
} | |
} |
This file contains 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
module Homework1 where | |
data Nat = Zero | Suc Nat | |
deriving (Show, Eq) | |
addNat :: Nat -> Nat -> Nat | |
addNat Zero Zero = Zero | |
addNat a Zero = a | |
addNat Zero b = b | |
addNat (Suc a) (Suc b) = addNat (Suc(Suc a)) b |
NewerOlder