MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: simple set operations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57653] Re: simple set operations
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Fri, 3 Jun 2005 05:33:37 -0400 (EDT)
  • References: <d7mk8b$c5m$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Edward Peschko wrote:
> hey all,
> 
> 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..
> 
> Thanks much for any help,
> 
> Ed
> 
Hi Ed,

Try CharacterRange["a","h"], if you really want to generate that 
particular list. There are also lots of other ways to generate lists - 
using Table, for example.

Your second question can be solved using MemberQ.

I think you may be making the mistake of trying to use Mathematica for a 
very specific task before you have mastered enough of it to get a feel 
for how it works. You do need to read the book and try the examples a 
bit before it clicks!

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Constrained Optimization
  • Next by Date: Re: Re: Complex Oddity
  • Previous by thread: Re: Re: simple set operations
  • Next by thread: Re: simple set operations