Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 186

How to select elements from a list of strings?

$
0
0
info = {"so96", "se35"};toplanti = {{"ag03", "sr93"}, {"ag03", "ma16"}, {"ma21", "mi06"}, {"ma21", "ma27"}, {"ma21", "so96"}, {"ma21", "si63"}, {"ma30", "mi06"}, {"ma30", "se39"}, {"ma30", "ma26"}, {"ss88", "st51"}, {"ss88", "st52"}, {"ss88", "ma25"}, {"ss88", "si63"}, {"ss88", "sr93"}, {"ss88", "ma26"}, {"ss88", "ma22"}, {"sr93", "ma16"}, {"sr93", "ma12"}, {"sr93", "ma28"}, {"sr93", "se35"}, {"sr93", "ma25"}, {"sr93", "se39"}, {"sr93", "ma22"}, {"sr93", "st50"}, {"sr93", "ma33"}, {"sr93", "mi08"}, {"sr93", "ma30"}, {"so96", "mi06"}, {"mi09", "ma27"}, {"mi09", "st53"}, {"ma26", "st52"}, {"ma26", "st50"}, {"st51", "se85"}, {"si63", "ag03"}, {"si63", "se85"}, {"se85", "ma28"}, {"ma16", "si61"}, {"ma16", "st53"}, {"ma16", "se85"}, {"ma16", "mi08"}, {"mi06", "si63"}, {"mi08", "se85"}, {"ma12", "si63"}, {"ma15", "si63"}, {"ma22", "si63"}, {"ma22", "se85"}, {"ma23", "se85"}, {"ma23", "si63"}, {"ma25", "si63"}, {"ma25", "se85"}, {"ma27", "si63"}, {"ma27", "se85"}, {"ma28", "si63"}, {"ma33", "si63"}, {"ma33", "se85"}, {"se39", "si63"}, {"st50", "se85"}, {"st50", "si63"}, {"st52", "se85"}, {"st52", "si63"}};sec = Select[toplanti, IntersectingQ[#, info] &]

This generates a list of lists:

{{"ma21", "so96"}, {"sr93", "se35"}, {"so96", "mi06"}}

This result is not what I want.

My objective is to select all the pairs from toplanti that start with the elements in info. Therefore, the only correctly chosen pair above is {"so96", "mi06"}.


Viewing all articles
Browse latest Browse all 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>