[Haskell-cafe] Find a point inside (x,y,z) -> Bool

Richard A. O'Keefe ok at cs.otago.ac.nz
Mon Nov 2 01:16:39 UTC 2015


On 29/10/2015, at 10:01 pm, martin <martin.drautzburg at web.de> wrote:

> Hello all,
> 
> I hope this is not a too silly question. It goes like this:
> 
> Suppose I have a shape defined as
> 
> (x,y,z) -> Bool
> 
> how can I find a Point inside this shape?


What are x, y, z?

Consider a simplified case:
   (Natural, Natural) -> Bool
You can search
   (0,0)
   (1,0), (0,1)
   (2,0), (1,1), (0,2)
   (3,0), (2,1), (1,2), (0,3)
   ...
and if the shape is not empty you'll find some point in it.

For 3D, consider
   (0,0,0)
   (1,0,0) (0,1,0) (0,0,1)
   (2,0,0) (1,1,0) (1,0,1) (0,2,0) (0,1,1) (0,0,2)
   ...
> Obviously I could iterate through all possible x,y and z, but this appears
> very expensive.

Yes it is, but if that's _all_ you know about a shape ...

What if the shape is empty?



More information about the Haskell-Cafe mailing list