From 4a4d70679834d29934a2738c96940b18974dd346 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 2 Jul 2020 17:47:05 +0200 Subject: [PATCH] add nth --- data-structures/lists.scm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/data-structures/lists.scm b/data-structures/lists.scm index 46dca47..2b01b17 100644 --- a/data-structures/lists.scm +++ b/data-structures/lists.scm @@ -1,3 +1,10 @@ +(define (nth li pos) + (cond + ((null? li) #f) + ((= pos 0) (car li)) + (#t (nth (cdr li) (- pos 1))))) + + (define (rangeinc b e) (cond ((> b e) '())