tweaking the colors of mbostock's Color Flood III
Prim’s algorithm is used to flood a 960×500 canvas with color.
Compare to Wilson’s algorithm and randomized breadth-first traversal.
def should_be_a_subset(superset, records_selected_by_scope, &condition) | |
flunk "Your superset is empty" if superset.empty? | |
flunk "Your scope did not select any records" if records_selected_by_scope.empty? | |
records_selected_by_block, records_excluded_by_block = superset.partition(&condition) | |
flunk "Your test condition did not select any records" if records_selected_by_block.empty? | |
flunk "Your test condition did not exclude any records" if records_excluded_by_block.empty? | |
records_selected_by_scope.map(&:id).should =~ records_selected_by_block.map(&:id) | |
end |
RSpec::Matchers.define :be_an_ordering_of do |all_records, condition| | |
match do |ordered_records| | |
should_be_an_ordering(all_records, ordered_records, &condition) | |
end | |
end | |
def should_be_an_ordering(all_records, ordered_records, &condition) | |
flunk "There are no records" if all_records.empty? | |
flunk "Your ordered records are the same as the default ordering" if all_records == ordered_records |
tweaking the colors of mbostock's Color Flood III
Prim’s algorithm is used to flood a 960×500 canvas with color.
Compare to Wilson’s algorithm and randomized breadth-first traversal.
require 'benchmark' | |
class LocalLambda | |
def local_lambda | |
a_lambda = -> { 1 } | |
a_lambda.call | |
1 | |
end | |
def nested_definition |
I hereby claim:
To claim this, I am signing this object: