[erlang-questions] Newbie Question, brute force method.
Bangon Kali
bangonkali@REDACTED
Fri Sep 2 12:21:49 CEST 2011
Hi guys! I'm a newbie here. I'm very new to Erlang. Although I've been
studying well im having problems converting sequential programs in to
Recursive ones. I'm using this book Pragmatic Programming Erlang (2007).
I've been half way in my readings. Although I kinda get some of the pieces
along the way, I have been having problems with some parts. Generally on how
to convert very sequential programs in to recursive ones.
In order to test my knowledge in Erlang I have setup a challenge to myself,
by converting http://j.mp/r8hS3C this program that I've made in several
other languages (C, Python, Javscript) into Erlang. This program basically
just Finds the set of Realistic Resistors and Capacitor for an Astable 555
IC implementation.
The program uses the brute force technique by testing all possible values
and calculating the frequency. It will then compare the percentage
difference between the previous frequency to the current frequency, if the
new frequency is lower, then it will save the R1, R2, and C combinations. It
will do in a loop until all possible realistic values of R1, R2 and C are
tested.
a simple pseudo code might be easier to understand
where:
get_error returns the percentage difference between 2 values
get_frequency returns the frequency of an R1, R2 and C combination
f_desired is the frequency target
the complete source code for this program (in some languages) are available
on this bitbucket site: http://j.mp/r8hS3C
i'm not asking for a direct translation in to erlang, but if you can easily
make one, then that would really help, since i can study it directly and
somehow learn to implement erlang on some other problems with the same
situation such as this.
here are some of my attempts, but im at loss at how to continue this.
i hope you guys can help. just some clue, if i may ask. thanks!
--
View this message in context: http://erlang.2086793.n4.nabble.com/Newbie-Question-brute-force-method-tp3785742p3785742.html
Sent from the Erlang Questions mailing list archive at Nabble.com.
More information about the erlang-questions
mailing list