I wouldn't say that templates are "for" functions. It's more like they
are "for" the combination of arguments to the function, which in this
case is the structure, because functions on the structure will all
share the same template. Furthermore, you can't write the template for
a structure unless you know what kind of values the fields contain,
which your excerpt doesn't contain. Plus, I don't think I should do
your homework. I could post an example, but the HtDP 2e link I
referenced before has a ton with more explanation than I would copy in
to this email.

Jay

On Sat, Oct 17, 2015 at 5:16 PM,  <david.cao2...@gmail.com> wrote:
> Hi Jay,
>
> Could you write a template for me for the below function?
> (define-struct stru (v1 v2))
>
> (define (my-fun s)
>   (cond [(> (stru-v1 s) (stru-v2 s)) (stru-v1 s)]
>    [else (stru-v2 s)]
>   )
> )
>
> (my-fun (make-stru 1 2))
> (my-fun (make-stru 2 1))
>
> thanks
> David
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.



-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

           "Wherefore, be not weary in well-doing,
      for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
                          - D&C 64:33

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to