1. Challenge.
--=====================_909587363==_
Hello,
While helping Andy Montgomery to add some stuff to his contribution math.e
I ran across a number of algorithms to list all:
p-q partitions of n
combinations of k out of n (with and without repetition)
permutations of n (all elements different as well as not all
elements necessarily different)
For each set there are two possibilities:
- a program that generates them all in a row and then processes each
new permutation in some way.
- a procedure which generates the next one when called from a program.
The algorithms for most of these cases are quite simple and straightforward
when it comes to programming them except the case of permutations of n where
not all elements are necessarily different.
The attached ZIP-file, if somebody would be so kind to look at it, contains
4 files:
PRMW.BAS - the program that lists all permutations in qbasic
PRMW.EX - the similar program in Euphoria
PRMPROC.EX- the program which contains the procedure mentioned above
TRACE.TXT - a trace of PRMW.EX using the locations which correspond
to the labels in PRMW.BAS
The programs all work, but I may assume that many of you may consider them
to contain ugly code (as I'm not a professional programmer I am not overly
concerned about it as long as it does the job). In Euphoria it is even more
difficult to follow what happens than in QBASIC. This is the reason I
added the file TRACE.TXT.
If somebody has a more elegant way to do this, please let me know.
Another question is about the procedure. In order to include it in an .e-file
for general use one has to add a few formal parameters which have to be
called by name (or call by reference). Euphoria, if I understand it
correctly, only supports call by value. Is there any solution, for instance
using a function instead of a procedure and how?
Thanks for your trouble
Alex van Baaren
avanb at arnprior.com
--=====================_909587363==_
x-mac-type="705A4950"; x-mac-creator="705A4950"