diff --git a/bin/print_vm.ml b/bin/print_vm.ml index d171716..11b706b 100644 --- a/bin/print_vm.ml +++ b/bin/print_vm.ml @@ -27,7 +27,7 @@ let main = let sources = get_sources_from ~directory () in try sources - |> Parser.get_ast ~include_stdlib:false + |> Parser.get_ast ~include_stdlib:true |> Compiler.compile |> Vm.eval ~root |> print_endline diff --git a/lib/pinc_parser/stdlib/Base_Array.pi b/lib/pinc_parser/stdlib/Base_Array.pi index addc506..bc45eb9 100644 --- a/lib/pinc_parser/stdlib/Base_Array.pi +++ b/lib/pinc_parser/stdlib/Base_Array.pi @@ -17,6 +17,30 @@ library Base_Array { array[0] }; + let map = fn (array, f) -> { + for (item in array) { + f(item) + } + }; + + let map_reverse = fn (array, f) -> { + for (item in reverse array) { + f(item) + } + }; + + let mapi = fn (array, f) -> { + for (index, item in array) { + f(index, item) + } + }; + + let mapi_reverse = fn (array, f) -> { + for (index, item in reverse array) { + f(index, item) + } + }; + let last = fn (array) -> { let len = length(array); if (len > 0) { @@ -63,30 +87,6 @@ library Base_Array { result }; - let map = fn (array, f) -> { - for (item in array) { - f(item) - } - }; - - let map_reverse = fn (array, f) -> { - for (item in reverse array) { - f(item) - } - }; - - let mapi = fn (array, f) -> { - for (index, item in array) { - f(index, item) - } - }; - - let mapi_reverse = fn (array, f) -> { - for (index, item in reverse array) { - f(index, item) - } - }; - let partition = fn (array, condition) -> { let len = length(array); let part = fn (yes, no, index) -> { diff --git a/lib/pinc_parser/stdlib/Base_String.pi b/lib/pinc_parser/stdlib/Base_String.pi index be20148..ef55eb9 100644 --- a/lib/pinc_parser/stdlib/Base_String.pi +++ b/lib/pinc_parser/stdlib/Base_String.pi @@ -81,6 +81,8 @@ library Base_String { result }; + let sub = fn (string, ofs, len) -> %%pinc_string_sub%%; + let trim = fn (string) -> { let len = length(string); let mutable i = 0; @@ -108,8 +110,6 @@ library Base_String { } }; - let sub = fn (string, ofs, len) -> %%pinc_string_sub%%; - let split = fn (string, sep) -> { let mutable result = []; let mutable j = length(string);