Re: How to make delayed functions from text info
- To: mathgroup at smc.vnet.net
- Subject: [mg81170] Re: [mg81117] How to make delayed functions from text info
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 14 Sep 2007 03:43:15 -0400 (EDT)
- Reply-to: hanlonr at cox.net
t1 = {{"AA", {15.}, {19.}, 4.}, {"AC", {17.}, {21.}, 4.}}; (ToExpression[#[[1]]][b_, t_] := Evaluate[If[#[[2, 1]] < t <= #[[3, 1]], b, 0]]) & /@ t1; funcs = ToExpression[#[[1]] & /@ t1]; defs = Flatten[DownValues /@ funcs]; Column[defs] defs[[1]] Definition[Evaluate[funcs[[1]]]] Bob Hanlon ---- P_ter <peter_van_summeren at yahoo.co.uk> wrote: > Hello, > I have a list like this t1= {{"AA", {15.}, {19.}, 4.}, {"AC", {17.}, {21.}, 4.}} > It means: AA[b_,t_]:= If[15<t<=19,b,0] Etc. > The problem is that I have a few hundred of these elements in a list. But when I do: > (ToExpression[#[[1]]][b_,t_]:= Evaluate[If[#[[2,1]]< t<= #[[3,1]],b,0]])& /@ t1 > I get out {Null, Null}, although AA and AC exist with ?AA,?AC > But I want to see these delayed functions in a list: > lst = {AA[b_,t_]:=If[15.<t<=19.,b,0],AC[b_,t_]:=If[17.<t<=21.,b,0] > ..} > I would like to say: lst[[1]] and get this delayed function. Is that possible? > Also I wonder if ?(AA,AC) could be done, such that I get all the definitions in a row. Any idea? > with friendly greetings, > P_ter >