出遅れたけど Common Lisp で、

(defun pyths (f n)
(loop for x from 1 to n
append (loop for y from 1 to n
append (loop for z from 1 to n
if (funcall f x y z)
collect (list x y z)))))

ネットで拾ったマクロを使えば

(defun pyths (f n)
(collect-list (list x y z)
(for x from 1 to n)
(for y from 1 to n)
(for z from 1 to n)
(funcall f x y z)))

となるけど、こんなのライブラリ使えばどの言語でもどうとでもなりそう。