Re: Position of arguments in function definition and performance

2002-02-07 Thread José Romildo Malaquias
The programs: -- common part module Main where reverse1 [] ys = ys reverse1 (x:xs) ys = reverse1 xs (x:ys) reverse2 ys [] = ys reverse2 ys (x:xs) = reverse2 (x:ys) xs -- program t1 main = print (length $! reverse1 [1..200] [])

Re: Position of arguments in function definition and performance

2002-02-06 Thread Hal Daume III
Actually, presumably you meant: > reverse2 ys (x:xs) = reverse2 (x:ys) xs (stupid cut & paste late at night). with this fix (and now we actually are reversing the list with reverse2), we get the following timings for reverse2: 11:49pm enescu:~/ time a.out 200 4.64u 0.31s 0:05.18 95.5% 11:49

Re: Position of arguments in function definition and performance

2002-02-06 Thread Hal Daume III
Well, I assume you meant: reverse1 [] ys = ys reverse1 (x:xs) ys = reverse1 xs (x:ys) reverse2 ys [] = ys reverse2 ys (x:xs) = reverse1 (x:ys) xs If so, and you make two programs: main = print (length $! reverse1 [1..200] []) and main = print (length $! reverse2 [] [1..200]) compile

Position of arguments in function definition and performance

2002-02-06 Thread José Romildo Malaquias
Hello. Please, tell me which set of definitions below should I expected to be more efficient: the reverse1 or the reverse2 functions. reverse1 [] ys = ys reverse1 (x:xs) ys = reverse2 (x:ys) xs reverse2 ys [] = ys reverse2 ys (x:xs) = reverse2 (x:ys) xs The difference rely on the posit