I’ve never used them but: Push-back lists on DCG rule heads
Here is some code that uses @jan’s approach (it contains two versions of the code, with/without library(yall)), also mentioned here: https://swi-prolog.discourse.group/t/autum-challenge-short-deadfish-numbers/6869/5: