I’ve been looking for a function (reporter) to substitute for … with one added feature: the first item will be removed from the input list immediately after reading - in this context such mechanism works much like readln in Pascal. Thus the code of the client process above may be shortened to something like this:
My proposal is this really small and simple function:
Perhaps is not particularly elegant, being imperative style and all that. Actually I had started out trying to code the whole thing in a functional style, employing , but couldn’t figure out how. I guess it could also be done in OOP-with-procedures style (Snap*!* Manual, chapter VIII) … anyone?
Either of those solutions can be purely functional.
Your solution is okay, too, provided that you don't mind erasing your input data. But you might, for example, want to do something else with each line after you finish the first pass.
But I wouldn't want your PICK procedure in the List Utilities library, because it really encourages people to process lists destructively, and we're trying to build functional programmers. And, as you say, it's easy to write. If it were big and complicated, that might be a reason to provide it in a library.