- #1
Physics_rocks
- 12
- 0
Hi guys ,
I'm a little new with Mathematica and I'm trying to write down some functions.
the first one is writing a functions that square the elements in a vector , recursively ,
using patterns .
so , I tried this one :
x = Range[1, 10];
sq[0,list_]=list^2;
sq[sum_,list_] := Sum[sum*sq[sum, list[n - 1]], _list]
but it isn't working . what's the problem ? 2. The second function is writing a function that sorts a list of numbers , by checking each time two numbers that are adjacent .
if I write this : sort[list_] :=
how can I tell mathematica that I want to use an actual list of numbers ? can I say list ?
thank you
I'm a little new with Mathematica and I'm trying to write down some functions.
the first one is writing a functions that square the elements in a vector , recursively ,
using patterns .
so , I tried this one :
x = Range[1, 10];
sq[0,list_]=list^2;
sq[sum_,list_] := Sum[sum*sq[sum, list[n - 1]], _list]
but it isn't working . what's the problem ? 2. The second function is writing a function that sorts a list of numbers , by checking each time two numbers that are adjacent .
if I write this : sort[list_] :=
how can I tell mathematica that I want to use an actual list of numbers ? can I say list ?
thank you