-- http docs google com View docID dc89n5kb_3gjtp5cz8 otherwise -- n-1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
-- http://docs.google.com/View?docID=dc89n5kb_3gjtp5cz8
r = 0.5
u 0 x
| x <= 0 = 1
| otherwise = 0
-- u n x = (1 + r) * (u (n-1) x) - r * (u (n-1) (x+1)) -- unstable
u n x = (1 - r) * (u (n-1) x) + r * (u (n-1) (x-1))
m = [-5..15]
levels = [0..10]
main = putStr process
where
lists = map (\n -> map (u n) m) levels
process = foldl (\acc i -> acc ++ process_ i ++ "\n") [] (take (length m) [0..])
where
process_ i = (show $ m !! i) ++ " " ++ foldl (\acc x -> acc ++ x ++ " ") [] (map (\l -> (show $ l !! i)) lists)