[racket] Delete Second
Ashley,
I think you're making this more difficult than it needs to be.
-Greg
-----Original Message-----
From: users-bounces at racket-lang.org [mailto:users-bounces at racket-lang.org] On Behalf Of Ashley Fowler
Sent: Monday, September 17, 2012 2:46 PM
To: David Van Horn
Cc: users at racket-lang.org
Subject: Re: [racket] Delete Second
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
____________________
Racket Users list:
http://lists.racket-lang.org/users