mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 10:53:40 +00:00
extras/curs/curs.m:
extras/curs/curs.panel.m:
Make panel a separate submodule of curs, not a nested submodule.
extras/base64/base64.m:
extras/curses/mcurses.basics.m:
extras/curses/mcurses.m:
extras/curses/mcurses.misc.m:
extras/curses/mcurses.user.m:
extras/gator/evolve.m:
extras/gator/genotype.m:
extras/gator/phenotype.m:
extras/gator/tausworthe3.m:
extras/monte/dots.m:
extras/monte/geom.m:
extras/monte/hg.m:
extras/monte/monte.m:
extras/monte/rnd.m:
extras/moose/grammar.m:
extras/moose/moose.m:
extras/mopenssl/mopenssl.m:
extras/net/echo.m:
extras/net/errno.m:
extras/net/getaddrinfo.m:
extras/net/net.m:
extras/net/netdb.m:
extras/net/sockets.m:
extras/net/streams.m:
extras/net/tcp.m:
extras/net/test_lookups.m:
extras/net/types.m:
extras/odbc/odbc.m:
extras/odbc/odbc_test.m:
extras/references/README:
extras/references/reference.m:
extras/references/scoped_update.m:
extras/solver_types/library/any.m:
extras/solver_types/library/any_array.m:
extras/solver_types/library/any_assoc_list.m:
extras/solver_types/library/any_list.m:
extras/solver_types/library/any_map.m:
extras/solver_types/library/any_tree234.m:
extras/solver_types/library/any_util.m:
extras/trail/trail.m:
extras/trailed_update/samples/interpreter.m:
extras/trailed_update/samples/vqueens.m:
extras/trailed_update/tests/var_test.m:
extras/trailed_update/tr_array.m:
extras/trailed_update/tr_store.m:
extras/trailed_update/trailed_update.m:
extras/trailed_update/unsafe.m:
extras/trailed_update/var.m:
Bring programming style up to date.
53 lines
1.7 KiB
Mathematica
53 lines
1.7 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 1994-2000 The University of Melbourne.
|
|
% This file may only be copied under the terms of the GNU General
|
|
% Public License - see the file COPYING in the Mercury Distribution.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% File: misc.m
|
|
% Main author: conway
|
|
%
|
|
% Provides miscellaneous functionality required by user.m and basics.m
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module mcurses.misc.
|
|
:- interface.
|
|
|
|
:- import_module array.
|
|
:- import_module int.
|
|
|
|
% for(Accumulator, Max, Closure, StoreIn, StoreOut)
|
|
% perform an operation much like a `for loop' in imperative languages. For
|
|
% every value of Accumulator =< Max, call Closure with the current value of
|
|
% Accumulator.
|
|
%
|
|
% Example:
|
|
%
|
|
% main -->
|
|
% for(0, 5, (pred(Num::in, di, uo) is det -->
|
|
% io.print(Num)
|
|
% )).
|
|
%
|
|
% Would print "012345".
|
|
:- pred for(int, int, pred(int, T, T), T, T).
|
|
:- mode for(in, in, pred(in, in, out) is det, in, out) is det.
|
|
:- mode for(in, in, pred(in, in, out) is semidet, in, out) is semidet.
|
|
:- mode for(in, in, pred(in, di, uo) is det, di, uo) is det.
|
|
:- mode for(in, in, pred(in, array_di, array_uo) is det,
|
|
array_di, array_uo) is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
for(Min, Max, Pred, Acc0, Acc) :-
|
|
( if Min =< Max then
|
|
Pred(Min, Acc0, Acc1),
|
|
for(Min + 1, Max, Pred, Acc1, Acc)
|
|
else
|
|
Acc = Acc0
|
|
).
|