1
$\begingroup$

I made the following list:

ELCo = Alphabet["English"];    
Characters[ToLowerCase[WordList[Language -> "English"]]];
Select[%, SubsetQ[ELCo, ToLowerCase[#1]] &];
LPr = Map[Sort, Map[DeleteDuplicates, %]];

This list LPr takes the English words and separates them into their characters while getting rid of duplication and capital letters. Now I make another list, basically the first five letters of the English language:

letters = Alphabet[][[1 ;; 5]];

Now I want to look at LPr and select all those words that are made of letters "a", "b", "c", "d", or "e" or the combination of them. I wonder how one would to this, I tried:

tmp = Table[SubsetQ[letters, LPr[[i]]], {i, Length[LPr]}];

and then,

Pick[LPr, tmp]

but this does not give me all those required words.

$\endgroup$
  • $\begingroup$ LPr does not contain any reference to original words anymore so what exactly is a desired output? Words or your LPr entires? $\endgroup$ – Kuba Nov 7 '18 at 10:04
  • $\begingroup$ LPr enteries that contains "a", "b", "c", "d", or "e" or the combination of them. $\endgroup$ – William Nov 7 '18 at 10:06
  • $\begingroup$ I tried different approach and I get exactly what your Pick returns. So I guess you should explain why do you think your result is not correct. $\endgroup$ – Kuba Nov 7 '18 at 10:10
  • $\begingroup$ If you run LPr you see for instance the second entry is {"a","h"} this element has "a" but was not picked. As I mentioned I need the return to contain contains "a" or "b" or "c" or "d" or "e" or the combination of them. $\endgroup$ – William Nov 7 '18 at 10:15
2
$\begingroup$

Is this what you need?

Select[ ContainsAny @ CharacterRange["a", "e"] ] @ LPr

{<<36k>>}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.