1

I have have list of lists and I would like to be able to append an element to the start of each list. I am sure there must be an elegant solution.

EG: a and {{b,c},{d,e,f}} -> {{a,b,c},{a,d,e,f}}

If I want to apply a function to a list of lists I normally use @@@ however I don't know how to modify this so that it gets feed into the second argument or AppendTo.

Can someone please explain how I could achieve this?

User
  • 153
  • 1
  • 6

2 Answers2

4

Could be done with:

l = {{b, c}, {d, e, f}};
Join[{a}, #] & /@ l
{{a, b, c}, {a, d, e, f}}
paw
  • 5,650
  • 23
  • 31
4
{a, ##} & @@@ {{b, c}, {d, e, f}}
(* {{a, b, c}, {a, d, e, f}}  *)
kglr
  • 394,356
  • 18
  • 477
  • 896