haskell question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

haskell question

IBRAHIM MOSHAYA
please can you help me with this function:

Significant Figures
I need to write a function to return a given number (1st argument) to a
given number of significant figures
(2nd argument). The function should be called sigFig and have a type
signature of the form:
sigFig :: (???) => a -> Int -> a
For instance:
*Main> sigFig 123.456 2
120.0
*Main> sigFig 123.456 4
123.5
*Main> sigFig 0.987 2
0.99
*Main> sigFig 0.432 2
0.43
The type variable a will need to be constrained, but you should aim for the
most general implementation you
can (replacing ??? above with the appropriate constraint(s)). You may make
free use of Prelude functions.
Referring to [Jon03] you may wish to consider the use of functions /
operators including:
/, div, mod, ^, ^^, **, round, fromIntegral, realToFrac

thanks alot


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: haskell question

Ketil Malde-2
"IBRAHIM MOSHAYA" <[hidden email]> writes:

> I need to write a function to return a given number

Homework assignment?

Perhaps if you get stuck, you can post your best current effort, and
people will be able to nudge you in the right direction?

-k
--
If I haven't seen further, it is by standing in the footprints of giants

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe