Login
|
Signup
langref.org
-
ruby
,
clojure
, and
erlang
add..
all
cpp
csharp
fantom
fsharp
go
groovy
haskell
java
ocaml
perl
php
python
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Structure
Loops
Perform an action a fixed number of times (FOR)
Display the string
"Hello"
five times like
"HelloHelloHelloHelloHello"
ruby
puts "Hello"*5
puts "Hello"*5
ruby
5.times { print "Hello" }
5.times { print "Hello" }
clojure
(dotimes [_ 5]
(print "Hello"))
(dotimes [_ 5]
(print "Hello"))
erlang
dotimes(5, fun () -> io:format("Hello") end).
-module(dotimes).
-export([start/0]).
start() ->
dotimes(5, fun () -> io:format("Hello") end).
dotimes(0, _) -> true;
dotimes(N, Action) -> Action(), dotimes(N - 1, Action).
erlang
lists:foreach(fun (_) -> io:format("Hello") end, lists:seq(1, 5)).
-module(dotimes).
-export([start/0]).
start() ->
lists:foreach(fun (_) -> io:format("Hello") end, lists:seq(1, 5)).
Submit a new solution for
ruby
,
clojure
, or
erlang
There are 32 other solutions in
additional
languages (
cpp
,
csharp
,
fantom
,
fsharp
...)