Skip to main content
added 62 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
x10 := MapThread[List, {x6, List /@ list10}]
x6 := Range[Length[list10]]
list10 = {a, b, c, d, e}
x10

{{1, {a}}, {2, {b}}, {3, {c}}, {4, {d}}, {5, {e}}}

n = 5;
lst = Array[Symbol["a" <> ToString@#] &, n];
MapIndexed[{#2[[1]], {#}} &, lst]

{{1, {a1}}, {2, {a2}}, {3, {a3}}, {4, {a4}}, {5, {a5}}}

Also

MapIndexed[{#2[[1]], #} &, List /@ lst]
MapIndexed[{#2.{1}, {#}} &, lst] (* thanks: Mr.Wizard *)
MapThread[List, {Range@n, List /@ lst}]
Thread[{Range @ n, List /@ lst}]

{{1, {a1}}, {2, {a2}}, {3, {a3}}, {4, {a4}}, {5, {a5}}}

x10 := MapThread[List, {x6, List /@ list10}]
x6 := Range[Length[list10]]
list10 = {a, b, c, d, e}
x10

{{1, {a}}, {2, {b}}, {3, {c}}, {4, {d}}, {5, {e}}}

n = 5;
lst = Array[Symbol["a" <> ToString@#] &, n];
MapIndexed[{#2[[1]], {#}} &, lst]

{{1, {a1}}, {2, {a2}}, {3, {a3}}, {4, {a4}}, {5, {a5}}}

Also

MapIndexed[{#2[[1]], #} &, List /@ lst]
MapThread[List, {Range@n, List /@ lst}]
Thread[{Range @ n, List /@ lst}]

{{1, {a1}}, {2, {a2}}, {3, {a3}}, {4, {a4}}, {5, {a5}}}

x10 := MapThread[List, {x6, List /@ list10}]
x6 := Range[Length[list10]]
list10 = {a, b, c, d, e}
x10

{{1, {a}}, {2, {b}}, {3, {c}}, {4, {d}}, {5, {e}}}

n = 5;
lst = Array[Symbol["a" <> ToString@#] &, n];
MapIndexed[{#2[[1]], {#}} &, lst]

{{1, {a1}}, {2, {a2}}, {3, {a3}}, {4, {a4}}, {5, {a5}}}

Also

MapIndexed[{#2[[1]], #} &, List /@ lst]
MapIndexed[{#2.{1}, {#}} &, lst] (* thanks: Mr.Wizard *)
MapThread[List, {Range@n, List /@ lst}]
Thread[{Range @ n, List /@ lst}]

{{1, {a1}}, {2, {a2}}, {3, {a3}}, {4, {a4}}, {5, {a5}}}

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

x10 := MapThread[List, {x6, List /@ list10}]
x6 := Range[Length[list10]]
list10 = {a, b, c, d, e}
x10

{{1, {a}}, {2, {b}}, {3, {c}}, {4, {d}}, {5, {e}}}

n = 5;
lst = Array[Symbol["a" <> ToString@#] &, n];
MapIndexed[{#2[[1]], {#}} &, lst]

{{1, {a1}}, {2, {a2}}, {3, {a3}}, {4, {a4}}, {5, {a5}}}

Also

MapIndexed[{#2[[1]], #} &, List /@ lst]
MapThread[List, {Range@n, List /@ lst}]
Thread[{Range @ n, List /@ lst}]

{{1, {a1}}, {2, {a2}}, {3, {a3}}, {4, {a4}}, {5, {a5}}}