Anonymous user
Text processing/Max licenses in use: Difference between revisions
Text processing/Max licenses in use (view source)
Revision as of 21:17, 17 August 2009
, 14 years agocleanup, and show use of CL-PPCRE for extracting IN/OUT and the time
m (Common Lisp Max License entry) |
(cleanup, and show use of CL-PPCRE for extracting IN/OUT and the time) |
||
Line 123:
=={{header|Common Lisp}}==
{{trans|Python}} {{libheader|CL-PPCRE}}
<lang lisp>(defun max-licenses (&optional (logfile "mlijobs.txt"))
(with-open-file (log logfile :direction :input)
(do ((current-logs 0) (max-logs 0) (max-log-times '())
(max-log-times '())▼
(line #1=(read-line log nil nil) #1#))
((null line)
(format t "~&Maximum simultaneous license use is ~w at the ~
max-logs (length max-log-times) (nreverse max-log-times)))
(cl-ppcre:register-groups-bind (op time)
(cond ((string= "OUT" op) (incf current-logs))
((string= "IN" op) (decf current-logs))▼
(setf max-
▲ (decf current-logs))
▲ (t (cerror "Ignore it." "Malformed entry ~s." line))))))</lang>
<pre>> (max-licenses)
|