The prerequisite for such a way of programming is to use plain universal interchangeable data structures.
It does not seem possible in mainstream languages where the OOP dogma tells you to obfuscate your sets, lists and maps and turn them into non-reusable classes.