> One major drawback for this is that it won't work out of the box for
> values like calc([0.1,0.1,0.8])   That is, call def a 10% of the time,
> def  b 10% of the time, def c 80% of the time.  It seems input values
> have to be unique.

Here's something that does the job, but I can't help thinking that if
I had more CS background, it could be a lot more elegant.  Seems like
a classic recursion problem:


a=20
b=20
c=10
d=0
e=40
f=10

a_range = [1..a]
b_range = [(a+1)..(b+a)]
c_range = [(a+b+1)..(a+b+c)]
d_range = [(a+b+c+1)..(a+b+c+d)]
e_range = [(a+b+c+d+1)..(a+b+c+d+e)]
f_range = [(a+b+c+d+e+1)..(a+b+c+d+e+f)]

puts a_range
puts b_range
puts c_range
puts d_range
puts e_range
puts f_range
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to