Hi guys ,(adsbygoogle = window.adsbygoogle || []).push({});

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 saylist?

thank you

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Mathematica functions

**Physics Forums | Science Articles, Homework Help, Discussion**