Use properFraction:
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AproperFraction
Hi,
In other weak-type language, `round i == i` would work. But in
haskell, what should I do? Thanks.
--
竹å¯å²å¦¨æµæ°´è¿
å±±é«åªé»éäºé£
It never matches to (_, 0.0)
I mean
case properFraction l of
(_, 0) - l
_ - 0 -- always goes here.
On Tue, Sep 29, 2009 at 2:18 PM, Jimmy Hartzell j...@shareyourgifts.net wrote:
Use properFraction:
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AproperFraction
On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds
magicloud.magiclo...@gmail.com wrote:
It never matches to (_, 0.0)
I mean
case properFraction l of
(_, 0) - l
_ - 0 -- always goes here.
Odd, it works fine for me.
f x =
case properFraction x of
(_,0) -
$ ghci
Prelude let isInteger' l = case properFraction l of { (_,0) - 1; _ - 0 }
Prelude isInteger' 2.0
1
Prelude isInteger' 1.9
0
Do you really get 1? For what input types/values? Although I would write:
isInteger = (== 0) . snd . properFraction
It never matches to (_, 0.0)
I mean
case
The original code is
givenSum num = map (\a -
let l = (sqrt $ fromIntegral (a * a + 2 + 2 *
num)) - (fromIntegral a) in
case properFraction l of
(_, 0) -
True
_ -
Unless I missed something, the function in question is:
sqrt (a * a + 2 + 2 * num) - fromIntegral a
where num = 10
1 - sqrt (1 * 1 + 2 + 2 * 10) - 1 - sqrt (1 + 2 + 20) - 1 - sqrt
(23) - 1 - 3.79x
the fractional will only ever come from the sqrt function. Do any of
the following actually
Did you test the properFraction-based code in isolation? If code is
broken, it's important to figure out which part of it is broken. Also,
this function is not divided into constituent parts, but is a long unruly
mess. Dividing it into parts would make it much much more readable, and
you would
Of course them are not. But that is why I need the detector
2009/9/29 Thomas DuBuisson thomas.dubuis...@gmail.com:
Unless I missed something, the function in question is:
sqrt (a * a + 2 + 2 * num) - fromIntegral a
where num = 10
1 - sqrt (1 * 1 + 2 + 2 * 10) - 1 - sqrt (1 + 2 + 20) - 1
The properFaction part is correct. So I posted the whole code, since
isInteger should accept any reasonable incoming types. Well, in this
one situation, it does not. And I cannot figure out why
On Tue, Sep 29, 2009 at 3:07 PM, Jimmy Hartzell j...@shareyourgifts.net wrote:
Did you test the
On Tue, Sep 29, 2009 at 9:13 AM, Magicloud Magiclouds
magicloud.magiclo...@gmail.com wrote:
The properFaction part is correct. So I posted the whole code, since
isInteger should accept any reasonable incoming types. Well, in this
one situation, it does not. And I cannot figure out why
*Should* isInteger be returning True for any numbers generated by this
code? If so, can you simplify this test down to that example, so that
it's obvious what the test should do, and that it's not doing it (if it in
fact is not doing as it should)? In any case, it would help to divide this
block
Resolved. As Thomas said, mixing up sure is a bad thing. But then I
have to name so many meanless (at least I think) computing process
On Tue, Sep 29, 2009 at 3:32 PM, Jimmy Hartzell j...@shareyourgifts.net wrote:
*Should* isInteger be returning True for any numbers generated by this
code?
On Tue, Sep 29, 2009 at 2:30 AM, Magicloud Magiclouds
magicloud.magiclo...@gmail.com wrote:
Resolved. As Thomas said, mixing up sure is a bad thing. But then I
have to name so many meanless (at least I think) computing process
That is the primary challenge of writing readable code:
Am Dienstag 29 September 2009 09:02:19 schrieb Thomas DuBuisson:
Unless I missed something, the function in question is:
sqrt (a * a + 2 + 2 * num) - fromIntegral a
where num = 10
1 - sqrt (1 * 1 + 2 + 2 * 10) - 1 - sqrt (1 + 2 + 20) - 1 - sqrt
(23) - 1 - 3.79x
the fractional will
On Tue, 29 Sep 2009, Magicloud Magiclouds wrote:
Hi,
In other weak-type language, `round i == i` would work. But in
haskell, what should I do? Thanks.
Am I right, that you want to check whether a number is a square number?
http://www.haskell.org/haskellwiki/Generic_number_type#isSquare
Hi,
In other weak-type language, `round i == i` would work. But in
haskell, what should I do? Thanks.
--
竹密岂妨流水过
山高哪阻野云飞
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
16 matches
Mail list logo