Predicate: group_by/4

Back to the example instead of talking about the meta of examples.

While I do agree that this is a much simpler example, for a new user who would want to just cut and paste the example to understand it, when they go to cut and paste in the data that should be in the Prolog database they will be confronted with

?- data(a,1).
data(b,2).
data(b,3).
data(a,4).ERROR: Unknown procedure: data/2 (DWIM could not correct goal)
?- ERROR: Unknown procedure: data/2 (DWIM could not correct goal)
?- ERROR: Unknown procedure: data/2 (DWIM could not correct goal)
?- 

To avoid the error was the reason I put the data into a list, but I do know that that is not the normal way to use the predicate.

Eariler version of example which has now been revised.

?- List=[(a,1), (b,2), (b,3), (a,4)],group_by(A,B, member((A,B),List), Bag).
List = [(a, 1),  (b, 2),  (b, 3),  (a, 4)],
A = a,
Bag = [1, 4] ;
List = [(a, 1),  (b, 2),  (b, 3),  (a, 4)],
A = b,
Bag = [2, 3].

So far examples needing data in the Prolog database, what should be done?

Should we note that examples are aimed at a user with a level of understanding that a person who has completed a single semester of a university course would have, should we aim for a level that they have at least completed the exercises from Learn Prolog Now!, should examples using the Prolog database include a link on how to get the data into the Prolog database?

I know, let’s wait and see. :slightly_smiling_face:

I am starting to think I need to start collecting these questions into a separate post so that as was we address them we can cross them off the list.