You work out a way to "copy" a list efficiently, so that you can make a new one for every step without it going really slow. It's easy to do this with a singly linked list; you can share identical list tails between all other lists that have the same tail. It's relatively easy to program, although quite hard to visualize, which is a recurrent theme for functional programming.
The other way is to google the answer. Although we are, apparently going through a functional craze at the moment, people have been thinking about this stuff for years. All the simple and obvious questions were answered 20 years ago, so you usually find the answer if you really want it.