sort
This commit is contained in:
parent
81b697a602
commit
ca9be8b792
16
parking.scm
16
parking.scm
@ -2,7 +2,6 @@
|
||||
(import http-client)
|
||||
(import srfi-1)
|
||||
(import (chicken io))
|
||||
(import (chicken sort))
|
||||
(import srfi-13)
|
||||
|
||||
(define (curry fn a)
|
||||
@ -36,9 +35,16 @@
|
||||
(define (has-key? k 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)
|
||||
(sort ln (lambda (a b)
|
||||
(less-than? (fn a) (fn b)))))
|
||||
(sort (lambda (a b)
|
||||
(less-than? (fn a) (fn b))) ln))
|
||||
|
||||
(define (display-newline str)
|
||||
(display str)
|
||||
@ -79,7 +85,7 @@
|
||||
(array . ,identity)) (json-parsers)))
|
||||
(display-newline "Parking spaces available:")
|
||||
(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) (get-parking-lots)))))
|
||||
(sort-via string-ci<? (curry value 'name)
|
||||
(filter (conjoin computerized? (complement only-has-handicap-spots?)) (get-parking-lots)))))
|
||||
|
||||
(main)
|
||||
|
Loading…
Reference in New Issue
Block a user