[metapost] Graph v New number systems
Hans Hagen
j.hagen at xs4all.nl
Fri Nov 4 10:04:34 CET 2022
On 11/4/2022 9:25 AM, Toby Thurston wrote:
> thanks for that.
>
> I think I will have a further look at marith.mp then, and see if it could be made compatible with the extended number systems.
>
> Something like:
>
> if numbersystem = “scaled”:
> % do normal marith
> else:
> % provide versions of all the marith functions that work with new number systems
> fi
you can plug in some lua ...
vardef MyFormat(expr f, n) =
string l ;
l := "return string.char(34) .. string.format(" &
ditto & (char 37) & f & ditto & "," & decimal n &
") .. string.char(34)";
% message(l);
runscript(l)
enddef ;
string s[] ;
s[1] := MyFormat("0.3f",123.456789) ;
s[2] := MyFormat("0.7f",123.456789);
message(s[1]);
message(s[2]);
% whatever suits:
draw textext(s[1]) ;
draw textext(s[2]) shifted (0,-1cm) ;
(not really the context / metafun way but good enough for plain usage)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
More information about the metapost
mailing list.