Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: strange behaviour : computing lowest divisor (Abhijit Ray)
----------------------------------------------------------------------
Message: 1
Date: Wed, 29 Dec 2010 17:59:53 +0800
From: Abhijit Ray <[email protected]>
Subject: Re: [Haskell-beginners] strange behaviour : computing lowest
divisor
To: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Thanks, that seems to have fixed it.
On Wed, Dec 29, 2010 at 5:46 PM, Lyndon Maydwell <[email protected]> wrote:
> Try with Integer rather than Int. Might be an overflow issue...
>
> On Wed, Dec 29, 2010 at 5:32 PM, Abhijit Ray <[email protected]> wrote:
> > HI,
> > I have written(copied) a small piece of code which finds the lowest
> divisor
> > of am integer (greater than 1)
> >
> > the code is here
> >
> > ld::Int->Int
> > ld n = ld' 2 n
> > where
> > ld' i n | rem n i == 0 = i
> > | i^2 > n = n
> > | otherwise = ld' (i+1) n
> >
> >
> > now it seems to work fine for small numbers but for a big number we get
> >
> > *Main> ld 278970415063349480483707695
> > 7
> >
> > the number is obviously divisible by 5 , so where is the anomaly ?
> >
> > Thanks,
> > Abhijit
> > On Wed, Dec 29, 2010 at 2:52 PM, Alex Rozenshteyn <[email protected]>
> > wrote:
> >>
> >> I'm trying to understand the technique referred to as "tying the knot",
> >> but documentation on the internet seems to be much sparser and more
> obtuse
> >> than I like.
> >>
> >> So I'm asking here.
> >>
> >> As far as I understand, "tying the knot" refers to a way of using
> laziness
> >> to implement something like references in a purely functional way.
> >>
> >> I'm trying to write a toy simulation:
> >> I have a population :: [Person]
> >> I want to collect a random subset of possible pairs of distinct people.
> >> So I go to each person in the population and select a subset of the
> people
> >> after him/her in the list; these are pairs in which s/he is the first
> >> element.
> >>
> >> I want to then be able to ask for all pairs in which a person is the
> first
> >> or the second element. I could give each person a unique id, but it
> seems
> >> like tying the knot is a valid way to implement this.
> >>
> >> Please correct me if I am misunderstanding.
> >>
> >> Thank you.
> >>
> >> --
> >> Alex R
> >>
> >> _______________________________________________
> >> Beginners mailing list
> >> [email protected]
> >> http://www.haskell.org/mailman/listinfo/beginners
> >>
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20101229/3942deed/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 30, Issue 45
*****************************************