This commit is contained in:
Victor Fors 2022-04-18 21:14:20 +02:00
parent 89ba2d6aef
commit 838b9bf5f1

View File

@ -28,7 +28,7 @@
(define (sort-via less-than? fn ln) (define (sort-via less-than? fn ln)
(sort ln (lambda (a b) (sort ln (lambda (a b)
(less-than? (fn a) (fn b))))) (less-than? (fn a) (fn b)))))
(define (display-newline str) (define (display-newline str)
(display str) (display str)
@ -36,16 +36,16 @@
(define (->string a) (define (->string a)
(cond ((string? a) a) (cond ((string? a) a)
((symbol? a) (symbol->string a)) ((symbol? a) (symbol->string a))
((number? a) (number->string a)) ((number? a) (number->string a))
((char? a) (string a)))) ((char? a) (string a))))
(define (format-assoc statement ln) (define (format-assoc statement ln)
(apply string-append (apply string-append
(map (lambda (directive) (map (lambda (directive)
(if (symbol? directive) (if (symbol? directive)
(->string (value directive ln)) (->string (value directive ln))
directive)) statement))) directive)) statement)))
(define (simple-json-request uri) (define (simple-json-request uri)
(with-input-from-request uri #f read-json)) (with-input-from-request uri #f read-json))
@ -70,6 +70,6 @@
(display-newline "Parking spaces available:") (display-newline "Parking spaces available:")
(let ((lots (sort-via string-ci<? (curry value 'Name) (get-parking-lots)))) (let ((lots (sort-via string-ci<? (curry value 'Name) (get-parking-lots))))
(map (compose display-newline (curry format-assoc '(Name ": " ParkingSpacesAvailable "/" ParkingSpaces))) (map (compose display-newline (curry format-assoc '(Name ": " ParkingSpacesAvailable "/" ParkingSpaces)))
(filter (conjoin computerized? (complement only-has-handicap-spots?)) lots)))) (filter (conjoin computerized? (complement only-has-handicap-spots?)) lots))))
(main) (main)