Ocaml implementation advice for an algorithm on sets -


I have a problem in converting the following algo into the ocm. I used the set to implement this algorithm. Make (String) <

This is really .. Help will be highly appreciated

    for all n, [n] = out [N] = Ø w = {set of all nodes} empty n = w.pop () outside [n] = ∪ n '∈ succ [n] in [n [n] = use [n] ∪ (outside [ N] - DIF [N]] If changes in [N], for all predecessors, w.push (M) and  [N] = Ex [n] = Ø w = {all set in n / pre> 

  in all nodes Repeat from empty n = w.pop () use [n] = [n] ∪ in [n] = [n] [n] in [n] = ∪ n '∈ succ [n] [n] (outside [n] - def [n ]) If the change is in [n], then for all the predecessors, w.push (m) end  

It is difficult for me to tell that in fact here What is happening is that I think there are some alignment problems with your text - until the empty two Nights should repeat next 5lines, right? And how and how to work out, they seem like arrays for me? Apart from those shortcomings, I will follow some common rules that I have adopted.

I have to translate numerical methods into functional languages ​​in C and Fortran algorithms and I have some suggestions for you.

0) Define the datatypes being used. This will really help you in the next step (after spoiler: searching for functional creation) After detecting the datatype, you can more accurately define functional constructs that you will eventually apply.

1) View folders, recursive and maps for functional structures, and when to use them. For example, I for all predecessors is one times (unsure that it is folded in a tree or a list, but none, one-fold). While loops are a good place for recursion - but do not worry about making tail calls, you can modify the parameters later to follow these requirements. Do not worry about being 100% pure. Remove enough impure construction (reference or array) to feel algorithm in a functional way.

2) Write the any part of the algorithm which you can do. Leave blank work, add dummy value, and just apply what you know - then you can ask better, more informed questions.

3) It is a good opportunity to write it again that you have left some functional creation or used an array or reference, where you now feel that you can use a list or You can set or pass an accumulator. You may have defined a list, but later you feel that you can not access it randomly (okay, it will be very harmful), or it should move forward and backward (one for a zip good place). Either way, when you finally get it, you will know, and your face should have a grin of ears-to-ears.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -