Player | Points |
---|---|
David | 9 |
Darryn | 6 |
Matt | 3 |
Koray | 3 |
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
data Action = Coin | Turn deriving Show | |
data Locked = Locked | Unlocked deriving Show | |
data State = State { locked :: Locked, coins :: Int, gumballs :: Int } deriving Show | |
update :: Action -> State -> State | |
update Coin s@(State { locked = Locked, gumballs = g }) | g == 0 = s | |
update Coin s@(State { locked = Locked, coins = c }) = s { locked = Unlocked, coins = c + 1 } | |
update Turn s@(State { locked = Unlocked, gumballs = g }) = s { locked = Locked, gumballs = g - 1 } | |
update _ s = s |
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 strict'; | |
const fs = require('fs'); | |
const R = require('ramda'); | |
const S = require('sanctuary'); | |
// unit :: () | |
const unit = void 0; |
Function composition has one huge benefit over chaining APIs: it allows any combination of JavaScript functions to be stuck together to form a pipeline. One could create a pipeline involving a function from library A, a function from library B, a function from library C, and a built-in function. With a chaining API one is restricted to the set of functions available on the object facilitating the chaining.
I found this to be a problem when using Underscore. This would be fine for a pipeline comprised solely of Underscore functions (represented here by lower-case identifiers):
_(x)
.a(...)
.b(...)
.c(...)
.value()
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
findX :: (MatchObj -> Maybe MatchObj) -> [String] -> Maybe MatchObj | |
findX matcher words = head xs | |
where | |
xs = do len <- length words .. 1 | |
idx <- 0 .. length words - len | |
let m = matcher { before: take idx words | |
, group: (drop idx >>> take len) words | |
, after: drop (idx + len) words | |
, matches: defaultTransaction | |
, context: [] |
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
var R = require('ramda'); | |
var zipMany = | |
R.cond(R.isEmpty, | |
R.always([]), | |
R.converge(R.map, | |
R.flip(R.pluck), | |
R.pipe(R.head, R.length, R.range(0)))); | |
var zipMany2 = function(lists) { |
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
DATE | |
9am, Sunday 15 June 2014 (NZ time) | |
VENUE | |
Level 2 | |
5 High Street | |
Auckland 1010 |
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
DOCTEST = node_modules/.bin/doctest --module commonjs | |
.PHONY: test | |
test: JS_FILES = $(shell find . -name '*.js' -not -path './node_modules/*' -not -path './test/*') | |
test: | |
@$(foreach file,$(JS_FILES),head -n 1 -- $(file) | grep --silent 'doctest ignore' - || $(DOCTEST) $(file) || exit 1;) |
I hereby claim:
- I am davidchambers on github.
- I am davidchambers (https://keybase.io/davidchambers) on keybase.
- I have the public key with fingerprint CC3A 9C98 F8FA 1729 D1ED C345 1625 E2CF 0BD0 FE42
To claim this, I am signing this object:
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
var alib = require('alib'); | |
var blib = require('blib'); | |
var clib = require('clib'); | |
+var zlib = require('zlib'); | |
var fruits = [ | |
'apples', | |
'bananas', | |
'cherries', |