mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-19 18:20:22 +02:00
Implement built-in string procedures.
* module/language/js-il/runtime.js (string-append): Extend to more than 2 arguments. (string-join): New procedure.
This commit is contained in:
parent
2adebea5d0
commit
2273eb4d06
1 changed files with 26 additions and 2 deletions
|
@ -797,8 +797,32 @@ def_guile0("string=?", function (self, cont, s1, s2) {
|
|||
});
|
||||
|
||||
def_guile0("string-append", function (self, cont, s1, s2) {
|
||||
var s = new scheme.String(s1.s + s2.s);
|
||||
return cont(s);
|
||||
var s = "";
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
s += arguments[i].s;
|
||||
}
|
||||
|
||||
//console.log("sap", s1, s2, arguments.length);
|
||||
return cont(new scheme.String(s));
|
||||
});
|
||||
|
||||
def_guile0("string-join", function (self, cont, strings) {
|
||||
var s = "";
|
||||
|
||||
while (!scheme.is_true(scheme.primitives["null?"](strings))) {
|
||||
if (scheme.is_true(scheme.primitives["pair?"](strings))) {
|
||||
s += strings.car.s;
|
||||
strings = strings.cdr;
|
||||
} else {
|
||||
console.log("string-join bad");
|
||||
not_implemented_yet();
|
||||
}
|
||||
}
|
||||
|
||||
return cont(new scheme.String(s));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Structs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue