You're being hit by filter
's laziness. Change (filter ...)
to (doall (filter ...))
in your recur
form and the problem should go away.
A more in-depth explanation:
The call to filter
returns a lazy seq, which materialises actual elements of the filtered seq as required. As written, your code stacks filter
upon filter
upon filter
..., adding one more level of filter
ing at each iteration; at some point this blows up. The solution is to force the whole result at each iteration so that the next one will do its filtering on a fully realised seq and return a fully realised seq instead of adding an extra layer of lazy seq processing; that's what doall
does.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…