|
Bryan |
Software engineer in the wireless communications industry. I’m interested in mobile communications networks, large-scale software projects, and anything related to C++. I’m just getting my feet wet with Erlang.
Posts by Bryan
|
12 Sep 2008, 05:08
Bryan (6 posts) |
I’m still trying to wrap my head around Erlang and functional programming, and I am very much stuck with looping. I have some code in a CRC algorithm that I want to write in Erlang. The C code is as follows:
The inner logic of the loop is easy enough in Erlang:
However, I am not sure how to do the loop mechanics. I must use the updated value of X in the next iteration of the loop. Do I need to append the output of each iteration to a list, and then at the end take the tail of the list for my result? Is there an easier way to do this? |
|
13 Sep 2008, 15:36
Bryan (6 posts) |
Thank you very much for walking me through the thought process and explaining the mechanics in such detail. It is all much clearer now, thank you! |
|
15 Sep 2008, 04:59
Bryan (6 posts) |
I’m very much embarrassed to say this, but I have a syntax problem and I cannot figure out where it is. The code is as follows:
The output of the Erlang interpreter is as follows: 38> c(crc16). ./crc16.erl:16: syntax error before: ')' ./crc16.erl:2: function calculate/1 undefined error I would greatly appreciate any hints. I’m sure I’ve made a very elementary mistake but I just can’t seem to find it. Thank you for your time and help! |
|
16 Sep 2008, 01:28
Bryan (6 posts) |
Thank you very much for your help. It sure was the “end” for the fun that I missed. |
|
24 Sep 2008, 10:16
Bryan (6 posts) |
Is there an easy way to prove that a given solution works? Being new to Erlang I’m not sure how I’d generate a testbench that would prove a solution works. |
|
24 Sep 2008, 10:22
Bryan (6 posts) |
Alain, Thanks for sharing your solution, it is very elegant. I hope eventually I’ll be able to adjust my “gears” to functional thinking. |
6 posts
