Sujet : Re: TERPRI
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp comp.lang.schemeDate : 11. Jul 2025, 09:01:17
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <104qgcc$1dbgg$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Rob Warnock wrote:
(running small "scripts" 100 times and histogramming the results), and I
needed to sum the "user" and "system" times reported by the "csh" builtin
"time" command (since the "total" time has one fewer digits of precision).
Here's what I wrote:
#!/usr/local/bin/cmucl -script
;;; Script to sum the first two times in a "csh" "time" output:
;;; 0.046u 0.007s 0:00.06 66.6% 147+3008k 0+0io 0pf+0w
(defun sum-u-s (line)
(+ (read-from-string line nil nil :start 0 :end (position #\u line))
(read-from-string line nil nil :start (1+ (position #\space line))
:end (position #\s line))))
(loop for line = (read-line *standard-input* nil nil)
while line
do (format t "~5,3f~%" (sum-u-s line)))
Trivial? Yes, but it's what I needed at the moment, and it was the
language I wa able to do it in fastest.
Gauche Scheme:
(until (read-line) eof-object? => line
(with-input-from-string (regexp-replace-all #/[us]/ line "")
(cut print (+ (read) (read)))))