Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. type BiNodo = (Int,[(Integer,(Int,Integer))])
  2.  
  3. nivelArbolBiLista :: BiNodo -> BiNodo
  4. nivelArbolBiLista (k,xs) = (k+1,concatMap g xs) where
  5. d = 2^k
  6. g (x,(n,y)) = [izq,der] where
  7. izq = (ii,(n,di))
  8. der = (id,(n+1,dd))
  9. (ii,id) = if even y then (x,x+d) else (x+d,x)
  10. di = if even y
  11. then quot y 2
  12. else quot (y + 3^n) 2
  13. dd = if odd y
  14. then quot (3*y + 1) 2
  15. else quot (3*y + 3^(n+1) + 1) 2
  16.  
  17. nivel n = secuencia !! n where
  18. secuencia = map (\ (_,xs) -> map (\ (a,(b,c)) -> (a,c)) xs) sec
  19. sec = iterate nivelArbolBiLista (2,[(3,(2,8))])
Add Comment
Please, Sign In to add comment