Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Trying to make my own reverse function
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
WJ  
View profile  
 More options Oct 17 2012, 6:42 am
Newsgroups: comp.lang.lisp
From: "WJ" <w_a_x_...@yahoo.com>
Date: 17 Oct 2012 10:42:26 GMT
Local: Wed, Oct 17 2012 6:42 am
Subject: Re: Trying to make my own reverse function

Pascal J. Bourguignon wrote:
> Otherwise, when processing lists, one may prefer to use list operators
> instead of cons operators:

>       list-level            cons-level
>       ----------            ----------
>       endp                  null
>       first                 car
>       rest                  cdr
>       list*                 cons
>       second                cadr
>       third                 caddr
>       fourth                cadddr
>       ----------            ----------

> (defun recursive-reverse (list)
>   (labels ((rev (list acc)
>      (if (endp list)
>           acc
>           (rev (rest list) (list* (first list) acc)))))
>       (rev list '())))

Racket:

(define (rev xs [accum '()])
  (if (empty? xs)
    accum
    (rev (rest xs) (list* (first xs) accum))))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.