[Haskell-cafe] Clausula where

vieira.ufpi at gmail.com vieira.ufpi at gmail.com
Sat Dec 19 13:45:24 UTC 2015

I’m using GHCi in a Haskell  version 7.10.2 and using this fragmente of coding:

data ArvBinA t = Folha t | No Int (ArvBinA t) (ArvBinA t) deriving (Eq, Ord, Show)

arvbina = No 4 (No 2 (Folha 14) (Folha 09)) (No 2 (Folha 19) (Folha 51))

tamArvBinA :: ArvBinA t -> Int
tamArvBinA (Folha x) = 1
tamArvBinA (No n xt yt) = n

rotula :: ArvBinA t -> ArvBinA t -> ArvBinA t
rotula ae ad
   = No n ae ad where n = (tamArvBinA ae) + (tamArvBinA ad)

listoArvBinA ::  (Eq t) => [t] -> ArvBinA t
listoArvBinA xs
   |m == 0    = Folha (head xs)
   |otherwise = rotula (listoArvBinA xse) (listoArvBinA xsd)
                          where  m              =  (length xs) `div` 2 
                                       (xse, xsd)  =  (take m xs,  drop m xs) 

After compiling there is this message: 

parse error on input   ‘=’. 

There is someone that he/she can help me? I think that’is na error by clause where and the offside rule, or so, but I’m not right of this.

Thanks in advance for some help

Francisco Vieira

Enviado do Email do Windows
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151219/216c4e2f/attachment.html>

More information about the Haskell-Cafe mailing list