[plt-scheme] problem running clock example for FrTime

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Aug 12 13:23:08 EDT 2009

First, it looks like you copied code from the PDF that contains weird
unicode display glyphs. In general, this will not work in DrScheme,
MzScheme, or any other PL environment.

I'm not sure why match doesn't work, but here is code that does....

(require scheme/match)

(define d (seconds->date seconds))
(define sec (date-second d))
(define min (date-minute d))
(define hr (date-hour d))
(define day (date-day d))
(define mon (date-month d))
(define yr (date-year d))

(define (pad n)
  (if (< n 10)
      (format "0~a" n)
      (number->string n)))

(define clock
  (format "~a:~a:~a ~a-~a-~a"
          hr (pad min) (pad sec)
          day (pad mon) (pad (modulo yr 100))))

Jay


On Wed, Aug 12, 2009 at 9:33 AM, Scott Hickey<sshickey at qwest.net> wrote:
> am working through the paper from 2004 on FrTime. There is a clock demo with
> sample source which doesn't run in version 4.2.
> I think there are two problems.
>
> First, the syntax for match has changed. I tried to update it but I still
> get the following error.
> match: date does not refer to a structure definition in: date
>
> Second, seconds->date won't work with seconds as an argument. Calling
> value-now gets pass the error but I'm guessing that's not going to make the
> demo run correctly?
>
>
> (require scheme/match)
> (define clock
>   (match (seconds->date (value-now seconds))
>     [(struct date (sec min hr day mon yr _ _ _ _))
>      (format " ̃a: ̃a: ̃a  ̃a- ̃a- ̃a"
>              hr (pad min) (pad sec)
>              day (pad mon) (pad (modulo yr 100)))]))
>
> ;; pads a number to two digits
> (define (pad n)
>   (if (< n 10)
>       (format "0 ̃a" n)
>       (number!string n)))
>
> Thanks,
>
> Scott Hickey
> Senior Consultant
> Object Partners, Inc.
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.