Skip to content

Commit be5f9df

Browse files
committed
string lib v1 contruct complete
1 parent 825f03d commit be5f9df

4 files changed

Lines changed: 18 additions & 13 deletions

File tree

stroll/lib/core.sr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
)
44
(fn scan prompt
55
(return (native "input(prompt)"))
6-
)
6+
)

stroll/lib/string.sr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
(fn )
1+
(fn splitstr value|sep
2+
(native 'value.split(sep)')
3+
)
4+
(fn joinstr values|joiner
5+
(native "joiner.join([f'{v}' for v in values])")
6+
)

stroll/src/runtime.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,7 @@ def import_module(kind: str, name: str, env: dict, here_file: str) -> str: # sel
4141
return abspath
4242

4343
NATIVE_GLOBALS = {
44-
"__builtins__": {
45-
"print": builtins.print,
46-
"input": builtins.input,
47-
"len": builtins.len,
48-
"range": builtins.range,
49-
"abs": builtins.abs,
50-
"min": builtins.min,
51-
"max": builtins.max,
52-
"sum": builtins.sum,
53-
"open": builtins.open,
54-
},
44+
"__builtins__": builtins,
5545
"math": math,
5646
} # we need it for the exec and eval for native code(Safe sand box) we will be changing and adding stuff here as we use more native code
5747

stroll/src/strlib.sr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(use "std" "core")
2+
(use "std" "string")
3+
4+
(let a (scan "string to input"))
5+
(let b (scan "sep"))
6+
7+
(let x (splitstr a b))
8+
(print (index x 2))
9+
10+
(print (joinstr (list 1 2 3 4) "-"))

0 commit comments

Comments
 (0)