Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: Mapping a scalar against a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28400] Re: Mapping a scalar against a list
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 16 Apr 2001 03:28:51 -0400 (EDT)
  • References: <9bb7q7$969@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mark,

We can ignore, or turn off, the message generated below.

In[6]:=
Thread[StringMatchQ["ab",{"aab", "bb", "ab"}]]

StringMatchQ::string: String expected at position 2 in \
StringMatchQ[ab,{aab,bb,ab}].

Out[6]=
{False,False,True}

Here's another way of avoiding the message:

In[7]:=
Block[{StringMatchQ},Thread[StringMatchQ["ab",{"aab", "bb", "ab"}]]
  ]

Out[7]=
{False,False,True}

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Mark Coleman" <mcoleman at bondspace.com> wrote in message
news:9bb7q7$969 at smc.vnet.net...
> Greetings,
>
> I've recently been working on a problem involving determining whether a
> given string is contained in a large list of strings. Ideally, the problem
> would be solved by a 'Map' function 'M' defined as
>
> M[f,{a,{b,c,d,...}}]= {f[a,b],f[a,c],f[a,d],...}
>
> For this particular problem, {a} is a stiring, and {b,c,d,...} is a list
of
> strings, then f=StringMatchQ. The function 'M' does not appear to match up
> against the standard Mathematica list functions. My current solution is to
'expand'
> the list {a} into a list of size Dimension[{b,c,d,...}] and then use
> MapThread. But this does not seem particularly elegant, especially if the
> list is very large.
>
> Any suggestions would be most welcome!
>
> Thanks,
>
> Mark
>
>




  • Prev by Date: Re: Mapping a scalar against a list
  • Next by Date: Re: Nested Lists
  • Previous by thread: Re: Mapping a scalar against a list
  • Next by thread: RE: How do I see justification of solution?