Skip to main content
added 144 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
List @@ sum
(* {a, -b, c, d} *)

{a, -b, c, d}

From the docs on Apply (@@):

f@@expr replaces the head of expr by f.

So List@@sum replaces Head[sum] (that is, Plus) with List.

You can also get the same result by changing 0th Part of sum (which is its Head) to List:

sum[[0]] = List; sum

{a, -b, c, d}

List @@ sum
(* {a, -b, c, d} *)

From the docs on Apply (@@):

f@@expr replaces the head of expr by f.

So List@@sum replaces Head[sum] (that is, Plus) with List.

List @@ sum

{a, -b, c, d}

From the docs on Apply (@@):

f@@expr replaces the head of expr by f.

So List@@sum replaces Head[sum] (that is, Plus) with List.

You can also get the same result by changing 0th Part of sum (which is its Head) to List:

sum[[0]] = List; sum

{a, -b, c, d}

added 214 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
List @@ sum
(* {a, -b, c, d} *)

From the docs on Apply (@@):

f@@expr replaces the head of expr by f.

So List@@sum replaces Head[sum] (that is, Plus) with List.

List @@ sum
(* {a, -b, c, d} *)
List @@ sum
(* {a, -b, c, d} *)

From the docs on Apply (@@):

f@@expr replaces the head of expr by f.

So List@@sum replaces Head[sum] (that is, Plus) with List.

Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

List @@ sum
(* {a, -b, c, d} *)