Hello,
I got these Results when I'm running my tests.
Test testSample2 failed: Expected App(App(Id('f),Id('a)),Id('b)), but got App(App(Id('f),Id('b)),Id('a))
In my opinion this is the same and I assume the solution wich arranges the parameters backward much more complicated.
So it would be nice to change the tests so that they allow both arrangments.
Assignment 4 Task 2
Re: Assignment 4 Task 2
You are assuming every function to be commutative. Generally speaking f(a,b) and f(b,a) are not the same.
Also I guess there is not so much to change in order to make your solution pass the tests, since the only difference between the two results depends on the direction you traverse the argument list.
Greetings
Kim
Also I guess there is not so much to change in order to make your solution pass the tests, since the only difference between the two results depends on the direction you traverse the argument list.
Greetings
Kim
Re: Assignment 4 Task 2
Ah okay, there is really a fault in my Implementation. But changing the order I'm traversing the list is really ugly in scala as far as I know.
But if the parameter order changes for Fun and App in the same way, the result would be the same. But because this would be a bit unrealistic this should be okay.
But if the parameter order changes for Fun and App in the same way, the result would be the same. But because this would be a bit unrealistic this should be okay.
Re: Assignment 4 Task 2
That's the reason why using higher-order functions is often less intuitive but actually the superior way of solving many tasks ...bluefish hat geschrieben:But changing the order I'm traversing the list is really ugly in scala as far as I know.

Another question about this task:
When looking at the tests, we are not allowed to preprocess a function without parameters to just it's body. I understand why we are not allowed to do this, and it isn't a problem for function definitions where we can use '_ as "empty" parameter. However, for function applications, don't we have to pass some "placeholder" expression as argument? If I use "Num(0)" or as argument, all tests are passed and the task seems solved. But I could also use "Add(Sub(Num(23), Num(42)), Num(666)))" and the solution is still correct. It just feels weird to me to use some random expression here. Is there a better way to solve this problem?
-
- Sonntagsinformatiker
- Beiträge: 222
- Registriert: 4. Okt 2010 18:15
Re: Assignment 4 Task 2
I assume that our preprocessor only needs to return a "valid" program if the input was "valid", too (if there is some unbound variable in the input then our preprocessor doesn't somehow correct this either). So it shouldn't matter what pseudo-parameter you use.
Greets Dennis
Greets Dennis