-login:
user: password:
Polski
huginn - programming language with no quirks, so simple every child can master it.
Fork me on GitHub
git clone https://codestation.org/repo/huginn.git
git clone https://github.com/AmokHuginnsson/huginn.git
git clone https://bitbucket.org/huginn/huginn.git
  1. Syntax
  2. Keywords
  3. Types

    Huginn provides several built-in scalar and collection types, as well as user defined compound types.

    integer real string number character boolean list deque dict order lookup set
  4. Built-ins
  5. Core library classes
  6. Packages

return statement:

Editor (vim) - return.hgn (Try it online!) [+line no]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#! /bin/sh
exec huginn -E "${0}" "${@}"
#! huginn

fib( n_ ) {
	x = 1;
	a = number( 0 );
	b = number( 1 );
	while ( x < n_ ) {
		t = a;
		a = copy( b );
		b += t;
		x += 1;
	}
	if ( n_ == 0 ) {
		b = 0;
	}
	return ( b );
}

main( argv_ ) {
	if ( size( argv_ ) < 2 ) {
		print(
			"Not enough arguments,"
			" you have to specify a number\n"
		);
		return ( 1 );
	}
	n = integer( argv_[1] );
	if ( n < 0 ) {
		print( "you must specify non-negative number\n" );
		return ( 2 );
	}
	print( "fib({}) = {}\n".format( argv_[1], fib( n ) ) );
	return ( 0 );
}

Program output:

Terminal - shell session [–line no]
[amok@vegeta](2/1)~/$ ./return.hgn
Not enough arguments, you have to specify a number
Exit 1
[amok@vegeta](2/1)~/$ ./return.hgn -2
you must specify non-negative number
Exit 2
[amok@vegeta](2/1)~/$ ./return.hgn 0
fib(0) = 0
[amok@vegeta](2/1)~/$ ./return.hgn 56
fib(56) = 225851433717
[amok@vegeta](2/1)~/$