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 PouchDB = require('pouchdb'); | |
const db = new PouchDB('choices'); | |
// doc that defines the view | |
var ddoc = { | |
_id: '_design/choice', | |
views: { | |
by_key: { | |
map: function (doc) { | |
emit(doc.key, doc.taste); |
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 choices = [ | |
[['VANILLA'], ['coconut flakes', 'pecans'], ['marshmallow']], | |
[['CHOCOLATE'], ['pecans'], ['chocolate']], | |
[['STRAWBERRY', 'VANILLA'], ['pineapple', 'coconut flakes'], ['marshmallow']], | |
[['STRAWBERRY'], ['pecans'], ['maple']], | |
[['VANILLA'], ['coconut flakes', 'pineapple'], ['chocolate']], | |
[['CHOCOLATE, STRAWBERRY'], ['pineapple', 'pecans'], ['butterscotch']], | |
]; | |
const keys = _.map(choices, c => { |
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 Combinator = function (opts) { | |
var combinations = []; | |
function combine(current, remainder) { | |
if (remainder.length === 0) { | |
if (current.length >= (opts.min || 0) && | |
current.length <= (opts.max || current.length)) | |
combinations.push(current); | |
} else { | |
combine(current.concat(remainder[0]), remainder.slice(1, remainder.length)); |
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 CombinatorGenerator = function (opts) { | |
function* combine(current, remainder) { | |
if (remainder.length === 0) { | |
if (current.length >= (opts.min || 0) && | |
current.length <= (opts.max || current.length)) { | |
yield(current); | |
} | |
} else { | |
combine(current.concat(remainder[0]), remainder.slice(1, remainder.length)) | |
combine(current, remainder.slice(1, remainder.length)) |
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 menu = require('./menu'); | |
var Combinator = require('./Combinator-generator-naive'); | |
function run() { | |
var threeCombos = new Combinator({ | |
min: menu.threeItems.min, | |
max: menu.threeItems.max | |
}) | |
.combine([], menu.threeItems.values); |
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 BowlingBall { | |
private String petName; | |
BowlingBall() { | |
} | |
void setPetName(String petName) { | |
this.petName = petName; | |
} |
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
interface IBowlingBall { | |
String getPetName(); | |
} | |
class Bowler { | |
static private class BowlingBall implements IBowlingBall{ | |
private String petName; | |
BowlingBall() { | |
} |
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 BowlingBallFactory { | |
static private class BowlingBall implements IBowlingBall{ | |
private String petName; | |
BowlingBall() { | |
} | |
private void setPetName(String petName) { | |
this.petName = petName; | |
} |
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
import java.util.ArrayList | |
import java.util.List | |
interface IBowlingBall { | |
String getBrand(); | |
String getSerialNumber(); | |
} | |
abstract class BowlingBall implements IBowlingBall { | |
private String brand, serialNumber; |
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
this.add({ | |
role: "movement", | |
cmd: "rawMoves", | |
}, (msg, reply) => { | |
var err = null; | |
var rawMoves = []; | |
var pos = msg.piece.position; | |
switch (msg.piece.piece) { |