[erlang-questions] Programming a recursive function that executes n times

Ahmed Omar spawn.think@REDACTED
Thu Oct 21 21:58:19 CEST 2010


ah Sorry i missed the title "Recursive" !

On Thu, Oct 21, 2010 at 9:18 PM, Ahmed Omar <spawn.think@REDACTED> wrote:

> Time consuming sounds a bit vage , do you want it to be "busy" during that
> time? or just "idle"?
> - To consume time just "waiting", you can user timer:sleep/1 , or do a
> receive
> - To repeat a task for N of times you can , lists:foreach(fun(_)-> test_mnesia:busqueda(cars)
> end, lists:seq(1,N)).
>
> Hope you found what you need
>
> On Thu, Oct 21, 2010 at 6:22 PM, Allan Wegan <allanwegan@REDACTED>wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> > I want to simulate a time consuming task on Erlang, let's say I want
>> to execute 10 000 times the above line:
>> >
>> > test_mnesia:busqueda(cars).
>> >
>> > How can I accomplish this on Erlang?
>>
>> Try:
>> fun test() ->
>> Test_fun = fun (F, 0) -> 'undefined'; (F, N) ->
>> test_mnesia:busqueda(cars), F(F, N - 1) end,
>> Test_fun(Test_fun, 10000)
>> .
>>
>> - --
>> Allan Wegan
>> Jabber: allanwegan@REDACTED
>> ICQ:    209459114
>> Phone:  +49 40 6732962
>> Schöneberger Straße 60, 22149 Hamburg
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v2.0.14 (MingW32)
>>
>> iQEcBAEBAgAGBQJMwGjGAAoJENm5axHh7AcxkQ4IALfcClXsAdPZXos3cEHDgVCB
>> SOtjB9evtY8FSTC/yx0d3iHcyD2qIDUWv0ekqNEBr9MR21KS5eT6NxusHZTS+xk6
>> yZXpW9ja9nOAiDkjjvLBVBx6O3V+0JZ2Xgx1L1UuXjq0LfBbpbTUgbIBOODk7Z01
>> oDyv7wTo/igjxhrMcHSMAlGIoXAEmAzPanfq3zKxJXQPYRYvc7Uh5MMZAQp8F62f
>> +MMGUYCnlGonXA4rSTWCF6lathY+r/DfLgcehJu4GDxAM9q6k1yVVzLQTCUahKY6
>> D26oWvisWZoqUR8VANiW9xdZuYKPFee6PIRatRITnUVEass5gyQbUKRJCppBE4Q=
>> =o1Lg
>> -----END PGP SIGNATURE-----
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>>
>>
>
>
> --
> Best Regards,
> - Ahmed Omar
> http://nl.linkedin.com/in/adiaa
> Follow me on twitter
> @spawn_think <http://twitter.com/#!/spawn_think>
>
>


-- 
Best Regards,
- Ahmed Omar
http://nl.linkedin.com/in/adiaa
Follow me on twitter
@spawn_think <http://twitter.com/#!/spawn_think>


More information about the erlang-questions mailing list