diff options
| author | 2024-09-08 08:22:39 -0400 | |
|---|---|---|
| committer | 2024-09-08 08:22:39 -0400 | |
| commit | 8bee2d39a43b589654a2067ff3385a33059fd308 (patch) | |
| tree | 3b99603d5e01495600e692ce86b9184cfcc43043 /util.scm | |
| parent | readtable: case folding (diff) | |
readtable: simplify
After taking a look at the R7RS syntax and how Chicken parses
directives, I realized that it's easier to have "#!", "#\\", etc.
parse identifiers instead of baking in trie actions. This is slightly
slower but completely removes the trie concept from the readtable,
which simplifies the implementation and removes many corner cases
involving combining readtables with different action types.
Diffstat (limited to 'util.scm')
| -rw-r--r-- | util.scm | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -33,3 +33,18 @@ ((not (f (car lst))) #f) (else (all f (cdr lst)))))) +;;; (REVAPPEND L1 ... LN) returns L{N-1}, L{N-2}, ... reversed and +;;; appended to LN, in that order. +(define revappend + (letrec ((loop + (lambda (lst1 lst2) + (if (null? lst1) + lst2 + (loop (cdr lst1) (cons (car lst1) lst2)))))) + (lambda lists + (cond + ((null? lists) '()) + ((null? (cdr lists)) (car lists)) + (else + (apply revappend (loop (car lists) (cadr lists)) + (cddr lists))))))) |
