Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
3
Task/Text-processing-1/NewLISP/text-processing-1-1.l
Normal file
3
Task/Text-processing-1/NewLISP/text-processing-1-1.l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(let (handle (open "readings.txt" "read"))
|
||||
(setq all-lines (collect (read-line handle)))
|
||||
(close handle))
|
||||
22
Task/Text-processing-1/NewLISP/text-processing-1-2.l
Normal file
22
Task/Text-processing-1/NewLISP/text-processing-1-2.l
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
;; (20.0 "1990-01-01" 1 0)
|
||||
(define (line->matrix line)
|
||||
(letn (fields (parse line {\s+} 0)
|
||||
day (pop fields)
|
||||
lst)
|
||||
(for (i 0 (- (length fields) 1) 2)
|
||||
(push (array 4 (list (float (fields i)) day (int (fields (+ i 1))) 0))
|
||||
lst -1))
|
||||
lst))
|
||||
|
||||
(setq all-readings
|
||||
(array (* 24 (length all-lines)) 4
|
||||
'(0.0 "2000-00-00" 0 0))
|
||||
_ nil)
|
||||
|
||||
(let (cnt 0)
|
||||
(dolist (line all-lines)
|
||||
(setq one-day (line->matrix line))
|
||||
(dolist (reading one-day)
|
||||
(setf (all-readings cnt) reading)
|
||||
(++ cnt)))
|
||||
'ok)
|
||||
7
Task/Text-processing-1/NewLISP/text-processing-1-3.l
Normal file
7
Task/Text-processing-1/NewLISP/text-processing-1-3.l
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(local (prev)
|
||||
(dotimes (i (length all-readings))
|
||||
(unless (= 1 (all-readings i -2))
|
||||
(setq prev
|
||||
(if (zero? i) 0 (all-readings (- i 1) -1)))
|
||||
(setf (all-readings i -1) (+ 1 prev))))
|
||||
'ok)
|
||||
2
Task/Text-processing-1/NewLISP/text-processing-1-4.l
Normal file
2
Task/Text-processing-1/NewLISP/text-processing-1-4.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(setq len (apply max (clean zero? (map last all-readings))))
|
||||
(println "Longest run of bad readings: " len)
|
||||
4
Task/Text-processing-1/NewLISP/text-processing-1-5.l
Normal file
4
Task/Text-processing-1/NewLISP/text-processing-1-5.l
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(setq days
|
||||
(map (fn(i) (all-readings i 1))
|
||||
(index (curry = len) (map last all-readings))))
|
||||
(println "Bad runs with that length ended on these days: " days)
|
||||
3
Task/Text-processing-1/NewLISP/text-processing-1-6.l
Normal file
3
Task/Text-processing-1/NewLISP/text-processing-1-6.l
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(setq grand-total (apply add (map first all-readings)))
|
||||
(setq grand-count (length (filter zero? (map last all-readings))))
|
||||
(println "Total number of bad readings: " (- (length all-readings) grand-count))
|
||||
2
Task/Text-processing-1/NewLISP/text-processing-1-7.l
Normal file
2
Task/Text-processing-1/NewLISP/text-processing-1-7.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(println (format "Grand total: %.3f Count: %d Average: %.3f"
|
||||
grand-total grand-count (div grand-total grand-count)))
|
||||
4
Task/Text-processing-1/NewLISP/text-processing-1-8.l
Normal file
4
Task/Text-processing-1/NewLISP/text-processing-1-8.l
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(define (get-day day)
|
||||
(filter (fn(e) (= day (e 1))) (array-list all-readings)))
|
||||
|
||||
(get-day "1993-03-05")
|
||||
8
Task/Text-processing-1/NewLISP/text-processing-1-9.l
Normal file
8
Task/Text-processing-1/NewLISP/text-processing-1-9.l
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(define (sum-day day)
|
||||
(letn (lst (filter (fn(a) (= 1 (a 2))) (get-day day))
|
||||
tot (apply add (map first lst)))
|
||||
(println (format "%s Good readings: %d Total: %.3f Avg.: %.3f"
|
||||
day (length lst) tot
|
||||
(div tot (if (zero? (length lst)) 0 (length lst)))))))
|
||||
|
||||
(sum-day "1993-03-05")
|
||||
Loading…
Add table
Add a link
Reference in a new issue