[racket] Delete Second

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

Well i got 




(list(car'(())) ===> (())
(list(car'(3))) ===> (3)




Are you saying I need to change (list(car ls)) ?

________________________________________
From: David Van Horn [dvanhorn at ccs.neu.edu]
Sent: Monday, September 17, 2012 3:37 PM
To: Ashley Fowler
Cc: Danny Yoo; users at racket-lang.org
Subject: Re: [racket] Delete Second

On 9/17/12 3:30 PM, Ashley Fowler wrote:
> 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.

>> (delete-second2 '())  ==>  ()
>> (delete-second2 '(3))  ==>  (3)

There's a striking relationship between what comes in and what goes out
in these two examples.  What is that relationship?  Do other examples of
this length exhibit the same relationship?

How is that relationship different from what (list (car ls)) computes?

David







Posted on the users mailing list.