On Oct 7, 2012, at 10:03 PM, Ashley Fowler wrote:
I need help with making a function that deletes the nth term from a
list.(list LS with its Nth element (with indexes starting at 0)
deleted)
So far I have
(define (deleteNth N ls)
(if (null? ls)
ls
(deleteNth (- N 1) (cdr ls))))
The results should be ...
(deleteNth 4 '()) returns ()
(deleteNth 0 '(a b c)) returns (b c)
(deleteNth 3 '(a b c)) returns (a b c)
Once again, notice that both of your arguments are of recursively-
defined types (a whole number and a list, respectively), so you need
to look at Chapter 25 of _Picturing Programs_ (http://
picturingprograms.com/download/chap25.pdf), or Chapter 17 of _How to
Design Programs_ (http://htdp.org/2003-09-26/Book/curriculum-Z-
H-22.html#node_chap_17).
Dr. Stephen Bloch
Math/CS Department
Adelphi University
sbl...@adelphi.edu
____________________
Racket Users list:
http://lists.racket-lang.org/users