[clean-list] slown down by time annotation

Valéry Croizier valery at freesurf.fr
Thu Jul 14 14:51:17 MEST 2005


Hello Clean users.

I have written a few programs to taste the language, and the one below 
is about arrays.
What puzzles me is the type annotation commented out in 'showflam', 
which makes the program 3 times slower.

Can anybody explain me what's happening ?

Valery.

swap :: *{#Int} !Int !Int -> *{#Int}
swap t i j
  #! ti = t.[i]
  #! tj = t.[j]
  = {t & [i] = tj, [j] = ti}

reverslice :: !Int !Int *{#Int} -> *{#Int}
reverslice i j t
  | i < j     = reverslice (inc i) (dec j) (swap t i j)
  | otherwise = t

flam :: *{#Int} -> *{#Int}
flam t
  #! end = t.[0]
  | end == 1 = t
  | otherwise  = flam (reverslice 0 (end - 1) t)

showflam :: !Int -> [Int]
showflam n
  #! t1 = t.[1]
  #! t2 = t.[n / 2]
  #! t3 = t.[n - 1]
  = [ t1, t2, t3 ] where
//  t :: *{#Int} // slows down 3X
  t = flam {{x+1 \\ x <- [1..n]} & [n-1] = 1}



More information about the clean-list mailing list