I think you have the tests backwards. Your predicate is expected to behave like a generator, and produce single values at a time. The tests check for this by gathering all the values produced into a list. Your solution however produces one single list of all values at once, so the tests collect that into a list, creating a nested list, while the expected result is just a list.
You need to rebuild your solution to produce individual values. Eg instead of this behaviour:
In Prolog, when running the test cases for the 'range' predicates, the tests are returning a list of a list instead of a single list. For example, for range(5), I would expect the result to be [1, 2, 3, 4, 5], but the test returns [[1, 2, 3, 4, 5]].
It seems the issue lies in how the 'findall/3' predicate is used within the tests. It actually collects the resulting list of the 'range' predicates in another list.
In C, when I print the registers[] array inside the function, the output matches the expected results exactly (at least when running the first test cases). Despite this, the tests still fail, showing that the registers are zero, not matching the expected output. What is the correct way to modify the array, so that the test framework correctly evaluates the results?
Thanks for the clarification. Seems I misunderstood the problem instructions.
I think you have the tests backwards. Your predicate is expected to behave like a generator, and produce single values at a time. The tests check for this by gathering all the values produced into a list. Your solution however produces one single list of all values at once, so the tests collect that into a list, creating a nested list, while the expected result is just a list.
You need to rebuild your solution to produce individual values. Eg instead of this behaviour:
You need behaviour like this:
In Prolog, when running the test cases for the 'range' predicates, the tests are returning a list of a list instead of a single list. For example, for
range(5)
, I would expect the result to be[1, 2, 3, 4, 5]
, but the test returns[[1, 2, 3, 4, 5]]
.It seems the issue lies in how the 'findall/3' predicate is used within the tests. It actually collects the resulting list of the 'range' predicates in another list.
the initial code tells you:
this is not what you are doing, you are putting a into
registers[0]
, b intoregisters[1]
, etcIn C, when I print the registers[] array inside the function, the output matches the expected results exactly (at least when running the first test cases). Despite this, the tests still fail, showing that the registers are zero, not matching the expected output. What is the correct way to modify the array, so that the test framework correctly evaluates the results?
This comment is hidden because it contains spoiler information about the solution