/* Array concatenation in Picat. From Rosetta Code: http://rosettacode.org/wiki/Array_concatenation """ Show how to concatenate two arrays in your language. If this is as simple as array1 + array2, so be it. """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ % import util. % import cp. main => go. go => L1 = [1,2,3,4,5], L2 = [6,7,8,9], % The tradtional concatenation writeln(L1 ++ L2), % Using built-in append append(L1,L2,L3), writeln(L3), % User defined append append2(L1,L2,L4), writeln(L4), nl. append2(Xs,Ys,Zs) ?=> Xs=[], Ys=Zs. append2(Xs,Ys,Zs) => Xs=[X|XsR], Zs=[X|Zss], append2(XsR,Ys,Zss).