PasteRack.org
Paste # 58091
2020-07-02 15:32:12

Fork as a new paste.

Paste viewed 535 times.


Embed:

  1. #lang racket
  2.  
  3. (define-syntax (define-mat4*mat4!/let stx)
  4.   (syntax-case stx ()
  5.     ((_ mat4*mat4!)
  6.      #`(define (mat4*mat4! R A B)
  7.          #,@(for/list ((r 4))
  8.               #`(let
  9.                     #,(for/list ((c 4))
  10.                         #`(#,(datum->syntax
  11.                               stx
  12.                               (string->symbol
  13.                                (string-append
  14.                                 "a"
  15.                                 (number->string c))))
  16.                            (unsafe-flvector-ref A #,(+ (* r 4) c))))
  17.                   #,@(for/list ((c 4))
  18.                        #`(unsafe-flvector-set!
  19.                           R
  20.                           #,(+ (* r 4) c)
  21.                           (unsafe-fl+
  22.                            #,@(for/list ((i 4))
  23.                                 #`(unsafe-fl*
  24.                                    #,(datum->syntax
  25.                                       stx
  26.                                       (string->symbol
  27.                                        (string-append
  28.                                         "a"
  29.                                         (number->string i))))
  30.                                    (unsafe-flvector-ref B #,(+ c (* i 4))))))))
  31.                   ))))))
  32.  
  33. (define-mat4*mat4!/let mat4*mat4!/let)

=>