list.c
char* list_tostr(atom_t* obj, int depth) {
    list_assert(obj, "list_tostr");
    atom_t** items = obj->val.list->items;
    char* o;
    char buf[1024];
    char ellipsis = 0;
    strcpy(buf, "(");

    for (int i = 0; i < list_len(obj); ++i) {

        if (ellipsis || strlen(buf) > 1000) {
            strcat(buf, " ... ");
            break;
        }

        o = atom_tostring(items[i], depth ? depth - 1 : depth);
        if (strlen(buf) + strlen(o) > 1000)
            ellipsis = 1;
        else
            strcat(buf, o);
        safe_free(o);

        if (i < list_len(obj) - 1)
            strcat(buf, " ");
    }

    strcat(buf, ")");
    o = malloc(strlen(buf) + 1);
    strcpy(o, buf);
    return o;
}
/*
--------------------------------------
list_tostr

    Make a stiring representing list.
--------------------------------------
*/
list_tostr
Make a stiring representing list.
list_tostr Make a stiring representing list .
char* list_tostr(atom_t* obj, int depth) {
    list_assert(obj, "list_tostr");
    atom_t** items = obj->val.list->items;
    char* o;
    char buf[1024];
    char ellipsis = 0;
    strcpy(buf, "(");
    for (int i = 0; i < list_len(obj); ++i) {
        if (ellipsis || strlen(buf) > 1000) {
            strcat(buf, " ... ");
            break;
        }
        o = atom_tostring(items[i], depth ? depth - 1 : depth);
        if (strlen(buf) + strlen(o) > 1000)
            ellipsis = 1;
        else
            strcat(buf, o);
        safe_free(o);
        if (i < list_len(obj) - 1)
            strcat(buf, " ");
    }
    strcat(buf, ")");
    o = malloc(strlen(buf) + 1);
    strcpy(o, buf);
    return o;
}
char * list_tostr ( atom_t * obj , int depth ) { list_assert ( obj , " " ) ; atom_t * * items = obj -> val . list -> items ; char * o ; char buf [ 1024 ] ; char ellipsis = 0 ; strcpy ( buf , " " ) ; for ( int i = 0 ; i < list_len ( obj ) ; ++ i ) { if ( ellipsis || strlen ( buf ) > 1000 ) { strcat ( buf , " " ) ; break ; } o = atom_tostring ( items [ i ] , depth ? depth - 1 : depth ) ; if ( strlen ( buf ) + strlen ( o ) > 1000 ) ellipsis = 1 ; else strcat ( buf , o ) ; safe_free ( o ) ; if ( i < list_len ( obj ) - 1 ) strcat ( buf , " " ) ; } strcat ( buf , " " ) ; o = malloc ( strlen ( buf ) + 1 ) ; strcpy ( o , buf ) ; return o ; }
list_tostr
Make a stiring representing list.
list_tostr Make a stiring representing list .