RE : string to identifier
- Subject: RE : string to identifier
- From: laurent couraud
- Date: Sun, 22 Jan 2012 01:39:50 +0100
You can also use eval_string from the package stringproc.
Laurent.
> -----Message d'origine-----
> De?: maxima-bounces at math.utexas.edu [mailto:maxima-bounces at math.utexas.edu] De la part de
> Adam Majewski
> Envoy??: dimanche 22 janvier 2012 01:08
> ??: maxima at math.utexas.edu
> Objet?: Re: [Maxima] string to identifier
>
> On 22.01.2012 00:07, Richard Fateman wrote:
> >
> >
> > Try
> > ?intern(concat("list",123)) :: 32
> >
> > which assigns 32 to a symbol that you can type in to Maxima as ?LIST123.
> >
> >
> > There is a peculiarity of switching upper and lower case for
> > convoluted reasons.
> >
> > Note that is "::" not ":"
> >
> > RJF
> It works now. Thanks.
>
> Below is code in which I have used it in main and draw sections.
> It draws 5 images on the screen.
>
>
> Adam
>
> ==============
> kill(all);
>
>
>
> /* ---------- functions ---------------------- */
>
> /* conformal map from circle to cardioid ( boundary
> of period 1 component of Mandelbrot set */
> F(w):=w/2-w*w/4;
>
>
> /*
> circle D={w:abs(w)=1 } where w=l(t,r)
> t is angle in turns ; 1 turn = 360 degree = 2*Pi radians
> r is a radius
> */
> ToCircle(t,r):=r*%e^(%i*t*2*%pi);
>
>
>
>
> /*
>
> http://en.wikipedia.org/wiki/Complex_quadratic_polynomial
> */
> f(z,c):=z*z+c $
>
> GiveCriticalOrbit(c,iMax):=
> /*
> computes (without escape test)
> critical orbit (forward orbit of critical point )
> and saves it to the list for draw package */
> block(
> [z,orbit,temp],
> z:0, /* first point = critical point z:0+0*%i */
> orbit:[[realpart(z),imagpart(z)]],
> for i:1 thru iMax step 1 do
> ( z:expand(f(z,c)),
> orbit:endcons([realpart(z),imagpart(z)],orbit)),
>
> return(orbit)
> )$
>
>
> /* find fixed point alfa , returns a list */
> GiveFixed(c):=
> (
> [z],
> z:float(rectform((1-sqrt(1-4*c))/2)),
> [[realpart(z),imagpart(z)]]
> )$
>
>
>
> GiveC(angle,radius):=
> (
> [w],
> /* point of unit circle w:l(internalAngle,internalRadius); */
> w:ToCircle(angle,radius), /* point of circle */
> float(rectform(F(w))) /* point on boundary of period 1 component of
> Mandelbrot set */
> )$
>
>
>
> compile(all)$
>
>
>
> /* ---------- constant ---------------------------*/
> Numerator :1;
> DenominatorMax :5;
> InternalRadius:1;
> iMax:500;
>
>
> /* -------------- main ----------------- */
>
>
>
> for Denominator:1 thru DenominatorMax step 1 do
> (
> InternalAngle: Numerator/Denominator,
> c: GiveC(InternalAngle,InternalRadius),
> /* */
> ?intern(concat("z",string(Denominator)))::GiveFixed(c),
> /* */
> ?intern(concat("orbit",string(Denominator)))::GiveCriticalOrbit(c,iMax)
> );
>
>
>
>
> /*------------------draw -------------------------------------*/
> load(draw); /* ( interface to gnuplot ) by Mario Rodriguez Riotorto
> http://www.telefonica.net/web2/biomates */
>
> draw(
>
> terminal = screen,
> columns =5,
> gr2d(
> title= "1/1 ",
> user_preamble = "set border 0;set nokey;set size square;set noxtics
> ;set noytics;",
>
> point_type = filled_circle,
> points_joined = false,
> point_size = 0.7,
> /* */
> color =red,
> key = "critical orbit",
> points(?ORBIT1),
> /* */
> color =black,
> point_size = 1.4,
> key = "parabolic fixed point",
> points(?Z1),
> /* */
> color =blue,
> key = "criitical point",
> points([0],[0])
> ),
>
> gr2d(
> title= " 1/2 ",
> user_preamble = "set border 0;set nokey;set size square;set noxtics
> ;set noytics;",
>
> point_type = filled_circle,
> points_joined = false,
> point_size = 0.7,
> /* */
> color =red,
> key = "critical orbit",
> points(?ORBIT2),
> /* */
> color =black,
> point_size = 1.4,
> key = "parabolic fixed point",
> points(?Z2),
> /* */
> color =blue,
> key = "criitical point",
> points([0],[0])
> ),
>
> gr2d(
> title= " 1/3 ",
> user_preamble = "set border 0;set nokey;set size square;set noxtics
> ;set noytics;;",
> point_type = filled_circle,
> points_joined = false,
> point_size = 0.7,
> /* */
> color =red,
> key = "critical orbit",
> points(?ORBIT3),
> /* */
> color =black,
> point_size = 1.4,
> key = "parabolic fixed point",
> points(?Z3),
> /* */
> color =blue,
> key = "criitical point",
> points([0],[0])
> ),
>
> gr2d(
> title= " 1/4 ",
> user_preamble = "set border 0;set nokey;set size square;set noxtics
> ;set noytics;;",
> point_type = filled_circle,
> points_joined = false,
> point_size = 0.7,
> /* */
> color =red,
> key = "critical orbit",
> points(?ORBIT4),
> /* */
> color =black,
> point_size = 1.4,
> key = "parabolic fixed point",
> points(?Z4),
> /* */
> color =blue,
> key = "criitical point",
> points([0],[0])
> ),
> gr2d(
> title= " 1/5 ",
> user_preamble = "set border 0;set nokey;set size square;set noxtics
> ;set noytics;;",
> point_type = filled_circle,
> points_joined = false,
> point_size = 0.7,
> /* */
> color =red,
> key = "critical orbit",
> points(?ORBIT5),
> /* */
> color =black,
> point_size = 1.4,
> key = "parabolic fixed point",
> points(?Z5),
> /* */
> color =blue,
> key = "criitical point",
> points([0],[0])
> )
>
>
>
> );
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima