1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2002-12-19 20:56:37 +00:00
parent c37140b351
commit 02a8d06fa8
6 changed files with 13 additions and 23 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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