Skip to content

Instantly share code, notes, and snippets.

#!/usr/local/bin/ruby
print "Input /^\\d \\d [NSEW] [LMR]+$/: "
raise "Bad input" unless input = gets.chomp.match(/^(\d+)\s(\d+)\s([NSEW])\s([LMR]+)$/)
x, y, direction, moves = input[1].to_i, input[2].to_i, input[3], input[4]
compass = %w{ N E S W }
i = compass.index(direction)
fns = lambda { y+=1 }, lambda { x+=1 }, lambda { y-=1 }, lambda { x-=1 }
diff --git a/dygraph.js b/dygraph.js
index 3d3326e..374c355 100644
--- a/dygraph.js
+++ b/dygraph.js
@@ -1521,8 +1521,18 @@ Dygraph.prototype.drawGraph_ = function(data) {
for (var i = 1; i < data[0].length; i++) {
if (!this.visibility()[i - 1]) continue;
+ // Reduce the resolution of the dataset if necessary.
+ var data_length = data.length
class FastBeustSequence
class << self
def find_all(max)
@listener = []
zero = Digit.new(nil, 0)
one = zero.next
start = Time.now
(1..10).each {|length| find(one, zero, length, 0, max, @listener)}
# List comprehension
# Haskell
[x*2 | x <- [1..10]] #=> [2,4,6,8,10,12,14,16,18,20]
# Ruby
(1..10).map { |x| x*2 } #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
# List comprehension with condition
# Haskell
[x*2 | x <- [1..10], x*2 >= 12] #=> [12,14,16,18,20]