using recursion to create a new list



I've written a function that takes a number and returns a list of all
the integer multiples of that number from 1 to 10, in as simple a way
as I can think of. Given the number 3, my function returns the list:

(define (multiples-list num)
(append (list num)
(map (lambda (x) (* num x))
'(2 3 4 5 6 7 8 9 10))))

==> (3 6 9 12 15 18 21 24 27 30)

How do I go about thinking recursively to do this by making a new list?
I.e., using a mapping function ala

;; Return a list of the square roots of the numbers in a list
(define (square-roots a-list)
(if (null? a-list)
'()
(cons (sqrt (car a-list))
(square-roots (cdr a-list)))))

.



Relevant Pages

  • Re: Sgt Slick.....
    ... >> I happen to think this is a stupid argument. ... >Integer multiples aren't the only multiples that exist my friend. ... ....To be a great NCO, you need three bones: a backbone, a wishbone and a funny bone. ... Prev by Date: ...
    (rec.sport.football.college)
  • Re: " Wanted the r iterated of f(x) = 2*x/(1-x^2) , f^[r](x) "
    ... >Do some of you know a closed form ... differ by integer multiples of pi and thus the possible values ... Prev by Date: ...
    (sci.math)
  • Re: Sgt Slick.....
    ... Integer multiples aren't the only multiples that exist my friend. ... Aaron ... Prev by Date: ...
    (rec.sport.football.college)

Loading