Re: Newbie question: what's this dot?



"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
.



Relevant Pages

  • Re: An uncountable countable set
    ... > But we could apply the transpositions even without any law, ... well-order by size too. ... the rationals is *not* a sequential process. ... I said "sequences". ...
    (sci.math)
  • Re: Problems I have with 1.999...=2
    ... we come to the problem of what these infinite decimal ... we know that rationals are dense on the real number ... infinite lists only contain rational numbers for our purposes here so ... As far as I understand these special sequences are ...
    (sci.math)
  • Re: Dedekind Cuts, Fundamental Sequences: why?
    ... real numbers can be described by convergent rational sequences. ... We speak of "fundamental sequences of rationals" instead. ... constructing the reals, if we are to avoid circularity. ... to get a compiler from the source code we have to compile the compiler. ...
    (sci.math)
  • Re: Dedekind Cuts, Fundamental Sequences: why?
    ... real numbers can be described by convergent rational sequences. ... We speak of "fundamental sequences of rationals" instead. ... no metric spaces and no Cauchy sequences until *after* we have finished ... constructing the reals, if we are to avoid circularity. ...
    (sci.math)
  • Re: Dedekind Cuts, Fundamental Sequences: why?
    ... speak of "Cauchy sequences of rationals" when constructing the real ... no metric spaces and no Cauchy sequences until after we have finished ... constructing the reals, if we are to avoid circularity. ...
    (sci.math)