Re: simple set operations

*To*: mathgroup at smc.vnet.net*Subject*: [mg57669] Re: [mg57635] simple set operations*From*: "David Annetts" <davidannetts at aapt.net.au>*Date*: Fri, 3 Jun 2005 05:34:32 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Hi Edward, > I'm hesitant to ask these questions (because they are so > simple) but after a > 15 minute search through the docs I'm getting nowhere, so here goes: > > 1) what's the easiest way to generate a list of elements? ie: > > 'a' .. 'h' == { a,b,c,d,e,f,g,h } > > 2) Is there a quick way to check whether an element is in a set? > > if ('a' == (any('a','b','c','d')) { print "a is in a,b,c,d"; } > > The first one I see could possibly be done by 'Array', but I > don't see how - the '#' refers to the generation of numbers, > but there seems to be no corresponding 'letter' symbol. > > > As for #2, the easiest way would be through an overloading of > the '==' operator, > but again, that doesn't seem to work.. (1) you need lst = CharacterRange["a", "h"]; I'd suggest looking for it by typing ?*Range*. Of the choices, pick the most obvious. (2) depending on what you want to do, any of Cases[lst, "a"] Position[lst, "a"] MemberQ[lst, "a"] Will give you something to work with, although the last might be the "best". Any of these pop right out of the documentation. This is not C++. Rather than a "15 minute search", I suggest a longer, more detailed examination during which you might learn some Mathematica syntax and some simple functions. Regards, Dave.

**Follow-Ups**:**Re: Re: simple set operations***From:*Edward Peschko <esp5@pge.com>