Work on A2
This commit is contained in:
parent
6809a95041
commit
585fb2e9e8
1
assignments/A2/.gitignore
vendored
Normal file
1
assignments/A2/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
A2temp.rkt
|
43
assignments/A2/A2.rkt
Normal file
43
assignments/A2/A2.rkt
Normal file
@ -0,0 +1,43 @@
|
||||
#lang racket
|
||||
|
||||
(require xml)
|
||||
(define (load-xexpr path)
|
||||
(xml->xexpr (document-element (read-xml (open-input-file path)))))
|
||||
|
||||
|
||||
(define (load-rubrics path)
|
||||
(define rubrics (load-xexpr path))
|
||||
(define (get-rubrics rubrics)
|
||||
(cond
|
||||
[(null? rubrics) '()]
|
||||
[(list? rubrics) (append (get-rubrics (car rubrics)) (get-rubrics (cdr rubrics)))]
|
||||
[else (list rubrics)]))
|
||||
(get-rubrics rubrics))
|
||||
|
||||
|
||||
; test for load-rubrics
|
||||
|
||||
(module+ test
|
||||
(require rackunit)
|
||||
(define rubrics (load-rubrics "rubrics.xml"))
|
||||
(check-equal? (length rubrics) 5)
|
||||
(for ([elt rubrics])
|
||||
(check-equal? (first elt) 'rubric)))
|
||||
|
||||
|
||||
|
||||
; test for assoc*
|
||||
|
||||
(module+ test
|
||||
(define test-list '(1 [keep 2] 3 [keep 4] [keep 5] 6))
|
||||
(check-equal? (assoc* 'keep test-list) 2)
|
||||
(check-equal? (assoc* 'discard test-list) #f))
|
||||
|
||||
(define (rubric-name rubric)
|
||||
(assoc* 'name (second rubric)))
|
||||
|
||||
(module+ test
|
||||
(check-equal?
|
||||
(sort (map rubric-name rubrics) string<=?)
|
||||
'("JavaScript Assignment" "Journal Entry" "Octave Assignment" "Python Assignment"
|
||||
"Racket assignment")))
|
9
assignments/A2/Explorer.rkt
Normal file
9
assignments/A2/Explorer.rkt
Normal file
@ -0,0 +1,9 @@
|
||||
#lang racket
|
||||
|
||||
(require xml)
|
||||
(define (load-xexpr path)
|
||||
(xml->xexpr (document-element (read-xml (open-input-file path)))))
|
||||
|
||||
(require explorer)
|
||||
(define data (load-xexpr "rubrics.xml"))
|
||||
(explore data)
|
1
assignments/A2/rubrics.xml
Normal file
1
assignments/A2/rubrics.xml
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user