I agree that (in this context, beginning learning Haskell) it is a
somewhat minor issue. But I disagree that this is something you should
ignore until it becomes a problem and I do think that it should be part
of learning Haskell. Properly using strictness is an important part of
using
That's a very good point. Yes, let's have some detailed explanations
accompanied by some good examples.
Cheers, Paul
At 08:43 03/12/2007, you wrote:
I agree that (in this context, beginning learning Haskell) it is a
somewhat minor issue. But I disagree that this is something you should
Hello PR,
Monday, December 3, 2007, 8:20:35 AM, you wrote:
occurs m (Node l n r) = m == n || occurs m l || occurs m r
in terms of style, i can prefer
occurs m (Node l n r) = or [m==n, occurs m l, occurs m r]
--
Best regards,
Bulatmailto:[EMAIL PROTECTED]
Johan Tibell [EMAIL PROTECTED] writes:
It would be great if someone could exemplify these rules of thumb,
e.g. Primitive types such as Int should be strict unless in the three
canonical examples X, Y and Z. My strictness radar is still quite
poor and I feel I can't make informed decisions on
On Mon, 2007-12-03 at 10:48 +0100, Ketil Malde wrote:
Johan Tibell [EMAIL PROTECTED] writes:
It would be great if someone could exemplify these rules of thumb,
e.g. Primitive types such as Int should be strict unless in the three
canonical examples X, Y and Z. My strictness radar is still
Johan Tibell wrote:
It would be great if someone could exemplify these rules of thumb,
e.g. Primitive types such as Int should be strict unless in the three
canonical examples X, Y and Z. My strictness radar is still quite
poor and I feel I can't make informed decisions on when I need to make
G'day all.
On Mon, 2007-12-03 at 10:48 +0100, Ketil Malde wrote:
I find that I often need to add strictness when:
left thumb) parsing [Char] into something more compact, i.e. almost
all cases.
right thumb) storing data into maps, especially when the values
are produced by
On Dec 3, 2007 9:23 PM, [EMAIL PROTECTED] wrote:
2. If it's logically a Functor, strictness will break the axioms,
so don't do that.
What do you mean by breaking the axioms? If I define
data List a = Nil | Cons !a !(List a)
instance Functor List where
fmap f Nil = Nil
fmap f (Cons x
Hi
data Tree = Leaf Int | Node Tree Int Tree
occurs :: Int - Tree - Bool
occurs m (Leaf n) = m == n
occurs m (Node l n r) = m == n || occurs m l || occurs m r
It works but I'd like to know if it can be improved in any way.
Thanks, Paul
___
prstanley:
Hi
data Tree = Leaf Int | Node Tree Int Tree
occurs :: Int - Tree - Bool
occurs m (Leaf n) = m == n
occurs m (Node l n r) = m == n || occurs m l || occurs m r
It works but I'd like to know if it can be improved in any way.
You could probably get away with:
data Tree =
On 12/2/07, Don Stewart [EMAIL PROTECTED] wrote:
prstanley:
Hi
data Tree = Leaf Int | Node Tree Int Tree
occurs :: Int - Tree - Bool
occurs m (Leaf n) = m == n
occurs m (Node l n r) = m == n || occurs m l || occurs m r
It works but I'd like to know if it can be improved in any
catamorphism:
On 12/2/07, Don Stewart [EMAIL PROTECTED] wrote:
prstanley:
Hi
data Tree = Leaf Int | Node Tree Int Tree
occurs :: Int - Tree - Bool
occurs m (Leaf n) = m == n
occurs m (Node l n r) = m == n || occurs m l || occurs m r
It works but I'd like to know if it
Fully lazy:
data Tree = Leaf Int | Node Tree Int Tree
$ time ./A 25
49
./A 25 18.20s user 0.04s system 99% cpu 18.257 total
^^
3556K heap use.
Strict in the elements, lazy in the spine:
data Tree
On Mon, Dec 03, 2007 at 05:20:35AM +, PR Stanley wrote:
Hi
data Tree = Leaf Int | Node Tree Int Tree
occurs :: Int - Tree - Bool
occurs m (Leaf n) = m == n
occurs m (Node l n r) = m == n || occurs m l || occurs m r
It works but I'd like to know if it can be improved in any way.
dons:
* Full strictness == teh suckness.
* Mixed lazy and strict == flexible and efficient data types.
Makes me wonder why Map is strict in the spine,
data Map k a = Tip
| Bin {-# UNPACK #-} !Size !k a !(Map k a) !(Map k a)
Spencer points out that
On Sun, 2007-12-02 at 21:54 -0800, Don Stewart wrote:
catamorphism:
On 12/2/07, Don Stewart [EMAIL PROTECTED] wrote:
prstanley:
Hi
data Tree = Leaf Int | Node Tree Int Tree
occurs :: Int - Tree - Bool
occurs m (Leaf n) = m == n
occurs m (Node l n r) = m == n || occurs
16 matches
Mail list logo