This commit is contained in:
Victor Fors 2022-04-20 18:09:35 +02:00
parent 81b697a602
commit ca9be8b792

View File

@ -2,7 +2,6 @@
(import http-client) (import http-client)
(import srfi-1) (import srfi-1)
(import (chicken io)) (import (chicken io))
(import (chicken sort))
(import srfi-13) (import srfi-13)
(define (curry fn a) (define (curry fn a)
@ -36,9 +35,16 @@
(define (has-key? k ln) (define (has-key? k ln)
(member? k (map car ln))) (member? k (map car ln)))
(define (sort less-than? ln)
(if (<= (length ln) 1)
ln
(append (sort less-than? (filter (complement (curry less-than? (car ln))) (cdr ln)))
(list (car ln))
(sort less-than? (filter (curry less-than? (car ln)) (cdr ln))))))
(define (sort-via less-than? fn ln) (define (sort-via less-than? fn ln)
(sort ln (lambda (a b) (sort (lambda (a b)
(less-than? (fn a) (fn b))))) (less-than? (fn a) (fn b))) ln))
(define (display-newline str) (define (display-newline str)
(display str) (display str)
@ -79,7 +85,7 @@
(array . ,identity)) (json-parsers))) (array . ,identity)) (json-parsers)))
(display-newline "Parking spaces available:") (display-newline "Parking spaces available:")
(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?)) (sort-via string-ci<? (curry value 'name)
(sort-via string-ci<? (curry value 'name) (get-parking-lots))))) (filter (conjoin computerized? (complement only-has-handicap-spots?)) (get-parking-lots)))))
(main) (main)