[Haskell-cafe] iterative algorithms: how to do it in Haskell?

2006-08-16 Thread Tamas K Papp
Hi, I am a newbie learning Haskell. I have used languages with functional features before (R, Scheme) but not purely functional ones without side-effects. Most of the programming I do is numerical (I am an economist). I would like to know how to implement the iterative algorithm below in

[Haskell-cafe] Int-[Char] conversion

2006-08-16 Thread Tamas K Papp
Hi, I am working through Hal Daume's tutorial, trying to do the exercises. I can't figure out how to output an integer with putStrLn (or any other way), I think I need an Int - [Char] conversion but couldn't find it. Specifically, in Exercise 3.10, I have the product of numbers in pp, and would

Re: [Haskell-cafe] iterative algorithms: how to do it in Haskell?

2006-08-17 Thread Tamas K Papp
On Thu, Aug 17, 2006 at 01:23:19AM -0400, [EMAIL PROTECTED] wrote: G'day all. Quoting Chris Kuklewicz [EMAIL PROTECTED]: The compiler may not deforest that list, so creating the list may be a small overhead of this method. And in return, you get: - Code that is smaller than the

Re: [Haskell-cafe] Haskell wiki: most popular pages

2006-08-17 Thread Tamas K Papp
On Thu, Aug 17, 2006 at 01:55:47AM +0400, Bulat Ziganshin wrote: Hello haskell-cafe, The http://haskell.org/haskellwiki/Special:Popularpages page lists most popular pages on haskell wiki. I think this list is very useful because it shows us what are the questions about Haskell people most

[Haskell-cafe] map (-2) [1..5]

2006-08-17 Thread Tamas K Papp
The code in the subject generates an error. I understand why this is (- is treated as part of the number), but I don't know how to solve it, ie how to tell Haskell that - is a function/binary operator? Thanks, Tamas ___ Haskell-Cafe mailing list

[Haskell-cafe] how to generate XHTML 1.1?

2006-08-18 Thread Tamas K Papp
Hi, I would like to use Haskell to generate static HTML webpages, preferably using XHTML 1.1. How can I do this? I found libraries to generate XHTML 1.0 transitional, but not 1.1. Scheme has LAML [1], which parses the DTD, uses S-expressions and validates the XHTML, I am looking for something

Re: [Haskell-cafe] Haskell wiki: most popular pages

2006-08-19 Thread Tamas K Papp
On Fri, Aug 18, 2006 at 04:46:14PM +0400, Bulat Ziganshin wrote: Hello Tim, Friday, August 18, 2006, 4:26:46 PM, you wrote: break p = span (not . p) it's definitely better and = foldr () True i think that definitions with omitted arguments can be more hrd to understand to newbie

[Haskell-cafe] implementing a csv reader

2006-08-22 Thread Tamas K Papp
Hi, Now that I have read the tutorials, I think that the best way to learn Haskell would be to use the language and write something simple yet useful. I noticed that Haskell lacks a module for reading/writing csv (comma separated value) files, so I thought I could implement that. Questions: 1.

Re: [Haskell-cafe] implementing a csv reader

2006-08-22 Thread Tamas K Papp
On Tue, Aug 22, 2006 at 11:26:45AM +0200, Henning Thielemann wrote: See also http://www.xoltar.org/languages/haskell.html http://www.xoltar.org/languages/haskell/CSV.hs Thanks. Haskell is incredibly neat ;-) Now I need to find something else for practice. Is there anything

[Haskell-cafe] data structures question

2006-08-30 Thread Tamas K Papp
Hi, Having read some tutorials, I would like to start using Haskell for real, but I have some questions about data structures. The mathematical description of the problem is the following: assume there is a function V(a,b,theta), where a and b can have two values, High or Low, and theta is a

Re: [Haskell-cafe] Re: data structures question

2006-09-01 Thread Tamas K Papp
On Thu, Aug 31, 2006 at 11:09:07AM +0400, Bulat Ziganshin wrote: Hello Benjamin, Wednesday, August 30, 2006, 11:40:09 PM, you wrote: Matthias Fischmann wrote: The trick is that Int is not the only index data type, but tuples of index data types are, too. Do this: | type Point =

[Haskell-cafe] getContents and lazy evaluation

2006-09-01 Thread Tamas K Papp
Hi, I am newbie, reading the Gentle Introduction. Chapter 7 (Input/Output) says Pragmatically, it may seem that getContents must immediately read an entire file or channel, resulting in poor space and time performance under certain conditions. However, this is not the case. The key

[Haskell-cafe] practice problems?

2006-09-03 Thread Tamas K Papp
Hi, I am a Haskell newbie. Having read some tutorials (Yet Another, Gentle Introduction) and some papers/tutorials on monads, I would like to spend some time practicing what I have learned before embarking on more abstract/obscure things and/or using Haskell for everyday tasks. I am looking for

Re: [Haskell-cafe] practice problems?

2006-09-03 Thread Tamas K Papp
On Sun, Sep 03, 2006 at 12:47:45PM +0400, Bulat Ziganshin wrote: Hello Tamas, Sunday, September 3, 2006, 12:15:48 PM, you wrote: I am looking for small to medium sized practice problems, preferably with solutions. Hal Daume's tutorial had some good one-liners (eg rewrite something

[Haskell-cafe] how do you debug programs?

2006-09-06 Thread Tamas K Papp
Hi, I would like to learn a reasonable way (ie how others do it) to debug programs in Haskell. Is it possible to see what's going on when a function is evaluated? Eg in f a b = let c = a+b d = a*b in c+d evaluating f 1 2 would output something like f called with values

Re: [Haskell-cafe] Re: how do you debug programs?

2006-09-06 Thread Tamas K Papp
On Wed, Sep 06, 2006 at 06:33:32AM -0400, Lennart Augustsson wrote: I've also used Visual Studio, and I wouldn't mind having something like that for Haskell. But I have to agree with Jon, I think the best way of debugging is to understand your code. I think people who come from

[Haskell-cafe] does the compiler optimize repeated calls?

2006-09-06 Thread Tamas K Papp
Hi, I have a question about coding and compilers. Suppose that a function is invoked with the same parameters inside another function declaration, eg -- this example does nothing particularly meaningless g a b c = let something1 = f a b something2 = externalsomething (f a b) 42

Re: [Haskell-cafe] how do you debug programs?

2006-09-07 Thread Tamas K Papp
On Wed, Sep 06, 2006 at 11:34:05AM +0200, Pepe Iborra wrote: Hi Tamas There are several ways to debug a Haskell program. The most advanced ones are based in offline analysis of traces, I think Hat [1] is the most up-to-date tool for this. There is a Windows port of Hat at [5]. Another

Re: [Haskell-cafe] map (-2) [1..5]

2006-09-08 Thread Tamas K Papp
Hi Brian and others, I posted the original question because I didn't know how to get map (-2) working. Since the original posting, many people have presented _a priori_ arguments about the merits of different approaches, most importantly whether or not to abandon the unary - operator. As a

[Haskell-cafe] smallest double eps

2006-09-29 Thread Tamas K Papp
Hi, Is there a built-in constant in Haskell (or, if it is compiler-specific, in ghc) that gives the smallest positive floating point number x such that 1+x /= x? Some languages refer to that as double.eps or similar. I need it for numeric algorithms. Thanks, Tamas

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Tamas K Papp
On Sat, Sep 30, 2006 at 12:20:16AM +, Joachim Breitner wrote: Hi, Am Freitag, den 29.09.2006, 19:30 -0400 schrieb Tamas K Papp: the smallest positive floating point number x such that 1+x /= x? That would be the smallest positive number, woudn't it? Do you mean the smalles postive

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Tamas K Papp
On Fri, Sep 29, 2006 at 09:26:27PM -0400, Lennart Augustsson wrote: As for using such an eps in a convergence test I'd be very careful. How do you know that your iteration doesn't make the value bounce back and forth with more than eps? Hi Lennart, Thanks for the answer, I will try it.

Re: [Haskell-cafe] Is Haskell a 5GL?

2006-09-29 Thread Tamas K Papp
On Mon, Sep 25, 2006 at 03:27:32PM +0200, Henning Thielemann wrote: Hi Henning, Actually, laziness allows me to formulate algorithms that look more like the specification of the problem than the solution. E.g., I can formulate the solution of a differential equation in terms of a power series

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Tamas K Papp
On Fri, Sep 29, 2006 at 06:53:35PM -0700, Chad Scherrer wrote: Tamas, You might want to read Joachim's post more carefully - he's trying to help you, and I think he makes a good point. Chad, If his point is that there is no smallest positive number, then I think I understand it, thanks. I

Re: [Haskell-cafe] smallest double eps

2006-09-30 Thread Tamas K Papp
On Sat, Sep 30, 2006 at 04:19:50AM -0400, Lennart Augustsson wrote: Hang on, hang on, now I'm getting confused. First you asked for the smallest (positive) x such that 1+x /= x which is around x=4.5e15. Then Joachim wondered if you wanted 1+x /= 1 which is around x=2.2e-16. Oops,

[Haskell-cafe] question - which monad to use?

2006-10-01 Thread Tamas K Papp
Hi, I have a computation where a function is always applied to the previous result. However, this function may not return a value (it involves finding a root numerically, and there may be no zero on the interval). The whole problem has a parameter c0, and the function is also parametrized by

Re: [Haskell-cafe] question - which monad to use?

2006-10-02 Thread Tamas K Papp
, 2006 at 06:00:43PM -0400, Tamas K Papp wrote: To: Haskell Cafe haskell-cafe@haskell.org From: Tamas K Papp [EMAIL PROTECTED] Date: Sun, 1 Oct 2006 18:00:43 -0400 Subject: [Haskell-cafe] question - which monad to use? Hi, I have a computation where a function is always applied

Re: [Haskell-cafe] question - which monad to use?

2006-10-02 Thread Tamas K Papp
On Mon, Oct 02, 2006 at 11:35:40AM -0400, Tamas K Papp wrote: Matthias, Sorry if I was not clear in stating the problem. Your solution works nicely, but I would like to try writing a monad. This is what I came up with: type Failure = String data Computation a = Computation (Either

[Haskell-cafe] cumulative sum

2006-10-02 Thread Tamas K Papp
Hi, I have two lists, p and lambda (both are finite). I would like to calculate 1) the cumulative sum of lambda, ie if lambda = [lambda1,lambda2,lambda3,...] then csum lambda = [lambda1,lambda1+lambda2,lambda1+lambda2+lambda3,...] 2) the cumulative sum of p*lambda (multiplication

Re: [Haskell-cafe] Yet Another Haskell Tutorial Question

2006-10-11 Thread Tamas K Papp
On Wed, Oct 11, 2006 at 09:16:57PM -0400, Bill Mill wrote: I've been working through the Yet Anther Haskell Tutorial at http://www.cs.utah.edu/~hal/docs/daume02yaht.pdf , and I've gotten up to Excercise 4.6. It says: Have you checked the solution? Page 167. Tamas

[Haskell-cafe] searching haskell.org

2006-10-15 Thread Tamas K Papp
Hi, I noticed that searching on Haskell.org (using the Search feature at the bottom) doesn't work as I expected. For example, searching for memoise produces no results. http://www.google.com/search?q=memoise+site%3Ahaskell.org produces 18 hits. Is this intentional? Thanks, Tamas

Re: [Haskell-cafe] Debugging Newton's method for square roots

2006-10-15 Thread Tamas K Papp
On Sun, Oct 15, 2006 at 12:17:20PM +, Vraj Mohan wrote: I am new to Haskell and need help in debugging my code. I wrote the following function for calculating square roots using Newton's method: my_sqrt :: Float - Float my_sqrt x = improve 1 x where improve y x = if abs (y

Re: [Haskell-cafe] searching haskell.org

2006-10-15 Thread Tamas K Papp
On Sun, Oct 15, 2006 at 03:41:53PM +0100, Neil Mitchell wrote: Hi I noticed that searching on Haskell.org (using the Search feature at the bottom) doesn't work as I expected. For example, searching for memoise produces no results. This is searching haskellwiki. Does anyone have the