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.)
pseudocode
add a comment |
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.)
pseudocode
According to the docs there'sRepeat
, 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
add a comment |
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.)
pseudocode
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
pseudocode
edited Jun 2 at 17:24
asked Jun 2 at 17:13
Wouter
1354
1354
According to the docs there'sRepeat
, 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
add a comment |
According to the docs there'sRepeat
, 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
add a comment |
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
}
add a comment |
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
}
add a comment |
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
}
add a comment |
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
}
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
}
answered 13 hours ago
Ludwik
1263
1263
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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