[Haskell-cafe] whats with cabal and libgmp.so.3

2013-05-14 Thread Rustom Mody
Today cabal suddenly started giving me errors that libgmp.so.3 is not found Moving away my old .cabal makes it work again Any explanations? [I am on debian testing. I think the causing factor was that debian switched major versions recently. There were a lot of updates... Nothing that looked like

Re: [Haskell-cafe] whats with cabal and libgmp.so.3

2013-05-14 Thread Tobias Dammers
On Tue, May 14, 2013 at 01:16:44PM +0530, Rustom Mody wrote: > Today cabal suddenly started giving me errors that libgmp.so.3 is not found > Moving away my old .cabal makes it work again > > Any explanations? > > [I am on debian testing. I think the causing factor was that debian > switched major

[Haskell-cafe] Trouble with Debug.Trace when using a library

2013-05-14 Thread hanjoosten
My project is split in two packages, A and B, where B uses A. All together, there are about 100 haskell modules. Currently, there seems to be a loop somewere, that only seems to occur when working with rather large datastructures. I use trace (from Debug.Trace) to see what exactly is going on. As

[Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread John
Hi, I have to write a function which returns a list of all pairs (x,y) where x, y ∈ N AND: – x is the product of two natural numbers (x = a · b, where a, b ∈ N) AND – x is really bigger than 5 but really smaller than 500, AND – y is a squer number (y = c² where c ∈ N) NOT greater than 1000, AND

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Alejandro Serrano Mena
For a first sight, you cannot use x <- [0..]*[0..] to mean 'all possible pairs x = a*b'. You would need to do something like [ (a*b, y) | a <- [0..], b <- [0..], a*b > 5, a*b < 500, and the rest of things ] 2013/5/14 John > Hi, > > I have to write a function which returns a list of all pairs (x

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Danny Gratzer
You can't write [1..] * [1..] Since Haskell's lists aren't Nums Instead you'd want to write something like a<-[1..], b<-[1..], and then multiply them together manually. But this still doesn't really work since it'll loop forever without finding any solutions. Haskell's list comprehensions

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread John
thanks to both! listPairs = [(a*b, y) | a <- [0..], b <- [0..], (a*b) > 5, (a*b) < 500, (y*y) < 1001, mod y x == 0] Now I have it as you said, however the compiler complains about all y and x and says they are NOT in scope. Why is it so? I can't see any problem with that... -- View this mess

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Danny Gratzer
Well you've deleted the portion of the code referring to x and y. listPairs = [(a*b, y) | y <- [0..], a <- [0..], b <- [0..], (a*b) > 5, (a*b) < 500, (y*y) < 1001, mod y (a*b) == 0] This will still never terminate however. On Tue, May 14, 2013 at 10:17 AM, John wrote: > thanks to both! > > li

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Brandon Allbery
On Tue, May 14, 2013 at 11:17 AM, John wrote: > listPairs = [(a*b, y) | a <- [0..], b <- [0..], (a*b) > 5, (a*b) < 500, > (y*y) < 1001, mod y x == 0] > > Now I have it as you said, however the compiler complains about all y and x > and says they are NOT in scope. > > Why is it so? I can't see any

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Daniel Díaz Casanueva
You can always write it like this: listPairs = [ (x,y) | x <- [6 .. 499] , y <- [0 .. 1000] , isProduct x , isSqrt y , mod y x == 0 ] So you have the bounds for x and y, and then the conditions. You then need to define isProduct and isSqrt with types isProduct :: Int -> Bool isSqrt :: Int -> Bo

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Daniel Díaz Casanueva
Well, definitely, isSqrt should be called isSquare. On Tue, May 14, 2013 at 5:22 PM, Daniel Díaz Casanueva < dhelta.d...@gmail.com> wrote: > You can always write it like this: > > listPairs = [ (x,y) | x <- [6 .. 499] , y <- [0 .. 1000] , isProduct x , > isSqrt y , mod y x == 0 ] > > So you hav

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Danny Gratzer
Isn't the product check actually redundant? re-reading the requirements we could just define a = 1 and b = x. Maybe I'm misunderstanding though. On Tue, May 14, 2013 at 10:24 AM, Daniel Díaz Casanueva < dhelta.d...@gmail.com> wrote: > Well, definitely, isSqrt should be called isSquare. > > > On

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread John
Danny Gratzer wrote > Well you've deleted the portion of the code referring to x and y. > > listPairs = [(a*b, y) | y <- [0..], a <- [0..], b <- [0..], (a*b) > 5, > (a*b) < 500, (y*y) < 1001, mod y (a*b) == 0] > > This will still never terminate however. oh I see, but as you say it doesn't termi

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread John
Danny Gratzer wrote > Isn't the product check actually redundant? re-reading the requirements we > could just define a = 1 and b = x. Maybe I'm misunderstanding though. I'm not sure. As I understand the requirement, the squer of y should not be greater than 1000. But anyway, without this conditio

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Danny Gratzer
> 1. Does the order of conditions affect the result at all? > Conditions, I don't believe so, the ordering/placement of bindings though can effect the results a great deal. When I say bindings, I mean something that involves a <- > 2. The "," means AND or &&, right? So how do you write OR || in

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread John
is'nt it possible, to write it in one line without any nested functions in WHERE? If it's possible I'd prefer that... any idea? Thanks -- View this message in context: http://haskell.1045720.n5.nabble.com/list-comprehension-doesn-t-work-tp5730158p5730170.html Sent from the Haskell - Haskell-C

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Mateusz Kowalczyk
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 14/05/13 16:59, John wrote: > is'nt it possible, to write it in one line without any nested > functions in WHERE? If it's possible I'd prefer that... > > any idea? > > Thanks > > > > -- View this message in context: > http://haskell.1045720.n5.

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread John
thanks for your tips. As I said, I'm at the very beginning of Haskell. I try it to understand as much as I can, however the topic is very new to me. Sorry about my silly questions... You said, their is a mailing list for beginner? Could you please tell me I get to that? Thanks -- View this me

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Mateusz Kowalczyk
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 14/05/13 17:53, John wrote: > thanks for your tips. > > As I said, I'm at the very beginning of Haskell. I try it to > understand as much as I can, however the topic is very new to me. > Sorry about my silly questions... > > You said, their is a m

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Jerzy Karczmarczuk
MATEUSZ, There is nothing wrong with sending beginner questions to h-café! After all, a FRIENDLY community is for whom? For Simon PJ only? Notice that "John" got more than a dozen answers, people TRY to help him anyway. == On the other hand, the original requester *should* have thought on: 1

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Daniel Díaz Casanueva
Hi John, On Tue, May 14, 2013 at 5:41 PM, John wrote: > Danny Gratzer wrote > > Well you've deleted the portion of the code referring to x and y. > > > > listPairs = [(a*b, y) | y <- [0..], a <- [0..], b <- [0..], (a*b) > 5, > > (a*b) < 500, (y*y) < 1001, mod y (a*b) == 0] > > > > This will sti

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Mark Lentczner
module Stuff where import Data.List -- Let's translate your specification directly into a list comprehension s1 :: [(Integer, Integer)] s1 = [(x,y) | x <- [1..]-- for this problem, better to have 0 ∉ N , let a = 1 -- if 1 ∈ N, , let b = x -- then by

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Mateusz Kowalczyk
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 14/05/13 18:18, Jerzy Karczmarczuk wrote: > MATEUSZ, > > There is nothing wrong with sending beginner questions to h-café! > After all, a FRIENDLY community is for whom? For Simon PJ only? > > Notice that "John" got more than a dozen answers, peo

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Richard A. O'Keefe
On 15/05/2013, at 2:57 AM, John wrote: > Hi, > > I have to write a function which returns a list of all pairs (x,y) where x, > y ∈ N AND: > – x is the product of two natural numbers (x = a · b, where a, b ∈ N) AND > – x is really bigger than 5 but really smaller than 500, AND > – y is a squer

Re: [Haskell-cafe] list comprehension doesn't work

2013-05-14 Thread Daniel Trstenjak
Hi Mateusz, > I don't think my post was out of order at all and I don't understand > why it sparked such an... energetic response - that wasn't my intent > at all. A friendly response might contain the things you told John, but it could also be a bit more empathic, otherwise its easy to perceive