[erlang-questions] 2 questions: Guards & Variables

Nils Müllner nils.muellner@REDACTED
Wed Nov 15 13:32:15 CET 2006

i currently implement depth first search tree for distributed 
fault-tolerance measurement. the enclosed module is just one part.

to run the attached file
   1. enter sample matrix:
       Matrix = [{a,0.1,pid,[{b,0.1},{c,0.1},{d,0.1}], cur, 
stab},{b,0.1,pid,[{e,0.1},{f,0.1}], cur, stab},{c,0.1,pid,[{g,0.1}], 
cur, stab},{d,0.1,pid,[{h,0.1},{i,0.1}], cur,    stab},{e,0.1,pid,[], 
cur, stab},{f,0.1,pid,[], cur, stab},{g,0.1,pid,[], cur, 
stab},{h,0.1,pid,[], cur, stab},{i,0.1,pid,[], cur, stab}].
   2 compile
   3. run

1. in line 81 (in function rip_neighbours the line Bool = 
lists:member(First, Raw_Neighbours),) i have to assign the desired value 
to variable Bool. if i used it directly in the if     following clause i 
get a guard error. why do i have to use this work-araound and why is it 
not possible to directly use
           lists:member(First, Raw_Neighbours) ->
   as guard?
2. in the end, everything is correctly assigned into variable 
Return_Value in line 50. but when i return this value, everything gets 
corrupted... why?

further information:
*the tree built can be seen in http://www.mue-tech.com/DFS.png
*the desired result is written to variable Return_Value and printed 
before crash
*the matrix has the following structure
*the function gets a matrix where all current values are arbitrary. to 
run the simulator (super module), this module has to assign the stable 
path (Stable_Value) for each node and finally add the list, in which the 
nodes will be visited by dfs-algorithm (compare: 
http://en.wikipedia.org/wiki/Depth-first_search )

thanks in advance for any help...

kind regards
nils müllner
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dfs_init_matrix.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20061115/7057964c/attachment.ksh>

More information about the erlang-questions mailing list