世界杯至今为止的比赛都看了,不过很多比赛都是在三心二意的看,凌晨的比赛则是在半睡半醒间。
Ruby的国际化这章,对UTF-8终于有了个比较全面的认识。也了解了一下
jcode库。
从
执行数值计算,学到了更多的东西。
数字原来可以这么表示。
1_048_576 # 和 1048576 相同
sprintf也有一个类似的方法。
str = 345.6789
str = sprintf("%5.1f", x) # "345.7"
str = "%5.1f" % x # "345.7"
矩阵Matrix。(非标准库NArray很有名)
m = Matrix[[1,2,3],[4,5,6],[7,8,9]]
有理数和复数
x = Rational(1,3) # 1/3
y = Complex(3,5) # 3+5i
使用memoize缓存函数结果,也是非标准库。作者居然在这节实现了一个简单的遗传算法。
require 'memoize'
indclude Memoize
def zeta(x, y, z)
lim = 0.0001
gen = 0
loop do
gen += 1
p, q = x + y/2.0, z + y/2.0
x1, y1, z1 = p*p*1.0, 2*p*q*1.0, q*q*0.9
sum = x1 + y1 + z1
x1 /= sum
y1 /= sum
z1 /= sum
delta = [[x1, x], [y1, y], [z1, z]]
break if delta.all? {|a, b| (a-b).abs < lim}
x, y, z = x1, y1, z1
end
gen
end
g1 = zeta(0.8, 0.1, 0.1)
memorize(:zeta) # 存在内存中
g2 = zeta(0.8, 0.1, 0.1)
memorize(:zeta, "z.cache") # 存在内文件中
g3 = zeta(0.8, 0.1, 0.1)
分享到:
相关推荐
The Ruby Way(第2版) <br>The Ruby Way assumes that the reader is already familiar with the subject matter. Using many code samples it focuses on "how-to use Ruby" for specific applications, either ...
The Ruby Way 第三版(英文版),全书22章,书中包含600多个按主题分类的示例。每个示例都回答了“如何使用Ruby来完成”的问题。 ——Ruby on Rails之父David Heinemeier Hansson倾力推荐!
the ruby way 2ed. the ruby way 2ed.
《The Ruby Way 第二版》...“《The Ruby Way (第2版)中文版》在阐述元编程(metaprogramming)等方面尤其出类拔萃,而元编程是Ruby最引人注目的方面之一。” ——Ruby on Rails之父David Heinemeier Hansson倾力推荐!
the ruby way the ruby way
11.5 时间日期the ruby way.rar
内含以下4个文档: 1、Addison.Wesley.The.Ruby.Way.2nd.Edition.Oct.2006.chm 2、O'Reilly.Learning.Ruby.May.2007.chm 3、Programming Ruby 2e.pdf 4、ruby中文文档.chm
TheRubyWay(Ruby之道)英文版 Addison.Wesley.The.Ruby.Way.2nd.Edition.Oct.2006.pdf
The Ruby Way(处理文件和目录)
the ruby way,ruby 入门经典
Addison Wesley The Ruby Way 2Nd Edition Oct 2006.pdf(英文版)
关于ruby的电子书,CHM格式 《The ruby way》这本书例子比较多!
Ruby is a fully object-oriented, dynamic scripting language which borrows some of the best features from LISP, Smalltalk, Perl, CLU, and other languages, and blends them into a harmonious whole. The ...
Shaw is the author of the popular online books Learn Python the Hard Way, Learn Ruby the Hard Way, and Learn C the Hard Way. He is also the creator of several open source software projects like ...
The Ruby Programming Language 2008 (English)包含精致书签,可复制文档内容,结合中文版可以对ruby相关语法进行学习,个人感觉ruby很大,死读书不如结合一些实例进行了解更好,本手册更适合遇到问题再来翻阅
实在是没有中文资料,就跟一哥们搞了些英文资料,有兴趣的就学学吧.
2008新作,是英文版啊. Ruby的作者的作品, part.1 一共两个压缩包 Part 2在http://download.csdn.net/source/424089