This file contains hidden or 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
pascal = Enumerator.new do |y| | |
a = [1,1] | |
y << [1] | |
y << [1,1] | |
loop do | |
y << a = [1,(a.each_cons(2).map {|p| p[0]+p[1]}),1].flatten | |
end | |
end |
This file contains hidden or 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
1 | |
512 | |
130816 | |
22238976 | |
2830007680 | |
287548742912 | |
24300687609984 | |
1756899020502400 | |
110931407479018176 | |
6214192137669063424 |
This file contains hidden or 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
def even_fib(m) | |
return 0 if m <= 2 | |
even_fibs = Enumerator.new do |yielder| | |
a, b, c = 1, 0, 1 | |
loop do | |
yielder << (a, b, c = 3*a + 2*b, 3*b + 2*c, 2*b + c)[1] | |
end | |
end | |
This file contains hidden or 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
module Enumerable | |
def until(&block) | |
sofar = [] | |
each do |element| | |
ret = block.call(element) | |
break if ret | |
sofar << element | |
end | |
sofar | |
end |
This file contains hidden or 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
def f(a) | |
a + 2 | |
end | |
def g(a) | |
3*a | |
end | |
def h(a) | |
a - 7 |
This file contains hidden or 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
def dec_to_binary_string(number) | |
number.to_s(2).rjust(8,"0") | |
end | |
def leader_byte?(byte) | |
!(byte[0].eql?("0") || byte[0..1].eql?("10")) | |
end | |
def utf8_to_binary_string(char_array) | |
char_array.map { |byte| byte[(byte.index("0")+1)..-1] }.join |
This file contains hidden or 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
fn mandel(e: f64, f: f64, a: f64, b: f64, its: u64, dwell: u64) -> u64 { | |
if e > 4f64 || its >= dwell { | |
its | |
} else { | |
mandel(e*e + f*f + a, 2f64*e*f + b, a, b, its + 1, dwell) | |
} | |
} | |
fn mandelbrot(a: f64, b: f64) -> u64 { | |
mandel(0f64,0f64,a,b,0,12918) // > 12918 blows the stack. LLVM not TCO :( |
This file contains hidden or 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 don't have a good name for it yet, webstorage git? | |
I want it to be kinda up-and-running for v0.1, so major sections are omitted intentionally. | |
basics: | |
config: object: key/val -> preference/state | |
{ 'branchname': 'master' } | |
tags: object: key/val -> tagname/(commit/tree/blob)hash | |
{ 'head': '' } | |
directory: object: key/val -> fullpathfilename/contents | |
{} |
This file contains hidden or 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
Documentation Best practices | |
- Consider your audience. | |
- Beginners and experts alike come to the docs. | |
- Readability. | |
- Make sure that the presentation of information aligns with the context. | |
- In a list of methods to a module, embolden the method name. | |
- make the examples syntax highlighted | |
- put a line or other visible separator between elements of a list. | |
- as a bonus, consider those browsing on different sizes of screens. |
This file contains hidden or 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
(Kuespert, 1990) | |
(Scheirer and Magoon, 2007) | |
(Scheirer and Magoon, 2007) | |
(Bowersox, 1990) | |
(Horton, et al., 2009) | |
(Horton et al., 1990) | |
(Schmidt and McDonald, 1979) | |
(Horton et al., 2009) | |
(Ali, 1981) | |
(California Division of Oil and Gas, 1998) |