summaryrefslogtreecommitdiff
path: root/prolog/problems/lists/last_elem_2/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/problems/lists/last_elem_2/common.py')
-rw-r--r--prolog/problems/lists/last_elem_2/common.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/prolog/problems/lists/last_elem_2/common.py b/prolog/problems/lists/last_elem_2/common.py
index 75cec75..9c44231 100644
--- a/prolog/problems/lists/last_elem_2/common.py
+++ b/prolog/problems/lists/last_elem_2/common.py
@@ -29,6 +29,7 @@ hint_type = {
'[]_should_not_succeed': Hint('[]_should_not_succeed'),
'list_returned': Hint('list_returned'),
'clumsy_conc_use': Hint('clumsy_conc_use'),
+ 'unsuccessful_conc_use': Hint('unsuccessful_conc_use'),
}
test_cases = [
@@ -77,15 +78,20 @@ def hint(code, aux_code):
# recursion is getting bigger and bigger
- # succeeds when asked to return the last element of an empty list
- if prolog.engine.ask_truthTO(engine_id, 'last_elem([], _)'):
- return [{'id': '[]_should_not_succeed'}]
-
# using conc, but clumsily: conc(_, X, L) instead of conc(_, [X], L)
if prolog.util.Token('NAME', 'conc') in tokens and \
prolog.engine.ask_truthTO(engine_id, 'last_elem([q,a,b,c], [q,a,b,c])'):
return [{'id': 'clumsy_conc_use'}]
+ # general unsuccessful use of conc, but not specifically detected
+ # return general_conc hint, not to confuse/force the student into a non-conc solution
+ if prolog.util.Token('NAME', 'conc') in tokens:
+ return [{'id': 'unsuccessful_conc_use'}]
+
+ # succeeds when asked to return the last element of an empty list
+ if prolog.engine.ask_truthTO(engine_id, 'last_elem([], _)'):
+ return [{'id': '[]_should_not_succeed'}]
+
# returns a list, not an element as required
if prolog.engine.ask_truthTO(engine_id, 'last_elem([q], X), is_list(X)'):
return [{'id': 'list_returned'}]