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
require 'pathname' | |
require 'pp' | |
class HTTPResponseBuilder | |
STATUS_CODES = {100 => "Continue", | |
101 => "Switching Protocols", | |
200 => "OK", | |
201 => "Created", | |
202 => "Accepted", | |
203 => "Non-Authoritative Information", |
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
# https://github.com/mikel/mail | |
# http://rdoc.info/github/mikel/mail/Mail | |
#### Retrieving mail | |
yahoo_imap = { | |
:address => "imap.mail.yahoo.com", | |
:port => 993, | |
:user_name => "", |
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
#Scrabblesque | |
class ScrabblesquePlay | |
def inititialize(word, multipliers) | |
end | |
# TODO I haven't decided the class properties quite yet. | |
end | |
$letter_values = { |
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 Robot | |
attr_reader :name, :instruction_count, :created_at, :reset_at | |
def make_name(name_length=5) | |
return Array.new(name_length){rand(36).to_s(36)}.join.upcase | |
end | |
def incf_instruction_count | |
@instruction_count += 1 | |
end | |
def set_name() | |
@name = make_name |
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
require 'prime' | |
def list_primes_below(n) | |
# List primes below argument | |
return Prime::EratosthenesGenerator.new.take_while { |i| i <= n } | |
end | |
def list_primes_count(n) | |
# List argument number of primes | |
return Prime::EratosthenesGenerator.new.take(n) |
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
# Wavelets calculations | |
# http://dmr.ath.cx/gfx/haar/ | |
require 'prime' | |
class NotPowerOfTwoError < StandardError; end | |
class NotEvenNumberError < StandardError; 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
CL-USER> (load "point-mutations-test.lisp") | |
;; Loading file point-mutations-test.lisp ... | |
To load "lisp-unit": | |
Load 1 ASDF system: | |
lisp-unit | |
; Loading "lisp-unit" | |
;; Loading file /Users/wclifford/exercism/lisp/point-mutations/dna.lisp ... | |
;; Loaded file /Users/wclifford/exercism/lisp/point-mutations/dna.lisp | |
INVALID-TO-GET-DISTANCE-FOR-DIFFERENT-LENGTH-STRINGS: 3 assertions passed, 0 failed. |
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
;;; One use of `macrolet' is to simplify purely structural concerns in | |
;;; one's functions. As one example, consider this implementation of | |
;;; the quadratic formula: | |
(defun quadratic (a b c) | |
(macrolet ((plus-or-minus-div (x y z) | |
`(values (/ (+ ,x ,y) ,z) (/ (- ,x ,y) ,z)))) | |
(plus-or-minus-div (- b) (sqrt (- (* b b) (* 4 a c))) (* 2 a)))) | |
;;; Although there's still some redundancy, it's contained to the point |
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
# Goals | |
# 1. Small class configurable with a block | |
# 2. puts settings in a ruby Struct | |
require 'Forwardable' | |
class Settable | |
extend Forwardable | |
def_delegator :@config, :foo | |
def_delegator :@config, :bar |
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
(ql:quickload "lisp-unit") | |
(defpackage #:mismatch-count-test | |
(:use #:cl #:lisp-unit) | |
(:export #:run)) | |
(in-package #:mismatch-count-test) | |
;;; Tests |
OlderNewer