Commit Graph

17 Commits

Author SHA1 Message Date
Julien Fischer
6495a31648 Fix a typo.
samples/README.md:
    As above.

samples/calculator.m:
    s/parser.m/mercury_term_parser.m/ in a comment.
2022-01-02 20:55:29 +11:00
Zoltan Somogyi
a653024ab7 Update many aspects of style in sample programs.
If we want to encourage people to read the sample programs
and learn Mercury programming from them, they should not be written
in an obsolete style.

samples/beer.m:
samples/calculator.m:
samples/calculator2.m:
samples/concurrency/midimon/midimon.m:
samples/diff/diff_out.m:
samples/e.m:
samples/eliza.m:
samples/muz/dict.m:
samples/muz/higher_order.m:
samples/muz/muz.m:
samples/muz/typecheck.m:
samples/muz/word.m:
samples/muz/zabstract.m:
samples/muz/zlogic.m:
samples/muz/zparser.m:
samples/muz/ztoken.m:
samples/muz/ztoken_io.m:
samples/muz/ztype.m:
samples/muz/ztype_op.m:
samples/rot13/rot13_concise.m:
samples/rot13/rot13_gustavo.m:
samples/rot13/rot13_juergen.m:
samples/rot13/rot13_ralph.m:
samples/rot13/rot13_verbose.m:
samples/solutions/all_solutions.m:
samples/solutions/n_solutions.m:
samples/solutions/one_solution.m:
samples/solutions/some_solutions.m:
samples/solver_types/eqneq.m:
samples/solver_types/sudoku.m:
samples/solver_types/test_eqneq.m:
    Replace uses of __ as module qualifier with dot.

    Replace (C->T;E) with (if C then T else E).

    Use our usual indentation for if-then-elses and for switches.

    Import one module per line. Put those imports into alphabetical order.

    Replace many uses of DCGs with state variables, leaving DCGs
    mostly just for parsing code.

    Use predmode declarations where this helps.

    Put predicates in top-down order where relevant.

    Use io.format where this helps.

    Do not put more than one predicate call on one line.

    Put each function symbol in a du type on a separate line.

    Put spaces after commas, around the bar in list syntax,
    around arithmetic operators, and around minus signs used for pairs.

    Replace tab indentation with four-space indentation.

    Delete spaces at the ends of lines.
    Replace two or more consecutive blank lines with one blank line.
    Delete blank lines that do not help structure the code.

    There are probably still some examples of old practices remaining;
    I do not claim to have fixed them all.
2021-07-07 05:32:09 +10:00
Julien Fischer
f5fdc98426 Style updates for benchmarks and samples. 2020-05-20 17:06:20 +10:00
Julien Fischer
dfce89d999 Branches: master, 13.05.
Make the calculator example handle CRLF line endings.

samples/calculator.m;
	As above.
2013-07-27 02:13:32 +10:00
Julien Fischer
a20fb1cf57 Further code and formatting cleanups. There are no changes
Branches; main, 11.01

samples/*.m:
	Further code and formatting cleanups.  There are no changes
	to any algorithms.
2011-01-10 02:29:33 +00:00
Julien Fischer
fa555e1b36 Use '.' as the module qualifier instead of '__'.
Estimatd hours taken: 0.5
Branches: main

samples/*.m:
	Use '.' as the module qualifier instead of '__'.

	Use the new foreign language interface.

	Fix minor formatting issues.

	Use state variables for passing the I/O state.
2006-03-21 00:51:03 +00:00
Zoltan Somogyi
5fb5874ba3 Fix some violations of good style in the sample programs.
Estimated hours taken: 0.3
Branches: main, release

samples/*.m:
	Fix some violations of good style in the sample programs.
2005-08-12 04:50:37 +00:00
Ian MacLarty
c3e0be6dca Bring some samples up to date with current coding standards.
Estimated hours taken: 1.0
Branches: main and 0.12

Bring some samples up to date with current coding standards.

samples/calculator.m
samples/calculator2.m
samples/cat.m
samples/e.m
samples/eliza.m
samples/expand_terms.m
samples/hello.m
samples/interpreter.m
samples/sort.m
samples/ultra_sub.m
	Bring up to date with current coding standards.
2005-02-09 08:41:13 +00:00
Tyson Dowd
e9ece03315 Fix some problems in the samples.
Estimated hours taken: 1

Fix some problems in the samples.

samples/calculator.m:
	Strip spaces from the input before using it.
	I keep forgetting that spaces aren't allowed in the input
	of this example, and I can only assume that new users get
	confused over this.

samples/c_interface/c_calls_mercury/Mmakefile:
	Use MLOBJS instead of MLLIBS for including .o files.
	Add a missing dependency.
	Remove an unnecessary dependency that MLOBJS takes care of.

samples/c_interface/mercury_calls_fortran/Mmakefile:
	Use MLOBJS instead of MLLIBS for including .o files.
	Use -lg2c instead of the old -lf2c for the fortran library.
	(libf2c no longer exists)
2000-02-03 05:13:11 +00:00
Fergus Henderson
02751f887e Add calls to `io__flush_output', so that the input and output
Estimated hours taken: 0.1

samples/calculator.m:
samples/eliza.m:
samples/interpreter.m:
	Add calls to `io__flush_output', so that the input and output
	are interleaved properly when you run the programs with output
	redirected to a pipe, e.g. "./calculator | tee logfile".
1999-11-04 03:16:52 +00:00
Fergus Henderson
c240ada1c6 Fix a bug in my previous change.
Estimated hours taken: 0.1

samples/calculator.m:
	Fix a bug in my previous change.
	Also change the program so that it prints a "calculator> " prompt.
1999-10-28 09:45:42 +00:00
Fergus Henderson
d0958be78b Improve the coding style: make `evalexpr'
Estimated hours taken: 0.25

samples/calculator.m:
	Improve the coding style: make `evalexpr'
	a function rather than a predicate.
1999-10-26 14:14:18 +00:00
Fergus Henderson
2c4bd735b4 Add comment "This source file is hereby placed in the public domain".
Estimated hours taken: 0.25

samples/*:
	Add comment "This source file is hereby placed in the public domain".
1997-09-10 11:01:12 +00:00
Fergus Henderson
b67c6e6ee1 Due to popular demand, I have finally succumbed and written a
Estimated hours taken: 0.5

samples/calculator.m:
	Due to popular demand, I have finally succumbed and written a
	"nicer" version of this.
1996-03-01 13:25:56 +00:00
Fergus Henderson
df41b9b715 Declare main/2 as cc_multi, not multi.
Estimated hours taken: 0.25

samples/calculator.m:
	Declare main/2 as cc_multi, not multi.
	Add a comment about the "1 - 2 - 3" bug.
1996-01-22 13:46:48 +00:00
Fergus Henderson
9164fa1bb6 Change main/2 from nondet' to multi'.
samples/calculator.m:
	Change main/2 from `nondet' to `multi'.
1995-07-21 18:26:36 +00:00
Fergus Henderson
7aaec23181 Add a bunch of new files.
samples/*:
	Add a bunch of new files.
	Remove lots of irrelevant stuff from the Mmake file.
	Add a comment to eliza.m.
1995-05-30 18:35:34 +00:00