Integers set

Description

Generating a list of integers in a given range.

Source: The Art of Prolog

Download

Program source code: integers_set.pl

Listing

/*
   range(M,N,Ns) :- Ns is the list of integers between M and N inclusive.
*/
     range(M,N,[M|Ns]) :- M < N, M1 is M+1, range(M1,N,Ns).
     range(N,N,[N]).
 
%  Program 8.12   Generating a list of integers in a given range

Comments

pl/prolog/pllib/integers_set.txt · ostatnio zmienione: 2017/07/17 08:08 (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