Rho Programming Language
Rho is a lightweight, dynamically typed programming language written in C. The language is largely inspired by Python, both in terms of syntax and implementation (CPython, to be exact).
Examples
"hello world"
# simple "hello world" program print 'hello world'
Arithmetic
print ((50 - 5*6)/4)**2 # prints 25
if
statements
b = 1 if b { print "b is non-zero!" # strings can be delimited by either " or ' } else { print "b is zero!" }
while
statements
# print integers from 1 to 9: a = 1 while a < 10 { print a a += 1 }
for
statements
# equivalent of while-loop above: for a in 1..10: # ':' can be used for single-statement blocks print a
Functions
# factorial function def fact(n) { if n < 2 { return 1 } else { return n * fact(n - 1) } } # hypotenuse function def hypot(a, b) { # functions can be nested: def square(x) { return x**2 } # functions can be anonymous: sqrt = (: $1 ** 0.5) return sqrt(square(a) + square(b)) }