www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 06bed29150b8b8572c91f6dce922d9be05b07ab2
parent ea3ed2a7623504cc337300d73dad74cced84420a
Author: Stephen Chang <stchang@ccs.neu.edu>
Date:   Wed, 23 Mar 2016 11:59:24 -0400

add small test to result.mlish

Diffstat:
Mtapl/tests/mlish/find.mlish | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/tapl/tests/mlish/find.mlish b/tapl/tests/mlish/find.mlish @@ -26,11 +26,25 @@ : (Option Int) -> (None {Int})) +;; args inferred in order, L-to-R, currently no backtracking (check-type (find (Nil {Int}) (λ ([x : Int]) (<= 2 x))) : (Option Int) -> (None {Int})) +;; reversing arg order leads to successful inference +(define (find2 [pred : (→ X Bool)] [lst : (List X)] → (Option X)) + (match lst with + [Nil -> None] + [Cons fst rst -> + (cond [(pred fst) (Some fst)] + [else (find2 pred rst)])])) + +(check-type + (find2 (λ ([x : Int]) (<= 2 x)) Nil) + : (Option Int) + -> (None {Int})) + (define (find-min/max [lst : (List X)] [<? : (→ Y Y Bool)] [extract-key : (→ X Y)] → (Option (× X X))) (match lst with