[Haskell-beginners] This code does not work : conversion error
mukesh tiwari
mukeshtiwari.iiitm at gmail.com
Sun Dec 1 08:17:03 UTC 2013
Hi Willie,
Here is the code modified
maxexp2:: Int -> Int
maxexp2 n
|n== 0 || 2^k `mod` n /=0 =0
|otherwise = k
where
k = e `div` f
e = round ( log ( fromIntegral n ) )
f = round ( (log 2.0 ))
When you computing k then use backticks (`) [1] not the single quote ( ' )
[1] http://book.realworldhaskell.org/read/functional-programming.html( See
Infix function )
On Sun, Dec 1, 2013 at 12:52 PM, willie ekaputra
<willieekaputra at gmail.com>wrote:
> Hi everyone !
> I am newbie and I made this code for counting k, so that 2^k divisor of
> n.Somehow it doesn't work.
> Anyone knows what is wrong?
>
> Regards and thanks.
> Wili.
>
> maxexp2:: Int -> Int
> maxexp2 n
> |n== 0 || 2^k 'mod' n /=0 =0
> |otherwise = k
> Where
> k= e ' div' f
> e=round (fromIntegral (log n))
> f = round (fromIntegral (log 2))
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131201/be8cdd98/attachment.html>
More information about the Beginners
mailing list