Example Discussion - Predicate: group_by/4

This is just a sample topic to demonstrate an example discussion for the related group_by/4 example.

The topic Predicate: group_by/4 holds the examples and this topic is to discuss the examples.

The code for the example was copied from Group_by/4 examples and I might just remove the topic from the Category Useful Code if leaving it in the Example category works better.

I know some to many will disagree with the use of test cases in the example; I have to agree as I think a new user will just be confused by looking for a simple example and then be confounded by the burden of trying to understand test cases. So by putting this out there in the test cases, it brings the point to the level of a discussion.

Should examples be demonstrated as test cases?

Should examples first be given as simple examples and then be followed by a series of test cases?

I quite strongly disagree with examples as tests. Simply use e.g. this below. Way easier to read for all uf us and for beginners even more so. We can create test cases out of this should we want to do so later.

?- member(X, [a,b]).
X = a ;
X = b.

Except for the use as test cases as discussed in Example Discussion - Predicate: group_by/4, I think examples should also minimize the amount of data. This set is rather big, which requires a lot of reading to figure out what it is doing. The relation to bagof/3 should IMO be at the end or (probably better) absent and in a separate example topic that compares similar aggregation options. Also comments about the examples should not be in code comment. Examples are a markdown document.

Notably the primary example (as files, in a file named after the example) should be short and only highlight a typical query on each sufficiently different mode.

Changed in example.

Removed all the examples but one.

Examples with comments were also removed.