1
$\begingroup$

Is there a short hand for adding a value to a vector? E.g.,

{.01,Range[.5,5,.5],10}

gives

{0.01, {0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5.},10}

but what I really want is

{0.01, 0.5, 1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5.,10}
$\endgroup$

closed as off-topic by C. E., m_goldberg, Coolwater, Henrik Schumacher, MarcoB Jan 28 '18 at 5:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – C. E., m_goldberg, Coolwater, Henrik Schumacher, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Prepend[Range[.5,5,.5],.01]? $\endgroup$ – kglr Jan 26 '18 at 4:10
  • $\begingroup$ I suppose... seems strange there's not a "expand" shorthand of sorts $\endgroup$ – Cody G Jan 26 '18 at 4:12
  • $\begingroup$ E.g., {.01,...Range[.5,5,.5],10} $\endgroup$ – Cody G Jan 26 '18 at 4:12
  • 3
    $\begingroup$ The operation you're looking for is Apply[Sequence]. It has no input alias. Best you can really get is Sequence @@ $\endgroup$ – b3m2a1 Jan 26 '18 at 4:17
  • 1
    $\begingroup$ you can do Flatten@{.01, Range[.5, 5, .5], 10, Range[5]}; or, to save a character, ## & @@@ {.01, Range[.5, 5, .5], 10, Range[5]}. $\endgroup$ – kglr Jan 26 '18 at 4:18

Browse other questions tagged or ask your own question.