Skip to content

Instantly share code, notes, and snippets.

@jsoffer
Created October 18, 2010 04:32
Show Gist options
  • Save jsoffer/631714 to your computer and use it in GitHub Desktop.
Save jsoffer/631714 to your computer and use it in GitHub Desktop.
type Nodo = (Int, (Integer,Integer))
nivelArbolLista xs = concatMap g xs where
g (n, y) = [izq,der] where
izq = (n, fizq y)
der = (n+1, fder y)
fizq x = if even x
then quot x 2
else quot (x + 3^n) 2
fder x = if odd x
then quot (3*x + 1) 2
else quot (3*x + 3^(n+1) + 1) 2
arbol :: String
arbol = map (\k -> if k then '1' else '0') arbolB
arbolB :: [Bool]
arbolB = map odd arbolI
arbolI = map snd $ concat $ iterate nivelArbolLista [(2,8)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment