-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

for statement:

Editor (vim) - for.hgn (Try it online!) [+line no]
1 2 3 4 5 6 7 8 9 10
#! /bin/sh
exec huginn -E "${0}" "${@}"
#! huginn

main( argv_ ) {
	for ( arg : argv_ ) {
		print( "arg = {}\n".format( arg ) );
	}
	return ( 0 );
}

Program output:

Terminal - shell session [–line no]
[amok@vegeta](2/1)~/$ ./for.hgn one two three
arg = ./for.hgn
arg = one
arg = two
arg = three
[amok@vegeta](2/1)~/$

User defined types and user defined iterators in for statement:

Editor (vim) - for-iterator.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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#! /bin/sh
exec huginn --no-argv -E "${0}" "${@}"
#! huginn

class ListNode {
	_next = none;
	_data = none;
	constructor( data_, next_ ) {
		_data = data_;
		_next = next_;
	}
}

class ListIterator {
	_cur = none;
	constructor( cur_ ) {
		_cur = cur_;
	}
	is_valid() {
		return ( _cur != none );
	}
	value() {
		return ( _cur._data );
	}
	next() {
		_cur = _cur._next;
	}
}

class List {
	_head = none;
	add( data_ ) {
		_head = ListNode( data_, _head );
		return ( this );
	}
	get_size() {
		node = _head;
		i = 0;
		while ( node != none ) {
			node = node._next;
			i += 1;
		}
		return ( i );
	}
	iterator() {
		return ( ListIterator( _head ) );
	}
}

main() {
	l = List();
	l.add( "one" ).add( "two" ).add( "three" );
	print( "List size = {}\n".format( size( l ) ) );
	print( "List items:\n" );
	for ( e : l ) {
		print( "{}\n".format( e ) );
	}
}

Program output:

Terminal - shell session [–line no]
[amok@vegeta](2/1)~/$ ./for-iterator.hgn
List size = 3
List items:
three
two
one
[amok@vegeta](2/1)~/$