Electrolytic or electrophoretic processes for the production of compounds or non-metals; apparatus therefor