MathGroup Archive 1997

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

Search the Archive

Extracting the domain of a function, dynamic programming

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8225] Extracting the domain of a function, dynamic programming
  • From: John JOWETT <John.Jowett at cern.ch>
  • Date: Tue, 19 Aug 1997 21:12:05 -0400
  • Organization: CERN
  • Sender: owner-wri-mathgroup at wolfram.com

--------------DA785FE9E40FF72720FAFD8D

Hello, I would like to extract the set of values on which a function is
defined.   Consider the following toy example (to illustrate a 
situation I have while using dynamic programming):

In[182]:=
Clear[f]
In[185]:=
f[1]:=f1;
f[2]:=f2;

To find out about f, I can always do

In[186]:=
?f
Global`f
f[1] := f1

f[2] := f2

However in my application, the values f1 and f2 are enormous expressions
that I have to avoid appearing in my notebook  (even if I allow them to
print, it is quite hard to sift through the output cells looking for
what I want).  In any case I would like to get hold of this domain 
list and do other things with it.

I would like something 
that returns just the list {1,2}, ie, the domain or set of values for 
which the function has been explicitly defined.

I have tried 

In[188]:=
DownValues[f]
Out[188]=
{HoldPattern[f[1]]\[RuleDelayed]f1,HoldPattern[f[2]]\[RuleDelayed]f2}

and  then

In[189]:=
First /@ DownValues[f]
Out[189]=
{HoldPattern[f[1]],HoldPattern[f[2]]}

Then I can use Length[] to find out at least for how many cases f 
is defined but I have trouble extracting my domain (basically because
attempts to dig deeper into the DownValues list always evaluate f[1] 
and f[2] at some point.

I am sure that someone who really understands held expressions 
can help me ..... 

(I realise that I could simply accumulate an auxiliary list at 
each point where a new value is defined for f but that's not really
satisfactory.)

Thanks for any efforts,
John Jowett

-- 
-------------------------------------------------------------------------
** Electronic mail: <John.Jowett at cern.ch>
   World Wide Web:  http://wwwslap.cern.ch/~jowett/
   Telephone:       +41 (0)22 76 76643 (direct line and voice mail)
   Postal address:  SL Division,   CERN,   CH-1211 Geneva 23,
Switzerland
   Fax:             +41 (0)22 76 78480
   Location:        Room 1-D18,Building 865, CERN Prevessin Site, France
   Secretaries:     +41 (0)22 76 75272 or 75875 or 74571
-------------------------------------------------------------------------
--------------DA785FE9E40FF72720FAFD8D
Content-Description: Card for John Jowett

begin:          vcard
fn:             John Jowett
n:              Jowett;John
org:            CERN
adr:            SL DIvision;;CERN;1211 Geneva 23 ;;;Switzerland
email;internet: John.Jowett at cern.ch
title:          Dr
tel;work:       +41 22 767 6643
note:           WWW:     http://wwwslap.cern.ch/~jowett/
=0A=
Telephone:       +41 (0)22 76 76643 (direct line and voice mail)
=0A=
Postal address:  SL Division,   CERN,   CH-1211 Geneva 23,
=0A=
Switzerland
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
end:            vcard


--------------DA785FE9E40FF72720FAFD8D--


  • Prev by Date: log files on PowerMac (Q:)
  • Next by Date: Saving Mma plots as .ps and .eps
  • Previous by thread: log files on PowerMac (Q:)
  • Next by thread: Re: Extracting the domain of a function, dynamic programming