2 Replies - 5964 Views - Last Post: 08 November 2012 - 03:28 PM

#1 manonthem00n   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-November 12

DrRacket Problem

Posted 06 November 2012 - 05:39 PM

Hey guys im learning how to use DrRacket. I have one problem giving me trouble. Im not sure how to set up a list entered to return a min.

Im trying to create a procedure that finds the min number from the keyboard until 0 is read, and that's adds them up. Note that 0 is included in the computation.

ANY help would be great.

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: DrRacket Problem

#2 manonthem00n   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-November 12

Re: DrRacket Problem

Posted 07 November 2012 - 10:34 AM

(define (minimum-list x) 
(cond [(empty? (rest x)) (first x)] 
[else (min (first x) (minimum-list (rest x)))]))

 (display (minimum-list (read)))


I have this so far, but I need to be able to enter numbers without having to use paranthesis... With this code, it works, but I need to write it with paranthesis for ex. (1 3 -3).. I need it 1 3 -3


Any help would be awesome :/
Was This Post Helpful? 0
  • +
  • -

#3 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2770
  • View blog
  • Posts: 4,429
  • Joined: 21-June 11

Re: DrRacket Problem

Posted 08 November 2012 - 03:28 PM

read reads a Racket value, so the input has to be entered using Racket syntax. Since you don't want that, you should use read-line which reads a line of input (without caring how it's formatted) and returns it as a string. You can then use string-split to turn that string into a list by splitting on white space.

This post has been edited by sepp2k: 09 November 2012 - 08:19 AM

Was This Post Helpful? 3
  • +
  • -

Page 1 of 1