The backtrack vocabulary implements simple non-determinism by selecting an element of a sequence, performing a test and backtracking to select the next element if the test fails.
The output means there is only one solution: the farmer has 23 chickens and 7 cows. If we want to only find the first solution, the following approach could be used:
: check ( chickens cows -- ? )
[ + 30 = ] [ 4 * swap 2 * + 74 = ] 2bi and ;
[
1 30 [a..b] amb 1 30 [a..b] amb
2dup check must-be-true
"%d chickens, %d cows\n" printf
t
] [ "No solution." print ] if-amb drop 23 chickens, 7 cows