# how to work with list as function parameter

I want to output an arrow based on input from user and I tried writing this small function to achieve this:

g[{matric}] :=
For[i = 1, i < Length[mat], i++,
Graphics[{Arrow[{{0, 0}, {matric[[1]], matric[[2]]}}]}, Axes -> True,
AspectRatio -> Automatic]]


To call it: g[mat[[1]]]

which is not working !!

I want to send array as list for example {{1,2},{3,4}} and create its output as arrow but I don't know how to break this list.

The second problem is that I can generate plots using Apply[f,arg,{1}] but it gives different plots for different elements in the list,so how can I combine them together in one plot.

I know about Show command but I just wanted to know if there is any other way too.

-
Your question was hard to read and incorrectly formatted. I edited it as best I could. Please familiarize yourself with the editing tools: mathematica.stackexchange.com/editing-help – Mr.Wizard Jan 26 '13 at 18:34
Your main issues are your syntax (you've missed the underscore in the function definition) and the use of unnecessary For loops. – Verbeia Jan 26 '13 at 22:10

Doing my best to interpret what you want:

g[matrix_] :=
Graphics[{Arrow[{{0, 0}, #}]}, Axes -> True, AspectRatio -> Automatic] & /@ matrix

g[{{1, 2}, {3, 4}}]


Notice the pattern matrix_ on the left-hand side and read Defining Functions.

To combine these properly simply use a single Graphics object with multiple Arrrows:

arrows[matrix_] := Arrow[{{0, 0}, #}] & /@ matrix

Graphics[
arrows[{{1, 2}, {3, 4}}],
Axes -> True,
AspectRatio -> Automatic
]


-
Alchemy as well as wizardry... – cormullion Jan 26 '13 at 18:46
@Mr.Wizard: thanks..that exactly what I wanted to know ! – Rorschach Jan 27 '13 at 5:31
@rafiki I'm glad I could help. It was not included in your answer but you would do well to learn about patterns and pattern matching. In this case it may be wise to match a more specific matrix before it is passed to the inner Function to make sure that the data given to Arrow is not invalid: arrows[matrix : {{_, _} ..}?(MatrixQ[#, NumericQ] &)] := -- this is a complicated pattern, somewhat intentionally: your effort to understand it may teach you several different aspects of Mathematica patterns and programming. Ask if you need help. mathematica.stackexchange.com/a/3146/121 – Mr.Wizard Jan 27 '13 at 5:46
@Mr.Wizard:thanks for suggestion on optimization...I will code more on it..thanks again :) – Rorschach Jan 27 '13 at 6:01