Skip to content

Instantly share code, notes, and snippets.

@enlacee
Created March 13, 2018 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enlacee/9ecb8372415c00bb65c3df6225df4442 to your computer and use it in GitHub Desktop.
Save enlacee/9ecb8372415c00bb65c3df6225df4442 to your computer and use it in GitHub Desktop.
lista-enlazada.agregar.al.inicio.rb
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