[racket] Find nth term of a List

From: Ashley Fowler (afowler2 at broncos.uncfsu.edu)
Date: Tue Sep 25 21:08:48 EDT 2012

I need to make a function that finds the nth term of a list
Hence (getNth N LS)

Examples of use:
(getNth 0 '(a b c))             ==> a
(getNth 3 '(a b c d e))         ==> d
(getNth 3 '(a b c))             ==> error

so far I have

(define getNth (lambda (N LS)
                   (if (eq? N 0)(car LS)

which only includes the "base case". I need help on how to create this function. Any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120926/ee46d547/attachment.html>

Posted on the users mailing list.