A
anansi
Hi,
I'm struggeling with writing a little script. It has a loop just e.g.
like this:
for x in 1..10 do
begin
puts "#{x}"
end
The userinput is the loop count (so above the userinput would have been
1..10): but now this userinput can be a fixnum like 12 or 36 or it can
be a range like 1..10 or 24..84 or an array like [23,41,35,63] and for
every 3 different input kinds the loop shall do the same.
Like in this example:
If userinput is just fixnum 11 it just prints 11 on the screen, is it a
range from 1..10 all numbers from 1..10 shall be printed and for an
array all single numbers stored in the array...you know what I mean. The
actual routine doesn't print anything it's just about I have to process
numbers which can the user give in, in three different ways and I was
wondering if it is possible to build this into one single loop and not
three different ones?
--
greets
(
)
(
/\ .-"""-. /\
//\\/ ,,, \//\\
|/\| ,;;;;;, |/\|
//\\\;-"""-;///\\
// \/ . \/ \\
(| ,-_| \ | / |_-, |)
//`__\.-.-./__`\\
// /.-(() ())-.\ \\
(\ |) '---' (| /)
` (| |) `
jgs \) (/
one must still have chaos in oneself to be able to give birth to a
dancing star
I'm struggeling with writing a little script. It has a loop just e.g.
like this:
for x in 1..10 do
begin
puts "#{x}"
end
The userinput is the loop count (so above the userinput would have been
1..10): but now this userinput can be a fixnum like 12 or 36 or it can
be a range like 1..10 or 24..84 or an array like [23,41,35,63] and for
every 3 different input kinds the loop shall do the same.
Like in this example:
If userinput is just fixnum 11 it just prints 11 on the screen, is it a
range from 1..10 all numbers from 1..10 shall be printed and for an
array all single numbers stored in the array...you know what I mean. The
actual routine doesn't print anything it's just about I have to process
numbers which can the user give in, in three different ways and I was
wondering if it is possible to build this into one single loop and not
three different ones?
--
greets
(
)
(
/\ .-"""-. /\
//\\/ ,,, \//\\
|/\| ,;;;;;, |/\|
//\\\;-"""-;///\\
// \/ . \/ \\
(| ,-_| \ | / |_-, |)
//`__\.-.-./__`\\
// /.-(() ())-.\ \\
(\ |) '---' (| /)
` (| |) `
jgs \) (/
one must still have chaos in oneself to be able to give birth to a
dancing star