Just a hint, but with Project Euler there's a chance you're headed in a
difficult direction if you're working with the decimal parts directly.
Usually (always?) you can approach the problem in a way that won't depend on
something like decimal precision that can be different across
systems/languages
Hi Ata,
You could write the following
decimalPart :: Float -> Integer
decimalPart f = read (tail (tail (show (f :: Integer
This basically says "convert f into a String using the show function, and then
get the tail of that String twice to get rid of the leading zero and the
decimal point
On Wed, 2011-08-03 at 02:06 +0300, Ata Jafari wrote:
> In the first step I want to write a little code that can give me only
> the decimal part of a float. For instance:
properFraction from the RealFrac type class will divide into the real
and fractional parts. Once you've got the fractional pa
Hi everyone,
I'm totally new to Haskell and functional programming. I try to solve
some problems from Proejct Euler with Haskell so that I can improve
myself in functional programming.
In the first step I want to write a little code that can give me only
the decimal part of a float. For inst
hi, all
testB :: (ArrowChoice t1, Num a1, Num a) => (a -> a1 -> t2) -> t1 a t3
-> t1 a1 t3 -> t1 (a, a1) t
testB f g h = proc (x,y) -> do
if (f x y)then g -< x + 1 else h -< y + 2
it's very strange that the type of _f_ is (a->a1->t2) which I thought
should be a -> a1 -> Bool,
btw, is there any wa
Hi! I usually use the function 'sized' for this. The function would look
something like this:
myIntGen :: Gen Int
myIntGen = sized $ \n -> choose (0,f n)
where 'f' is a function that uses the size value to generate an upper value
for your random range. I usually use ^2 or sqrt or something like t
On Tue, Aug 2, 2011 at 5:57 AM, Patrick Browne wrote:
> data Eq a => Set1 a = NilSet1 | ConsSet1 a (Set1 a)
> data Set2 a = NilSet2 | ConsSet2 a (Set2 a) deriving Eq
>
The former declaration is a language wart, IMO. All it does is attach a
restriction to the constructors of Set1; try
>
On Tue, 2 Aug 2011, Patrick Browne wrote:
What is the difference between using a class context and deriving in
data type declaration?
Are there certain situations in which one or the other is preferred?
data Eq a => Set1 a = NilSet1 | ConsSet1 a (Set1 a)
Note that these contexts might get re
Hi Patrick,
On 2 August 2011 13:57, Patrick Browne wrote:
> What is the difference between using a class context and deriving in
> data type declaration?
A class context simply says something about the types involved in the
construction. In your example,
> data Eq a => Set1 a = NilSet1 | ConsSe
What is the difference between using a class context and deriving in
data type declaration?
Are there certain situations in which one or the other is preferred?
data Eq a => Set1 a = NilSet1 | ConsSet1 a (Set1 a)
data Set2 a = NilSet2 | ConsSet2 a (Set2 a) deriving Eq
(NilSet1) == (NilSet
Am 01.08.2011 17:51, schrieb Alex Clemmer:
Hi Haskell people,
I've been snooping through various mailing lists and the current Haskell
implementation of regular expressions and I was wondering if there has
been a discussion about implementing regex parsing with derivatives. If
so, I haven't seen
11 matches
Mail list logo