Plaster
New
List
Login
common-lisp
default
anonymous
2023.10.17 23:38:43
(defun get-line (source) "Reads a single line from the given stream or string." (wrap-if (stringp source) (with-input-from-string (source source)) (declare (capture :variable source)) (read-line source))) ; => GET-LINE (defparameter *line* "1 2 3") (get-line *line*) ; => "1", NIL (with-input-from-string (in *line*) (get-line in)) ; => "1", NIL ;; Or with wrap-if* you can have multiple "wraps" (defun get-line (source) "Reads a single line from the given stream, pathname or string." (wrap-if* (((stringp source) (with-input-from-string (source source))) ((pathnamep source) (alexandria:with-input-from-file (source source)))) (declare (capture :variable source)) (read-line source))) ; => GET-LINE (get-line #P"~/.sbclrc") ; => ";;; The following lines added by ql:add-to-init-file: ;", NIL
Raw
Annotate
Repaste
Edit