Linggo, Pebrero 12, 2012

BOO!!!

Boo is a object oriented statically typed programming language for the Common Language Infrastructure with a python inspired syntax and a special focus on language and compiler extensibility.

Loop 

range(end)
range(start, end)
range(start, end, step)

for loop:
for var in range():
//...
sample:
for i in range (1, 6) : //loop syntax from 1 to 5
print (i) //show numbers from 1 to 5

continue statement:
if the loop is followed by an condition.
sample:
for i in range(10):
    continue if i % 2 == 0
    print i

while loop:
var while var < max var: 
print (var) 
++var
sample:
i = 0 //initialize var
while i < 10: //while condition
print (i) //show var
++i ,--i, i mdas = n//increment or decrement var

while-break-unless loop statement:
similar to do-while.
i = 10
while true:
    print i
    i -= 1
    break unless i < 10 and i > 5

Condition

if statement:
var = n
if var operator n:
 //...
sample:
i=70
if i == 70:
print"Passed."

if else statement:
var = n
if var operator n:
 //...
else:
//...
sample:
i=70
if i  >= 70:
print"Passed."
else:
print"Failed."

if-elif-else statement:
i = 5 //initialize var
if i > 5: //condition
    print "i is greater than 5." //output text
elif i == 5: //condition
    print "i is equal to 5." //output text
elif i < 5: //condition
    print "i is less than 5." //output text

unless statement:
The unless statement is handy if you want a readable way of checking if a condition is not true.

i = 5//initialize var
unless i == 5: //condition
    print "i is not equal to 5." //output text

Array
a[]
print((0, 'alpha', 4.5, char('d')))
output:
(0, alpha, 4.5, d)

print array('abcdefghij')
output:
(a, b, c, d, e, f, g, h, i, j)

a= array(range(5))
print a
output:
(0, 1, 2, 3, 4)

a[2] = 5 
print a
output:
(0, 1, 5, 3, 4)


Reference:
http://boo.codehaus.org
http://boo.codehaus.org/BooManifesto.pdf

Walang komento:

Mag-post ng isang Komento