% This is a comment function permutate(sequence) % yield here, equals returning from next() in Java code is sequence empty? yield the empty sequence for i = 0 then i + 1 while i < sequence.length % sequence.subsequence(int start, int stop) % assumed to return the subsequence that goes from element start (inclusive) to stop (exclusive) % sequence.subsequence(int start) % assumed to return the subsequence that starts in index start and ends at the end of the sequence n = sequence.subsequence(i, i + 1) % This gives us one element in a sequence for every subsequence m in permutate(sequence.subsequence(0, i).concatenate(sequence.subsequence(i + 1)) yield n.concatenate(m) stopIteration() % This equals setting the value of the next hasNext() call to false