algorithm2e: do N times











up vote
2
down vote

favorite












I want to write this in algorithm2e pseudocode:



Do N times
stuff that has to be done N times
end


or maybe



Repeat N times
stuff that has to be done N times
end


Since the loop body does not depend on a loop index, introducing one (like in a typical "for" loop) seems overkill.



My current best solution is



For{$N$ times}{
do stuff
}


but the output, "for N times do" is unclear.



(there are Do and Repeat commands in algorithm2e, but they both use end conditions: Do...while and Repeat...until, so not what I'm looking for.)










share|improve this question
























  • According to the docs there's Repeat, so you should have a look at the package's documentation.
    – TeXnician
    Jun 2 at 17:18










  • There is indeed Repeat, but that gives "repeat ... until condition"
    – Wouter
    Jun 2 at 17:21















up vote
2
down vote

favorite












I want to write this in algorithm2e pseudocode:



Do N times
stuff that has to be done N times
end


or maybe



Repeat N times
stuff that has to be done N times
end


Since the loop body does not depend on a loop index, introducing one (like in a typical "for" loop) seems overkill.



My current best solution is



For{$N$ times}{
do stuff
}


but the output, "for N times do" is unclear.



(there are Do and Repeat commands in algorithm2e, but they both use end conditions: Do...while and Repeat...until, so not what I'm looking for.)










share|improve this question
























  • According to the docs there's Repeat, so you should have a look at the package's documentation.
    – TeXnician
    Jun 2 at 17:18










  • There is indeed Repeat, but that gives "repeat ... until condition"
    – Wouter
    Jun 2 at 17:21













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I want to write this in algorithm2e pseudocode:



Do N times
stuff that has to be done N times
end


or maybe



Repeat N times
stuff that has to be done N times
end


Since the loop body does not depend on a loop index, introducing one (like in a typical "for" loop) seems overkill.



My current best solution is



For{$N$ times}{
do stuff
}


but the output, "for N times do" is unclear.



(there are Do and Repeat commands in algorithm2e, but they both use end conditions: Do...while and Repeat...until, so not what I'm looking for.)










share|improve this question















I want to write this in algorithm2e pseudocode:



Do N times
stuff that has to be done N times
end


or maybe



Repeat N times
stuff that has to be done N times
end


Since the loop body does not depend on a loop index, introducing one (like in a typical "for" loop) seems overkill.



My current best solution is



For{$N$ times}{
do stuff
}


but the output, "for N times do" is unclear.



(there are Do and Repeat commands in algorithm2e, but they both use end conditions: Do...while and Repeat...until, so not what I'm looking for.)







pseudocode






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 2 at 17:24

























asked Jun 2 at 17:13









Wouter

1354




1354












  • According to the docs there's Repeat, so you should have a look at the package's documentation.
    – TeXnician
    Jun 2 at 17:18










  • There is indeed Repeat, but that gives "repeat ... until condition"
    – Wouter
    Jun 2 at 17:21


















  • According to the docs there's Repeat, so you should have a look at the package's documentation.
    – TeXnician
    Jun 2 at 17:18










  • There is indeed Repeat, but that gives "repeat ... until condition"
    – Wouter
    Jun 2 at 17:21
















According to the docs there's Repeat, so you should have a look at the package's documentation.
– TeXnician
Jun 2 at 17:18




According to the docs there's Repeat, so you should have a look at the package's documentation.
– TeXnician
Jun 2 at 17:18












There is indeed Repeat, but that gives "repeat ... until condition"
– Wouter
Jun 2 at 17:21




There is indeed Repeat, but that gives "repeat ... until condition"
– Wouter
Jun 2 at 17:21










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










It seems there is no such built-in loop. Luckily, you can create your own! In algoritm2e, there are loops "with the condition at the start", or "with the condition at the end". To create your own "at the start" loop, do:



SetKwFor{RepTimes}{repeat}{times}{end}


Then, to use it:



RepTimes{100}{
foobar
}


rendered latex image






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',
    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%2f434664%2falgorithm2e-do-n-times%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








    up vote
    1
    down vote



    accepted










    It seems there is no such built-in loop. Luckily, you can create your own! In algoritm2e, there are loops "with the condition at the start", or "with the condition at the end". To create your own "at the start" loop, do:



    SetKwFor{RepTimes}{repeat}{times}{end}


    Then, to use it:



    RepTimes{100}{
    foobar
    }


    rendered latex image






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      It seems there is no such built-in loop. Luckily, you can create your own! In algoritm2e, there are loops "with the condition at the start", or "with the condition at the end". To create your own "at the start" loop, do:



      SetKwFor{RepTimes}{repeat}{times}{end}


      Then, to use it:



      RepTimes{100}{
      foobar
      }


      rendered latex image






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        It seems there is no such built-in loop. Luckily, you can create your own! In algoritm2e, there are loops "with the condition at the start", or "with the condition at the end". To create your own "at the start" loop, do:



        SetKwFor{RepTimes}{repeat}{times}{end}


        Then, to use it:



        RepTimes{100}{
        foobar
        }


        rendered latex image






        share|improve this answer












        It seems there is no such built-in loop. Luckily, you can create your own! In algoritm2e, there are loops "with the condition at the start", or "with the condition at the end". To create your own "at the start" loop, do:



        SetKwFor{RepTimes}{repeat}{times}{end}


        Then, to use it:



        RepTimes{100}{
        foobar
        }


        rendered latex image







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 13 hours ago









        Ludwik

        1263




        1263






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f434664%2falgorithm2e-do-n-times%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

            サソリ

            広島県道265号伴広島線

            Accessing regular linux commands in Huawei's Dopra Linux