4sum

One more from Programming Praxis, this time we’re dealing with summing combinations of a sequence. More formally, given a secquence S, either choose four elements s_1
through s_4
from S such that s_1 + s_2 + s_3 + s_4 = 0
or verify that it isn’t possible. This immediately makes me about working through possible solutions until we find one and then bailing out, ergo call/cc:

I think that this may have been the first time that I legitimately used call/cc without being told to do so and I have to admit… I’m a convert. It’s kind of powerful. (Even if I’m not using a fraction of what I’m capable of.)

Alternatively, we can write a more Rackety solution, using for*/first
to loop over the values and return the first matching case: