Created
December 5, 2014 03:22
-
-
Save mathias/9e6773508969e06c62e7 to your computer and use it in GitHub Desktop.
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
lval* builtin_join_str(lenv* e, lval* a) { | |
for(int i = 0; i < a->count; i++) { | |
LASSERT_TYPE("join", a, i, LVAL_STR); | |
} | |
lval* x = lval_pop(a, 0); | |
while (a->count) { | |
lval* y = lval_pop(a, 0); | |
char* concatted = malloc(strlen(x->str) + strlen(y->str) + 1); | |
concatted = strcat(x->str, y->str); | |
x = lval_str(concatted); | |
free(concatted); | |
free(y); | |
} | |
lval_del(a); | |
return x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment