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
(ns factors.core-spec | |
(:require [speclj.core :refer :all] | |
[factors.core :refer :all])) | |
(defn factors-of [n] | |
(loop [n n, d 2, fs []] | |
(cond (= n 1) fs | |
(zero? (mod n d)) (recur (/ n d) d (conj fs d)) | |
:else (recur n (inc d) fs)))) |
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
(ns bowling.core-spec | |
(:require [speclj.core :refer :all])) | |
(defn is-strike? [[first & _]] (= 10 first)) | |
(defn is-spare? [[first second & _]] (= 10 (+ first second))) | |
(defn split-frame [rolls] | |
(cond (is-strike? rolls) [(take 3 rolls) (rest rolls)] | |
(is-spare? rolls) [(take 3 rolls) (drop 2 rolls)] | |
:else [(take 2 rolls) (drop 2 rolls)])) |
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
(ns bowling.core-spec | |
(:require [speclj.core :refer :all])) | |
(defn is-strike? [rolls] (= 10 (first rolls))) | |
(defn is-spare? [rolls] (= 10 (apply + (take 2 rolls)))) | |
(defn ->frames [rolls] | |
(cond | |
(empty? rolls) [] |
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
(ns bowling.core-spec | |
(:require [speclj.core :refer :all])) | |
(def all-pins 10) | |
(def frames-per-game 10) | |
(defn game-over [frame] (= frame frames-per-game)) | |
(defn strike-score [rolls] (+ all-pins (nth rolls 1) (nth rolls 2))) | |
(defn spare-score [rolls] (+ all-pins (nth rolls 2))) | |
(defn frame-score [rolls] (+ (first rolls) (second rolls))) | |
(defn is-strike [rolls] (= all-pins (first rolls))) |
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 templates | |
import ( | |
"bytes" | |
"fmt" | |
"io" | |
"text/template" | |
) | |
func ParseAndExecute(format string, args ...interface{}) string { |
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
#lang racket | |
(define LAST-FRAME 10) | |
(define ALL-PINS 10) | |
(define (is-spare? rolls) (= ALL-PINS (+ (first rolls) (second rolls)))) | |
(define (is-strike? rolls) (= ALL-PINS (first rolls))) | |
(define (score-frame frame score rolls) | |
(score-frames (add1 frame) |
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
type StackTraceError struct { | |
inner error | |
stack []byte | |
} | |
func NewStackTraceError(inner error) *StackTraceError { | |
return &StackTraceError{ | |
inner: inner, | |
stack: debug.Stack(), | |
} |
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
#!/usr/bin/env bash | |
# TCR: test && commit || revert | |
# codified by Kent Beck | |
# https://medium.com/@kentbeck_7670/test-commit-revert-870bbd756864 | |
function test() { | |
echo | |
cd `git rev-parse --show-toplevel` | |
go test ./... |
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 Path(object): | |
""" | |
This nifty class uses dynamic attribute resolution to mimic a directory | |
tree on a file system (either real or contrived). | |
""" | |
def __init__(self, root, enforce_real_paths=False): | |
self.root___ = str(root) | |
self.navigation___ = [] | |
self.enforce___ = enforce_real_paths | |
if self.enforce___ and not os.path.exists(self.root___): |
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
Show hidden characters
{ | |
"close_windows_when_empty": true, | |
"color_scheme": "Packages/Dayle Rees Color Schemes/sublime/darkside.tmTheme", | |
"draw_white_space": "all", | |
"font_face": "Source Code Pro", | |
"font_size": 19, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], |