Hello, I try tu use the software Mathematica for my studies. I do some exercices (really easy), because i loose the two first month of school. I try to implement two modules:
- Exercise 5 : Implement a Mathematica module, whose input is a string x and an integer n, to compute x^n
- Exercise 6 : Implement a Mathematica module that returns the segments of an input string x
And what I try :
(* Exercice 5 *)
puissance[x_, n_] := Module[{res, i},
res = x;
For[i = 1, i < n, i++, res = res*x;];
Return res; ]
(* Exercice 6, do the same thing that Characters *)
characters[string_] := Module[{s, i},
s = {};
For[i = 0, i < Length[string], i++, AppendTo[s, string[[i]]]; ];
Return[s]; ]
I test it with puissance[2,3] and characters["A string."] but both doesn’t work.
Hope someone will help me, and sorry for my english!