Skip to content

Commit 4ff0858

Browse files
committed
test sub1 on Int>1 returns PosInt
1 parent 9798e4b commit 4ff0858

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#lang typed/racket
2+
3+
;; From this stack overflow question by Lyu Yao Ting:
4+
;; Type mismatch issue of sub1
5+
;; https://stackoverflow.com/questions/58887937/type-mismatch-issue-of-sub1
6+
7+
(define-predicate one? One)
8+
(: pick1 (-> Positive-Integer (Listof Any) Any))
9+
(define pick1
10+
(λ (n lat)
11+
(cond [(one? n) (car lat)]
12+
[else (pick1 (sub1 n)
13+
(cdr lat))])))

0 commit comments

Comments
 (0)