Seite 1 von 1

Assignment 05 Task 1

Verfasst: 16. Mai 2014 00:11
von Dennis Albrecht
Hey guys!

I'm just doing the homework but didn't got very far:
After I made some mistakes with some variable names (used X where I had to use Y etc.) I finally got a solution that let all the tests pass (public and specification).
But this version breaks the contract of subst:
The third argument of subst is called value but my version does not pass a value as third argument. May it be the case that the third argument does not need to be value anymore? At the moment it seems to be impossible for me to pass a value to subst.

Greets Dennis

Re: Assignment 05 Task 1

Verfasst: 18. Mai 2014 14:58
von simon.r
Well, I was able to implement it without changing any of the method signatures. As a matter of fact, all I did was adding the definitions for the LetRec pattern to the interp and subst methods.
Like the hint of the assignment suggests the part required to make the actual recursion work is centered on the interp method.

Re: Assignment 05 Task 1

Verfasst: 18. Mai 2014 15:44
von Dennis Albrecht
I'm not completely sure if I totally understand your approach but it seems to fit to my implementation. I also didn't change the signature of any of the methods but does your implementation pass a value as third argument to subst? Value here means either a function or a number and nothing else (and especially no LetRec)?

Greets Dennis

Re: Assignment 05 Task 1

Verfasst: 18. Mai 2014 17:30
von simon.r
Okay, I did not realize you meant it that way - I actually pass a LetRec as the third argument, too. However, I'm not sure whether a parameter name can be considered a strict contract in the sense that whoever decided this name really gave it that much thought...

Re: Assignment 05 Task 1

Verfasst: 19. Mai 2014 00:28
von Dennis Albrecht
That's why I asked this question to be sure about it. There are languages like Scheme where you define parameter-types by their names (or at least this is one possibility) and even in languages like Java you use the name to give parameters (especially those of some primitive types) a meaning. In this task we don't have a special Value-type (interp translates from one language into the same language back) so, if two of the parameters of subst have the same type then the names have to be important (or at least they might be).

But its good to see that I'm not the only one with this kind of solution.

Greets Dennis

Re: Assignment 05 Task 1

Verfasst: 19. Mai 2014 09:41
von errt
I also managed to do this task using a solution like the one you described. While it passes all public tests (and a few additional I wrote), so I'm quite confident it is at least not too far away from being correct, the specification tests fail with a running failure and test score 0/-1. Did anyone else experience this and/or has a solution to this problem?

Re: Assignment 05 Task 1

Verfasst: 19. Mai 2014 12:39
von Boddlnagg
I experienced the same problem concerning the specification tests and have not yet found a solution ...

Re: Assignment 05 Task 1

Verfasst: 19. Mai 2014 12:52
von LordHoto
Boddlnagg hat geschrieben:I experienced the same problem concerning the specification tests and have not yet found a solution ...
If you get 0/-1 something is wrong with your solution. This might, for example, indicate that the tests do not terminate AFAICT.

Re: Assignment 05 Task 1

Verfasst: 19. Mai 2014 13:51
von Boddlnagg
LordHoto hat geschrieben:
Boddlnagg hat geschrieben:I experienced the same problem concerning the specification tests and have not yet found a solution ...
If you get 0/-1 something is wrong with your solution. This might, for example, indicate that the tests do not terminate AFAICT.
Thank you! I managed to find a failing test case now and fixed the implementation.

Re: Assignment 05 Task 1

Verfasst: 19. Mai 2014 17:17
von errt
Thanks. Found an error and could fix it. Hint, if anyone else has the same problem: As the specification says, "generate a “self-replicating” copy of the recursive definition", not one that replicates something else.

Re: Assignment 05 Task 1

Verfasst: 20. Mai 2014 14:52
von Eichhorn
Probably a stab in the dark, but was anyone else stuck at 12/12 public tests 18/19 private tests and then figured out what was wrong with his implementation? Any hint would be appreciated. :)

Re: Assignment 05 Task 1

Verfasst: 20. Mai 2014 16:57
von errt
Yes, I encountered that while fixing my solution. Hint: The 19th testcase is of the form "LetRec(...,...,App(...,...))"