i have this code:
Minimum[numbers_] :=
{
minimum = numbers[[1]];
For[i = 1, i <= Length[numbers], i++,
If[minimum > numbers[[i]],
minimum = numbers[[i]],
minimum = minimum;
]
]
Return[minimum];
}
Minimum[{1, 2, 3, 4, 5, 6, 7}]
Why i always get a NULL value from this function?(Out[] = {Null})
Thank you very much.
CompoundExpressionand suppresses the output if it is not followed by another command, because it then assumes that the "other command" isNone. – Jens Mar 12 '15 at 18:50{}wrapping your "function" code are a basic error (unless you intend to output a one element list..). Make those()and terminate theForwith a semicolon and this works (not pretty but it works.. ) – george2079 Mar 12 '15 at 19:29Fold[If[# < #2, ##] &, {4, 8, 1, 5, 3, 9, 5}]– Mr.Wizard Mar 12 '15 at 20:57