Ex07 refering to group exercise 6
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...
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
I am also interested in the solution of the group exercise.
I wonder why no official solutions are provided.
I wonder why no official solutions are provided.
-
- 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...
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?
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.
Re: Ex07 refering to group exercise 6
Are you sure about having 2 and 0 there?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))
Re: Ex07 refering to group exercise 6
my mistake.
the 2 should be a 0
the 2 should be a 0

Re: Ex07 refering to group exercise 6
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: Ctor('Num, List(1)) should evaluate to CtorV('NumV, List(NumV(1))
why not CtorV('Num, List(NumV(1))
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.Wambolo hat geschrieben: Another question: Could anyone give me a hint how to use Eq in the "FWAE Interpreter" task.
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.
-
- 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?
Re: Ex07 refering to group exercise 6
the second argument of insert could be Ctor('Pair, List(...
-
- 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))),
('Add, List('lhs, 'rhs), ....
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?
If i have
val fwaeInterp = Rec('interp,
Fun('expr,
Fun('env,
Match('expr, List(
('Num, List('n),
Ctor('NumV, List('n))),
('Add, List('lhs, 'rhs), ....
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?
-
- 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
-
- BASIC-Programmierer
- Beiträge: 102
- Registriert: 18. Apr 2010 13:45
Re: Ex07 refering to group exercise 6
Thanks!Wambolo hat geschrieben:the second argument of insert could be Ctor('Pair, List(...