Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type BiNodo = (Int,[(Integer,(Int,Integer))])
- nivelArbolBiLista :: BiNodo -> BiNodo
- nivelArbolBiLista (k,xs) = (k+1,concatMap g xs) where
- d = 2^k
- g (x,(n,y)) = [izq,der] where
- izq = (ii,(n,di))
- der = (id,(n+1,dd))
- (ii,id) = if even y then (x,x+d) else (x+d,x)
- di = if even y
- then quot y 2
- else quot (y + 3^n) 2
- dd = if odd y
- then quot (3*y + 1) 2
- else quot (3*y + 3^(n+1) + 1) 2
- nivel n = secuencia !! n where
- secuencia = map (\ (_,xs) -> map (\ (a,(b,c)) -> (a,c)) xs) sec
- sec = iterate nivelArbolBiLista (2,[(3,(2,8))])
Add Comment
Please, Sign In to add comment