Commit Graph

65 Commits

Author SHA1 Message Date
Zoltan Somogyi
6909674f14 Bring these modules up to date with our current style guidelines.
Estimated hours taken: 8
Branches: main

library/*.m:
	Bring these modules up to date with our current style guidelines.
	Use predmode declarations where appropriate. Use state variable syntax
	where appropriate. Reorder arguments where this makes it possible to
	to use state variable syntax. Standardize format of predicate
	description comments. Standardize indentation.
2004-03-15 23:49:36 +00:00
Zoltan Somogyi
ee2218ae46 Bring these modules up to date with our current style guidelines.
Estimated hours taken: 10
Branches: main

library/*.m:
	Bring these modules up to date with our current style guidelines.
	Use predmode declarations where appropriate. Use state variable syntax
	where appropriate. Reorder arguments where this makes it possible to
	to use state variable syntax.

library/io.m:
	Export some predicates that are duplicated in term_io.m and/or
	parser.m, and give them more expressive names.

library/parser.m:
library/term_io.m:
	Delete the now unnecessary copies of those predicates in these modules.
2004-03-15 06:50:18 +00:00
Julien Fischer
db4217666a Fix a typo in a comment in integer.m.
library/integer.m:
	s/mode/mod/.
2004-01-20 01:01:56 +00:00
Julien Fischer
0b2aee5bd1 More code cleanups for the integer module.
Estimated hours taken: 1
Branches: main

More code cleanups for the integer module.  This does not change
any algorithms.

library/integer.m:
	Use distinct variable names. e.g X and Y rather than X1 and X2

	Fix indentation so it adheres more closely to what is specified
	in the coding standards.

	While converting a list of digits to string call error/1 if something
	goes wrong rather than appending "Woops" to the string.

	Replace calls to int__to_float/2 with calls to float__float/1.

	Fix an incorrect reference in an error message.
2004-01-05 12:40:25 +00:00
Julien Fischer
90d2b4f1d2 Add some functions to the integer and rational modules.
Estimated hours taken: 1.5
Branches: main

Add some functions to the integer and rational modules.

Clean up the code in these modules so it adheres more closely to
our current coding standards.

NEWS:
	Mention these changes.

library/integer.m:
	Shift the constant functions integer.zero/0 and integer.one/0
	back into the interface.  According to the log they were deleted
	because they were not sufficiently useful.  In my view they
	the symbolic names are preferable to writing them as integer(1)
	and integer(0).

	Add a function version of integer.pow/3.

	Shift a large comment that concerns implementation details and
	possible improvements to the module from the interface into the
	implementation.
	(This avoids it being included in the library reference manual).

	Various code cleanups, in particular fix spacing and
	indentation throughout.

library/rational.m:
	Add function rational/1 that converts an int to a rational and
	function from_integer/1 that does the same with an integer.

	For consistency with the above add a function from_integers/2 and
	deprecate the version rational_from_integers/2.

	Remove the functions izero and ione from the implementation and
	just call integer.zero/0 and integer.one/0 now that they are
	exported from the integer module again.

	Various code cleanups.
2003-12-18 07:48:19 +00:00
Fergus Henderson
78a61c514c Delete some unused procedures warned about by --warn-dead-procs.
Estimated hours taken: 1.75
Branches: main

Delete some unused procedures warned about by --warn-dead-procs.

library/eqvclass.m:
library/integer.m:
library/io.m:
library/list.m:
library/relation.m:
library/string.m:
library/term.m:
	Delete the following procedures:
		eqvclass.find_partition/3
		integer.int_max/0
		io.buffer_to_string/3
		list.qsort/3
		list.partition/4
		relation.tsort_2/6
		relation.tsort_3/6
		string.to_int_list/2,
		string.int_list_to_char_list/2,
		string.char_list_to_int_list
		term.require_equal/2
		term.contains_functor/3
		term.subterm/2

library/exception.m:
library/set_bbbtree.m:
library/tree234.m:
	Comment out unused modes of
		exception.wrap_success_or_failure/2
		exception.call_goal/2
		exception.call_handler/2
	Comment out unused di/uo modes of
		set_bbbtree.build_node/4
		set_bbbtree.{single,double}_rot_{l,r}/4
		tree234.insert2/4
		tree234.insert3/4
2003-08-17 13:30:13 +00:00
Simon Taylor
d325ed1f4c These modules were unintentionally licensed under the
Estimated hours taken: 0.2
Branches: main, release

library/mer_std.m:
library/rational.m:
library/integer.m:
	These modules were unintentionally licensed under the
	GPL rather than the LGPL.
2002-08-29 10:09:07 +00:00
Simon Taylor
b96ff7a174 Remove functions int:^/2' and integer:^/2', since
Estimated hours taken: 0.1

library/int.m:
library/integer.m:
	Remove functions `int:^/2' and `integer:^/2', since
	the operator `^' is now used for record syntax.

compiler/code_util.m:
	Remove `int:^/2' from the list of builtins.

NEWS:
	Document record syntax and the removal of the above functions.
2000-01-16 04:34:37 +00:00
Simon Taylor
3b00a6e94c Replace integer:^/2' with integer__xor/2' because
Estimated hours taken: 0.1

NEWS:
library/integer.m:
	Replace `integer:^/2' with `integer__xor/2' because
	`^' will be used for record syntax.
1999-12-01 02:54:06 +00:00
Mark Brown
f59b67cdf9 Use `int__xor' instead of the now obsolete '^'.
Estimated hours taken: 0.1

library/integer.m:
	Use `int__xor' instead of the now obsolete '^'.
1999-11-04 04:41:07 +00:00
Fergus Henderson
1b8834f807 Incorporate Dan Hazel's rewrite of library/integer.m into the standard
Estimated hours taken: 2
	(+ unknown time from Dan Hazel)

Incorporate Dan Hazel's rewrite of library/integer.m into the standard
library, with the following changes:
	- I added determinism declarations for a couple of functions,
	  so that it compiles with `--no-infer-all'.
	- I deleted the functions `integer__zero', `integer__one', ...,
	  `integer__ten' and `integer__intmax' from the interface,
	  since I don't think they are sufficiently useful.
	- I changed the messages in the calls to error/1 to be
	  a bit more consistent

The log message below is Dan Hazel's original description of his
changes revised a little by me.

library/integer.m:
	integer.m was a bit sleepy to be of effective use so I've butchered
	it.  Sincere apologies to author aet (I'm not sure who you are.)
	I've followed some of the suggested "Possible improvements:" in the
	preface and rewritten all of the code using a different data
	structure.

	i)   Previously stored as a "sign" and list of integers of base 10000
	     ordered least significant to most.
	     My problems with this are:
		It doesn't sort into an intuitive order using mercury's compare
		(for solutions output for example).
		It makes div/mod too slow.
		The benefits -- simpler algorithms for `+' `*' -- are not cost
		benefits (which I think should be the priority in a library)
		as aet is walking the full list to normalise anyway.
	     ** Now stored as a "sign" which also stores the list length and
		a list of all +ve or all -ve digits of base 2^14 ordered most
		significant to least.
		The conversion to base 10 string is more complex of course.
		It's no longer quite arbitrary precision - something like
		    (2^14)^maxint

	ii)  Normalisation was being done as a separate pass and too often.
	     This was the most expensive part if I remember.
	     ** Almost all normalisation is now done on the fly (you're down
		there anyway).

	iii) The new data structure reduces comparison to mercury term
	     comparison which seems much faster.

	iv)  I've added
		 /\ \/ << >> ^ \

	v)   I've added:
	       :- func integer__float(integer) = float.
	     which will clumsily overflow I imagine (fix if you care); and
	       :- func integer__int(integer) = int.
	     which checks for overflow and calls error/1 in that case.

	vi)  Normalising can now be done using machine arithmetic.

	vii) There's a new pow algorithm which works by shifting the exponent.

	viii)
	     The procedure/function names should be recognisable but
	     much of the code is completely rewritten.  Sorry if it's
	     clumsy and ugly.
1999-11-04 02:39:17 +00:00
Fergus Henderson
ce403ce9d5 Fix a bug in the definition of `big_plus': it wasn't handling the
Estimated hours taken: 0.5

library/integer.m:
	Fix a bug in the definition of `big_plus': it wasn't handling the
	cases where the sign was zero correctly.   I added some additional
	code to handle those cases.

	Also a few cosmetic changes to make the layout more consistent.
1999-09-02 17:08:20 +00:00
Fergus Henderson
65782f9925 Add functions for the single output det predicates in a number
Estimated hours taken: 5

[This change was by Ralph Becket.
I'm just the person who reviewed it and committed it.  -fjh.]

Add functions for the single output det predicates in a number
of modules in the standard library.  Basically, for each

	:- pred f(in, ..., in, out) is det.

I have added the declaration

	:- func f(in, ..., in) = out.

and definition

	f(X1, ..., Xn) = Y :-
		f(X1, ..., Xn, Y).

library/char.m:
library/dir.m:
library/map.m:
library/string.m:
library/list.m:
library/set.m:
	Make the changes described above.

library/array.m:
	As above, except array input modes are all array_ui or
	array_di as appropriate and array output modes are array_uo.

library/int.m:
	Added forward versions of +/2, */2 and -/2 as plus/2, times/2
	and minus/2 respectively, to make it easier to pass these
	as arguments to higher-order predicates.
	Also added func constants for max_int, min_int and bits_per_int.

library/integer.m:
	Replaced local functions for list head, tail and length with
	calls to equivalent functions now defined in list.m.

library/io.m:
	Added func for error_message/2.

library/list.m:
	Add functions det_head/1 and det_tail/1 which abort on null lists.

library/set.m:
	Add functions map/2, filter_map/2 and fold/3.

library/std_util.m:
	Added utility function to construct a pair object from its
	arguments and general purpose higher order functions for
	partial functions and for function composition, exponentiation
	and exchanging the arguments of a binary function.
1999-07-07 15:19:42 +00:00
Bert Thompson
e1c06160e5 <overview or general description of changes>
Estimated hours taken: _____

<overview or general description of changes>

<directory>/<file>:
	<detailed description of changes>
1998-04-16 12:13:42 +00:00
Bert Thompson
33662abbb8 Implementation of an arbitrary precision integer type and
Estimated hours taken: 13

library/integer.m:
	Implementation of an arbitrary precision integer type and
	operations on it.
library/rational.m:
	Implementation of arbitrary precision rational numbers.
library/library.m:
	Necessary changes for adding the above two modules.
NEWS:
	Noted the addition of the above two modules.
1998-04-15 06:50:14 +00:00