Infinity = 1.0/0
def read_data(num_in = nil, num_out = nil, num_lines = Infinity)
unless inFile.nil?
@count = 0
File\.foreach\(inFile\) do |line|
# def read_data(num_in, num_out, num_lines)
break if @count >= num_lines
arr = line\.chomp\.split\(','\)
float\_array = arr\.map \{ |x| x\.to\_f \}
# def read_data(num_in, num_out)
if num_in and num_out
arr_in =
arr_out =
for i in 0...num_in
arr_in << float_array[i]
end
in\_data\.push\(arr\_in\)
for j in num\_in\.\.\.\(num\_in\+num\_out\)
arr\_out << float\_array\[j\]
end
out_data.push(arr_out)
elsif num_in or num_out
raise ArgumentError
else
# def read_data
file_data.push(float_array)
end
@count = @count \+ 1
end
file\_data
end
end
···
On Thu, Jan 27, 2011 at 9:52 PM, Ted Flethuseo <flethuseo@gmail.com> wrote:
David Masover wrote in post #978005:
On Thursday, January 27, 2011 02:55:24 pm Ted Flethuseo wrote:
Ah that's too bad... I knew I could put some default values for x and y
and z.. getting the same effect sort of...but this isn't a solution if the methods that I want to "overload" (I
call it
overload, not sure what the proper term should be) are
completely different, and are not differentiated simply by different
values.If they're not differentiated by different values, how were you
expecting
overloading to work? If the problem is that you need the behavior to be
different, I think default values still work -- for example:def sum_or_inverse a, b=nil
if b.nil?
-a
else
a+b
end
endBut I don't really know what you were asking.
I agree with Jesús. We need more details.Ok.. I didn't want to post so much code but you asked for it. I am
trying to read a file, with a number of different methods. The methods
allow you to interpret the file as an input and output matrices, input
only or both but with only a number of rows.