Added another implementation of the same algorithm in agonas2.sml