Skip to main content
added 1 character in body
Source Link
ubpdqn
  • 64.9k
  • 3
  • 65
  • 154

Using Association and Merge

islis = {{"ab", 2, "c", 3}, {"d", 3, "e", 4}, {"ac", 5, "f", 6}, {"c", 7,
     "d", 8}, {"ad", 9, "c", 10}};
"a" /. Merge[Association[StringTake[#[[1]], 1] -> #] & /@ lis, 
  Identity]

gives:

{{"ab", 2, "c", 3}, {"ac", 5, "f", 6}, {"ad", 9, "c", 10}}

Using Association and Merge

is = {{"ab", 2, "c", 3}, {"d", 3, "e", 4}, {"ac", 5, "f", 6}, {"c", 7,
     "d", 8}, {"ad", 9, "c", 10}};
"a" /. Merge[Association[StringTake[#[[1]], 1] -> #] & /@ lis, 
  Identity]

gives:

{{"ab", 2, "c", 3}, {"ac", 5, "f", 6}, {"ad", 9, "c", 10}}

Using Association and Merge

lis = {{"ab", 2, "c", 3}, {"d", 3, "e", 4}, {"ac", 5, "f", 6}, {"c", 7,
     "d", 8}, {"ad", 9, "c", 10}};
"a" /. Merge[Association[StringTake[#[[1]], 1] -> #] & /@ lis, 
  Identity]

gives:

{{"ab", 2, "c", 3}, {"ac", 5, "f", 6}, {"ad", 9, "c", 10}}

Source Link
ubpdqn
  • 64.9k
  • 3
  • 65
  • 154

Using Association and Merge

is = {{"ab", 2, "c", 3}, {"d", 3, "e", 4}, {"ac", 5, "f", 6}, {"c", 7,
     "d", 8}, {"ad", 9, "c", 10}};
"a" /. Merge[Association[StringTake[#[[1]], 1] -> #] & /@ lis, 
  Identity]

gives:

{{"ab", 2, "c", 3}, {"ac", 5, "f", 6}, {"ad", 9, "c", 10}}