зеркало из https://github.com/github/ruby.git
Improve.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c37140b351
Коммит
02a8d06fa8
|
@ -2,9 +2,9 @@
|
|||
# usege: ruby occur2.rb file..
|
||||
freq = {}
|
||||
while gets()
|
||||
for word in $_.split(/\W+/)
|
||||
for word in split(/\W+/)
|
||||
begin
|
||||
freq[word] = freq[word] + 1
|
||||
freq[word] += 1
|
||||
rescue NameError
|
||||
freq[word] = 1
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
k, a, b, a1, b1 = 2, 4, 1, 12, 4
|
||||
|
||||
while TRUE
|
||||
loop do
|
||||
# Next approximation
|
||||
p, q, k = k*k, 2*k+1, k+1
|
||||
a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
|
||||
|
|
|
@ -8,22 +8,23 @@ w = 20.0 # distance between eyes
|
|||
h =1.0 # distance from screen and base plane
|
||||
d = 0.2 # z value unit
|
||||
ss="abcdefghijklmnopqrstuvwxyz0123456789#!$%^&*()-=\\[];'`,./"
|
||||
rnd = srand()
|
||||
rnd = srand() # You don't actually need this in ruby - srand() is called
|
||||
# on the first call of rand().
|
||||
|
||||
while gets()
|
||||
# print($_)
|
||||
xr = -hdw; y = h * 1.0; maxxl = -999
|
||||
s = "";
|
||||
s = ""
|
||||
while xr < hdw
|
||||
x = xr * (1 + y) - y * w / 2
|
||||
i = (x / (1 + h) + sw / 2)
|
||||
if (1 < i && i < $_.length);
|
||||
if (1 < i && i < $_.length)
|
||||
c = $_[i, 1].to_i
|
||||
else
|
||||
c = 0
|
||||
end
|
||||
y = h - d * c
|
||||
xl = xr - w * y / (1 + y);
|
||||
xl = xr - w * y / (1 + y)
|
||||
if xl < -hdw || xl >= hdw || xl <= maxxl
|
||||
tt = rand(ss.length)
|
||||
c = ss[tt, 1]
|
||||
|
@ -36,14 +37,3 @@ while gets()
|
|||
end
|
||||
print(s, "\n")
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5,4 +5,4 @@ system(cmd)
|
|||
e = Time.now
|
||||
ut, st, cut, cst = Time.times.to_a
|
||||
total = (e - b).to_f
|
||||
printf STDERR, "%11.1f real %11.1f user %11.1f sys\n", total, cut, cst
|
||||
STDERR.printf "%11.1f real %11.1f user %11.1f sys\n", total, cut, cst
|
||||
|
|
|
@ -5,7 +5,7 @@ path = ENV['PATH'].split(File::PATH_SEPARATOR)
|
|||
for dir in path
|
||||
if File.directory?(dir)
|
||||
for f in d = Dir.open(dir)
|
||||
fpath = dir+"/"+f
|
||||
fpath = File.join(dir, f)
|
||||
if File.file?(fpath) && (File.stat(fpath).mode & 022) != 0
|
||||
printf("file %s is writable from other users\n", fpath)
|
||||
end
|
||||
|
|
|
@ -8,11 +8,11 @@ addr = gs.addr
|
|||
addr.shift
|
||||
printf("server is on %s\n", addr.join(":"))
|
||||
|
||||
while TRUE
|
||||
loop do
|
||||
Thread.start(gs.accept) do |s|
|
||||
print(s, " is accepted\n")
|
||||
while s.gets
|
||||
s.write($_)
|
||||
while line = s.gets
|
||||
s.write(line)
|
||||
end
|
||||
print(s, " is gone\n")
|
||||
s.close
|
||||
|
|
Загрузка…
Ссылка в новой задаче