0
|
6379 Views
|
2 Replies
|
1 Total Likes
View groups...
Share

# how to use built-in debugger in Mathematica?

Posted 10 years ago
 Hello everyone, I am now having problems with code that I had written, so I thought to use debugger,but the aid does not give me much information, then I thought I'd ask the community how work this debugger, for example if I have the following code : While[FreeQ[vistos, {{1, 2, 3}, {4, 5, 6}, {7, 8, 0}}, Infinity] && contador < 15, exa = mutacion[Last[vistos]]; For[i = 1, i <= Length@exa, i++, If[FreeQ[vistos, exa[[i]], Infinity] && FreeQ[examinados, exa[[i]], Infinity], AppendTo[aux, exa[[i]]]; ](*end if*) ];(*end for*) fmaximo = f /@ aux; buscaf = Flatten[Position[fmaximo, Max[fmaximo]]]; If[Length[buscaf] == 1, AppendTo[vistos, aux[[First[buscaf]]]]; aux = DeleteCases[aux, aux[[First[buscaf]]]]; For[k = 1, k <= Length[aux], k++, AppendTo[examinados, aux[[k]]]]; ,(* else *) For[i = 1, i <= Length[buscaf], i++, AppendTo[auxuno, aux[[buscaf[[i]]]]]; aux = DeleteCases[aux, aux[[buscaf[[i]]]]]; ];(* end for*) minimog = g /@ (auxuno /. {0 -> 9}) ; If[MemberQ[minimog, 0], Which[Length [minimog] == 1, minimog[[1]] = 1, Length [minimog] == 2, For[b = 1, b <= 2, b++, minimo[[b]] = 2], Length [minimog] == 3, For[b = 1, b <= 3, b++, minimo[[b]] = 3]]]; buscag = Flatten[Position[minimog, Min[minimog]]]; For[k = 1, k <= Length[aux], k++, AppendTo[examinados, aux[[k]]] ];(* end for*) aux = {};  how to do step by step to see the code I've written, you can do line by line? thanks in advance
2 Replies
Sort By:
Posted 10 years ago
 some idea for make this, because in documentation there is little information on how to use this command, any idea is welcome,or could recommend any site or book that will be helpful to learn how to use it. Greetings to all
Posted 10 years ago
 Before trying to debug the code, I suggest you rewrite it, replacing the For loops. For example, constructing a list with Table is much more efficient than using a For loop and AppendTo. That will make the code easier to debug.