RE: [Haskell-cafe] strictness and the simple continued fraction

2004-10-12 Thread Simon Peyton-Jones
If you are interested in arbitrary precision arithmetic using continued fractions, you may want to check out the work of David Lester. And Peter Potts et al. Just type "exact real arithmetic" into Google. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On

Re: [Haskell-cafe] strictness and the simple continued fraction

2004-10-12 Thread William Lee Irwin III
On Tue, Oct 12, 2004 at 08:48:27AM +0100, Simon Peyton-Jones wrote: > If you are interested in arbitrary precision arithmetic using continued > fractions, you may want to check out the work of David Lester. And > Peter Potts et al. Just type "exact real arithmetic" into Google. That's where I go

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-12 Thread MR K P SCHUPKE
One to add to your list, string edit distance - as its hard, and useful. Keean. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] List implementation.

2004-10-12 Thread MR K P SCHUPKE
With reference to the discussion a couple of days ago about list implementations, here is some code showing the idea I was talking about... Its a list that you can write either single elements or blocks (UArrays) to, but it always reads like a list of elements, so blocks can be read in, but you ca

Re: [Haskell-cafe] List implementation.

2004-10-12 Thread Ronny Wichers Schreur
Keean writes (in the Haskell cafe): [..] data AList a = One !a (AList a) | Many !Int !(UArray Int a) (AList a) | Nil [..] head (Many i a _) = a!i [..] a ++: l = Many 0 a l You probably want to test in the definition of (++:) that the array a is not of length 0. Cheers, Ronny

Re: [Haskell-cafe] List implementation.

2004-10-12 Thread MR K P SCHUPKE
Hows this: ... tail (Many i a l) | i < (e-s) = (Many (i+1) a l) | otherwise = l where (s,e) = bounds a ... a ++: l | e >= s = Many s a l | otherwise = l where (s,e) = bounds a A futher though is that with constructors you can do: f (a:as) =

Re: [Haskell-cafe] List implementation.

2004-10-12 Thread MR K P SCHUPKE
>class List l where > head :: IArray UArray a => l a -> Maybe a > tail :: IArray UArray a => l a -> Maybe (l a) changed my mind about this... you cannot do: tail $ tail $ tail x so added a 'null' test instead. ___ Haskell-Cafe mailing list [EMAIL PRO

[Haskell-cafe] Strict evaluation not working?

2004-10-12 Thread Christian Hofer
Hi, having found a bit of time to play with Haskell, I am trying to figure out how to enforce strict evaluation. I wrote the following program: main = let x = zipWith (+) [5..] [6..] in putStrLn $ show $ x `seq` head x I expected this program not to terminate - because of the seq-

Re: Language extension idea (was Re: [Haskell-cafe] Re: OCaml list sees...)

2004-10-12 Thread Jon Fairbairn
On 2004-10-10 at 11:20BST Malcolm Wallace wrote: > As an example, instead of the following list-only code, > > f :: List a -> ... > f []= ... > f (h:t) = ... > > you could write this more general version, which assumes only some > class Sequence with operations null, head, tail, e

Re: [Haskell-cafe] Strict evaluation not working?

2004-10-12 Thread Jon Fairbairn
On 2004-10-12 at 18:07+0200 Christian Hofer wrote: > Hi, > > having found a bit of time to play with Haskell, I am trying to figure > out how to enforce strict evaluation. > I wrote the following program: > > main = > let x = zipWith (+) [5..] [6..] > in putStrLn $ show $ x `seq` hea

Re: [Haskell-cafe] Strict evaluation not working?

2004-10-12 Thread Keith Wansbrough
> main = > let x = zipWith (+) [5..] [6..] > in putStrLn $ show $ x `seq` head x > > I expected this program not to terminate - because of the seq-Operator, > but it happily returns 11 in ghc as well as in ghci. What do I make > wrong? "seq" forces its argument to "Weak Head Normal

Re: [Haskell-cafe] Strict evaluation not working?

2004-10-12 Thread Christian Hofer
Am 12.10.2004 um 18:20 schrieb Keith Wansbrough: But if you are just learning Haskell, you almost certainly don't need to do this. Just make use of the laziness, and learn to love it! Thank you for your replies. You are right: I don't need it. It's just that I am currently studying the book Algor

[Haskell-cafe] Re: Tutorial about low-level I/O in Haskell

2004-10-12 Thread Peter Simons
Ferenc Wagner writes: > Pretty neat. Wouldn't it be a nice addition to the > Tutorials section on the Haskell Bookshelf? Thank you. I certainly wouldn't mind having a link from haskell.org to it. Neither would I mind having a link to the BlockIO library itself, but in the past I couldn't seem t

[Haskell-cafe] One-way and two-way monads.

2004-10-12 Thread Kwanghoon Choi
Dear All, List and IO are both monads when appropriate operations are defined. The IO monad, which is a one-way monad, does not have a function of type IO a -> a, in general, except an unsafe function "unsafePerformIO :: IO a -> a". A two-way monad, such as List, has such a function "head ::

[Haskell-cafe] OO idioms redux

2004-10-12 Thread John Goerzen
OK, recently I posed a question about rethinking some OO idioms, and that spawned some useful discussion. I now have a followup question. One of the best features of OO programming is that of inheritance. It can be used to slightly alter the behavior of objects without requiring modification to

Re: [Haskell-cafe] OO idioms redux

2004-10-12 Thread Ben Rudiak-Gould
On Tue, 12 Oct 2004, John Goerzen wrote: > One of the best features of OO programming is that of inheritance. It > can be used to slightly alter the behavior of objects without requiring > modification to existing code or breaking compatibility with existing > APIs. I hesitate to express a contr

Re: [Haskell-cafe] strictness and the simple continued fraction

2004-10-12 Thread Dylan Thurston
On Mon, Oct 11, 2004 at 09:53:16PM -0400, Scott Turner wrote: > Evenutally I realized that calculating with lazy lists is not as > smooth as you might expect. For example, the square root of 2 has a > simple representation as a lazy continued fraction, but if you > multiply the square root of 2 by