[Haskell-cafe] Question about STRef

Antoine Rimlet antoine.rimlet at gmail.com
Thu Jan 26 13:56:29 UTC 2017


Thanks to all for your answers!
With "return $!" the program now works "as expected".
Forcing Int, and moving the "let b" in the "else" part, also brings some
(but comparatively far less) improvement.
Note that, as indicated in my initial post, this program is a *modified*
version of "Man or boy", and therefore it does not return the same values.
Best,
Antoine

2017-01-26 14:32 GMT+01:00 Frank Staals <frank at fstaals.net>:

> Antoine Rimlet <antoine.rimlet at gmail.com> writes:
>
> > Hi list,
> >
> > I try to get the following little program (a slightly modified "Man or
> > boy", it prints -14254067) work "as expected", that is, without consuming
> > lots of memory
>
> Are you sure "-14254067" is correct for k=22? Wikipedia [1] and
> RosettaCode [2] both seem to suggest that -865 609 is the right
> answer. Similarly, for k=10 it is supposed to return -67 rather than -577.
>
> [1] https://en.wikipedia.org/wiki/Man_or_boy_test
> [2] http://rosettacode.org/wiki/Man_or_boy_test
>
> --
>
> - Frank
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170126/7d6d2bc8/attachment.html>


More information about the Haskell-Cafe mailing list