File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change
1
+ from ltypes import i32
2
+
1
3
def _lpython_strcmp_eq (a : str , b : str ) -> bool :
2
4
if len (a ) != len (b ):
3
5
return False
@@ -38,6 +40,17 @@ def _lpython_strcmp_gt(a: str, b: str) -> bool:
38
40
def _lpython_strcmp_gteq (a : str , b : str ) -> bool :
39
41
return _lpython_strcmp_eq (a , b ) or _lpython_strcmp_gt (a , b )
40
42
43
+ def _lpython_str_concat (a : str , b : str ) -> str :
44
+ return a + b
45
+
46
+ def _lpython_str_repeat (a : str , n : i32 ) -> str :
47
+ s : str
48
+ s = ""
49
+ i : i32
50
+ for i in range (n ):
51
+ s += a
52
+ return s
53
+
41
54
def f ():
42
55
assert _lpython_strcmp_eq ("a" , "a" )
43
56
assert not _lpython_strcmp_eq ("a2" , "a" )
@@ -80,4 +93,9 @@ def f():
80
93
assert _lpython_strcmp_gteq ("bg" , "abc" )
81
94
assert _lpython_strcmp_gteq (a , b )
82
95
96
+ assert _lpython_str_concat ("abc" , "def" ) == "abcdef"
97
+ assert _lpython_str_concat ("" , "z" ) == "z"
98
+ assert _lpython_str_repeat ("abc" , 3 ) == "abcabcabc"
99
+ assert _lpython_str_repeat ("" , - 1 ) == ""
100
+
83
101
f ()
You can’t perform that action at this time.
0 commit comments