Skip to content

arshajii/rho

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

Example:

def foo(a : Int, b : Int = 0) : Int {
	return 3*a - b
}

print foo(42, 99)    # OK
print foo(42)        # OK
print foo(4.2, 9.9)  # exception
print foo('x')       # exception
3a25140

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
doc
August 3, 2016 23:25
obj
December 14, 2014 19:51
February 15, 2016 13:17
src
December 30, 2017 18:48
February 15, 2016 13:17
November 24, 2017 11:05
December 27, 2017 17:01
November 24, 2017 12:26
November 24, 2017 10:19
December 11, 2015 18:10

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

About

The Rho programming language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages