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 Lisp vs. Scheme
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
 
Joe Marshall  
View profile  
 More options Sep 19 2003, 9:38 am
Newsgroups: comp.lang.lisp
From: Joe Marshall <j...@ccs.neu.edu>
Date: Fri, 19 Sep 2003 09:38:42 -0400
Local: Fri, Sep 19 2003 9:38 am
Subject: Re: Lisp vs. Scheme

g...@jpl.nasa.gov (Erann Gat) writes:
> In article <b295356a.0309181447.44dbe...@posting.google.com>,
> thelif...@gmx.net (thelifter) wrote:

>> Can anyone give a simple example where you do some computational task
>> with Lisp that would be much harder to do with Scheme so that the
>> advantage of Lisp becomes more apparent?

> (defmacro compile-time-factorial (n)
>   (if (numberp n)
>     (if (and (integerp n) (> n 0))
>       (factorial n)
>       (error "Can't take the factorial of ~S" n))
>     (if (or (symbolp n) (listp n))
>       `(factorial ,n)
>       (error "Can't take the factorial of ~S" n))))

> E.

(require (lib "defmacro.ss"))

(defmacro compile-time-factorial (n)

  (define (factorial x)
    (if (zero? x)
        1
        (* x (factorial (sub1 x)))))

  (if (number? n)
      (if (and (integer? n) (> n 0))
          (factorial n)
          (error "Can't take the factorial of " n))
      (if (or (symbol? n) (list? n))
          `(factorial ,n)
          (error "Can't take the factorial of " n))))


 
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.