root/trunk/examples/benchmarks/module.pl

Revision 4601, 509 bytes (checked in by pmoura, 7 weeks ago)

Added svn:mime-type property to source files (set to text/x-logtalk).

  • Property svn:mime-type set to text/x-logtalk
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2% you may need to update the module directive that follows for
3% compatibility with your Prolog compiler module system
4
5:- module(module, [mod_length/2]).
6
7
8mod_length(List, Length) :-
9    (   integer(Length) ->
10        Length >= 0,
11        mod_make_list(Length, List)
12    ;   mod_length(List, 0, Length)
13    ).
14
15
16mod_make_list(0, []):-
17    !.
18
19mod_make_list(N, [_| Tail]):-
20    M is N-1,
21    mod_make_list(M, Tail).
22
23
24mod_length([], Length, Length).
25
26mod_length([_| Tail], Acc, Length) :-
27    Acc2 is Acc + 1,
28    mod_length(Tail, Acc2, Length).
Note: See TracBrowser for help on using the browser.