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 - Arreglos JSON - Guzmán Martínez Ricardo Alejandro
SECOND LAB
2 - Codificador Empresa JSON Completo galletas corregido
json con objetos y arreglos recursivos
Ejercicio atributos
PRODUCTIVAS
Tarea 4NM70 HCHCHP.2
Clasificador con If's anidados- Guerrero Hernandez Angel
Tarea 2
Ge