MathGroup Archive 1996

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

Search the Archive

list splitting

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4905] [mg4872] list splitting
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Fri, 4 Oct 1996 00:17:41 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

osbornece at cardiff.ac.uk (c. osborne)
[mg4872] list splitting
writes

>i have  some mathematica code which generates a list of results in  
>theform ;
>{{{ 1, 2, {a-> 3, b-> 4, c-> 4}, 5}, {6, 7, {a-> 8, b-> 9, ...}}}
>what i would like to do is to be able to select those parts of the
>list which have a>0, b> 4 etc.

Cases should help, but you may have to use the levelspec setting.

?Cases
Cases[{e1, e2, ...}, pattern] gives a list of the ei that match the
pattern.
Cases[{e1, ...}, pattern -> rhs] or Cases[{e1, ...}, pattern :>  
rhs] gives a list of the values of rhs corresponding to the ei that  
match the pattern.
Cases[expr, pattern, levelspec] gives a list of all parts of expr  
on levels specified by levelspec which match the pattern.

Allan Hayes
hay at haystack.demon.co.uk





==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Transformation rule exercise
  • Next by Date: Running mathematica on the net
  • Previous by thread: Re: Transformation rule exercise
  • Next by thread: Re: list splitting