<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body style="word-wrap:break-word" fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Well this is what I got so far...
<div><br>
</div>
<div>
<div>(define deleteNth</div>
<div>&nbsp; &nbsp; (lambda(N LS)</div>
<div>&nbsp; &nbsp; (cond</div>
<div>&nbsp; &nbsp; &nbsp; (null? LS) LS)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;((= N 0)(cdr LS))</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(else(cons(car LS)(deleteNth(- N 1)(cdr LS))))))</div>
<div><br>
</div>
<div>and it keeps giving me the error of &quot;cond: bad syntax (clause is not a test-value pair) in: ls&quot;</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF503536" style="direction: ltr; "><font face="Tahoma" size="2" color="#000000"><b>From:</b> Matthias Felleisen [matthias@ccs.neu.edu]<br>
<b>Sent:</b> Monday, October 08, 2012 9:51 AM<br>
<b>To:</b> Ashley Fowler<br>
<b>Cc:</b> users@racket-lang.org<br>
<b>Subject:</b> Re: [racket] Delete Nth Term<br>
</font><br>
</div>
<div></div>
<div>
<div><br>
</div>
<div>3 versions, all pass the test suite. Now write the function&nbsp;</div>
<div><br>
</div>
<div>&nbsp;pick-one-of-three : [List X X X] -&gt; X&nbsp;</div>
<div><br>
</div>
<div>and turn in.&nbsp;</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>#lang racket</div>
<div><br>
</div>
<div>(require rackunit)</div>
<div><br>
</div>
<div>;; Nat [Listof X] -&gt; [Listof X]</div>
<div>;; delete the n-th item from l, if there is one&nbsp;</div>
<div><br>
</div>
<div>(module&#43;&nbsp;</div>
<div>&nbsp; test</div>
<div>&nbsp; (check-equal? (deleteNth 4 '()) '())</div>
<div>&nbsp; (check-equal? (deleteNth 0 '(a b c)) '(b c))</div>
<div>&nbsp; (check-equal? (deleteNth 3 '(a b c)) '(a b c))</div>
<div>&nbsp; (check-equal? (deleteNth 2 '(a b c)) '(a b)) )</div>
<div><br>
</div>
<div>(define (deleteNth n l)</div>
<div>&nbsp; (cond</div>
<div>&nbsp; &nbsp; [(= n 0) (rest l)]</div>
<div>&nbsp; &nbsp; [(&lt; n (length l)) (append (take l n) (rest (drop l n)))]</div>
<div>&nbsp; &nbsp; [else l])</div>
<div>&nbsp; #;</div>
<div>&nbsp; (cond&nbsp;</div>
<div>&nbsp; &nbsp; [(empty? l) l]</div>
<div>&nbsp; &nbsp; [(zero? n) (rest l)]</div>
<div>&nbsp; &nbsp; [else (cons (first l) (deleteNth (sub1 n) (rest l)))])</div>
<div>&nbsp; #;</div>
<div>&nbsp; (cond</div>
<div>&nbsp; &nbsp; [(and (zero? n) (empty? l)) l]</div>
<div>&nbsp; &nbsp; [(and (positive? n) (empty? l)) l]</div>
<div>&nbsp; &nbsp; [(and (zero? n) (cons? l)) (rest l)]</div>
<div>&nbsp; &nbsp; [(and (positive? n) (cons? l)) (cons (first l) (deleteNth (sub1 n) (rest l)))]))</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div><br>
</div>
<div><br>
</div>
<br>
<div>
<div>On Oct 7, 2012, at 10:03 PM, Ashley Fowler wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div>
<div style="direction:ltr; font-family:Tahoma; color:rgb(0,0,0); font-size:10pt">
I need help with making a function that deletes the nth term from a list.(<span style="white-space:pre-wrap">list LS with its Nth element (with indexes
</span><span style="white-space:pre-wrap">starting at 0) deleted)</span>
<div>So far I have&nbsp;</div>
<div><br>
</div>
<div>
<div>(define (deleteNth N ls)</div>
<div>&nbsp; &nbsp; (if (null? ls)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; ls</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; (deleteNth (- N 1) (cdr ls))))</div>
</div>
<div><br>
</div>
<div>The results should be ...</div>
<div><br>
</div>
<div>
<pre style="word-wrap:break-word; white-space:pre-wrap">(deleteNth 4 '()) returns ()
(deleteNth 0 '(a b c)) returns (b c)
(deleteNth 3 '(a b c)) returns (a b c)</pre>
</div>
</div>
____________________<br>
&nbsp;Racket Users list:<br>
&nbsp;<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>