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

The string is a scalar type that is used to represent and operate on character strings. It supports basic operations of addition and comparisons, it also supports subscript and range operators.

Methods
  • clear() - erase string content
  • find( needle, from ) - find position of substring needle that start not sooner than from position in the string
  • find_last( needle, before ) - find position of substring needle that ends just before before in the string
  • find_last_one_of( set ) - find position of any characters from given set that appears last just before before position in the string
  • find_last_other_than( set ) - find position of any characters that in not present in given set that appears last just before before position in the string
  • find_one_of( set ) - find position of any of characters in given set that appears first in the string but not sooner than from
  • find_other_than( set ) - find position of any of characters that is not present in given set that appears first in the string but not sooner than from
  • format( item... ) - construct string based on format template using items as format substitutions
  • replace( what, with ) - replace all occurrences of what substring with with substring
  • strip( set ) - strip all occurrences of characters in set from both ends of the string
  • strip_left( set ) - strip all occurrences of characters in set from the left side of the string
  • strip_right( set ) - strip all occurrences of characters in set from the right side of the string
  • to_lower() - turn all string's characters to lower case
  • to_upper() - turn all string's characters to upper case
Editor (vim) - string.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
#! /bin/sh
exec huginn --no-argv -E "${0}" "${@}"
#! huginn

main() {
	s = "manhole cover";
	print( s + "\n" );
	print( "type of s is {}\n".format( type( s ) ) );
	s.replace( "hole co", "ou" );
	print( s + "\n" );
	s.to_upper();
	print( s + "\n" );
	print( "VER at {}\n".format( s.find( "VER" ) ) );
	print( ( s = s[1::2].to_lower() ) + "\n" );
	print( s.strip( "ar" ) + "\n" );
	s.clear();
	print( "[{}]\n".format( s ) );
	return ( 0 );
}

Program output:

Terminal - shell session [–line no]
[amok@vegeta](2/1)~/$ ./string.hgn
manhole cover
type of s is string
manouver
MANOUVER
VER at 5
aovr
ov
[]
[amok@vegeta](2/1)~/$