1
$\begingroup$

My task is something like this:

PrependTo[Evaluate[Table[{x, Sin[x]}, {x, 0.1, 2 \[Pi], 0.1}], {0., 1.}]]

where I tried also skipping the

Evaluate 

and I get a

PrependTo::rvalue:

error.

If I do:

a = Table[{x, Sin[x]}, {x, 0.1, 2 \[Pi], 0.1}];
b = PrependTo[b, {0., 0.}];

everything works fine. I want it to be a part of a big code, so doing it in one line without defining the first list separately would speed up the program. And I don't need the first list, only the second one, so why should I store both?

How can I deal with this problem?

Edit: The case is to make

Join[{{0., 0.}}, Table[{x, Sin[x]}, {x, 0.1, 2 \[Pi], 0.1}], 1]

but are there other, maybe better, solutions?

$\endgroup$
6
$\begingroup$

PrependTo is probably not what you are seeking for, because it needs a variabl which is assigned. I guess you want Prepend

Prepend[Table[{x, Sin[x]}, {x, 0.1, 2 \[Pi], 0.1}], {0., 1.}]
$\endgroup$
  • $\begingroup$ Thank you, that's what I was thinking about. $\endgroup$ – corey979 Mar 16 '13 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.