Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6365 > unrolled thread

Pattern to match element in nested list

Started byJasonE <ebaughjason@gmail.com>
First post2011-11-11 09:59 +0000
Last post2011-11-12 12:40 +0000
Articles 4 — 4 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Pattern to match element in nested list JasonE <ebaughjason@gmail.com> - 2011-11-11 09:59 +0000
    Re: Pattern to match element in nested list Ray Koopman <koopman@sfu.ca> - 2011-11-11 12:33 +0000
    Re: Pattern to match element in nested list Peter Breitfeld <phbrf@t-online.de> - 2011-11-12 12:33 +0000
    Re: Pattern to match element in nested list "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-11-12 12:40 +0000

#6365 — Pattern to match element in nested list

FromJasonE <ebaughjason@gmail.com>
Date2011-11-11 09:59 +0000
SubjectPattern to match element in nested list
Message-ID<j9irl5$8ee$1@smc.vnet.net>
This is pretty basic and I am surprised at myself that I can't figure
this out, but I guess its where I am at.

What pattern would pick students with a score of zero out of this list
(which is {"student", score}):

{{"Smith, Tim",3},{"Wheres,Waldo",4},{"Muffet, LilMiss",0},{"Brown,
Charlie",1},{"X, Doctor",0}}



Thanks,
Jason

Contact: jasonebaugh@jasonebaugh.info
Blog: www.jasonebaugh.info/wordpress/
LinkedIn: www.linkedin.com/in/jasonebaugh

[toc] | [next] | [standalone]


#6387

FromRay Koopman <koopman@sfu.ca>
Date2011-11-11 12:33 +0000
Message-ID<j9j4nb$a71$1@smc.vnet.net>
In reply to#6365
On Nov 11, 1:59 am, JasonE <ebaughja...@gmail.com> wrote:
> This is pretty basic and I am surprised at myself that I can't figure
> this out, but I guess its where I am at.
>
> What pattern would pick students with a score of zero out of this list
> (which is {"student", score}):
>
> {{"Smith, Tim",3},{"Wheres,Waldo",4},{"Muffet, LilMiss",0},{"Brown,
> Charlie",1},{"X, Doctor",0}}
>
> Thanks,
> Jason
>
> Contact: jasoneba...@jasonebaugh.info
> Blog:www.jasonebaugh.info/wordpress/
> LinkedIn:www.linkedin.com/in/jasonebaugh

Cases[{{"Smith, Tim",3},{"Wheres,Waldo",4},{"Muffet, LilMiss",0},
       {"Brown, Charlie",1},{"X, Doctor",0}}, {_,0}]

{{Muffet, LilMiss,0},{X, Doctor,0}}

[toc] | [prev] | [next] | [standalone]


#6397

FromPeter Breitfeld <phbrf@t-online.de>
Date2011-11-12 12:33 +0000
Message-ID<j9lp36$lbd$1@smc.vnet.net>
In reply to#6365
JasonE wrote:

> This is pretty basic and I am surprised at myself that I can't figure
> this out, but I guess its where I am at.
>
> What pattern would pick students with a score of zero out of this list
> (which is {"student", score}):
>
> {{"Smith, Tim",3},{"Wheres,Waldo",4},{"Muffet, LilMiss",0},{"Brown,
> Charlie",1},{"X, Doctor",0}}
>

Try (ll is your list):

Cases[ll,{__,0}]

-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

[toc] | [prev] | [next] | [standalone]


#6406

From"Dr. Wolfgang Hintze" <weh@snafu.de>
Date2011-11-12 12:40 +0000
Message-ID<j9lpfl$lhd$1@smc.vnet.net>
In reply to#6365
"JasonE" <ebaughjason@gmail.com> schrieb im Newsbeitrag 
news:j9irl5$8ee$1@smc.vnet.net...
> This is pretty basic and I am surprised at myself that I can't figure
> this out, but I guess its where I am at.
>
> What pattern would pick students with a score of zero out of this 
> list
> (which is {"student", score}):
>
> {{"Smith, Tim",3},{"Wheres,Waldo",4},{"Muffet, LilMiss",0},{"Brown,
> Charlie",1},{"X, Doctor",0}}
>
>
>
> Thanks,
> Jason
>
> Contact: jasonebaugh@jasonebaugh.info
> Blog: www.jasonebaugh.info/wordpress/
> LinkedIn: www.linkedin.com/in/jasonebaugh
>
Something like this:
t = {{"Smith, Tim", 3}, {"Wheres,Waldo", 4}, {"Muffet, LilMiss", 0}, 
{"Brown, Charlie", 1},
{"X, Doctor", 0}}
    {{"Smith, Tim", 3}, {"Wheres,Waldo", 4}, {"Muffet, LilMiss", 0}, 
{"Brown, Charlie", 1},
    {"X, Doctor", 0}}

Cases[t, {_, 0}]
    {{"Muffet, LilMiss", 0}, {"X, Doctor", 0}}

Regards,
Wolfgang

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web