I have a program where I have two arrays throughout. They begin empty but through the program they get populated.
If this is my first function:
program():-
populate_arrays([],[]),
carry_on().
In order to pass my populated arrays into carry_on() must I have four parameters in populate_arrays()? Two to declare the arrays as empty upon starting and another two to pass into carry_on()?
So like:
program():-
populate_arrays([],[],A,B),
carry_on(A,B).
it seems awkward I have to double my parameters
Yes, this is what you do. And no, it is not awkward because these are not duplicates: the first pair is your input arguments, and the second pair is your output results.
This is a common use pattern, corresponding to state transformation: old in, new out. The state of your knowledge is changed by this predicate,
populate_arrays. This is reflected in how you use it.BTW, if the starting values are always
[], you can provide a “wrapper” for your “working” predicate: