Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
List intro
%simple lists %swi-prolog 7.2.3 % A list is a collection of things in between [ ] % eg. [apples, oranges, grapes, pears ] % or [1,2,3,4] % Let's define some numbers of interest to me mynumbers([1,2,3,4]). % To see these numbers remove the % below % and run it to see how we set up variable X % ?- mynumbers(X), write('X is '), write(X), nl. % to add up some numbers we split a list into % a head H and tail T like this [H|T] % try this just remove the % and run it % ?- mynumbers([H|T]), write('H is '), write(H), nl, write('T is '), write(T), nl. % using this way to split a list into a head and tail % we can add up the numbers in a list sumlist([],0). sumlist([H|T],N) :- sumlist(T,N1), N is N1+H. % as before just remove the % and run it to try it ?- mynumbers(X), sumlist(X, Total), write('X is '), write(X), nl, write('Total is '), write(Total),nl.
run
|
edit
|
history
|
help
0
tarea por punto extra
MARTINEZ LOPEZ SAID - ARBOL
inicio del clasificador de objetos json
clase 2
Codificacion y despliegue de redes bayesianas-Guerrero Hernandez Angel
Act 1
is_sort
inteligencia de negocios: completa los parámetros, separa con comas
Luis Fernando Jiménez De Jesús_Ejercicio2_IngenieriaDeConocimiento_Examen
Tarea SQL Query Red Bayesiana Arredondo Amaro Carlos Jair