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


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

Re: how to check for NumericQ arbitrary data structure

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-04-25 04:41 +0000
Last post2012-04-25 04:41 +0000
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: how to check for NumericQ arbitrary data structure Bob Hanlon <hanlonr357@gmail.com> - 2012-04-25 04:41 +0000

#9792 — Re: how to check for NumericQ arbitrary data structure

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-04-25 04:41 +0000
SubjectRe: how to check for NumericQ arbitrary data structure
Message-ID<jn7v94$6gp$1@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@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
>

[toc] | [standalone]


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


csiph-web