Jump to content

A little help with Dr. Scheme

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Mt570

Mt570

    Newbie

  • Members
  • Pip
  • 3 posts
Hey, I have to create a Scheme procedure find_min that reads numbers from the keyboard until 0 is read, and display the minimum of all read numbers. 0 is included in the computation.

This is what I have so far
(define find_min2 (lambda (x y)

                    (if ( < x y )

                        x

                        y

                        )

                    )

  )


(define find_min (lambda (x)

                  (if ( = x 0)

                      (if ( < x 0)

                         (display x )

                          (display 0 )

                          )

                      ((define y read)

                      (if ( = (find_min2 x  y ) x)

                          (find_min x)

                          (find_min y)))

                      )

                  )

  )
However it doesn't run. I'm not sure how to assign what I read in, to a variable. It crashes on the line "(define y read)"

#2
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
hum, you need to call the read function, I'm not a scheme expert but I would say:
(define y (read))