[racket] Delete Second

From: Greg Graham (GGraham at cistercian.org)
Date: Mon Sep 17 15:53:04 EDT 2012

I think you're making this more difficult than it needs to be.


-----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?


  Racket Users list:

Posted on the users mailing list.