View Problem

Perform an action multiple times based on a boolean condition, checked after the first action (DO .. WHILE)

Simulate rolling a die until you get a six. Produce random numbers, printing them until a six is rolled. An example output might be "4,2,1,2,6"
ExpandDiskEdit
scala
val dice = new GenRandInt(1, 6) ; var rnd = 0 ; var fmt = ""
do { rnd = dice.next ; fmt = if (rnd != 6) "%d," else "%d" ; printf(fmt, rnd) } while (rnd != 6)
ExpandDiskEdit
erlang
Pred = fun (DiceRoll) -> DiceRoll =/= 6 end,
Action = fun (DiceRoll) -> io:format("~B,", [DiceRoll]), dice_roll() end,

do_while(Pred, Action, dice_roll()).
DiskEdit
erlang
-module(dice).
-export([start/0]).

start() ->
roll(dice_roll()).

roll(6) ->
io:format("6~n", []);
roll(N) ->
io:format("~B,", [N]),
roll(dice_roll()).

dice_roll() -> random:uniform(6).
DiskEdit
csharp .Net 1.1 or higher
System.Random die = new System.Random();
int roll;

do
{
roll = die.Next(1, 6);
Console.Write(roll);
if (roll < 6) Console.Write(",");
}
while (roll != 6);

Submit a new solution for scala, erlang, or csharp
There are 14 other solutions in additional languages (clojure, cpp, fantom, fsharp ...)