From 2e259163aad22fa953eb95bf3dab4456477be614 Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Thu, 10 Mar 2016 16:35:57 -0500 Subject: [PATCH] add find-min/max --- tapl/tests/mlish/find.mlish | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tapl/tests/mlish/find.mlish b/tapl/tests/mlish/find.mlish index f795f62..c1c88e6 100644 --- a/tapl/tests/mlish/find.mlish +++ b/tapl/tests/mlish/find.mlish @@ -31,3 +31,43 @@ : (Option Int) -> (None {Int})) +(define (find-min/max [lst : (List X)] [ None] + [Cons x1 rst -> + (let ([y1 (extract-key x1)]) + (Some (find-min/max-accum rst (tup x-min x-max)] + [Cons x2 rst -> + (let ([y2 (extract-key x2)]) + (cond [( (None {Int})) + +(check-type + (find-min/max (Cons 1 (Cons 2 (Cons 3 Nil))) + (λ ([x : Int] [y : Int]) + (< x y)) + (λ ([x : Int]) + x)) + : (Option (× Int Int)) + -> (Some (tup 1 3))) +