Ikkljoup

From Esolang
Jump to navigation Jump to search

Ikkljoup or Ikl for short, by User:XFire35.

Notes

Comments are created in the following way:

// Creates a comment which continues to the end of the line
\\ Code \\ Creates a comment block, all code within is ignored

Variable assignments use a ':'

var foo: 'bar';

All statements must end with a ';'

var foo: 'bar';

To use a variable after declaration, use a '$'

$foo: 'bar1';

All strings are encapsulated with a pair of apostrophes:

'This is a string'

Numbers can be:

4
4.00
-4.00

Variables

Ikl has three variable declarations, "var", "con" and "loc". "var" creates a variable which may be changed at any point. "con" creates a variable which may only be destroyed, it's value cannot be modified. "loc" creates a variable with local scope.

var foo: 'bar';
con foo: 'bar';
loc foo: 'bar';

Within Ikl, there are there several types: string, number, table, boolean and object.

var foo: 'bar';
var foo: 1;

var foo: {'foo','bar'};   // To create a list
var foo: {'foo':'bar'};   // To create an associated list

var foo: t                // To create true boolean
var foo: f                // To create false boolean

obj foo: {.a:m[];};

Mathematical Operatorations

+[a b n];                // Adds values a, b, n...
-[a b n];                // Subtracts values a, b, n...
*[a b n];                // Multiplies values a, b, n...
/[a b n];                // Divides values a, b, n...
^[a b n];                // Exponents values a, b, n...

==[a b];                 // Returns 't' if a and b are equal
/=[a b];                 // Returns 't' if a and b are not equal
>[a b];                  // Returns 't' if a is greater than b
<[a b];                  // Returns 't' if a is less than b
>=[a b];                 // Returns 't' if a is greater than or equal to b
<=[a b];                 // Returns 't' if a is less than or equal to b

++[a b n];               // Adds values a, b, n... together
 if Strings: ++['Foo' 'bar']; gives 'foobar'
 if numbers: ++[1 4]; gives 14
 if strings and numbers: ++['Foo' 1 'bar']; gives 'Foo1bar'
 if tables, adds last table to the second from last and so on until the end is reached
 if object, adds the classes within the last object to the second from last object and so on until the end is reached

Functions

Functions are created in the following way:

<[function] code>;

Function Library

Standard Functions

usr:state[msg]; 	   // States contents of msg
 state: msg;    	   // May alternatively be used
usr:read[$var];            // Reads user input and assigns to $var

Type Functions

type:ask[$var]; 	   // Provides the type of $var
type:num[$var]; 	   // Converts $var to number
type:str[$var]; 	   // Converts $var to string

String Functions

string:find[$str.arg];    // Finds occurrences of arg in $str and returns count
string:sub[$str.arg.rep]; // Returns string with instances of arg replaced with rep in $str

string:size[$str];        // Returns length of $str
string:low_case[$str];    // Changes all characters of upper-case nature to lower case in $str
string:cap_case[$str];    // Changes all characters of lower-case nature to upper case in $str

Table Functions

table:size[$tab];	  // Returns quantity of indexes in $tab
table:put[$tab.val.pos];  // Insert val in $tab at position pos. Ommit pos to add val to end of $tab

table:rem[$tab.pos];      // Remove position pos from $tab. Ommit pos to remove last value in $tab
table:com[$tab.sep];      // Compress table with sepeator between values, sep

File Functions

file:open[file.mode];
file:close[file];
file:write[file];

Program Flow

self:main;                // Returns to the main function
self:func;                // Runs function named 'func';
self:break;               // Breaks current function and returns to the main function
self:exit;                // Stops the program, exits with 0

me:return[val];           // Returns value 'val'
me:break;                 // Breaks current loop

other:func;               // Runs functionn 'func' from 'other' module