From fbc6c6c8f4fe51ff276a2c0fffb2e921b7271a9e Mon Sep 17 00:00:00 2001 From: pho4cexa Date: Sun, 25 Dec 2022 14:35:31 -0800 Subject: [PATCH] today i learned cute/cut (srfi-26, built in to chicken) for sorta-currying --- main.scm | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/main.scm b/main.scm index 9111f3a..3ee380d 100755 --- a/main.scm +++ b/main.scm @@ -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 #\$))) ""