Welcome to W3Courses
 Like Us on Facebook

Append

Appends Two Lists using Prolog Source Code

The following code appends two lists

CODE
append([],Y,Y).
append([X|T],Y,[X|R]) :- append(X,Y,R).

RESULT
?- append([a],[b,c],R).
R = [a, b, c]
Yes
 

Share

Append Two Lists Using Scheme Source Code

The following code appends two lists

 (define (append x y)
         (cond((null? x) y)
                (else (cons (car x) (append (cdr x) y) ))))

Share