イメージとしては
flat(x) = (if (list?(first x)) then flat(first x) else (first x))::(tail x)
のような感じの記述で出来ない?