how do i repeat a func in a loop, while returning the func just before each iteration
Fri Aug 5 09:39:49 CEST 2005
Den 2005-08-05 02:22:58 skrev MEENA SELVAM <>:
> I would like to know how I can repeat the function
> nselect_cols say 10 times, each time the PId parameter
> being changed to 1,2, 3,... upto 10. But I should be
> able to get the return value as before.(return value
> of snasSessionDetailTable is what function foo
There are some nice functions that operate on lists.
You can use some of those. Just to get you thinking,
I can suggest the following way to "loop" and collect
Iters = lists:seq(1,10), % -> [1,2,3,4,5,6,7,8,9,10]
[foo(...) || I <- Iters].
fun(Iter, Acc) ->
case ... of
... -> ...;
end, InitialAcc, Iters).
I wouldn't worry too much about creating a list rather
than using a loop counter, but if your program is really
that performance-critical, you can write your own
iterator function in order to skip this step. It's a
good idea to adhere to the pattern of map and fold.
More information about the erlang-questions