[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: In search of cool Scheme
From: |
Hans O. Lowe |
Subject: |
Re: In search of cool Scheme |
Date: |
Tue, 22 May 2001 21:58:22 -0500 |
Sam & Klaus,
I don't know about doing it with data stream and delayed evaluation,
but I was thinking of something simple like this:
(define (differentiate y)
(if (list? y)
(cond ((eq? (car y) '+) (cons '+ (map differentiate (cdr y))))
((eq? (car y) '-) (cons '- (map differentiate (cdr y))))
((eq? (car y) 'sin) (list '*
(list 'cos (cadr y))
(differentiate (cadr y))))
(else 'y))
(cond ((number? y) 0)
((eq? y 'x) 1)
(else (list 'differentiate y)))))
;;; Try this:
(display (differentiate '(4 x (sin u))))
It's is simple, crude, incomplete, and possibly flawed, but you get
the idea. Symbolic manipulation is natural to Lisp and its
dialects. This simple script may not convince anyone of the virtue of
using Scheme, but can certainly serve to demonstrate one major
difference between Scheme and Perl.
Regards,
Hans
----------------------------------------------------------------------
The opinions expressed here do not represent those of my computer.
----------------------------------------------------------------------
Re: In search of cool Scheme, Klaus Schilling, 2001/05/22
- Re: In search of cool Scheme,
Hans O. Lowe <=
- Re: In search of cool Scheme, Hans O. Lowe, 2001/05/23
- Re: In search of cool Scheme, Harvey J. Stein, 2001/05/23
- Re: In search of cool Scheme, Hans O. Lowe, 2001/05/23
- Re: In search of cool Scheme, Harvey J. Stein, 2001/05/24
- Re: In search of cool Scheme, Harvey J. Stein, 2001/05/24
- Re: In search of cool Scheme, Hans O. Lowe, 2001/05/24
Re: In search of cool Scheme, Alex Shinn, 2001/05/22