View Problem

Perform an action a fixed number of times with a counter

Display the string "10 .. 9 .. 8 .. 7 .. 6 .. 5 .. 4 .. 3 .. 2 .. 1 .. Liftoff!"
DiskEdit
clojure
(dotimes [i 10]
(print (str (- 10 i) " .. ")))

(println "Liftoff!")
ExpandDiskEdit
cpp C++/CLI .NET 2.0
for(int i = 10; i != 0; --i) Console::Write("{0} .. ", i);
Console::WriteLine("Liftoff!");
DiskEdit
csharp
for (int i = 10; i > 0; i--)
{
Console.Write("{0} .. ", i);
}

Console.WriteLine("Liftoff!");
ExpandDiskEdit
erlang
fromto(10, 1, -1, fun (X) -> io:format("~B .. ", [X]) end), io:format("Liftoff!~n").
ExpandDiskEdit
erlang
lists:foreach(fun (X) -> io:format("~B .. ", [X]) end, lists:seq(10, 1, -1)), io:format("Liftoff!~n").
ExpandDiskEdit
fantom
(10..1).each { Env.cur.out.print("$it .. ") }
Env.cur.out.print("Liftoff!")
ExpandDiskEdit
fantom
for (i := 10; i >= 1; i--)
Env.cur.out.print("$i .. ")
Env.cur.out.print("Liftoff!")
ExpandDiskEdit
fsharp
for i = 10 downto 1 do printf "%d .. " i done
printfn "Liftoff!"
ExpandDiskEdit
fsharp
// Repetition via ranging over a Sequence type
for i in {10 .. -1 .. 1} do printf "%d .. " i done ; printfn "Liftoff!"
DiskEdit
groovy
10.downto(1) { print it + " .. " }
println "Liftoff!"
DiskEdit
haskell
countDown = mapM_ printN [10,9..1] >> putStr "Liftoff!"
where printN n = putStr $ show n ++ " .. "
ExpandDiskEdit
java
for(int i=10; i>=1; i--) {
System.out.print(i + " .. ");
}
System.out.print("Liftoff!");
DiskEdit
ocaml
for i = 10 downto 1 do
Printf.printf "%d .. " i
done;
print_endline "Liftoff!"
DiskEdit
perl
for (my $i = 10; $i > 0; $i--) {
print "$i .. ";
}
print "Liftoff!";
DiskEdit
perl
print "$_ .. " for reverse 1..10;
print "Liftoff!";
ExpandDiskEdit
php
for($i = 10; $i > 0; $i--) {
echo $i." .. ";
}
echo "Liftoff!";
DiskEdit
python 2.4
print " .. ".join(str(i) for i in range(10, 0, -1)), ".. liftoff!"
DiskEdit
ruby
10.downto(1) { |n| print n, " .. " }
puts "Liftoff!"
ExpandDiskEdit
scala
for (i <- List.range(1, 11).reverse) printf("%d .. ", i) ; println("Liftoff!")
ExpandDiskEdit
scala
for (i <- List.range(-10, 0)) printf("%d .. ", (-i)) ; println("Liftoff!")
ExpandDiskEdit
scala
var i = 10 ; while (i > 0) { printf("%d .. ", i) ; i -= 1 } ; println("Liftoff!")
ExpandDiskEdit
scala
for (i <- -10 to -1) printf("%d .. ", (-i)) ; println("Liftoff!")

Submit a new solution for clojure, cpp, csharp, erlang ...