Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:prolog:pllib:flatten_4 [2019/06/27 15:50]
pl:prolog:pllib:flatten_4 [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== Flatten 4 ======
 +{{tag>​lists operators}}
 +===== Description =====
 +Flattening a list of lists using difference-lists
 +
 +**Source**: ​ The Art of Prolog
 +===== Download =====
 +Program source code: {{flatten_4.pl}}
 +===== Listing =====
 +<code prolog>
 +/*
 +   ​flatten(Xs,​Ys) :-
 + Ys is a flattened list containing the elements in Xs.
 +*/
 + :- op(40,​xfx,​\).
 +
 + flatten(Xs,​Ys) :- flatten_dl(Xs,​Ys\[]).
 +
 + flatten_dl([X|Xs],​Ys\Zs) :-
 +    ​flatten_dl(X,​Ys\Ys1),​ flatten_dl(Xs,​Ys1\Zs).
 + flatten_dl(X,​[X|Xs]\Xs) :-
 +    ​constant(X),​ X \== [].
 + flatten_dl([],​Xs\Xs).
 +
 +% Program 15.2 : Flattening a list of lists using difference-lists
 +</​code>​
 +===== Comments =====
  
pl/prolog/pllib/flatten_4.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0