Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 6th, 2012, 06:55 PM
man0nthemoon man0nthemoon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 3 man0nthemoon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 2 m 18 sec
Reputation Power: 0
Scheme/DrRacket

I'm trying to create a procedure that finds the min number from the keyboard until 0 is read. Using "display" and "read". Note that 0 is included in the computation.

Any tips, pointer or solutions would be awesome.

Thanks.

\

Reply With Quote
  #2  
Old November 7th, 2012, 11:33 AM
man0nthemoon man0nthemoon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 3 man0nthemoon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 2 m 18 sec
Reputation Power: 0
Code:
(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 :/

Reply With Quote
  #3  
Old November 7th, 2012, 06:52 PM
Schol-R-LEA's Avatar
Schol-R-LEA Schol-R-LEA is offline
Commie Mutant Traitor
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2004
Location: Norcross, GA (again)
Posts: 1,759 Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level)Schol-R-LEA User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 3 h 38 m 3 sec
Reputation Power: 1568
If you look into the Racket Documentation, you'll find the section on Ports, and specifically, the port->list procedure:
Code:
#lang racket

(require racket/port)

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

(display (minimum-list (port->list)))

Mind you, this probably still doesn't do quite what you want; you need to hit enter after each number, and at the end of the numbers, hit the EOF button on the end of the entry box. It is designed mainly for reading files, so using it from the listener is something of a kludge.

As an alternative, you could use port->string and string-split parse the numbers individually, but that's a good deal more work.

This is assuming you are using the Racket language, rather than, say, R6RS Scheme. Most of the different Scheme variants have similar procedures, however.
__________________
Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
#define KINSEY (rand() % 7) λ Scheme is the Red Pill
Scheme in ShortUnderstanding the C/C++ Preprocessor
Taming PythonA Highly Opinionated Review of Programming Languages for the Novice, v1.1

FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov

Last edited by Schol-R-LEA : November 7th, 2012 at 06:57 PM.

Reply With Quote
  #4  
Old November 7th, 2012, 06:56 PM
man0nthemoon man0nthemoon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 3 man0nthemoon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 2 m 18 sec
Reputation Power: 0
Wow thank you. It works that way! Not exactly what I wanted but it does the trick. Thank you.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Scheme/DrRacket

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap