mirror of
https://github.com/usatiuk/psil.git
synced 2025-10-28 18:57:48 +01:00
47 lines
1.1 KiB
Plaintext
47 lines
1.1 KiB
Plaintext
(define (getmax a b)
|
|
(if (> a b) a b)
|
|
)
|
|
|
|
(define (equal a b)
|
|
(if (nil? a) (if (nil? b) 1 0)
|
|
(if (atom a)
|
|
(if (atom b) (= a b) 0)
|
|
(if (atom b) 0 (if (equal (car a) (car b)) (equal (cdr a) (cdr b)) 0))
|
|
)
|
|
)
|
|
)
|
|
|
|
(define (coffee-shop-impl times last cur max)
|
|
(if (= times (nil))
|
|
(getmax cur max)
|
|
(if (equal last (car times))
|
|
(coffee-shop-impl (cdr times) last (+ cur 1) max)
|
|
(coffee-shop-impl (cdr times) (car times) 1 (getmax cur max))
|
|
)
|
|
)
|
|
)
|
|
|
|
(define (coffee-shop times)
|
|
(coffee-shop-impl times (nil) 0 0)
|
|
)
|
|
|
|
(equal (nil) (nil))
|
|
(equal (nil) ())
|
|
(equal () (nil))
|
|
(equal (nil) (quote()))
|
|
(equal () (nil))
|
|
(equal () (quote()))
|
|
|
|
(equal (quote(a))(quote()))
|
|
(equal (quote(a)) ())
|
|
(equal (quote(a)) (nil))
|
|
|
|
(equal (quote(a)) (quote(a.)))
|
|
(equal (quote(a.)) (quote(a b)))
|
|
|
|
(equal (quote(a b)) (quote(a.b)))
|
|
(equal (quote(a b)) (quote(a b)))
|
|
|
|
(coffee-shop (nil))
|
|
(coffee-shop (quote( (8 0) (8 10) (8 10) (8 45) )))
|
|
(coffee-shop (quote( (8 12) (10 11) (10 11) (15 15) (15 15) (15 15) (22 22) (22 22) (22 59) ))) |