The following code is intended to build a list of numbers for a stat
package:
(define (buildList)
(define inputList ())
(display "Please enter a number or simply press return when done: ")
(let ((inputElement (read)))
(cond ((eq? inputElement 'done )
(display "Finished building list.")
(newline))
(#t
(display "inputElement: ")(display (list inputElement))
(newline)
(display "inputList: ")(display inputList)(newline)
(append inputList (list inputElement))
(newline)
(display "The appended list: ")(display inputList)(newline)
(buildList)))) ;tail recursion
(display inputList))
(buildList)
---------------------------------------
Here is the output...
Please enter a number or simply press return when done: 1
inputElement: (1)
inputList: ()
The appended list: ()
Please enter a number or simply press return when done: 2
inputElement: (2)
inputList: ()
The appended list: ()
Please enter a number or simply press return when done: 3
inputElement: (3)
inputList: ()
The appended list: ()
Please enter a number or simply press return when done: done
Finished building list.
()()()()
----------------------------
I want it to read...
(1 2 3)
Any help would be appreciated.
Kindly,
Sean