Erlang/OTP Forums

Author Message

<  Trapexit Forums  ~  Error in example "Random Numbers Biased"

ahmet sevki
Posted: Tue May 10, 2011 8:25 pm Reply with quote
Joined: 09 May 2011 Posts: 7 Location: USA
Example in:
http://www.trapexit.org/Random_Numbers_Biased

As it is the current example doesn't
work in release Erlang R14B02 (erts-5.8.3) [smp:2:2] [rq:2]
[async-threads:0]

There is a logic problem in one of the pattern matching.
"case This#dist_state.state of " tries to match 'true' which is never set. Instead it is set to a floating point number, which is used later to calculate the new value. I am suspecting that in the older releases any floating number was being cast into true?? But with the R14B02 release that I am working with the example doesn't work.

I fixed it in the attached code (I named it as module tut10), pls see the comments in attached file.

I named the file tut10.erl

I just started w./ erlang so can someone double check the code and the changes I made?



tut10.erl
 Description:
pattern starting with " case This#dist_state.state of" is changed.

Download
 Filename:  tut10.erl
 Filesize:  2.04 KB
 Downloaded:  340 Time(s)

View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum