aboutsummaryrefslogtreecommitdiffstats
path: root/src/cklist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cklist.c')
-rw-r--r--src/cklist.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cklist.c b/src/cklist.c
index d22ee49..e1ca7d8 100644
--- a/src/cklist.c
+++ b/src/cklist.c
@@ -137,16 +137,16 @@ cklist* list_copy_part(cklist *ckl, int from, int until) {
return _ckl;
}
-void list_print_lisp(cklist *ckl) {
+void print_list_enclose_in(cklist *ckl, const char before, const char after) {
if (ckl->size > 0) {
list_rewind(ckl);
- printf("( \"%s\"", list_get(ckl));
+ printf("%c \"%s\"", before, list_get(ckl));
if (ckl->size == 1) {
- printf(" )\n");
+ printf(" %c\n", after);
}
while (list_next(ckl)) {
if (ckl->pos == ckl->size-1) {
- printf(", \"%s\" )\n", list_get(ckl));
+ printf(", \"%s\" %c\n", list_get(ckl), after);
}
else {
printf(", \"%s\"", list_get(ckl));
@@ -156,9 +156,18 @@ void list_print_lisp(cklist *ckl) {
}
}
+void list_print_lisp(cklist *ckl) {
+ print_list_enclose_in(ckl, '(', ')');
+}
+
+void list_print_python(cklist *ckl) {
+ print_list_enclose_in(ckl, '[', ']');
+}
+
void list_print(cklist *ckl) {
if (ckl->size > 0) {
list_rewind(ckl);
+ printf("%s\n", list_get(ckl));
while (list_next(ckl)) {
printf("%s\n", list_get(ckl));
}