Groups | Search | Server Info | Login | Register
Groups > comp.lang.scheme > #6502
| From | "B. Pym" <Nobody447095@here-nor-there.org> |
|---|---|
| Newsgroups | comp.lang.lisp, comp.lang.scheme |
| Subject | Re: TERPRI |
| Date | 2025-07-11 08:01 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <104qgcc$1dbgg$1@dont-email.me> (permalink) |
Cross-posted to 2 groups.
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)))))
Back to comp.lang.scheme | Previous | Next — Next in thread | Find similar
Re: TERPRI "B. Pym" <Nobody447095@here-nor-there.org> - 2025-07-11 08:01 +0000 Re: TERPRI "B. Pym" <Nobody447095@here-nor-there.org> - 2025-07-11 15:45 +0000
csiph-web