POV-Ray : Newsgroups : povray.off-topic : Nobody will read this : Re: Nobody will read this Server Time
28 Jul 2024 18:18:16 EDT (-0400)
  Re: Nobody will read this  
From: Orchid Win7 v1
Date: 26 Jul 2013 18:03:10
Message: <51f2f21e$1@news.povray.org>
> At this point, we can say
>
> quadratic c z = addCx (mulCx z z) c
>
> This is, of course, awful.

I missed a step. I meant to use this as a neat opportunity to point out 
that you can do

   quadratic c z = (z `mulCx` z) `addCx` c

Putting any function name in backticks magically makes it infix. This is 
an improvement, although not a large one in the example given.

Then again, for standard arithmetic operations, there are well-known 
symbols, which are much more concise. For less common operations like 
set union, writing

   setA `union` setB

is regarded by many as being nicer than

   union setA setB

Each to their own. Perhaps the "mod" function is a better example:

   p^e `mod` m

verses

   mod (p^e) m

Weirdly, you can even set an "operator precedence" for backtick infix...

(In case I didn't explain, "infixr" means infix with Right 
associativity, while "infixl" means Left associativity.)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.