Re: Newbie question: Using expanded Boolean Criteria w the Select funtion
- To: mathgroup at smc.vnet.net
- Subject: [mg111645] Re: Newbie question: Using expanded Boolean Criteria w the Select funtion
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sun, 8 Aug 2010 07:23:55 -0400 (EDT)
On 8/7/10 at 1:30 AM, Scotty at yahoo.com (Scotty) wrote: >To find all 6 letter words where the 1st & last characters are not >equal, the following works & returns a list of 9921 words >l1 = Select[DictionaryLookup[], StringLength[#] == 6 & ]; Length[l1] >l2 = Select[l1, StringTake[#, 1] != StringTake[#, -1] & ]; >Length[l2] >10549 >9921 >What does it take to get this single boolean expression working w >select??? i.e. How can it be done in 1 step?? >Select[DictionaryLookup[], >{StringLength[#] == 6} && {StringTake[#, 1] != StringTake[#, -1]} & = ] Don't use curly braces to group things. Those are used to define lists. To group things use parenthesises. That is: In[2]:= Length@ Select[DictionaryLookup[], (StringLength[#] == 6) && (StringTake[#, 1] != StringTake[#, -1]) &] Out[2]= 9921