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 am curious why a fiber returns the arguments when there are no more yield statements left to evaluate--see below. Why not return nil? | |
fiber = Fiber.new do |first, second| | |
Fiber.yield first + 30 | |
Fiber.yield first + 20 | |
end | |
p fiber.resume 10, 20 # => 40 | |
p fiber.resume 10, 20 # => 30 |
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 Array | |
def test | |
end | |
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 Tim | |
def test | |
end | |
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
public | |
def rec_flatten | |
collection ||= [] | |
return collection if self == [] | |
if self.class != Array | |
return collection << self | |
end | |
collection + self[0].rec_flatten + self[1..-1].rec_flatten | |
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
public | |
def rec_flatten | |
collection ||= [] | |
return collection if self == [] | |
if self.class != Array | |
return collection << self | |
end | |
collection + self[0].rec_flatten + self[1..-1].rec_flatten | |
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
public | |
def rec_flatten | |
collection ||= [] | |
return collection if self == [] | |
if self.class != Array | |
return collection << self | |
end | |
collection + self[0].rec_flatten + self[1..-1].rec_flatten | |
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
require 'rinruby' | |
collection = [] | |
r=RinRuby.new(:echo=>false) | |
10.times{collection << rand(10)} | |
r.y = collection | |
r.eval "plot(c(1:10), y)" | |
#need to sleep so that when the script ends, and R closes, the plot window won't close also |
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 'rinruby' | |
collection = [] | |
100.times{collection << rand(100)} | |
y = collection | |
x = (1..100).to_a | |
def point_plot(x,y,color) | |
r=RinRuby.new(:echo=>false) | |
r.y = y |
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 'rinruby' | |
collection = [] | |
100.times{collection << rand(100)} | |
y = collection | |
x = (1..100).to_a | |
def point_plot(x,y,color) | |
r=RinRuby.new(:echo=>false) | |
r.y = y |
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 'rinruby' | |
def point_plot(data_dir, data_file, pdf_file) | |
data_in = File.join(data_dir, data_file) | |
pdf = File.join(data_dir, pdf_file) | |
r = RinRuby.new(:echo=>false) | |
puts "Messages From R console:" | |
r.eval <<EOF | |
pdf(#{pdf.inspect}, onefile = TRUE) |
OlderNewer