## Ex07 refering to group exercise 6

Osterlaus
BSc Spammer
Beiträge: 1263
Registriert: 23. Aug 2007 12:46
Wohnort: DA

### Ex07 refering to group exercise 6

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

Wambolo
Computerversteher
Beiträge: 381
Registriert: 18. Okt 2007 11:36

### Re: Ex07 refering to group exercise 6

I am also interested in the solution of the group exercise.

I wonder why no official solutions are provided.

dominik_andreas
Erstie
Beiträge: 18
Registriert: 21. Mai 2012 15:07

### Re: Ex07 refering to group exercise 6

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

Wambolo
Computerversteher
Beiträge: 381
Registriert: 18. Okt 2007 11:36

### Re: Ex07 refering to group exercise 6

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?
Zuletzt geändert von Wambolo am 5. Jun 2013 15:10, insgesamt 1-mal geändert.

Osterlaus
BSc Spammer
Beiträge: 1263
Registriert: 23. Aug 2007 12:46
Wohnort: DA

### Re: Ex07 refering to group exercise 6

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?

Wambolo
Computerversteher
Beiträge: 381
Registriert: 18. Okt 2007 11:36

### Re: Ex07 refering to group exercise 6

my mistake.

the 2 should be a 0

Seldon
BASIC-Programmierer
Beiträge: 119
Registriert: 19. Apr 2012 18:12

### Re: Ex07 refering to group exercise 6

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.

spyro.makedonski
BASIC-Programmierer
Beiträge: 102
Registriert: 18. Apr 2010 13:45

### Re: Ex07 refering to group exercise 6

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?

cofi
Mausschubser
Beiträge: 86
Registriert: 22. Sep 2009 12:07

### Re: Ex07 refering to group exercise 6

Look at the definition of lookup.

Wambolo
Computerversteher
Beiträge: 381
Registriert: 18. Okt 2007 11:36

### Re: Ex07 refering to group exercise 6

the second argument of insert could be Ctor('Pair, List(...

dummdidumm
Windoof-User
Beiträge: 39
Registriert: 28. Apr 2010 18:49

### Re: Ex07 refering to group exercise 6

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?

cofi
Mausschubser
Beiträge: 86
Registriert: 22. Sep 2009 12:07

### Re: Ex07 refering to group exercise 6

How would you do it in the Scala FWAE interpreter?

dummdidumm
Windoof-User
Beiträge: 39
Registriert: 28. Apr 2010 18:49

### Re: Ex07 refering to group exercise 6

With Matching. Ok i wrote a matcher in the according language now, it works. Thanks

spyro.makedonski
BASIC-Programmierer
Beiträge: 102
Registriert: 18. Apr 2010 13:45

### Re: Ex07 refering to group exercise 6

Wambolo hat geschrieben:the second argument of insert could be Ctor('Pair, List(...
Thanks!