# Select strings in a list?

**URL:** <https://community.wolfram.com/t/select-strings-in-a-list/10073>\
**Category:** Questions\
**Tags:** data-science, computational-linguistics\
**Created:** [February 28, 2017, 9:26am UTC](https://community.wolfram.com/t/select-strings-in-a-list/10073 "2017-02-28T09:26:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![claudemante](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@claudemante](https://community.wolfram.com/u/claudemante)\
**Post date:** [February 28, 2017, 9:26am UTC](https://community.wolfram.com/t/select-strings-in-a-list/10073/1 "2017-02-28T09:26:39Z")

</div>

Hi!

Consider a list of strings:

```
BASES = {"A", "Aéro", "Agro-", "Algie", "Allo-", "Amphi", "Ana-", 
   "Andro", "Anthropos", "Anti-", "Arachn-", "Archi-", "Aristo", 
   "Arthr", "?", "aster", "astr-", "auto", "B", "Bacchus", "Biblio", 
   "Bio", "C", "Cardio", "Cérès", "Chaos", "Chromo", "Chrono", "Ciné",
    "Cosmo", "Crate", "cratie", "D", "Démo-", "Dia-", "Doros", "Dory",
    "Doxa", "Drome", "Dynami", "E", "Echo", "Eco", "Eros", "Ethno", 
   "Eu", "G", "Gamos", "Gaster-", "Gastro-", "Gène", "Géo", "Gér-", 
   "géronto", "gloss", "Glott", "Gonè", "Gonos", "Graphe", "Gyne", 
   "gynéco", "H", "Hermès", "Hippo-", "Histoire", "homéo", "Homo", 
   "Hydro", "Hypno", "Hygi-", "I", "Iatre", "K", "kiné", "L", "Lith", 
   "Logie", "logue", "Lys-", "lyt", "M", "Macro", "Mane", "manie", 
   "Mars", "Méduse", "Méga", "mégalo", "Méter", "Mètre", "métro", 
   "Micro", "Miso", "Mono", "Morphè", "Morphée", "Muses", "musique", 
   "Mytho", "N", "Narcisse", "Naute", "Nécro", "Nésie", "Neuro", 
   "névr", "Nome", "O", "Océan", "-oïde", "Oligo", "Olympe", "Onyme", 
   "Ops", "Ortho", "Ostéo", "P", "Pan", "Patho", "Péd/pod", "Péd", 
   "Phago", "Philo", "Phobie", "Phonè", "Phore", "Photo", "Pneumo", 
   "Pole", "Poly", "Porno", "Proto", "Psychè", "Pyr", "S", "scène", 
   "Scope", "Sèm-", "Sismo", "Sophos", "sosie", "sperm", "spore", 
   "sym", "Syn", "T", "Taur", "Techno", "Théâtre", "Théo", "Théorie", 
   "Thèque", "Therap-", "Thermo", "Titan", "V", "Vénus", "Volcan", 
   "Z", "Zoo"};

```

I merely want to get rid of single characters, but

```
Select[BASES, (StringLength[#] > 1) &]

```

does nothing, while

```
Map[(StringLength[#] > 1) &, BASES]

```

gives the expected logical list.

Why? What is the right way to use Select here?

Thanks,  
Claude

---

<div class="post-metadata">

**Author:** ![vaungureanu](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vaungureanu/32/23129_2.png) [@vaungureanu](https://community.wolfram.com/u/vaungureanu)\
**Post date:** [February 28, 2017, 9:56am UTC](https://community.wolfram.com/t/select-strings-in-a-list/10073/2 "2017-02-28T09:56:30Z")

</div>

The function Select[] selects from the list BASES strings with length greater than 1:

```
 In[2]:= Select[BASES, (StringLength[#] > 1) &]

Out[2]= {"Aéro", "Agro-", "Algie", "Allo-", "Amphi", "Ana-", "Andro", \
"Anthropos", "Anti-", "Arachn-", "Archi-", "Aristo", "Arthr", \
"aster", "astr-", "auto", "Bacchus", "Biblio", "Bio", "Cardio", \
"Cérès", "Chaos", "Chromo", "Chrono", "Ciné", "Cosmo", "Crate", \
"cratie", "Démo-", "Dia-", "Doros", "Dory", "Doxa", "Drome", \
"Dynami", "Echo", "Eco", "Eros", "Ethno", "Eu", "Gamos", "Gaster-", \
"Gastro-", "Gène", "Géo", "Gér-", "géronto", "gloss", "Glott", \
"Gonè", "Gonos", "Graphe", "Gyne", "gynéco", "Hermès", "Hippo-", \
"Histoire", "homéo", "Homo", "Hydro", "Hypno", "Hygi-", "Iatre", \
"kiné", "Lith", "Logie", "logue", "Lys-", "lyt", "Macro", "Mane", \
"manie", "Mars", "Méduse", "Méga", "mégalo", "Méter", "Mètre", \
"métro", "Micro", "Miso", "Mono", "Morphè", "Morphée", "Muses", \
"musique", "Mytho", "Narcisse", "Naute", "Nécro", "Nésie", "Neuro", \
"névr", "Nome", "Océan", "-oïde", "Oligo", "Olympe", "Onyme", "Ops", \
"Ortho", "Ostéo", "Pan", "Patho", "Péd/pod", "Péd", "Phago", "Philo", \
"Phobie", "Phonè", "Phore", "Photo", "Pneumo", "Pole", "Poly", \
"Porno", "Proto", "Psychè", "Pyr", "scène", "Scope", "Sèm-", "Sismo", \
"Sophos", "sosie", "sperm", "spore", "sym", "Syn", "Taur", "Techno", \
"Théâtre", "Théo", "Théorie", "Thèque", "Therap-", "Thermo", "Titan", \
"Vénus", "Volcan", "Zoo"}

```

The logic of the code with Map[] is to verify if the length of the string is greater than 1 or no:

```
In[3]:= Map[(StringLength[#] > 1) &, BASES]

Out[3]= {False, True, True, True, True, True, True, True, True, True, \
True, True, True, True, False, True, True, True, False, True, True, \
True, False, True, True, True, True, True, True, True, True, True, \
False, True, True, True, True, True, True, True, False, True, True, \
True, True, True, False, True, True, True, True, True, True, True, \
True, True, True, True, True, True, True, False, True, True, True, \
True, True, True, True, True, False, True, False, True, False, True, \
True, True, True, True, False, True, True, True, True, True, True, \
True, True, True, True, True, True, True, True, True, True, True, \
True, False, True, True, True, True, True, True, True, False, True, \
True, True, True, True, True, True, True, False, True, True, True, \
True, True, True, True, True, True, True, True, True, True, True, \
True, True, True, False, True, True, True, True, True, True, True, \
True, True, True, False, True, True, True, True, True, True, True, \
True, True, False, True, True, False, True}

```

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [February 28, 2017, 12:31pm UTC](https://community.wolfram.com/t/select-strings-in-a-list/10073/3 "2017-02-28T12:31:51Z")

</div>

Note that **Select** does not update the variable **BASES**. You have to explicitly update it:

```
BASES = Select[BASES, .......]

```

This is generally true in Mathematica, though there are exceptions; there are function that update the symbol for you. E.g. Increment, AppendTo, AssociateTo, KeyDromFrom, etc. and the more obvious (mostly because of the infix notation) ones: SubtractFrom, AddTo, TimesBy et cetera,

---

<div class="post-metadata">

**Author:** ![claudemante](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@claudemante](https://community.wolfram.com/u/claudemante)\
**Post date:** [February 28, 2017, 1:35pm UTC](https://community.wolfram.com/t/select-strings-in-a-list/10073/4 "2017-02-28T13:35:34Z")

</div>

Everything works very well now!

Thanks a lot
