The Rho programming language
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
obj
resources
src
.gitignore
.travis.yml
LICENSE
Makefile
README.md
TODO.md

README.md

logo

Rho Programming Language

Build Status License

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))
}