[racket] Delete Second

From: Ashley Fowler (afowler2 at broncos.uncfsu.edu)
Date: Mon Sep 17 15:30:04 EDT 2012

Disregard the last message with the questions, I get what your saying now. I had to switch the sign.

(define delete-second2
    (lambda(ls)
      (if(> (length ls) 1) (append(list(car ls))(cdr(cdr ls)))
         (list(car ls)))))

Only problem I got now is the first test still doesn't work.
________________________________________
From: danny.yoo at gmail.com [danny.yoo at gmail.com] on behalf of Danny Yoo [dyoo at hashcollision.org]
Sent: Monday, September 17, 2012 3:18 PM
To: Ashley Fowler
Cc: users at racket-lang.org
Subject: Re: [racket] Delete Second

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:

    http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html#(part._sec~3atesting)


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




Posted on the users mailing list.