Plaster
New
List
Login
common-lisp
default
anonymous
2021.02.05 10:21:12
;; This slow and very consing, but remarkably succinct. It has the benefit of ;; knowing the stream's current column by way of the implementation's stream ;; machinery. It might be nice if it got the COLS from the same place. (defun old-justify-text (s &key (cols 80) (stream *standard-output*) (prefix "") (separator #\space) omit-first-prefix) "Print the string S right justified by words, into COLS characters wide, on the stream STREAM. SEPARATOR is a character or string which separates the input words. PREFIX is printed in front of each line. If OMIT-FIRST-PREFIX is true, don't print the first prefix." (format stream (format nil "~a~a~a~d~a" "~a~{~<~%" prefix "~1," cols ":;~a~> ~}") (if omit-first-prefix "" prefix) (split-sequence separator s :omit-empty t)))
Raw
Annotate
Repaste
Edit