1/*  Part of Ciao Prolog compatibility library
    2
    3    Author:        Jan Wielemaker, Edison Mera
    4    E-mail:        J.Wielemaker@uva.nl, efmera@gmail.com
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (C): 2010, University of Amsterdam and
    7                   2013, Process Design Center, Breda, The Netherlands.
    8
    9    This program is free software; you can redistribute it and/or
   10    modify it under the terms of the GNU General Public License
   11    as published by the Free Software Foundation; either version 2
   12    of the License, or (at your option) any later version.
   13
   14    This program is distributed in the hope that it will be useful,
   15    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17    GNU General Public License for more details.
   18
   19    You should have received a copy of the GNU General Public
   20    License along with this library; if not, write to the Free Software
   21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
   22
   23    As a special exception, if you link this library with other files,
   24    compiled with a Free Software compiler, to produce an executable, this
   25    library does not by itself cause the resulting executable to be covered
   26    by the GNU General Public License. This exception does not however
   27    invalidate any other reasons why the executable file might be covered by
   28    the GNU General Public License.
   29*/
   30
   31:- module(ciao_lists,
   32	  [ nth/3,			% ?Index, ?List, ?Element
   33	    list_insert/2,		% -List, +Term
   34	    sublist/2			% ?List1, +List2
   35	  ]).   36:- reexport('../../lists').   37:- reexport('../../lists', [subtract/3 as difference]).
 nth(?Index, ?List, ?Element) is nondet
True if Element is the N-th element in List. Counting starts at 1.
deprecated
- use nth1/3.
   46nth(Index, List, Element) :-
   47	nth1(Index, List, Element).
 list_insert(-List, +Term)
Adds Term to the end of List if there is no element in List identical to Term.
   54list_insert(List, Term) :-
   55        var(List), !,
   56        List=[Term|_].
   57list_insert([Term0|_], Term) :-
   58        Term0==Term, !.
   59list_insert([_|List], Term) :-
   60        list_insert(List, Term).
 sublist(?List1, +List2)
List2 contains all the elements of List1.
   66sublist([], _).
   67sublist([Element|Residue], List) :-
   68	member(Element, List),
   69	sublist(Residue, List)