-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lib: list::length -> list::size, add list::map, string::length, strin…
…g::split, string::trim
- Loading branch information
1 parent
435c163
commit e41cbaa
Showing
7 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#import: | ||
list/length | ||
list/size | ||
list/join | ||
list/map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#function map with t!* r!* returns list!r: | ||
#list!t values | ||
#function!(t uint list!t r) mapper | ||
|
||
#list!r result = [ | ||
#each values as var i, var value: | ||
#set result = [...result, mapper(value, i, values) | ||
|
||
#return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#function length returns uint: | ||
#function size returns uint: | ||
#list!* values | ||
|
||
#uint result = 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
#import: string/hex | ||
#import: | ||
string/length | ||
string/hex | ||
string/split | ||
string/trim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#function length returns uint: | ||
#string input | ||
|
||
#uint result = 0 | ||
#each input as var char: | ||
#set result++ | ||
|
||
#return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#function split returns list!string: | ||
#string target | ||
#string separator ??= " | ||
#list!string result = [ | ||
|
||
#if separator == "": | ||
#each in target as string char: | ||
#set result = [...result, char | ||
|
||
#else: | ||
#uint l = separator::length | ||
#uint s = 0 | ||
#each in target as uint i, string char: | ||
#uint e = i + l | ||
#if target[i..e] == separator: | ||
#set result = [...result, target[s..i] | ||
#set s = i + l | ||
#set result = [...result, target[s...] | ||
|
||
#return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#function trim returns string: | ||
#string input | ||
|
||
#uint length = input::length | ||
#uint start = 0 | ||
#uint end = input::length | ||
|
||
#while start < length: | ||
#string char = input[start] | ||
#if char == " " || char == "\t" || char == "\r" || char == "\n": | ||
#set start++ | ||
#continue | ||
|
||
#break | ||
|
||
#while end > start: | ||
#string char = input[end - 1] | ||
#if char == " " || char == "\t" || char == "\r" || char == "\n": | ||
#set end-- | ||
#continue | ||
|
||
#break | ||
|
||
#string result = "" | ||
#for var i = start, i < end, set i++: | ||
#set result = result . input[i] | ||
|
||
#return result |