Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 1.14 KB | None | 0 0
  1. #lang racket
  2.  
  3. (require syntax/parse/define
  4.          plot)
  5.  
  6. (provide (except-out (all-from-out racket)
  7.                     #%module-begin)
  8.          (rename-out [lesson1:#%module-begin #%module-begin]))
  9.  
  10. (module reader syntax/module-reader lesson1)
  11.  
  12. (define (plot-it functions names)
  13.   (define (make-surface function name color)
  14.     (surface3d function -1 1 -1 1 #:label name #:color color #:line-color color))
  15.   (define surfaces
  16.     (for/list ([color (in-naturals)]
  17.                [function (in-list functions)]
  18.                [name (in-list names)])
  19.       (make-surface function name color)))
  20.   (plot3d surfaces))
  21.  
  22. (define-syntax (lesson1:#%module-begin stx)
  23.   (syntax-parse stx
  24.     [(_ (~describe "function definition of two variables that returns a real number"
  25.                    ((~literal define) (name:id x-argument:id y-argument:id)
  26.                                       body:expr ...+)) ...+)
  27.      #'(#%module-begin
  28.         (define/contract (name x-argument y-argument)
  29.           (-> real? real? real?)
  30.           body ...)
  31.         ...
  32.         (plot-it (list name ...)
  33.                  (list (symbol->string 'name) ...)))]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement