I can't figure out why the sub1 function in pick1 has type mismatch issue,but pick0 don't
(define-predicate one? One)
(: pick1 (-> Positive-Integer (Listof Any) Any))
(define pick1
(λ(n lat)
(cond [(one? n) (car lat)]
[else (pick1 (sub1 n)
(cdr lat))])))
I have tried this workaround, but I think this is not a right way to fix this issue.
(: pick1-workaround (-> Positive-Integer (Listof Any) Any))
(define pick1-workaround
(λ(n lat)
(cond [(one? n) (car lat)]
[else (pick1-workaround (cast (sub1 n) Positive-Integer)
(cdr lat))])))
pick0 don't have this issue.
;;(: pick0 (-> Natural (Listof Any) Any))
(define pick0
(λ(n lat)
(cond [(zero? n) (car lat)]
[else (pick0 (sub1 n)
(cdr lat))])))