**************Ruby***************
# this program generates all possible syllables
initials = %w/b ch d/
medials = %w/a i u/
finals = [''] + %w/n s/
open('syllables.txt', 'w') do |out|
initials.each do |initial|
medials.each do |medial|
finals.each do |final|
out.puts initial + medial + final
end
end
end
end
puts 'Finished. It was a pleasure to serve you.'
**************Java***************
// this program generates all possible syllables
im****t java.io.PrintWriter;
im****t java.io.IOException;
public final class Syllables {
private static final String[] initials = {"b", "ch", "d"};
private static final String[] medials = {"a", "i", "u"};
private static final String[] finals = {"", "n", "s"};
public static void main(final String[] args) throws IOException {
final PrintWriter out = new PrintWriter("syllables.txt");
for (final String anInitial : initials)
for (final String aMedial : medials)
for (final String aFinal : finals)
out.println(anInitial + aMedial + aFinal);
out.close();
System.out.println("Finished. It was a pleasure to serve you.");
}
}
--
John W. Kennedy
"Only an idiot fights a war on two fronts. Only the heir to the throne
of the kingdom of idiots would fight a war on twelve fronts"
-- J. Michael Straczynski. "Babylon 5", "Ceremonies of Light and Dark"


|