Skip to content

Commit

Permalink
fix n-ary subtract and divide
Browse files Browse the repository at this point in the history
Quite simply we had the associativity wrong from subtract and divide
  • Loading branch information
cbaggers committed Oct 4, 2022
1 parent 9e77f30 commit 7949aa6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/vari.cl/nary-operators.lisp
Expand Up @@ -28,7 +28,9 @@
(t t t &rest t) 0 :pure t)

(v-define-compiler-macro / ((a t) (b t) (c t) &rest (d t))
`(/ ,a (/ ,b (/ ,c ,@d))))
(if d
`(/ (/ (/ ,a ,b) ,c) ,@d)
`(/ (/ ,a ,b) ,c)))

(v-def-glsl-template-fun + (a b c &rest c) "(~a £+£ ~a £+£ ~a ~{ £+£ ~a~})"
(t t t &rest t) 0 :pure t)
Expand All @@ -40,7 +42,9 @@
(t t t &rest t) 0 :pure t)

(v-define-compiler-macro - ((a t) (b t) (c t) &rest (d t))
`(- ,a (- ,b (- ,c ,@d))))
(if d
`(- (- (- ,a ,b) ,c) ,@d)
`(- (- ,a ,b) ,c)))

(v-def-glsl-template-fun + () "0" () :int :pure t)
(v-def-glsl-template-fun + (x &rest y) "(~a~{ + ~a~})" (v-number &rest v-number) nil :pure t)
Expand Down

0 comments on commit 7949aa6

Please sign in to comment.