tags:

views:

207

answers:

7

Hi I have written a program which generates parameter index for 2 variables. Say, a and b in steps of 5. like this I have to do for 23 variables. So I don't want to write 23 for-loops to run, how can I make it into a single for-loop which is common for all 23 variables. I hope it can be done with an array, but i don't know how to implement it via program. Could you please help me?

Program:

int z, p
float a, b
float  a0, an, s, a1, b0, bn, b1
str var
s=5; a0=1; an=10; b0=8; bn=13     // s= steps, a0, b0= initial  value, an,bn=final value
z=0

a1=(an-a0)/s
b1=(bn-b0)/s

for (a=(a1+a0);a<=an;a=a+a1)   
for (b=(b1+b0);b<=bn;b=b+b1)
echo {z} {a} {b}  -format "%25s" >> /home/genesis/genesis-2.3/genesis/Scripts/kinetikit/dhanu19.txt
z=z+1
end
end

output : dhanu19.txt
                        0                      2.8                        9
                        1                      2.8                       10
                        2                      2.8                       11
                        3                      2.8                       12
                        4                      2.8                       13
                        5                      4.6                        9
                        6                      4.6                       10
                        7                      4.6                       11
                        8                      4.6                       12
                        9                      4.6                       13
                       10                      6.4                        9
                       11                      6.4                       10
                       12                      6.4                       11
                       13                      6.4                       12
                       14                      6.4                       13
                       15                      8.2                        9
                       16                      8.2                       10
                       17                      8.2                       11
                       18                      8.2                       12
                       19                      8.2                       13
                       20                       10                        9
                       21                       10                       10
                       22                       10                       11
                       23                       10                       12
                       24                       10                       13
A: 

Which Shell are you referring to? Declaring Arrays has some syntactical differences between zsh, bash or so...

wishi
+1  A: 

Have you considered writing either a script or a program to write the script for you? Generating shell-scripts, then running them can sometimes be a powerful solution to problems.

Vatine
A: 

fine .... i will follow d same.....

can u suggest me how to write theis progrm without repeating the loop...... its urgent for me...

devika
that is not bash
dsm
Could you please take the time to write properly ?People take some of their time to answer, it is not that long to write are and program
shodanex
And people, like myself actually take the time you should've taken to write Your text properly.
Filip Ekberg
A: 

Let's assume you write the 23 for loop. If you have 5 steps for each loop, you will end up with 5^23 parameter !

Let's suppose each loop outputs 1 byte, you still need to store something like 10^16 bytes, or ten thousand terabytes. I think you should reconsider your problem, or reformulate your question

Edit : This is not a forums (and aven in forums you can edit your post). Please edit your question instead of posting new answer, I think it is interesting

shodanex
A: 

one more thing is i dont want dis for loop to b repeated for 23 time.... i should have only 1 for loop which should automatically take the values....

i too know tat its difficult to run the for 5^23

so can u suggest me a progem in tat i should not repeat writing this for loop and should automatically take all values .... just i want for some 5 values u just leave tat 23 values....

devika
Suggestion: try breathing, counting to ten, and writing properly. Bad grammar is excusable for people that don't speak English as a mother tongue, but writing 'tat', 'u', 'progem', 'dont' is not.
Adriano Varoli Piazza
A: 

for tat 5^23 thing we will not b running in single processor

devika
A: 

I vote troll

dsm