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


Groups > comp.soft-sys.math.mathematica > #14058

Re: extract from Reduce

From awnl <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: extract from Reduce
Date 2013-04-05 02:29 +0000
Message-ID <kjlcuj$b5s$1@smc.vnet.net> (permalink)
References <kjkc5k$7n0$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Hi,

> I have a result from the command Reduce that looks like this (as an
> example):
>
> a:= x==3||x==4||x==7
>
> I need to extract the numbers but I can't find a nice way to handle
> the case when there is only one equation, for instance:
>
> a:= x==6
>
> currently I check what the head of the expression is (Head[a]) and
> handle the case Head[a]=Or with a Map[] and the case Head[a]="Equal"
> with a[[2]]. Not very nice, but I guess that there is a neat way to
> do it.
>

There might be more efficient ways to do this, but I think this is clear 
and compact:

Cases[{a}, Equal[x, v_?NumericQ] :> v, Infinity]

hth,

albert

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

extract from Reduce hamiltoncycle@gmail.com - 2013-04-04 17:10 +0000
  Re: extract from Reduce awnl <awnl@gmx-topmail.de> - 2013-04-05 02:29 +0000
  Re: extract from Reduce debguy <johnandsara2@cox.net> - 2013-04-05 02:29 +0000
  Re: extract from Reduce Peter Pein <petsie@dordos.net> - 2013-04-05 02:30 +0000

csiph-web