From 0452f442b1ec1a3a482d1f3c3503afdc25496f07 Mon Sep 17 00:00:00 2001 From: alex-eg Date: Thu, 5 Jun 2025 12:15:06 +0300 Subject: [PATCH] filter out '()s from the tree --- sexc.scm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sexc.scm b/sexc.scm index 5aeeda1..b027d85 100644 --- a/sexc.scm +++ b/sexc.scm @@ -3,7 +3,9 @@ (chicken string) fmt fmt-c - getopt-long) + getopt-long + srfi-1 ; list routines + ) (define (unkebabify sym) (string->symbol @@ -63,7 +65,8 @@ If filter-proc returns something other, use it instead of processing the element (cons (let ((r (read))) (when (eof-object? r) - (return (reverse collect))) + (return (filter (lambda (e) (not (null? e))) + (reverse collect)))) (case (car r) ((define) (eval r) @@ -76,8 +79,7 @@ If filter-proc returns something other, use it instead of processing the element (define (emit-c forms) (map (lambda (form) - (if (not (null? form)) - (fmt #t (c-expr form))) + (fmt #t (c-expr form)) (fmt #t "\n")) forms))