Logo

Programming-Idioms

  • Erlang
  • Perl
print "Hello\n" for 1 .. 10;

Note the necessary newline (\n), not to print every time on the same line
print "Hello\n" x 10;

Without using a loop, using the repeat operator.
say "Hello" for 1 .. 10;

Recent (5.10 and later) versions of Perl also provide
say function, which automatically adds the newline.
lists:foreach(
  fun(_) ->
    io:format("Hello~n")
  end, lists:seq(1, 10)).
with Ada.Text_IO;
use Ada.Text_IO;
for I in 1 .. 10 loop
  Put_Line ("Hello");
end loop;

New implementation...
< >
programming-idioms.org