Home | Community | Message Board


Gaiana.nl
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: 3 years, 10 months
SCHEME
    #1860998 - 08/29/03 12:26 AM (13 years, 3 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 (13 years, 3 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: 3 years, 10 months
Re: SCHEME [Re: djfrog]
    #1861631 - 08/29/03 04:08 AM (13 years, 3 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 (13 years, 3 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: 3 years, 10 months
Re: SCHEME [Re: djfrog]
    #1861673 - 08/29/03 04:28 AM (13 years, 3 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 872 6 01/30/05 02:35 PM
by phi1618
* Apple MacBookPro 15 or 17 inch ?
( 1 2 all )
Locus 1,225 23 12/11/08 02:07 AM
by MHbound
* EBay Scams??? LQQK! Cow Shit Collector 728 5 09/24/03 05:46 PM
by longshot
* Information travelling faster than 'light' ..
( 1 2 3 all )
cleeen 5,683 58 09/12/07 09:49 PM
by cleeen
* Hope You Didn't Buy An HD-DVD Player... Madtowntripper 992 9 01/15/08 11:56 AM
by Anno
* Anyone here know java?
( 1 2 3 all )
Psy Baba 2,650 40 05/05/07 01:29 AM
by AgingHippy
* HD-DVD Anti-copy Cryptosystem Cracked DiploidM 841 2 01/02/07 07:30 PM
by rod
* Like downloading content illegally? Stay away from France then.... HagbardCeline 582 5 06/20/08 06:04 AM
by Seuss

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

Copyright 1997-2016 Mind Media. Some rights reserved.

Generated in 0.031 seconds spending 0.005 seconds on 14 queries.