Hack

Hack

Installation

Ubuntu
apt-get update
apt-get install software-properties-common apt-transport-https
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94
add-apt-repository https://dl.hhvm.com/ubuntu
apt-get update
apt-get install hhvm

Examples

Fibonacci Numbers
// Fibonacci Numbers
function fib(int $n): int {
    if ($n < 2) {
        return $n;
    } else {
        return fib($n - 2) + fib($n - 1);
    }
}

<<__EntryPoint>>
function main(): void {
    $n = (int) (vec(\HH\global_get('argv') as Container<_>)[1]);
    print fib($n);
    exit(0);
}

/*
    example
        run:
            hhvm fib.hack 39
*/