Why does this syntax outputs an error under METAFUN/METAPOST?Why does anyone prefer Metapost?Why won't this...

Is there anything in the universe that cannot be compressed?

Are there any writings by blinded and/or exiled Byzantine emperors?

Strange LockTime values in Electrum transactions?

Is it safe for a student to give negative feedback in student evaluations?

Importance of electrolytic capacitor size

Map a function that takes arguments in different levels of a list

Is it rude to ask my opponent to resign an online game when they have a lost endgame?

How do we know if a dialogue sounds unnatural without asking for feedback?

Field of a uniformly charged disk: integration question

How did Gollum know Sauron was gathering the Haradrim to make war?

Calculus Books, preferably Soviet.

Are there photos of the Apollo LM showing disturbed lunar soil resulting from descent engine exhaust?

Is mathematics truth?

Do we know the problems the University of Manchester's Transistor Computer was intended to solve?

How to use multiple criteria for -find

How do you manage to study and have a balance in your life at the same time?

Solve this icositetragram

How do I stop making people jump at home and at work?

Heuristic argument for the Riemann Hypothesis

Received email from ISP saying one of my devices has malware

What is the converted mana cost of land cards?

How is total raw calculated for Science Pack 2?

Initializing a std::array with a constant value

properties that real numbers hold but complex numbers does not



Why does this syntax outputs an error under METAFUN/METAPOST?


Why does anyone prefer Metapost?Why won't this Metapost while loop terminate?Why two intersected paths can't buildcycle in MetaPost?What's “logarifm” in Metapost and why I get the error “Undefined control sequence”?How does MetaPost compare to MetaFont, featurewise?Why is the resolution of output of this metapost file very bad?Metapost error ! An expression can't begin with `]'Why custom TEX command for labels does not work in MetaPost?metapost “ missing `,' has been inserted.” compilation error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















Given this MWE (compiled under ConTeXt)



starttext
startMPpage

%variables
u:=1mm ;
numeric l[];
l[1]:=30 ;
l[2]:=70 ;

draw (0,0) -- (0,100u) ;
%this does not work
%fill unitsquare xscaled (l[2]-l[1])*u yscaled 100*u shifted (l[1]*u,0) withcolor red ;

%this does
fill unitsquare xscaled (l[2]*u-l[1]*u) yscaled 100u shifted (l[1]*u,0) withcolor red ;

stopMPpage
stoptext


Could you explain me why



fill unitsquare xscaled (l[2]-l[1])*u yscaled 100*u shifted (l[1]*u,0) withcolor red ;


fails, whereas



fill unitsquare xscaled (l[2]*u-l[1]*u) yscaled 100*u shifted (l[1]*u,0) withcolor red ;


does the job?



From my (not so good in maths) points of view, (l[2]-l[1])*u should be exactly the same, and this misunderstandings leads me often to frustrating errors.



I hope this is not a duplicate, but didn't know how to produce a proper title.










share|improve this question






















  • 1





    Have you tried xscaled ((l[2]-l[1])*u)?

    – Ruixi Zhang
    9 hours ago


















2















Given this MWE (compiled under ConTeXt)



starttext
startMPpage

%variables
u:=1mm ;
numeric l[];
l[1]:=30 ;
l[2]:=70 ;

draw (0,0) -- (0,100u) ;
%this does not work
%fill unitsquare xscaled (l[2]-l[1])*u yscaled 100*u shifted (l[1]*u,0) withcolor red ;

%this does
fill unitsquare xscaled (l[2]*u-l[1]*u) yscaled 100u shifted (l[1]*u,0) withcolor red ;

stopMPpage
stoptext


Could you explain me why



fill unitsquare xscaled (l[2]-l[1])*u yscaled 100*u shifted (l[1]*u,0) withcolor red ;


fails, whereas



fill unitsquare xscaled (l[2]*u-l[1]*u) yscaled 100*u shifted (l[1]*u,0) withcolor red ;


does the job?



From my (not so good in maths) points of view, (l[2]-l[1])*u should be exactly the same, and this misunderstandings leads me often to frustrating errors.



I hope this is not a duplicate, but didn't know how to produce a proper title.










share|improve this question






















  • 1





    Have you tried xscaled ((l[2]-l[1])*u)?

    – Ruixi Zhang
    9 hours ago














2












2








2








Given this MWE (compiled under ConTeXt)



starttext
startMPpage

%variables
u:=1mm ;
numeric l[];
l[1]:=30 ;
l[2]:=70 ;

draw (0,0) -- (0,100u) ;
%this does not work
%fill unitsquare xscaled (l[2]-l[1])*u yscaled 100*u shifted (l[1]*u,0) withcolor red ;

%this does
fill unitsquare xscaled (l[2]*u-l[1]*u) yscaled 100u shifted (l[1]*u,0) withcolor red ;

stopMPpage
stoptext


Could you explain me why



fill unitsquare xscaled (l[2]-l[1])*u yscaled 100*u shifted (l[1]*u,0) withcolor red ;


fails, whereas



fill unitsquare xscaled (l[2]*u-l[1]*u) yscaled 100*u shifted (l[1]*u,0) withcolor red ;


does the job?



From my (not so good in maths) points of view, (l[2]-l[1])*u should be exactly the same, and this misunderstandings leads me often to frustrating errors.



I hope this is not a duplicate, but didn't know how to produce a proper title.










share|improve this question
















Given this MWE (compiled under ConTeXt)



starttext
startMPpage

%variables
u:=1mm ;
numeric l[];
l[1]:=30 ;
l[2]:=70 ;

draw (0,0) -- (0,100u) ;
%this does not work
%fill unitsquare xscaled (l[2]-l[1])*u yscaled 100*u shifted (l[1]*u,0) withcolor red ;

%this does
fill unitsquare xscaled (l[2]*u-l[1]*u) yscaled 100u shifted (l[1]*u,0) withcolor red ;

stopMPpage
stoptext


Could you explain me why



fill unitsquare xscaled (l[2]-l[1])*u yscaled 100*u shifted (l[1]*u,0) withcolor red ;


fails, whereas



fill unitsquare xscaled (l[2]*u-l[1]*u) yscaled 100*u shifted (l[1]*u,0) withcolor red ;


does the job?



From my (not so good in maths) points of view, (l[2]-l[1])*u should be exactly the same, and this misunderstandings leads me often to frustrating errors.



I hope this is not a duplicate, but didn't know how to produce a proper title.







metapost metafun






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 9 hours ago







sztruks

















asked 10 hours ago









sztrukssztruks

1,7431 gold badge8 silver badges17 bronze badges




1,7431 gold badge8 silver badges17 bronze badges











  • 1





    Have you tried xscaled ((l[2]-l[1])*u)?

    – Ruixi Zhang
    9 hours ago














  • 1





    Have you tried xscaled ((l[2]-l[1])*u)?

    – Ruixi Zhang
    9 hours ago








1




1





Have you tried xscaled ((l[2]-l[1])*u)?

– Ruixi Zhang
9 hours ago





Have you tried xscaled ((l[2]-l[1])*u)?

– Ruixi Zhang
9 hours ago










1 Answer
1






active

oldest

votes


















5















According to the Metapost manual, xscaled is a primary, so it has the same priority as multiplication.



It takes as arguments a pair, path or picture and a number, returning a pair, path or picture respectively; with your “non working” syntax Metapost is doing



unitsquare xscaled (l[2]-l[1])


and then trying to multiply the result by u, which is an invalid operation.



When operations have the same priority (all primaries, for instance), Metapost associates on the left. To get a different association you need parentheses.



The error you get is



>> path
>> 2.83464
! Not implemented: (path)*(known numeric).
<to be read again>
yscaled


Of course ((l[2]-l[1])*u) would work as well, but the outer parentheses cannot be omitted.






share|improve this answer




























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f506723%2fwhy-does-this-syntax-outputs-an-error-under-metafun-metapost%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5















    According to the Metapost manual, xscaled is a primary, so it has the same priority as multiplication.



    It takes as arguments a pair, path or picture and a number, returning a pair, path or picture respectively; with your “non working” syntax Metapost is doing



    unitsquare xscaled (l[2]-l[1])


    and then trying to multiply the result by u, which is an invalid operation.



    When operations have the same priority (all primaries, for instance), Metapost associates on the left. To get a different association you need parentheses.



    The error you get is



    >> path
    >> 2.83464
    ! Not implemented: (path)*(known numeric).
    <to be read again>
    yscaled


    Of course ((l[2]-l[1])*u) would work as well, but the outer parentheses cannot be omitted.






    share|improve this answer






























      5















      According to the Metapost manual, xscaled is a primary, so it has the same priority as multiplication.



      It takes as arguments a pair, path or picture and a number, returning a pair, path or picture respectively; with your “non working” syntax Metapost is doing



      unitsquare xscaled (l[2]-l[1])


      and then trying to multiply the result by u, which is an invalid operation.



      When operations have the same priority (all primaries, for instance), Metapost associates on the left. To get a different association you need parentheses.



      The error you get is



      >> path
      >> 2.83464
      ! Not implemented: (path)*(known numeric).
      <to be read again>
      yscaled


      Of course ((l[2]-l[1])*u) would work as well, but the outer parentheses cannot be omitted.






      share|improve this answer




























        5














        5










        5









        According to the Metapost manual, xscaled is a primary, so it has the same priority as multiplication.



        It takes as arguments a pair, path or picture and a number, returning a pair, path or picture respectively; with your “non working” syntax Metapost is doing



        unitsquare xscaled (l[2]-l[1])


        and then trying to multiply the result by u, which is an invalid operation.



        When operations have the same priority (all primaries, for instance), Metapost associates on the left. To get a different association you need parentheses.



        The error you get is



        >> path
        >> 2.83464
        ! Not implemented: (path)*(known numeric).
        <to be read again>
        yscaled


        Of course ((l[2]-l[1])*u) would work as well, but the outer parentheses cannot be omitted.






        share|improve this answer













        According to the Metapost manual, xscaled is a primary, so it has the same priority as multiplication.



        It takes as arguments a pair, path or picture and a number, returning a pair, path or picture respectively; with your “non working” syntax Metapost is doing



        unitsquare xscaled (l[2]-l[1])


        and then trying to multiply the result by u, which is an invalid operation.



        When operations have the same priority (all primaries, for instance), Metapost associates on the left. To get a different association you need parentheses.



        The error you get is



        >> path
        >> 2.83464
        ! Not implemented: (path)*(known numeric).
        <to be read again>
        yscaled


        Of course ((l[2]-l[1])*u) would work as well, but the outer parentheses cannot be omitted.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 9 hours ago









        egregegreg

        766k90 gold badges1999 silver badges3351 bronze badges




        766k90 gold badges1999 silver badges3351 bronze badges

































            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f506723%2fwhy-does-this-syntax-outputs-an-error-under-metafun-metapost%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m