CS2613/labs/L05/match-ex.rkt

14 lines
209 B
Racket
Raw Normal View History

2022-09-27 18:09:00 -03:00
#lang racket
(define (list-length2 rst)
(match lst
['() 0]
[(list fst rst ...) (add1 (list-length2 rst))]))
(define (list-length3 lst)
(match lst
['() 0]
[(cons fst rst) (add1 list-length3 rst)]))