mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-05 22:48:43 +00:00
name tree mostly finished
This commit is contained in:
parent
263b58a17c
commit
fc114ff959
14 changed files with 116 additions and 38 deletions
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
:: module; // import module to current namespace
|
||||
|
||||
:: _ = module; // import module to current namespace and use functions inside without namespace
|
||||
:: _ = module_2; // import module to current namespace and use functions inside without namespace
|
||||
|
||||
:: module : func1 func2 func3;
|
||||
:: module_namespace = module;
|
||||
:: module_3 : func1 func2 func3;
|
||||
:: module_namespace = module_4;
|
||||
|
||||
func = {
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ sum 'a? 'b? =
|
|||
: example that shows that default annotations are argument names (without ')
|
||||
@a is integer
|
||||
@b also integer
|
||||
sum 'a 'b = 'a + 'b;
|
||||
sum_2 'a 'b = 'a + 'b;
|
||||
|
||||
: this function can be used to calculate Fibonacci sequence elements
|
||||
: it is important is some algorithmic tasks
|
||||
|
|
@ -137,7 +137,7 @@ bubble_sort 'arr : <> Array['A] = {
|
|||
}
|
||||
|
||||
: bubble_sort with names instead of symbols
|
||||
bubble_sort 'arr : ref Array['A] = {
|
||||
bubble_sort_2 'arr : ref Array['A] = {
|
||||
var swap_occured := true;
|
||||
for swap_occured do {
|
||||
swap_occured = false;
|
||||
|
|
@ -151,9 +151,7 @@ bubble_sort 'arr : ref Array['A] = {
|
|||
& @key Key
|
||||
& @value Value
|
||||
& @left ^TreeNode['Key 'Value]
|
||||
& @right ^TreeNode['Key 'Value];
|
||||
|
||||
TreeNode {
|
||||
& @right ^TreeNode['Key 'Value] {
|
||||
new = do_something; // static methods
|
||||
|
||||
$insert 'key = do_something; // const methods
|
||||
|
|
@ -186,7 +184,7 @@ print_two 'a 'b = print 'a, print 'b;
|
|||
swap 'a 'b : <> 'A <> 'A = %c := <- 'a, 'a := <- 'b, 'b := <- c;
|
||||
|
||||
: previous example with automatic type deduction
|
||||
swap <> 'a <> 'b = %c := <- 'a, 'a := <- 'b, 'b := <- c;
|
||||
swap_2 <> 'a <> 'b = %c := <- 'a, 'a := <- 'b, 'b := <- c;
|
||||
|
||||
: several outputs example
|
||||
scan_three : -> String -> String -> String = scan & scan & scan;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue