Created
March 13, 2018 03:19
-
-
Save enlacee/9ecb8372415c00bb65c3df6225df4442 to your computer and use it in GitHub Desktop.
lista-enlazada.agregar.al.inicio.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def printt() | |
a = [nil, 3, nil] | |
b = [nil, 5, nil] | |
c = [nil, 10, nil] | |
nuevo = [nil, 50, nil] # crear un nodo nuevo | |
a[2] = b | |
b[0] = a | |
b[2] = c | |
c[0] = b | |
## add | |
inicio = a | |
if inicio == nil | |
# inicio = nuevo | |
else | |
nuevo[2] = inicio | |
inicio[0] = nuevo | |
inicio = nuevo | |
end | |
print a | |
end | |
printt(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment