Skip to content

Instantly share code, notes, and snippets.

@JuanFdS
Created August 18, 2020 21:21
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 JuanFdS/da1524c6be5dda3f518c8a1ed243dbea to your computer and use it in GitHub Desktop.
Save JuanFdS/da1524c6be5dda3f518c8a1ed243dbea to your computer and use it in GitHub Desktop.
Código de la clase de listas de PdeP
listaDelSuper([pera, banana, manzana, naranja, banana, mandarina]).
siguienteEnListaDelSuperA(Alimento, AlimentoSiguiente):-
listaDelSuper(Alimentos),
nth1(N, Alimentos, Alimento),
nth1(Siguiente, Alimentos, AlimentoSiguiente),
Siguiente > N.
proximo(Elemento, ElementoSiguiente, Lista):-
nth1(PosicionElemento, Lista, Elemento),
nth1(PosicionElementoSiguiente, Lista, ElementoSiguiente),
PosicionElementoSiguiente is PosicionElemento + 1.
estaOrdenada(Lista):-
forall(proximo(Elemento, Siguiente, Lista),
Siguiente > Elemento).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment