%gen

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

%gen

Message par compsystems » mer. févr. 13, 2019 2:38 pm

Hello
The output of the next instruction places space at the end of gen, Why?

printf("%gen:%gen~%gen",eval(id0,0),eval(id0,1),approx(id0)) returns
id0: ¾ ~0.75
the expected output should be
id0:¾~0.75

the spaces to add should be those that are within the string

printf("%gen: %gen ~ %gen",eval(id0,0),eval(id0,1),approx(id0)) returns
id0: ¾ ~ 0.75

Code : Tout sélectionner

f():={
local id0;
id0:=3/4;
DispG; ClrIO;
printf("%gen:%gen~%gen",eval(id0,0),eval(id0,1),approx(id0))
return "Done";
}:;

parisse
Messages : 5743
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: %gen

Message par parisse » jeu. févr. 14, 2019 7:10 am

I don't see any space added. Where did you test?

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: %gen

Message par compsystems » ven. févr. 15, 2019 7:53 pm

^ ok in online version

in the following code the output of the roots are printed as list[], I would like to see the printf (prettyprint) impression of list[ ] as { }

Code : Tout sélectionner

testPrintformat():={
  local f, Slope, Roots, Area, x;
  
  assume(x,symbol);
  
  ClrIO;
  f(x):=-2*x^2-4*x+12;
  printf("f(x):%gen",f(x));
  
  Slope:=unapply(diff(f(x),x),x);
  printf("Slope:∂xf(x)=%gen",right(Slope));
  
  
  Roots:=solve(f(x)=0,x);
  printf("Roots:%gen ~ %gen", Roots, approx(Roots)); 
  
  Area:=int(f(x),x,Roots(1),Roots(2));
  printf("Area:%gen ~ %gen", Area, approx(Area)); 
  return "Done";
}:;
testPrintformat() [enter]

f(x): -2 x^2-4x+12
Slope: ∂xf(x)=-4x-4
Roots: list[sqrt(-7)-1,sqrt(7)-1] ~ list[-3.64575131106,1.64575131106]
Area: -1/3×(-28*sqrt(7)-40 )+1/3×(28*sqrt(7)-40) ~ 49.3873578065

PD: when copying the output to the clipboard, the sqrt() function and ^ operator is not added

f(x): -2 x2-4x+12
Slope: ∂xf(x)=-4x-4
Roots: list[-7-1,7-1] ~ list[-3.64575131106,1.64575131106]
Area: -13× (-287-40 )+13× (287-40 ) ~ 49.3873578065

Répondre