# HG changeset patch # User Steve Losh # Date 1639527046 18000 # Node ID 86d92162dc1f41b42812027a3790fe93866f9000 # Parent e3aefcbf364cb6449942981685138f329723e5ad Update to latest cl-losh diff -r e3aefcbf364c -r 86d92162dc1f src/package.lisp --- a/src/package.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/package.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -27,6 +27,7 @@ :hamming :string-empty-p + :strjoin :first-char :Σ :Π :binomial-coefficient diff -r e3aefcbf364c -r 86d92162dc1f src/problems/grph.lisp --- a/src/problems/grph.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/problems/grph.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -49,10 +49,10 @@ data) ;; (ql:quickload :cl-digraph.dot) ;; (digraph.dot:draw graph) - (-<> (iterate (for (l . r) :in (digraph:edges graph)) + (_ (iterate (for (l . r) :in (digraph:edges graph)) (collect (format nil "~A ~A~%" l r))) - (sort <> #'string<) - (str:join nil <>)))) + (sort _ #'string<) + (str:join "" _)))) diff -r e3aefcbf364c -r 86d92162dc1f src/problems/lcsm.lisp --- a/src/problems/lcsm.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/problems/lcsm.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -65,15 +65,15 @@ (defun longest-common-substrings-of-any (substrings string) "Return the longest common substrings of `string` and any one of `substrings`." - (-<> (iterate + (_ (iterate (for substring :in substrings) (appending (longest-common-substrings substring string))) longest - (remove-duplicates <> :test #'string=))) + (remove-duplicates _ :test #'string=))) (define-problem lcsm (data stream) *input* *output* (let ((lines (mapcar #'cdr (u:read-fasta-into-alist data)))) - (-<> (reduce #'longest-common-substrings-of-any (rest lines) + (_ (reduce #'longest-common-substrings-of-any (rest lines) :initial-value (list (first lines))) - (sort <> #'string<) ; tests + (sort _ #'string<) ; tests first))) diff -r e3aefcbf364c -r 86d92162dc1f src/problems/mprt.lisp --- a/src/problems/mprt.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/problems/mprt.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -25,10 +25,10 @@ (defun motif-to-regex (motif) "Turn a protein motif shorthand into a PPCRE scanner." - (-<> motif + (_ motif ;; All we have to do is turn {X} into [^X] and compile. - (ppcre:regex-replace-all "[{]" <> "[^") - (substitute #\] #\} <>) + (ppcre:regex-replace-all "[{]" _ "[^") + (substitute #\] #\} _) ppcre:create-scanner)) (defun all-matches-dammit (regex target-string) diff -r e3aefcbf364c -r 86d92162dc1f src/problems/orf.lisp --- a/src/problems/orf.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/problems/orf.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -24,10 +24,10 @@ (let* ((dna (cdr (first (u:read-fasta-into-alist data)))) (rna1 (u:transcribe dna)) (rna2 (u:transcribe (u:reverse-complement dna)))) - (-<> (append (translate-all rna1) + (_ (append (translate-all rna1) (translate-all rna2)) - (remove-duplicates <> :test #'string=) - (sort <> #'< :key #'length) - (format nil "~{~A~^~%~}" <>)))) + (remove-duplicates _ :test #'string=) + (sort _ #'< :key #'length) + (format nil "~{~A~^~%~}" _)))) diff -r e3aefcbf364c -r 86d92162dc1f src/problems/perm.lisp --- a/src/problems/perm.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/problems/perm.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -19,4 +19,4 @@ (format nil "~D~%~{~A~^~%~}" count ;; sort to ensure consistent output for the unit test - (sort (mapcar (u:curry #'str:join " ") perms) #'string<)))) + (sort (mapcar (u:curry #'u:strjoin " ") perms) #'string<)))) diff -r e3aefcbf364c -r 86d92162dc1f src/problems/sign.lisp --- a/src/problems/sign.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/problems/sign.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -30,4 +30,4 @@ ;; sort to ensure consistent output for the unit test (format nil "~D~%~{~A~^~%~}" count - (sort (mapcar (u:curry #'str:join " ") perms) #'string<)))) + (sort (mapcar (u:curry #'u:strjoin " ") perms) #'string<)))) diff -r e3aefcbf364c -r 86d92162dc1f src/problems/sseq.lisp --- a/src/problems/sseq.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/problems/sseq.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -30,6 +30,6 @@ (define-problem sseq (data stream) *input* *output* (let* ((haystack (nth-value 1 (u:read-fasta data))) (needle (nth-value 1 (u:read-fasta data)))) - (-<> (subsequence-positions needle haystack :test #'char=) - (mapcar #'1+ <>) - (format nil "~{~D~^ ~}" <>)))) + (_ (subsequence-positions needle haystack :test #'char=) + (mapcar #'1+ _) + (format nil "~{~D~^ ~}" _)))) diff -r e3aefcbf364c -r 86d92162dc1f src/problems/subs.lisp --- a/src/problems/subs.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/problems/subs.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -14,5 +14,5 @@ (for pos :seed -1 :then (search needle haystack :start2 (1+ pos))) (while pos) (collect (1+ pos) :into result) - (finally (return (str:join " " result)))))) + (finally (return (u:strjoin " " result)))))) diff -r e3aefcbf364c -r 86d92162dc1f src/utils.lisp --- a/src/utils.lisp Fri Jan 24 23:05:16 2020 -0500 +++ b/src/utils.lisp Tue Dec 14 19:10:46 2021 -0500 @@ -100,9 +100,9 @@ (iterate (for (head body) :in clauses) (collect (list (subseq head 1) body))))) (split (clauses) - (-<> clauses - (group-by (rcurry #'aref 0) <> :key #'first) - (iterate (for (k v) :in-hashtable <>) + (_ clauses + (group-by (rcurry #'aref 0) _ :key #'first) + (iterate (for (k v) :in-hashtable _) (collect (list k (strip v))))))) (recursively ((clauses (split clauses)) (codons (list x y z)) @@ -170,6 +170,11 @@ nil (char string 0))) +(defun strjoin (sep seq) + (iterate (for el :in-whatever seq) + (concatenating (if (stringp el) el (aesthetic-string el)) + :separator sep))) + ;;;; Math --------------------------------------------------------------------- (defun factorial (x)