forked from shriram/repro-in-cs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filters.rkt
53 lines (43 loc) · 1.48 KB
/
filters.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#lang racket
(require "structure-data.rkt")
(provide builds)
(provide build-fails)
(provide papers-with-build-status)
(provide and-filters or-filters not-filter
building? not-building?
disputed? not-disputed?
misclassified? not-misclassified?
cleared? not-cleared?
problem? not-problem?
checked? not-checked?)
(define (and-filters . fs)
(lambda (e)
(let loop ([fs fs])
(or (empty? fs)
(and ((first fs) e)
(loop (rest fs)))))))
(define (or-filters . fs)
(lambda (e)
(let loop ([fs fs])
(and (not (empty? fs))
(or ((first fs) e)
(loop (rest fs)))))))
(define (not-filter f)
(lambda (e) (not (f e))))
(define building? paper-builds?)
(define not-building? (not-filter building?))
(define misclassified? paper-misclassified?)
(define not-misclassified? (not-filter misclassified?))
(define disputed? paper-dispute?)
(define not-disputed? (not-filter disputed?))
(define cleared? paper-cleared?)
(define not-cleared? (not-filter cleared?))
(define problem? paper-problem?)
(define not-problem? (not-filter problem?))
(define checked? (or-filters cleared? problem?))
(define not-checked? (not-filter checked?))
(define (builds ss) (filter building? ss))
(define (build-fails ss) (filter not-building? ss))
#| The 8th column has the build status, as a string that is not "-". |#
(define (papers-with-build-status ss)
(filter (lambda (p) (not (string=? "-" (list-ref p 7)))) ss))