Programming-Idioms

History of Idiom 2 > diff from v54 to v55

Edit summary for version 55 :
[D] main() not needed

Version 54

2017-08-06, 15:36:57

Version 55

2017-08-07, 19:40:40

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration

Idiom #2 Print Hello 10 times

Loop to execute some code a constant number of times

Illustration
Imports
import std.stdio : writeln;
import std.range : iota;
import std.algorithm.iteration : each;
Imports
import std.stdio : writeln;
import std.range : iota;
import std.algorithm.iteration : each;
Code
void main(){iota(0,10).each!(a => "Hello".writeln);}
Code
iota(0,10).each!(a => "Hello".writeln);
Comments bubble
iota generates an iterable sequence of number.
each is a higher order function.
Hello is written using UFCS in a delegate literal.
Comments bubble
iota generates an iterable sequence of number.
each is a higher order function.
Hello is written using UFCS in a delegate literal.
Doc URL
https://dlang.org/phobos/std_algorithm_iteration.html#each
Doc URL
https://dlang.org/phobos/std_algorithm_iteration.html#each
Demo URL
http://ideone.com/MjsOpv
Demo URL
http://ideone.com/MjsOpv