From dfe1bc702d95d6a12918d9251cf6261d323eaba8 Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Wed, 15 Mar 2023 21:27:29 +0100 Subject: 10 exercises not bad --- shared/lists.rkt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'shared/lists.rkt') diff --git a/shared/lists.rkt b/shared/lists.rkt index 9279a57..d5cfc61 100644 --- a/shared/lists.rkt +++ b/shared/lists.rkt @@ -1,9 +1,4 @@ #lang racket -(provide - append - length - list-ref) - (define (append list1 list2) (if (null? list1) list2 @@ -19,9 +14,10 @@ (define (list-ref items n) (if (= n 0) (car items) - (list-ref - (cdr items) + (list-ref + (cdr items) (- 1 n)))) + (define (last-pair l) (if (null? (cdr l)) l -- cgit v1.2.3