Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: how to check for NumericQ arbitrary data structure

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126216] Re: how to check for NumericQ arbitrary data structure
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Wed, 25 Apr 2012 00:36:55 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201204201144.HAA21808@smc.vnet.net>

myNumericQ[data_] := VectorQ[Flatten[data], NumericQ]

data = {a, {b, c}, {d, {e, f}, {g}}};

sub = Thread[{a, b, c, d, e, f, g} -> Hold[RandomInteger[{0, 9}]]] //
  ReleaseHold

{a -> 6, b -> 9, c -> 1, d -> 5, e -> 1, f -> 1, g -> 4}

data // myNumericQ

False

data /. sub // myNumericQ

True


Bob Hanlon


On Tue, Apr 24, 2012 at 5:32 AM, Ted Sariyski <tsariysk at craft-tech.com> wrote:
> Hi,
> I have a data structure e.g. {a,{b,c},{d,{e,f},{g}}}, which I want to
> check for NumericQ. For vectors and matrices I can use
> VectorQ[x,NumericQ] or MatrixQ[x,NumericQ]. Is there a way to check an
> arbitrary data structure that all elements are NumericQ or I have to
> construct a function for each data structure?
> Thanks in advance,
> --Ted
>



  • Prev by Date: Re: how to check for NumericQ arbitrary data structure
  • Next by Date: Re: Question about DayOfWeek
  • Previous by thread: Re: is there internal variable like $0 in perl?
  • Next by thread: Re: Find all roots with FindRoot