aboutsummaryrefslogtreecommitdiffstats
path: root/src/cklist.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-08-18 18:44:14 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-08-18 18:44:14 +0300
commit0f33c8a9cbabda257c4dd73009266a4cf5f857a7 (patch)
tree1b0ca0c9a3d06b6ccd32c456f8fe8d84cb153093 /src/cklist.c
parentffc33043a488ecf038d8414fc8af1e99389619f8 (diff)
downloadck-0f33c8a9cbabda257c4dd73009266a4cf5f857a7.tar.gz
ck-0f33c8a9cbabda257c4dd73009266a4cf5f857a7.tar.bz2
ck-0f33c8a9cbabda257c4dd73009266a4cf5f857a7.zip
steps towards list
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));
}