View Problem

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

Starting with a variable x=1, Print the sequence "1,2,4,8,16,32,64,128," by doubling x and checking that x is less than 150.
DiskEdit
ruby
x=1
while x < 150
puts x
x <<= 1
end
ExpandDiskEdit
erlang
X = 1, print_while_X_less_150(X).
ExpandDiskEdit
erlang
Pred = fun (X) -> X < 150 end,
Action = fun (X) -> io:format("~B,", [X]), X * 2 end,
X = 1,

while_do(Pred, Action, X).
DiskEdit
csharp
int x = 1;

while (x < 150)
{
x *= 2;
Console.Write("{0},", x);
}

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