commit b82d43f
chld
·
2026-08-15 15:44:02 +0000 UTC
parent b82d43f
init: line by line file parsing and test.scm
A
Makefile
+4,
-0
1@@ -0,0 +1,4 @@
2+x: a b
3+a: c
4+b:
5+c:
A
test.scm
+7,
-0
1@@ -0,0 +1,7 @@
2+(use-modules (util))
3+(define m-list (file-read "Makefile"))
4+(do ((l 0 (+ l 1)))
5+ ((>= l (length m-list)))
6+ (begin
7+ (display (list-ref m-list l))(newline)
8+ ))
A
util.scm
+11,
-0
1@@ -0,0 +1,11 @@
2+(define-module (util)
3+ #:use-module (ice-9 popen)
4+ #:use-module (ice-9 rdelim)
5+ #:export (file-read)
6+)
7+
8+(define (file-read f)
9+ (call-with-input-file f (lambda (p)
10+ (let loop ((L '()))
11+ (let ((l (read-line p)))
12+ (if (eof-object? l)(reverse L)(loop (cons l L))))))))