Prolog and Scala exercises