Re: efficiency question

2002-02-09 Thread Jorge Adriano
On Saturday 09 February 2002 11:38, Jorge Adriano wrote: If you make it strict on the (,), like:  test3 l =      let s = foldr (\x (a,b) - ((,)$!x+a)$!x-b) (1,1) l      in  s Things will get worst. Well, that's what I expected, the elements of the list will b reduced to head normal form

Re: efficiency question

2002-02-08 Thread Jorge Adriano
On Friday 08 February 2002 22:14, Hal Daume III wrote: define test1 l = let s1 = foldr (+) 1 l s2 = foldr (-) 1 l in (s1, s2) test2 l = let s = foldr (\x (a,b) - (x+a,x-b)) (1,1) l in s why is test1 so much faster than test2 for long lists l (eg

Re: efficiency question

2002-02-08 Thread Jorge Adriano
I'd say that's because in the second case you also got to apply the (,), besides the (+)/(-) constructor during the transversing... Am I right? opss... I meant to write: the (,) constructor besides the (+)/(-)... J.A. ___ Glasgow-haskell-users

Re: efficiency question

2002-02-08 Thread Jorge Adriano
On Friday 08 February 2002 22:14, you wrote: define test1 l = let s1 = foldr (+) 1 l s2 = foldr (-) 1 l in (s1, s2) test2 l = let s = foldr (\x (a,b) - (x+a,x-b)) (1,1) l in s why is test1 so much faster than test2 for long lists l (eg [1..100])?

Re: efficiency question

2002-02-08 Thread Jorge Adriano
On Friday 08 February 2002 23:52, Hal Daume III wrote: I've tried using a strict fold: foldl' f a [] = a foldl' f a (x:xs) = (foldl' f $! f a x) xs but that has no effect (or minimal effect). That wouldn't work even if if laziness is the problem because that would only cause the

Re: character syntax

2002-02-08 Thread Jorge Adriano
On Friday 08 February 2002 14:35, Ketil Z. Malde wrote: Jorge Adriano [EMAIL PROTECTED] writes: Haskell looks nice... Isabell looks beautiful :-) I'm not familiar with Isabell, but aren't we comparing apples and oranges here? E.g. you can prettify .lhs pretty nicely with one of the LaTeX

Re: efficiency question

2002-02-08 Thread Jorge Adriano
I'd say that's because in the second case you also got to apply the (,), besides the (+)/(-) constructor during the transversing... Am I right? opss... I meant to write: the (,) constructor besides the (+)/(-)... J.A. ___ Haskell-Cafe mailing list

Re: Passing values taking implicit parameters

2002-01-31 Thread Jorge Adriano
I'd like write a function taking values with implicit parameters. This may not be exactly what you're after, but .. I understand the need for implicit parameters (sometimes when my functions seem to need A LOT of parameters, the code looks really messy, and adding another parameter is a

Re: Passing values taking implicit parameters

2002-01-31 Thread Jorge Adriano
BEGIN wishlist: snip My whilist for records. 'Records' provide projection functions, but IMO that is not enough, it would be really handy to have some 'update' and 'apply field' functions provided automaticly for each field. I always find myself having to write this functions by hand for

Re: Passing values taking implicit parameters

2002-01-31 Thread Jorge Adriano
Forgot to mention that a particular case in which these functions are extremely useful, is when using implicit parameters as John Huges describes in http://www.md.chalmers.se/~rjmh/Combinators/MonadTransformers.hs opsss wrong link, correct one is: http://www.md.chalmers.se/~rjmh/Globals.ps

Re: State Transformer

2002-01-28 Thread Jorge Adriano
On Saturday 12 January 2002 07:31, Ashley Yakeley wrote: At 2002-01-11 06:18, Jorge Adriano wrote: The whole problem is with passing the 'r' as a parameter, which is precisly what I'm trying to avoid. You could always pass it implicitly (using -fglasgow-exts): Thanks, at first it seemed

Re: Random questions after a long haskell coding day

2002-01-27 Thread Jorge Adriano
On Sunday 27 January 2002 05:36, Hal Daume III wrote: For your last question (about reduction to hnf), use the attached code; search the haskell mailing list for deepseq for more. Thanks... I found myself trying to define a function deepSeq :: [a]-[a] to evaluate all the elements of the

Random questions after a long haskell coding day

2002-01-26 Thread Jorge Adriano
Am I the only one who'd like to have some the function specified by scan_and_fold f e xs= (scanl f e xs, foldl f e xs) In the Lists library. Or is it there somewhere and I missed it? What about: pair (f,g) x = (f x, g x) cross (f, g) = pair(f.fst, g.snd) I kind of like point free style.

Re: performance of monads

2002-01-24 Thread Jorge Adriano
I agree with others who mentioned that viewing monads as simply providing a way to sequentialize things or to program imperatively is the wrong way to look at them. snip Yes, Lists are the classical example. That said, the EFFICIENCY of monads is often poorly understood. To state the

Bug? Re: GHC version 5.02.2 is available - SuSE RPMs

2002-01-12 Thread Jorge Adriano
Here are SuSE RPMs (built with SuSE 7.3 but I guess they also work with earlier versions): http://www.informatik.uni-bonn.de/~ralf/ghc-5.02.2-1.i386.rpm http://www.informatik.uni-bonn.de/~ralf/ghc-prof-5.02.2-1.i386.rpm Just tried them out and something seems to be wrong... I'm running

Re: Bug? Re: GHC version 5.02.2 is available - SuSE RPMs

2002-01-12 Thread Jorge Adriano
module Main where main :: IO() main = do putStr n: n - readLn :: IO(Int) print n Used to work fine with ghc 5.00.2, that is, it would print n:, then wait for the input, and finaly print n. With Ghc 5.02.2 it only prints n: after reading the n. snip

Bug? Re: GHC version 5.02.2 is available - SuSE RPMs

2002-01-12 Thread Jorge Adriano
Here are SuSE RPMs (built with SuSE 7.3 but I guess they also work with earlier versions): http://www.informatik.uni-bonn.de/~ralf/ghc-5.02.2-1.i386.rpm http://www.informatik.uni-bonn.de/~ralf/ghc-prof-5.02.2-1.i386.rpm Just tried them out and something seems to be wrong... I'm running

Re: Bug? Re: GHC version 5.02.2 is available - SuSE RPMs

2002-01-12 Thread Jorge Adriano
module Main where main :: IO() main = do putStr n: n - readLn :: IO(Int) print n Used to work fine with ghc 5.00.2, that is, it would print n:, then wait for the input, and finaly print n. With Ghc 5.02.2 it only prints n: after reading the n. snip

Re: State Transformer

2002-01-11 Thread Jorge Adriano
If I understand you correctly, you want global mutable variables, right? This is, I believe, only possible using IORef's and unsafePerformIO. Kind of, I'm searching for the best approach to keep track of data in my algorithms without constantly changing signatures. State monad as defined in

Re: State Transformer

2002-01-11 Thread Jorge Adriano
I agree with you. My work-around is then to define foo and bar locally to testfunc, in the scope of r: testfunc = do r - newSTRef ('x',0) let foo = do (c,n) - readSTRef r writeSTRef r ('a', n+1) bar = do

Re: State Transformer

2002-01-11 Thread Jorge Adriano
[Obs: most answers I got end up in my pvt e-mail and not in the mailing list... I replyed in pvt to those. I do feel it some cases that is probably accidental as I do it all the time :), and the discussion ends leaving the mailing list. So i'd just like to let you know that I for one am in

State Transformer

2002-01-07 Thread Jorge Adriano
Hi, I'm studying, among other things, Genetic Algorithms and Neural Networks and I decided I'd use haskell to code some simple GAs and NNs along with my study. Well, maybe it was not such a good idea after all, because I've been spending way more time learning more Haskell then GAs and NNs :(

Strictness making it worst?

2001-11-29 Thread Jorge Adriano
Hi, I've just started messing around with strictness. My goal now is understanding when and how to use it. I began with simple examples like making a strict foldl. When trying to sum a list of 6 elements with lazy foldl I'd get a stack space overflow, with a strict foldl I was able to sum

Re: Strictness making it worst?

2001-11-29 Thread Jorge Adriano
Then I tried: sfibac :: IntPos - (IntPos,IntPos) - (IntPos,IntPos) sfibac n (a,b) | n == 0= (a,b) | otherwise = sfibac (n-1) (b, (+b) $! a) I'm sorry I meant: sfibac :: IntPos - (IntPos,IntPos) -

Re: Counting recursive calls

2001-11-13 Thread Jorge Adriano
The functions: f [] w = (w,0) f (x:xs) w = (nextw, steps+1) where (nextw, steps) = f xs (g x w) f2 [] k w = (w,k) f2 (x:xs) k w = f2 xs (k+1) (g x w) f3 [] w = w f3 (x:xs) w = f3 xs (g x w) Oh oh ---

Counting recursive calls

2001-11-11 Thread Jorge Adriano
Hi all, got some questions on recursive functions. I got a simple recursive function (f3) In *some* situations I'll want to know how many recursive calls did it make. I came up with two simple implementations to do that (f1) and (f2) f [] w = (w,0) f (x:xs) w = (nextw, steps+1)

Using the std libraries in Ghc(i)

2001-11-04 Thread Jorge Adriano
How can I use the std functions (listed in the 'Standard Libraries for Haskell 98' documentation) in ghc(i)? I've read the ghc documentation, and seen the several categories (which can be added with '-package category_name') available, but I still don't know how to access functions like

SuSE 7.3

2001-10-09 Thread Jorge Adriano
Está para sair a 22 de Outubro... até eu estou a ficar surpreendido com a evolução destes tipos. Qd penso do 1o Linux que instalei (à cerca de dois anos? - andava eu no 4o ano) sinto-me como aquelas velhas que dizem eu ainda sou do tempo..., err... em que tinha de andar a alterar XF86Config à

Opsss... Sorry (SuSE 7.3)

2001-10-09 Thread Jorge Adriano
I just accidently sent a mail written in portuguese about SuSE 7.3. I'm really sorry, it will not happen again. My apologies J.A. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

broken link

2001-10-05 Thread Jorge Adriano
Just thought I'd report that the PolyGP link: http://www.cs.ucl.ac.uk/staff/T.Yu/research.html at the 'Haskell in Practice' section (http://www.haskell.org/practice.html) seems to be broken. J.A. ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Re: 0-based versus 1-based

2001-09-27 Thread Jorge Adriano
On Thursday 27 September 2001 23:16, Tom Pledger wrote: Just as a matter of idle curiosity, is there a particular reason for tuples starting at element 1 (fst) whereas lists start at element 0? fst ('x', 'y') -- 'x' xy !! 1 -- 'y' xs = [1,2,3,4] If I were to ask you which one

Haskell - C/C++ comunication (sockets/pipes?)

2001-09-25 Thread Jorge Adriano
Hi all, I was thinking about making some GUIs in Qt/KDE for some haskell applications (compiled with ghc). My first idea was to simply run haskell applications with some args using the GUI and get the results from some file or something like that. Anyway someone told me that a better idea

<    1   2