Assignment 05 Task 1

Dennis Albrecht
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 222
Registriert: 4. Okt 2010 18:15

Assignment 05 Task 1

Beitrag von Dennis Albrecht » 16. Mai 2014 00:11

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

simon.r
Mausschubser
Mausschubser
Beiträge: 59
Registriert: 4. Okt 2010 16:13

Re: Assignment 05 Task 1

Beitrag von simon.r » 18. Mai 2014 14:58

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.

Dennis Albrecht
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 222
Registriert: 4. Okt 2010 18:15

Re: Assignment 05 Task 1

Beitrag von Dennis Albrecht » 18. Mai 2014 15:44

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

simon.r
Mausschubser
Mausschubser
Beiträge: 59
Registriert: 4. Okt 2010 16:13

Re: Assignment 05 Task 1

Beitrag von simon.r » 18. Mai 2014 17:30

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...

Dennis Albrecht
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 222
Registriert: 4. Okt 2010 18:15

Re: Assignment 05 Task 1

Beitrag von Dennis Albrecht » 19. Mai 2014 00:28

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

errt
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 18. Okt 2012 19:12

Re: Assignment 05 Task 1

Beitrag von errt » 19. Mai 2014 09:41

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?

Boddlnagg
Mausschubser
Mausschubser
Beiträge: 54
Registriert: 10. Dez 2012 12:07

Re: Assignment 05 Task 1

Beitrag von Boddlnagg » 19. Mai 2014 12:39

I experienced the same problem concerning the specification tests and have not yet found a solution ...

LordHoto
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 135
Registriert: 14. Dez 2009 17:00

Re: Assignment 05 Task 1

Beitrag von LordHoto » 19. Mai 2014 12:52

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.
Compiler 1 Tutor WS 12/13

Boddlnagg
Mausschubser
Mausschubser
Beiträge: 54
Registriert: 10. Dez 2012 12:07

Re: Assignment 05 Task 1

Beitrag von Boddlnagg » 19. Mai 2014 13:51

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.

errt
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 18. Okt 2012 19:12

Re: Assignment 05 Task 1

Beitrag von errt » 19. Mai 2014 17:17

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.

Eichhorn
Windoof-User
Windoof-User
Beiträge: 36
Registriert: 9. Mär 2012 18:11

Re: Assignment 05 Task 1

Beitrag von Eichhorn » 20. Mai 2014 14:52

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. :)

errt
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 18. Okt 2012 19:12

Re: Assignment 05 Task 1

Beitrag von errt » 20. Mai 2014 16:57

Yes, I encountered that while fixing my solution. Hint: The 19th testcase is of the form "LetRec(...,...,App(...,...))"

Antworten

Zurück zu „Archiv“