[racket] Delete Second

From: Danny Yoo (dyoo at hashcollision.org)
Date: Mon Sep 17 15:18:37 EDT 2012

On Mon, Sep 17, 2012 at 12:54 PM, Ashley Fowler
<afowler2 at broncos.uncfsu.edu> wrote:
> Okay I understand. I made some changes
> (define delete-second2
>     (lambda(ls)
>       (if(< (length ls) 1) (append(list(car ls))(cdr(cdr ls)))
>          (list(car ls)))))
> it works for when I do the following tests:
> (delete-second2 '(3 7))  ==>  (3)
> (delete-second2 '(a b c d))  ==>  (a c d)
> but it gives me a error for the tests:
> (delete-second2 '())  ==>  ()
> (delete-second2 '(3))  ==>  (3)

Yup.  The bugs you have now are "semantic".  This is different from
the syntax errors you were having earlier.  The program you've written
can finally run, but it does not mean what you want it to mean.

I actually do not quite believe you when you say your test works on

    (delete-second2 '(a b c d))

Are you using check-expect to automatically check that the output
matches the expected value?  See:


Just because a program runs without crashing doesn't mean it's
actually computing a good value.  :)

Posted on the users mailing list.