Assignment 3, Task 2 (MultiArgFLAEPreproc), Test testZeroArg2

MrGumby
Mausschubser
Mausschubser
Beiträge: 65
Registriert: 16. Apr 2013 15:07

Assignment 3, Task 2 (MultiArgFLAEPreproc), Test testZeroArg2

Beitrag von MrGumby » 21. Nov 2016 12:23

Hi,
in testZeroArg2 I don't understand how I can return '_. I tried a bit, but since underscores aare usually interpreted as being a placeholder I could find no way to return it, without getting an error message like
error: missing parameter type for expanded function
Anybody know how to do it? I would post more details, but I don't know whether that would reveal too much about my solution.

Talaron
Mausschubser
Mausschubser
Beiträge: 85
Registriert: 26. Apr 2012 11:34

Re: Assignment 3, Task 2 (MultiArgFLAEPreproc), Test testZeroArg2

Beitrag von Talaron » 21. Nov 2016 13:27

Did you definitely use '_ (starts with a single quotation mark and no space in between, to make it a symbol) instead of _ ? Please also make sure you don't confuse it with ´ or ` (the accent symbols). Scala can definitely handle the '_ symbol as any other symbol!

MrGumby
Mausschubser
Mausschubser
Beiträge: 65
Registriert: 16. Apr 2013 15:07

Re: Assignment 3, Task 2 (MultiArgFLAEPreproc), Test testZeroArg2

Beitrag von MrGumby » 21. Nov 2016 13:31

  • - I copied it from the test
    - I used the symbol which on german keyboards is above #
    - I used the accent `, which is interpreted as quote and gives a error because no closing one is found
    - I tried just simple _ or _:Symbol
Nothing's working. But I read from your answer that it should somehow work like this?

Can I post the line where I am trying or is that too much of the solution (It is the line where I match params and it is empty)...

EDIT: It works now, there was another error in the code, sorry. :roll:

Talaron
Mausschubser
Mausschubser
Beiträge: 85
Registriert: 26. Apr 2012 11:34

Re: Assignment 3, Task 2 (MultiArgFLAEPreproc), Test testZeroArg2

Beitrag von Talaron » 21. Nov 2016 21:44

Don't worry, this has happened to the best of us. I hope you still learned something and I'm looking forward to giving you full score for your solution. :D

MrGumby
Mausschubser
Mausschubser
Beiträge: 65
Registriert: 16. Apr 2013 15:07

Re: Assignment 3, Task 2 (MultiArgFLAEPreproc), Test testZeroArg2

Beitrag von MrGumby » 22. Nov 2016 11:48

Ok, thanks. But before you can do that. I am trying sth similar with the case App, but I can't figure out how to return a FLAE-placeholder. If I try to give sth like

Code: Alles auswählen

App([some expression], _:FLAE)
I get
error: type mismatch;
found : MultiArgFLAEPreproc.FLAE => MultiArgFLAEPreproc.App
required: MultiArgFLAEPreproc.FLAE
So the next question is how I can return this placeholder. If I leave out the type, he just says
missing parameter type for expanded function

Talaron
Mausschubser
Mausschubser
Beiträge: 85
Registriert: 26. Apr 2012 11:34

Re: Assignment 3, Task 2 (MultiArgFLAEPreproc), Test testZeroArg2

Beitrag von Talaron » 22. Nov 2016 12:29

Well, using an explicit Scala placeholder probably won't work well here, either because Scala misunderstands it as a function definition (in your case, Scala thinks you want to write a syntactic short form of "(x) => { App([...], x) }"), or because the compiler would probably end up inserting "null" for the placeholder, which breaks our interpreter.

But as you don't use the argument you pick anyway, you can insert basically anything you want. So how about just going for something like "Num(0)" or "Num(-1)" or whatever you find appropriate as an "ignore me" value. :)

MrGumby
Mausschubser
Mausschubser
Beiträge: 65
Registriert: 16. Apr 2013 15:07

Re: Assignment 3, Task 2 (MultiArgFLAEPreproc), Test testZeroArg2

Beitrag von MrGumby » 22. Nov 2016 13:30

Ok, thanks. That worked, though I am not yet exactly sure how, but I'll figure it out :lol:

Antworten

Zurück zu „Archiv“