Files
mercury/browser/util.m
Bert Thompson eee1996975 Add a simple term browser for use by the trace-based debugger.
Estimated hours taken: 40

Add a simple term browser for use by the trace-based debugger.

This is minimal but useful browser. Not included in this version
are a scripting language, Windows Explorer-style tree expansion,
and other features not yet thought of.

N.B. This still needs to be hooked into the debugger.

browser/Mmakefile:
	Added target browse_test.

browser/browser_library.m:
	Added modules required for the browser.

browser/browse_test.m:
	A simple driver for the browser with an example
	data structure to browse. (new file)

browser/browse.m:
	The browser proper. (new file)

browser/parse.m:
	Parser for browser's command language. (new file)

browser/util.m:
	Miscellaneous utilities used in the browser code. (new file)

browser/frame.m:
	Bare minimal ASCII graphics frames. (new file)
1998-10-25 07:16:41 +00:00

46 lines
1.3 KiB
Mathematica

%---------------------------------------------------------------------------%
% Copyright (C) 1998 The University of Melbourne.
% This file may only be copied under the terms of the GNU Library General
% Public License - see the file COPYING.LIB in the Mercury distribution.
%---------------------------------------------------------------------------%
:- module util.
:- interface.
:- import_module list.
:- pred util__zip_with(pred(T1, T2, T3), list(T1), list(T2), list(T3)).
:- mode util__zip_with(pred(in, in, out) is det, in, in, out) is det.
% Apply predicate to argument repeatedly until the result
% remains the same.
:- pred util__limit(pred(list(T), list(T)), list(T), list(T)).
:- mode util__limit(pred(in,out) is det, in, out) is det.
%---------------------------------------------------------------------------%
:- implementation.
:- import_module list, int, require.
util__zip_with(Pred, XXs, YYs, Zipped) :-
( (XXs = [], YYs = []) ->
Zipped = []
; (XXs = [X|Xs], YYs = [Y|Ys]) ->
Pred(X,Y,PXY),
Zipped = [PXY|Rest],
util__zip_with(Pred, Xs, Ys, Rest)
;
error("zip_with: list arguments are of unequal length")
).
util__limit(Pred, Xs, Ys) :-
Pred(Xs, Zs),
( Xs = Zs ->
Ys = Zs
;
util__limit(Pred, Zs, Ys)
).
%---------------------------------------------------------------------------%