POV-Ray : Newsgroups : povray.off-topic : Unexpected : Re: Unexpected Server Time
28 Jul 2024 16:16:08 EDT (-0400)
  Re: Unexpected  
From: Orchid Win7 v1
Date: 18 Aug 2013 04:47:13
Message: <52108a11$1@news.povray.org>
On 17/08/2013 08:15 PM, Samuel Benge wrote:
> Orchid Win7 v1<voi### [at] devnull>  wrote:
>> I'm sure there must be more evil ways of doing this...)
>
> Here's one (probably not the best) way to do it:
>
> return x*(1-2*(x<0));
>
> Not sure how C# handles types, but in C that would return an int.

Well, I mean, the "obvious" way is

   if (x<0) return -x; else return x;

But you can phrase that as

   return x ? x : -x;

if you prefer.

> Thanks for the laughs, btw :) When Haskell isn't the main subject, you're
> actually pretty funny ;)

If you wanted to find crazy ways to do this in Haskell, you would have 
some pretty scary options available... ;-)


Post a reply to this message

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