tag_find: Racket implementation (non-recursive)
[experiments.git] / tag_find / tag-find.rkt
1 #lang racket
2
3 (define tag "tag")
4
5 (define start-sequence "#+")
6
7 (define tag-match? ( lambda (line)
8 (and (string-prefix? line start-sequence)
9 (string-contains? line tag))))
10
11 ;; TODO Make recursive
12 (define files
13 (filter file-exists? (directory-list)))
14
15 (define (find-file files)
16 (when (not (empty? files))
17 (define file (first files))
18 (define (find-line lines)
19 (when (not (empty? lines))
20 (if (tag-match? (first lines))
21 (displayln file)
22 (find-line (rest lines)))
23 ))
24 (find-line (file->lines file))
25 (find-file (rest files))
26 ))
27
28 (find-file files)