[Haskell-cafe] Re: Difference between div and /
Maciej Piechotka
uzytkownik2 at gmail.com
Tue Jun 1 20:05:07 EDT 2010
On Wed, 2010-06-02 at 01:13 +0200, Daniel Fischer wrote:
> On Wednesday 02 June 2010 00:55:08, Maciej Piechotka wrote:
> > On Tue, 2010-06-01 at 15:29 -0700, Evan Laforge wrote:
> > > > [1] By co I mean Ruby, Python, Perl and others. There are no so many
> > > > languages that do recognize the difference.
> > >
> > > % python -Q new
> > > Python 2.4.6 (#1, Aug 3 2009, 17:05:16)
> > > [GCC 4.0.1 (Apple Inc. build 5490)] on darwin
> > > Type "help", "copyright", "credits" or "license" for more information.
> > > 10 / 3
> > > #-> 3.3333333333333335
> > > 10 // 3
> > > #-> 3
> > >
> > >
> > > The python guys decided that int/int -> int was a mistake, but because
> > > it's an incompatible change, the removal process has been long (hence
> > > the -Q flag, or a from __future__ import). In fact, I think they gave
> > > up on making it the default before python 3.
> > >
> > > I appreciate that haskell has differentiated from the beginning.
> >
> > Well - i tried to write some package dealing with distributions etc.
> >
> > If you have something like that:
> >
> > instance ... => Distribution (Linear a) a where
> > rand (Linear f s) g =
> > let (gf, gt) = genRange g
> > (v, g') = next g
> > in (g', f + (fromIntegral v * s) / fromIntegral (gt - gf))
> >
> > (I haven't check it but IMHO it is right implementation)
> >
> > Now I have following options:
> >
> > - Implement per Int/Int8/...
> > - Implement IntegerLinear and FractionalLinear separatly
>
> - use realToFrac instead of fromIntegral
> (using the logfloat package is probably not a bad idea then)
>
I'm not quire sure how to use it. I would have to either use floor/...
which would make result Integral or left it as it is and having
(Fractional a, Real a) constraint.
> >
> > Neither of choices are IMHO not ideal.
>
> Methinks that is not what you wanted to say ;)
>
Ups. Sorry - it's rather late and I'm not native speaker (and my native
language do use double negation). "Neither of the choices are ideal
IMHO".
> >
> > Regards
>
Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100601/b7e96363/attachment.bin
More information about the Haskell-Cafe
mailing list