today i learned cute/cut (srfi-26, built in to chicken) for sorta-currying

This commit is contained in:
pho4cexa 2022-12-25 14:35:31 -08:00
parent 696ed31f85
commit fbc6c6c8f4

View file

@ -110,13 +110,9 @@
(let ((linkurl (alist-ref 'href (alist-ref '@ i))))
`(,t .
,(if (and adjust-relative
(not (string-prefix? "#" linkurl))
(not (string-prefix? "/" linkurl))
(not (string-prefix? "https://" linkurl))
(not (string-prefix? "http://" linkurl))
(not (string-prefix? "mailto:" linkurl))
(not (string-prefix? "https://" linkurl)))
(not (any
(cute string-prefix? <> linkurl)
'("#" "/" "https://" "http://" "mailto:" "https://"))))
(alist-update '@
(alist-update 'href `(,adjust-relative ,linkurl) (alist-ref '@ i))
i)
@ -138,7 +134,7 @@
"-\t-\t"
(call-with-input-pipe
(string-append "git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 --numstat HEAD -- " source-file)
(lambda (port) (read-line port 4))))))
(cute read-line <> 4)))))
(define (git-repository->paths-list)
(call-with-input-pipe "git ls-tree -r --name-only HEAD" read-lines))
@ -281,15 +277,15 @@
. ,(pathname-strip-directory (string-chomp html-repo-path "/")))
;; the first README file found, if any.
(readme_file
. ,(find (lambda (x) (member x source-files-list))
. ,(find (cut member <> source-files-list)
'("README" "README.md" "README.txt")))
;; the first LICENSE file found, if any.
(license_file
. ,(find (lambda (x) (member x source-files-list))
. ,(find (cut member <> source-files-list)
'("LICENSE" "LICENSE.md" "LICENSE.txt")))
;; the string "ISSUES" if any files exist in ISSUES/
(issues_file
. ,(and (find (lambda (x) (string-prefix? "ISSUES/" x)) source-files-list) "ISSUES"))
. ,(and (find (cut string-prefix? "ISSUES/" <>) source-files-list) "ISSUES"))
(repo2html_version
. ,(if (equal? version-ident (list->string '(#\$ #\I #\d #\$)))
""