If you are using functionality that is defined in the standard library, you need to include the library:
java -jar muckefuk.jar helloworld.mkfk -J muckefuk-std.jar
The object data structure provides another way of creating a namespace object. Its constructor takes a list of pairs.
import("std.Object");
obj = Object.new (
foo: 10,
bar: func() 18;
);
obj.foo + obj.bar(); # returns 28
This is the same as writing:
obj = {
foo = 10;
bar = func() 18;
};
import("std.Array");
# create array
arr = Array.new(1, 2, 3, 4);
# add number
arr.add(8);
# print the size
print(arr.size());
# print all numbers
for (num in arr)
print(num);
# clear array
arr.clear();
import("std.Map");
# create map
map = Map.new(
1: "foo",
2: "bar"
);
# add entry
map.put(8, "test");
# get value
map.get(8);
# try to get value, otherwise return value
map.tryget(10, "nil");
# print all key-value pairs
for (k,v in map)
print(k, v);
# clear map
map.clear();
import("std.Set");
# create set
set = Set.new( 5, 1, 2, 5, 3, 3, 4 );
# add entry
set.add(8);
# check value
set.has(3);
# print all values
for (n in set)
print(n);
# clear set
set.clear();