First off: you’re very close.

Thing two: I think you need a clearer comment on the meaning of the “months” 
vector. Your description does not actually say what the vector represents or 
contains.

Thing three: Here’s my question to you. Suppose that I tell you a year and a 
month and the result of (vector-ref months x). 

To be more concrete, suppose I tell you the year is 2234 and the month is 4 and 
the result of (vector-ref months x) is 30. How many days would that month have? 
Can you explain how to compute the answer for each of the test cases below?

John Clements

> On Apr 19, 2020, at 11:50, Suz Renae <kahrend...@gmail.com> wrote:
> 
> I am new to racket (first year student) and since class has been pushed to 
> online only, I am having a harder time.
> 
> We are currently working on vectors and hash tables. I feel like I keep 
> overthinking it and keep getting stuck. I know that the first parameter in 
> the function will be the year and the second will be the (vector-ref months 
> x)that I pull from the defined vector.
> 
> The question I am having a hard time with and what I have actually done below.
> 
> Create a function that calculates the number of days in a month given a year 
> and a month
>       • Call the function number-of-days-in-month, and it's signature is 
> number, number -> number
>       • Example:
> (number-days-in-month 2016 1) -> 31
> (number-days-in-month 2016 11) -> 30
> (number-days-in-month 2016 12) -> 31
> (number-days-in-month 1900 2) -> 28
> (number-days-in-month 2000 2) -> 29
> (number-days-in-month 2016 2) -> 29
> (number-days-in-month 2200 2) -> 28
> What I have so far...
> 
> ;Leap Year
> (define (leap-year? year)
>   (and (zero? (modulo year 4))
>        (or (not (zero? (modulo year 100)))
>           (zero? (modulo year 400))
>           )
>        )
>   )
> 
> ;Months with days vector, beginning at an index of 0 since there is not 0th 
> month
> (define months (vector 0 31 28 31 30 31 30 31 31 30 31 30 31))
> 
> (check-expect(number-days-in-month 2016 1)31)
> (check-expect(number-days-in-month 2016 11)30)
> (check-expect(number-days-in-month 2016 12)31)
> (check-expect(number-days-in-month 1900 2)28)
> (check-expect(number-days-in-month 2000 2)29)
> (check-expect(number-days-in-month 2016 2)29)
> (check-expect(number-days-in-month 2200 2)28)
> 
> I  need help with building the actual function and what conditionals I should 
> be using.
> 
> (define (number-days-in month ?? ??)
>     (cond
>          [
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/5d017eef-b235-4a8b-94fa-fe1e3f7b766e%40googlegroups.com.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/02cda61a-5bea-4087-8518-e4a44d4dfa56%40mtasv.net.

Reply via email to