Re: Newbie question: what's this dot?
- From: jadamson@xxxxxxxxxxxx (Joel J. Adamson)
- Date: 31 May 2007 11:32:52 -0400
"Kjetil S. Matheussen" <k.s.matheussen@xxxxxxxxxx> writes:
On Thu, 31 May 2007, Joel J. Adamson wrote:
when I divide using
(/ 1 2)
or
(quotient 1 2)
I get 1/2.
When I divide using
(/ 1 2.)
I get 0.5
As I want to use this to calculate Taylor series and other such
sequences, I really need the decimal representation.
Why?
Because the point of the program is to print out the partial sums of a
series, and also find the limit of a series, or tell me that it's
divergent. This is just for learning.
How do I coerce
this (do I need to coerce it or is this much simpler)?
For example, if I
(define series
(lambda (x)
(/ 1 x)))
and then do
(map series '(1 2 3 4 5))
I get a list of ones as a result. That's not right ;)
Really?
Really.
Then your scheme is broken. This is what you are supposed to get:
(1 1/2 1/3 1/4 1/5)
Hmmm, it's definitely treating them as integers and giving me the
integer ceiling. I'm pretty sure it's doing what it's supposed to do,
and I'm not doing what I'm supposed to do. I hope you consider that a
productive attitude.
I'm not sure, but I have a feeling that you don't know the concept of
rationals in lisp?
Bingo. I will read about it.
(btw, I know the concept of rational in mathematics, and so perhaps
thinking of it as a subset of real numbers is what's tripping me up;
these things seem to have a different meaning; i.e., to scheme, a
rational and an integer are different, to me they are the same in the
sense that an alligator is a crocodile, i.e., subsets).
Thanks for your help,
Joel
--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA 02114
(617) 643-1432
(303) 880-3109
.
- Follow-Ups:
- Re: Newbie question: what's this dot?
- From: Kjetil S. Matheussen
- Re: Newbie question: what's this dot?
- References:
- Newbie question: what's this dot?
- From: Joel J. Adamson
- Re: Newbie question: what's this dot?
- From: Kjetil S. Matheussen
- Newbie question: what's this dot?
- Prev by Date: Re: Newbie question: what's this dot?
- Next by Date: Re: Newbie question: what's this dot?
- Previous by thread: Re: Newbie question: what's this dot?
- Next by thread: Re: Newbie question: what's this dot?
- Index(es):
Relevant Pages
|