3
$\begingroup$

I just want to add ± with Function Thread

Output that I want

{±1, ±2, ±3, ±5, ±7, ±9}

Thread[{1, 2, 3, 5, 7, 9}, "\[PlusMinus]"]
$\endgroup$
5
$\begingroup$
PlusMinus /@ {1, 2, 3, 5, 7, 9}

{±1, ±2, ±3, ±5, ±7, ±9}

If you have to use Thread you can do:

Thread @ PlusMinus @ {1, 2, 3, 5, 7, 9}

{±1, ±2, ±3, ±5, ±7, ±9}

or

Thread[Prefix[foo /@ {1, 2, 3, 5, 7, 9}, "±"]]

{±1, ±2, ±3, ±5, ±7, ±9}

Prefix[foo @ #, #2] & @@@ Thread[{{1, 2, 3, 5, 7, 9}, "±"}]

{±1, ±2, ±3, ±5, ±7, ±9}

$\endgroup$
  • $\begingroup$ What's wrong with Thread in this code here? $\endgroup$ – kile Oct 28 at 9:32
  • $\begingroup$ @kile, added alternative ways to use Thread to get the desired result. $\endgroup$ – kglr Oct 28 at 9:42

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.