static Object* ListPrint(Context* ctx) { Object* o = StackPop(ctx->stack); if(!ListP(o)) { abort(); // TODO: return error } List* l = ObjectGetDataPtr(o); fputc('(', stdout); while(l->value) { if(l->value->type->printFn && l->value->type->printFn->isBuiltIn) { StackPush(ctx->stack, l->value); l->value->type->printFn->builtIn(ctx); if(l->next && ListP(l->next) && ((List*)ObjectGetDataPtr(l->next))->value) { fputc(' ', stdout); } } if(!l->next) { break; } o = l->next; if(!ListP(o)) { abort(); // TODO: return error } l = ObjectGetDataPtr(o); } fputc(')', stdout); return NULL; }
int main() { int *n, num, i, cont; puts("Informe n: "); scanf("%d", &num); n = malloc(sizeof(int) * num); for(cont = 0; cont < num; cont++) { n[cont] = cont + 1; } ListP(n, num); return 0; }