I am new to scheme, and are learning it using Dr.Scheme, please help

I came across this question, but have some trouble with it:
A clock structure (define-struct Clock(hours minutes seconds)). Make a function that Consume a Clock structure and output the total seconds


;;this is what i did
(define-struct Clock (hours minutes seconds))

(define Clock1(make-Clock 10 10 10))

(define (ChangeIntoSec ClockX)
(+ (+ (* (Clock-hours Clock1) 3600)
(* (Clock-minutes Clock1) 60))
(Clock-seconds Clock1)))

;;end
did I do it right? because is the user suppose to type in the hours, minutes and seconds themself in the interactive window? In my answer I made a clock myself, instead of asking the user to type in the time for the clock structure

please help

thanks in advance

Recommended Answers

All 2 Replies

The logic is right.
you don't need to go into nesting here.
this will work too
(+ (* (Clock-hours Clock1) 3600) (* (Clock-minutes Clock1) 60) (Clock-seconds Clock1))

Not sure what you meant by user interface.

oh I got it now thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.