From 0bbb74b7b0d8130cfcb71aedd7971e2906362a08 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 12 May 2020 12:32:57 -0700 Subject: for -> turn Inspired by hoon --- z.scm | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'z.scm') diff --git a/z.scm b/z.scm index e379066..46e6fcf 100644 --- a/z.scm +++ b/z.scm @@ -155,7 +155,7 @@ (define (index-node id) (let ([node (load-node id)]) (dict.set *titles* (title node) id) - (for (tags node) + (turn (tags node) (/. tag (if tag (dict.update @@ -177,14 +177,6 @@ (define (get-by-title title) (dict.get *titles* title)) - ;; Printing - -(define (print-titles) - (for (list-nodes) - (lambda (id) - (pr id) (pr ": ") - (prn (title (load-node id)))))) - ;; webserver (define *css* "body{max-width:650px;margin:40px auto;padding:0 10px;font:18px/1.5 -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, \"Noto Sans\", sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";color:#444}h1,h2,h3{line-height:1.2}@media (prefers-color-scheme: dark){body{color:white;background:#444}a:link{color:#5bf}a:visited{color:#ccf}}") @@ -240,7 +232,7 @@ ['() (respond `((ul - ,@(for (list-nodes) + ,@(turn (list-nodes) (lambda (id) `(li (a (@ (href ,(fmt "/node/~a" id))) ,(fmt "~a: ~a" @@ -254,14 +246,14 @@ (let ((tags (dict.keys *tags*))) (reindex) (respond - `((ul ,@(for tags + `((ul ,@(turn tags (lambda [tag] `(li (a (@ (href ,(fmt "/tag/~a" tag))) ,(fmt "~a" tag)))))))))] [("tag" tag) (let ([ids (tagged tag)]) (respond - `((ul ,@(for ids + `((ul ,@(turn ids (lambda [id] `(li (a (@ (href ,(fmt "/node/~a" id))) ,(fmt "~a: ~a" @@ -292,11 +284,15 @@ where 'command' is: [editor (os.getenv "EDITOR")]) (subprocess.call (list editor (path node))) (exit EXIT_SUCCESS))] - [("ls") (print-titles)] + [("ls") + (turn (list-nodes) + (lambda (id) + (pr id) (pr ": ") + (prn (title (load-node id)))))] [("tagged" tag) (begin (reindex) - (for (tagged tag) + (turn (tagged tag) (lambda (id) (pr id) (pr ": ") -- cgit v1.2.3