mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-21 18:10:42 -04:00
FEATURE: Add a chars attribute to the strings.ops module.
This commit is contained in:
parent
ec756636b0
commit
352f932485
@ -18,12 +18,14 @@ let ops = module {
|
||||
str="",
|
||||
} => ({len=len,
|
||||
str=str,
|
||||
chars=chars,
|
||||
split_on=split_on,
|
||||
split_at=split_at,
|
||||
substr=substr,
|
||||
}) {
|
||||
let len = import "std/lists.ucg".len(mod.str);
|
||||
let str = mod.str;
|
||||
let chars = reduce(func(acc, char) => acc + [char], [], mod.str);
|
||||
|
||||
let split_on = module{
|
||||
on=" ",
|
||||
|
@ -28,6 +28,11 @@ assert asserts.equal{
|
||||
right = 7,
|
||||
};
|
||||
|
||||
assert asserts.equal{
|
||||
left = str_class.chars,
|
||||
right = ["f", "o", "o", " ", "b", "a", "r"],
|
||||
};
|
||||
|
||||
assert asserts.equal{
|
||||
left = str_class.substr{start=1}.str,
|
||||
right = "oo bar",
|
||||
|
Loading…
x
Reference in New Issue
Block a user