MathCurvesSurfacesWallpaper GroupsGallerySoftwarePOV-Ray
ProgramingLinuxPerl PythonHTMLCSSJavaScriptPHPJavaEmacsUnicode ♥
Web Hosting by 1&1

Python, Ruby, Perl: “while” Loop Example

Xah Lee, , …,

Python

#-*- coding: utf-8 -*-
# python

x = 1
while x <= 9:
    print x
    x += 1

http://docs.python.org/reference/compound_stmts.html#while

Ruby

#-*- coding: utf-8 -*-
# ruby

x = 1;
while x <= 9 do
  p x
  x += 1
end

Perl

#-*- coding: utf-8 -*-
# perl

$x = 1;
while ($x <= 9) {
  print $x, "\n";
  $x++;
}

perldoc perlsyn

blog comments powered by Disqus