Home | Community | Message Board


Vesp.co, Inc.
Please support our sponsors.

General Interest >> Science and Technology

Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Jump to first unread post. Pages: 1
Offlinedaba
Stranger
 User Gallery

Registered: 12/30/02
Posts: 3,881
Last seen: 5 years, 3 months
SCHEME
    #1860998 - 08/29/03 12:26 AM (14 years, 7 months ago)

Anyone program in SCHEME?
I am having some troubles trying to make a simple procedure.
I am enrolled in CS3, introduction to Computer Science with the main emphasis on SCHEME.

How do you write a procedure:
(inch-count '(2 3)) where 2 = foot 3 = inches and would give you an answer 27?

I already wrote the inverse: Input inches, and it will transform inches into feet and inches.

(define (height inches)
(sentence (truncate (/ inches 12))
(- inches (* 12 (truncate (/inches))))))

Anyone?


--------------------
Fold for The Shroomery!


Post Extras: Print Post  Remind Me! Notify Moderator
Invisibledjfrog
omgws!!!1!

Registered: 10/23/00
Posts: 3,710
Re: SCHEME [Re: daba]
    #1861375 - 08/29/03 02:20 AM (14 years, 7 months ago)

first, the parameters on you function would indicate to me it expects input like "(inch-cont 2 3)" not "(inch-count '(2 3))".

How about



(define (inch-count inputt)
(+ (* 12 (car inputt))
(cadr inputt)))



Its been awhile since I've looked at Scheme though, I'm not sure I'm using the car and cadr functions right. Scheme is a useless dead language, well, it does have one use. "Structure and Interpretation of Computer Programs" is a brilliant book and it uses Scheme to explain a lot of interesting concepts.


Post Extras: Print Post  Remind Me! Notify Moderator
Offlinedaba
Stranger
 User Gallery

Registered: 12/30/02
Posts: 3,881
Last seen: 5 years, 3 months
Re: SCHEME [Re: djfrog]
    #1861631 - 08/29/03 04:08 AM (14 years, 7 months ago)

djfrog:
(inch-count '(2 3)) was the input I needed to follow.
(inch-count 2 3) is easy to produce. The catch was (inch-count '(2 3)). It has to be the inverse of (height 27), the process I wrote.


--------------------
Fold for The Shroomery!


Post Extras: Print Post  Remind Me! Notify Moderator
Invisibledjfrog
omgws!!!1!

Registered: 10/23/00
Posts: 3,710
Re: SCHEME [Re: daba]
    #1861665 - 08/29/03 04:24 AM (14 years, 7 months ago)

: (define (inch-count inputt) (+ (* 12 (car inputt)) (cadr inputt)))
: (inch-count '(2 3))
=> (+ (* 12 (car (2 3))) (cadr (2 3))))
=> (+ (* 12 2) (cadr (2 3))))
=> (+ 24 (car (3)))
=> (+ 24 3)
=> 27


What did I miss?



Post Extras: Print Post  Remind Me! Notify Moderator
Offlinedaba
Stranger
 User Gallery

Registered: 12/30/02
Posts: 3,881
Last seen: 5 years, 3 months
Re: SCHEME [Re: djfrog]
    #1861673 - 08/29/03 04:28 AM (14 years, 7 months ago)

:thumbup: 


--------------------
Fold for The Shroomery!


Post Extras: Print Post  Remind Me! Notify Moderator
Jump to top. Pages: 1

General Interest >> Science and Technology

Similar ThreadsPosterViewsRepliesLast post
* Looking for an LCD monitor....why are 24 inch more than 27 inch??? PsillyNilly 951 6 01/30/05 02:35 PM
by phi1618
* Quantum Field Theory question TheCow 1,301 2 05/14/08 09:21 PM
by TheCow
* Studios win $100 million judgment against TorrentSpy
( 1 2 3 all )
Ferris 3,666 56 05/23/08 10:22 PM
by johnm214
* Is this a good computer course to study?
( 1 2 all )
Jalruza 2,304 27 10/26/06 10:36 AM
by Jalruza
* EBay Scams??? LQQK! Cow Shit Collector 746 5 09/24/03 05:46 PM
by longshot
* Information travelling faster than 'light' ..
( 1 2 3 all )
cleeen 6,101 58 09/12/07 09:49 PM
by cleeen
* Hope You Didn't Buy An HD-DVD Player... Madtowntripper 1,068 9 01/15/08 11:56 AM
by Anno
* Anyone here know java?
( 1 2 3 all )
Psy Baba 2,761 40 05/05/07 01:29 AM
by AgingHippy

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: Lana, trendal, automan
724 topic views. 0 members, 5 guests and 3 web crawlers are browsing this forum.
[ Toggle Favorite | Print Topic | Stats ]
Search this thread:
Shroom Supply
Please support our sponsors.

Copyright 1997-2018 Mind Media. Some rights reserved.

Generated in 0.032 seconds spending 0.009 seconds on 19 queries.