0
我打算假设在Fractal Mandelbrot
的情况下,escapeCount f (C comp3)
的f
代表Mandelbrot
数据类型。我将如何访问诸如MaxIter之类的元素。我是否必须为每个可能需要的元素编写定义?如何从实例中的数据定义中获取特定类型?
type MaxIter = Int
type Row = Int
type Col = Int
data Complex = C Double Double deriving (Show,Eq)
data Mandelbrot = M MaxIter Row Col Complex Complex deriving (Eq)
class (Show f) => Fractal f where
escapeCount :: f -> Complex -> Int
instance Fractal Mandelbrot where
escapeCount f (C comp3) = <- I assume this means that comp3 is of type C?
谢谢,不幸的是我必须让自己的复杂。此外,escapeCount有一个我试图在实例下实现的签名,但是如何访问它需要的第二个“参数”?另外当我试图做模式匹配它说变量不在范围内? – octoCat