I know this is a question that possibly does not belong to pure TeX, as MetaFont is part of a project to which TeX relates, ie as part of building TeX.
My question is as follows:
I call MetaFont from my bash terminal.
and then provide the expr
entry (see below).
#mf
This is METAFONT, Version 2.7182818 (TeX Live 2019/Arch Linux) (preloaded base=mf)
**expr
(/usr/share/texmf-dist/fonts/source/public/knuth-lib/expr.mf
gimme an expr: 4+5-8+4
>> 5
gimme an expr:
Now I wanted, instead of typing an expression, that I could write some command to have metafont read a line from a values.txt
(see below) file containing the expression 4+5-8+4
in the first line e etc.
values.txt:
4+5-8+4
4+5-8+7
4+5-8+13
My output should be:
5
11
17
Is there any way to do this?
mf expr < values.txt
but why useexpr
which is just an infinite loop reading standard in, rather than have a normal metafont file as input?subprocess
module to automatically read multiple lines as invalues.txt
, perform the operations, and direct each result of each line separately to aresult.txt
file containing each result separated by line respectively with respect tovalues.txt
. I will try from now on to draw inspiration from your advice.