[racket] Delete Nth Term

From: Bloch Stephen (bloch at adelphi.edu)
Date: Mon Oct 8 21:47:30 EDT 2012

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- 

Dr. Stephen Bloch
Math/CS Department
Adelphi University
sbloch at adelphi.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121008/a182e5c3/attachment-0001.html>

Posted on the users mailing list.