Seite 1 von 1

### Ex07 refering to group exercise 6

Verfasst: 4. Jun 2013 15:59
Hi there,
could someone provide solutions to the sixth group exercise that the homework is refering to? Even if I already got the right syntax for Ctor extends DRCFAE and Match, I don't have a clue about the result of the evaluation of Ctor. And as this is the fundament for the following two tasks, I'd love to see some hints that could probably be in the solution of the group exercise...

### Re: Ex07 refering to group exercise 6

Verfasst: 4. Jun 2013 23:33
I am also interested in the solution of the group exercise.

I wonder why no official solutions are provided.

### Re: Ex07 refering to group exercise 6

Verfasst: 5. Jun 2013 12:48
I've got the exact same problem. I've been sitting on this for over an hour without a real clue on what to do precicely.. And I'm betting we're not the only ones who skipped the group exercise last friday...

### Re: Ex07 refering to group exercise 6

Verfasst: 5. Jun 2013 14:15
At least I was able to pass the test cases of "ADTs" and "Boolean Interpreter".

As far as I understand Ctor simply evaluates to CtorV:
Ctor('Cons, List(0, Ctor('Nil, List.empty)) -> CtorV('Cons, List(NumV(0), CtorV('Nil, List.empty))

But I wonder why:
Ctor('Num, List(1)) should evaluate to CtorV('NumV, List(NumV(1))
why not CtorV('Num, List(NumV(1))
From my point of view this seems to be inconsistent with the former tasks. But maybe I am wrong.

Another question: Could anyone give me a hint how to use Eq in the "FWAE Interpreter" task.

By the way: Is there anybody out there who doesn't speak German?

### Re: Ex07 refering to group exercise 6

Verfasst: 5. Jun 2013 15:07
Wambolo hat geschrieben:As far as I understand Ctor simply evaluates to CtorV:
Ctor('Cons, List(2, Ctor('Nil, List.empty)) -> CtorV('Cons, List(NumV(0), CtorV('Nil, List.empty))
Are you sure about having 2 and 0 there?

### Re: Ex07 refering to group exercise 6

Verfasst: 5. Jun 2013 15:09
my mistake.

the 2 should be a 0

### Re: Ex07 refering to group exercise 6

Verfasst: 5. Jun 2013 21:58
Wambolo hat geschrieben: Ctor('Num, List(1)) should evaluate to CtorV('NumV, List(NumV(1))
why not CtorV('Num, List(NumV(1))
Just like we interpreted Num in our FWAE interpreter as NumV, we have to convert those expressions in our meta interpreter. Don't confuse CtorV, which represents a value of our interpreting language in Scala, with CtorV('NumV...), which represents a value of the interpreted language in DRCFAE.
Wambolo hat geschrieben: Another question: Could anyone give me a hint how to use Eq in the "FWAE Interpreter" task.
Eq just checks if two interpreted expressions return identical case class objects and returns NumV(1) for true and NumV(0) for false. Those values can be tested with the If0 expression.

However, you don't require Eq for this task, it's only necessary for the environment lookup. Have a look at the Scala interpreter https://repository.st.informatik.tu-dar ... terp.scala and implement each match 1:1 in DRCFAE.

### Re: Ex07 refering to group exercise 6

Verfasst: 6. Jun 2013 03:33
How can i use insert and lookup? someone provide an example please... when i do App(insert,a->b), it doesnt work. How can i insert key/value pair then?

### Re: Ex07 refering to group exercise 6

Verfasst: 6. Jun 2013 09:44
Look at the definition of `lookup`.

### Re: Ex07 refering to group exercise 6

Verfasst: 6. Jun 2013 14:36
the second argument of insert could be Ctor('Pair, List(...

### Re: Ex07 refering to group exercise 6

Verfasst: 6. Jun 2013 15:38
In Exercise 7.3,
If i have

val fwaeInterp = Rec('interp,
Fun('expr,
Fun('env,
Match('expr, List(
('Num, List('n),
Ctor('NumV, List('n))),

can someone give me a hint on how to convert the "CortV('NumV ..."-Values into NumV-Values so that for example DRCFAE-Add can use them?

### Re: Ex07 refering to group exercise 6

Verfasst: 6. Jun 2013 15:47
How would you do it in the Scala FWAE interpreter?

### Re: Ex07 refering to group exercise 6

Verfasst: 6. Jun 2013 16:17
With Matching. Ok i wrote a matcher in the according language now, it works. Thanks

### Re: Ex07 refering to group exercise 6

Verfasst: 6. Jun 2013 19:20
Wambolo hat geschrieben:the second argument of insert could be Ctor('Pair, List(...
Thanks!