From d259285459176fc281193adb12483a6e6d527cf5 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Tue, 6 Sep 2016 16:48:08 +0200 Subject: English translation for sum/2 added. --- prolog/problems/lists_advanced/len_2/en.py | 6 +++--- prolog/problems/lists_advanced/len_2/sl.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'prolog/problems/lists_advanced/len_2') diff --git a/prolog/problems/lists_advanced/len_2/en.py b/prolog/problems/lists_advanced/len_2/en.py index 33b1675..6518eec 100644 --- a/prolog/problems/lists_advanced/len_2/en.py +++ b/prolog/problems/lists_advanced/len_2/en.py @@ -15,14 +15,14 @@ plan = ['''\ is of length LenT + 1.

''', '''\

If I take away the head, and the recursion solves this smaller problem (tail), and if I add 1 to the -result returned by the recursion, then I got the length of the whole list.

+result returned by the recursion, then I get the length of the whole list.

'''] hint = { 'eq_instead_of_equ': '''\

The operator == is "stricter" than operator = in the sense that for the latter it is enough to be able to make the two operands equal (unification). Perhaps by using = -you can make the predicate conc/3 more general (e.g. able to work with output arguments becoming inputs).

+you can make the predicate len/2 more general (e.g. able to work with output arguments becoming inputs).

Of course, you can also solve the exercise without explicit use of either of these two operators, just remember that unification is implicitly performed with the predicate's arguments (head of clause).

''', @@ -78,7 +78,7 @@ second operand and only then attempts the unification of both operands.

'forcing_result_onto_recursion': '''

Don't force the result onto recursion, don't tell it what it should return. Just assume it will do its job. If this assumption is correct, then the rule will work for a larger case.

-

Is your recursive call of the form len(T, LenT + 1)? This forces the recursive call to +

Is your recursive call of the form len(Tail, LenTail + 1)? This forces the recursive call to return the length of the whole list, not just the tail! This will not work. It is your job to increase by one the result returned by the recursion. In short, add one outside the recursive call.

''', diff --git a/prolog/problems/lists_advanced/len_2/sl.py b/prolog/problems/lists_advanced/len_2/sl.py index 49b9eea..28fe25e 100644 --- a/prolog/problems/lists_advanced/len_2/sl.py +++ b/prolog/problems/lists_advanced/len_2/sl.py @@ -75,8 +75,8 @@ svoji levi strani.

'forcing_result_onto_recursion': '''

Ne vsiljuj rekurziji kaj naj vrne, prepusti se ji. To je tisti del, ko narediš predpostavko, če je ta izpolnjena, potem bo tvoje pravilo delovalo za večji primer.

-

Je tvoj rekurzivni klic oblike len(T, LenT + 1)? S tem vsiljuješ rekurziji -da mora vrniti dolžino celega seznama in ne samo repa. To ni v redu, za ena moraš ti povečati +

Je tvoj rekurzivni klic oblike len(Tail, LenTail + 1)? S tem vsiljuješ rekurziji +da mora vrniti dolžino celega seznama in ne samo repa. To ni v redu, za ena moraš ti povečati rezultat, ki ti ga rekurzija vrne. Skratka, prištevanje naredi izven rekurzivnega klica.

''', -- cgit v1.2.1