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 TestTriangle < Test::Unit::TestCase | |
def test_isosceles_given_base_and_height | |
triangle(:ABC, :isosceles, :base => 5, :height :=> 9).tap do |t| | |
assert_point_equal p(2.5,9), t.apex | |
assert_point_equal p(0,0), @register[:A] | |
assert_point_equal p(5,0), @register[:B] | |
assert_point_equal p(2.5,9), @register[:C] | |
assert_equal t, @register.retrieve(:triangle, :ABC) | |
end |
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 InstanceEval | |
def initialize(code) | |
@code = code | |
@context = Object.new | |
end | |
def run | |
code = @code | |
result = @context.instance_eval(&code) | |
"* run --> #{result.inspect}" |
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
; Ways in which I want to improve this code: | |
; * less explicit looping; more higher-order functions | |
; * use records or types as appropriate to capture the structure of the data | |
; that flows through the functions | |
; * break a couple of functions into smaller ones | |
; * extract a general data type for a 2D table that is iterable by rows or columns | |
; * implement organised unit tests instead of the ad-hoc ones spread throughout | |
; * use namespaces and private/public functions idiomatically | |
(ns gs.ahigs.draw |
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
/usr/lib/ruby/1.9.1/net/http.rb:763: [BUG] rb_sys_fail(connect(2)) - errno == 0 | |
ruby 1.9.3p545 (2014-02-24) [i386-cygwin] | |
-- Control frame information ----------------------------------------------- | |
c:0037 p:---- s:0223 b:0223 l:000222 d:000222 CFUNC :initialize | |
c:0036 p:---- s:0221 b:0221 l:000220 d:000220 CFUNC :open | |
c:0035 p:0029 s:0216 b:0216 l:0023d0 d:000215 BLOCK /usr/lib/ruby/1.9.1/net/http.rb:763 | |
c:0034 p:0031 s:0214 b:0214 l:000213 d:000213 METHOD /usr/lib/ruby/1.9.1/timeout.rb:55 | |
c:0033 p:0026 s:0202 b:0202 l:000201 d:000201 METHOD /usr/lib/ruby/1.9.1/timeout.rb:100 | |
c:0032 p:0038 s:0196 b:0196 l:0023d0 d:0023d0 METHOD /usr/lib/ruby/1.9.1/net/http.rb:763 |
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
I know class-method contracts have been discussed (and fixed -- #7 ) before, but I have occasional problems with contracts on class methods. Here is the latest one, for example. | |
#<ParamContractError: Contract violation for argument 3 of 3: | |
Expected: nil, | |
Actual: #<Proc:0x80354744@.../lib/scm_roster/report/roster.rb:19> | |
Value guarded in: SCMRoster::Report::Util::process_data_and_notify_change | |
With Contract: Module, Func => None | |
At: .../lib/scm_roster/report/util.rb:22 > | |
[I have snipped the paths for readability.] |
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: | |
In code: | |
(tag> value) or (t> form arg1 arg2 ...) to tag a value to stdout. | |
(tagseq> 20 x) or (ts> 20 form arg1 arg2 ...) to tag a sequence, printing 20 items. | |
Note: the value of a (tag>) or (t>) or (tagseq>) or (ts>) form is always the complete | |
value, so it can be inserted into code without a problem. | |
At the REPL: |
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
(ns aoc.day13 | |
(:use aoc.common) | |
(:require [clojure.set :as set] | |
[clojure.string :as str] | |
[clojure.test :refer [testing is]] | |
[clojure.pprint :as pp])) | |
(defn y-x-comparator | |
"Compares location vectors in a way that enables sorting from top-left to bottom-right." |
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
(ns aoc.day16 | |
(:use aoc.common) | |
(:require [clojure.set :as set] | |
[clojure.string :as str] | |
[clojure.test :refer [testing is]] | |
[clojure.pprint :as pp] | |
[clojure.spec.alpha :as s] | |
[clojure.spec.test.alpha :as stest] | |
[better-cond.core :as b])) |
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
\documentclass[10pt,a4paper]{article} | |
% This LaTeX file is tested with xelatex. Note 'microtype'. | |
% | |
% Copyright (c) 2019 Gavin Sinclair, released under the Do What You Want With It licence. | |
% If you think of any improvements, let me know so I can learn more LaTeX. | |
\usepackage{microtype} | |
\usepackage{setspace} | |
\usepackage{parskip} |
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
# ----------------------------------------------------------------------------- | |
# Informations 2019 Week 2 | |
# ----------------------------------------------------------------------------- | |
# | |
# After Week 1 we had the following functions: | |
# is_divisible(number, factor) --> True/False | |
# factors(n) --> list | |
# is_prime(n) --> True/False | |
# | |
# This week we calculate the HIGHEST COMMON FACTOR of two numbers. |
OlderNewer