Skip to content

Commit

Permalink
Merge pull request #75 from kilianc/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ph0enixKM authored May 23, 2024
2 parents 90550c7 + 88f9051 commit 6c3b5a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/std/main.ab
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ pub fun lines(text: Text): [Text] {
return result
}

pub fun words(text: Text): [Text] {
return split(text, " ")
}

pub fun join(list: [Text], delimiter: Text): Text {
return unsafe $IFS="{delimiter}" ; echo "\$\{{nameof list}[*]}"$
}
Expand Down
8 changes: 8 additions & 0 deletions src/tests/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,10 @@ fn test_std_library() {
loop line in lines(\"hello\nworld\") {
echo line
}
// Split a multiline string into a list of string by one or more spaces
loop word in words(\"hello world ciao mondo\") {
echo word
}
// Join a list of strings into a string
echo join(split(\"hello world\", \"l\"), \"l\")
// Transform string into a lowercase string
Expand Down Expand Up @@ -790,6 +794,10 @@ fn test_std_library() {
"he o wor d",
"hello",
"world",
"hello",
"world",
"ciao",
"mondo",
"hello world",
"hello world",
"HELLO WORLD",
Expand Down

0 comments on commit 6c3b5a1

Please sign in to comment.