This is different. They are combining streams in the original article. (‘Start with the stream of integers from 1 to infinity <…>’).
Your code is
take 10 mutable_spaghetti_functionYour code is
take 10 mutable_spaghetti_functionThe code may be spaghetti, but I mostly just lifted it from the referenced article and solved the problems the original author brought up, namely the separation of concerns. The C++ solution to this problem will never be as beautiful as the Haskell one, but I wanted to show it doesn't have to be alienating for people who program C++ daily.
C++ iterators are powerful, and can be used for a lot more than stepping through a container. We write too few of them.
I've found using const a lot also goes hand-in-hand with raii. If a member of a class is const it must be initialized in the constructor, and it just seems to make me code a bit more "hygienically".
pyth x = [(a,b,c) | a<-[1..x], b<-[1..x], c<-[1..x], (a^2)+(b^2) == (c^2)]