library/array2d.m:
Add lookup and unsafe_lookup, in both function and predicate forms,
as alternatives to rafe's ^elem notation.
Use meaningful variable names in both code and documentation.
For example, use NumRows and NumColumns instead of M and N.
Replace the implementation of the function that converts a 2d array
back to lists. The new implementation has one loop over rows and one
loop over columns, while the old one had a single loop that did
both jobs. The new one returns [] (meaning no rows) for a 0x0 array,
while the old returned [[]] (meaning one row with no columns).
NEWS:
Announce the changes.
tests/hard_coded/test_array2d.m:
Use a lookup instead of ^elem.
tests/hard_coded/test_array2d.exp:
Expect the updated output from lists. Expect any exceptions to come
from lookup functions, not ^elem functions (since the latter now
just call the former).
Also, throw software_error/1 exceptions rather than directly throwing strings
in a few spots.
Undo special Ralph-style formatting.
library/*.:
As above.
tests/hard_coded/array2d_from_array.exp:
tests/hard_coded/array2d.exp:
tests/hard_coded/test_injection.exp:
Update to conform with the above change.
library/io.m:
Add predicates io.write_array/[56] which are are similar to
io.write_list but work on arrays and do _not_ require converting
the array into a list first.
library/array2d.m:
Add array2d.is_empty/1.
NEWS:
Announce the above additions.
tests/hard_coded/Mmakefile:
tests/hard_coded/write_array.{m,exp}:
Add a test for write_array.
tests/hard_coded/test_array2d.{m,exp}:
Extend this test to cover is_empty/1.
Estimated hours taken: 4
Branches: main
Added a new library module, array2d.m, implementing 2d rectangular arrays.
NEWS:
Report the new addition.
library/array2d.m:
Added.
library/library.m:
Added import for array2d.
compiler/modules.m:
Added clause for array2d to mercury_std_library_module/1.
tests/hard_coded/test_array2d.m:
tests/hard_coded/test_array2d.exp:
tests/hard_coded/Mmakefile:
Test case added.