How can I create a user defined function to map two variables into a vector on the prime?

i.e. something along the lines of:

defvect(angle, magnitude):=[magnitude*cos(angle), magnitude*sin(angle)]

but that works.

OK so I solved my task by making it a program

Code:

EXPORT DEFVECT(mag,ang)

BEGIN

RETURN([mag*COS(ang),mag*SIN(ang)]);

END;

But that really feels like tapping an exposed nail head with a sledge hammer. Is there no way to return a vector or matrix from the 'Define' window?

Here is a way to return a vector from a User Defined function (a bit cumbersome but it seems to work…):

[

attachment=2273]

But in your case it's much more simpler to use the existing rectangular_coordinates() function:

[

attachment=2274]

By using a list first, try this function, which will create the variables M0, mag, and ang. (Uncheck the [M0]):

[Shift] [Define]

NAME: defvect

Function: M0:=list2mat({mag*COS(ang), mag*SIN(ang)})

M0:[ ] mag:[ ✔] ang:[ ✔]

oops, I see Didier beat me to it!

Thanks to both of you for the solution and pointing out the built in function.