Ex. 2.4: Lazy Evaluation

Benutzeravatar
sproksch
Computerversteher
Computerversteher
Beiträge: 346
Registriert: 15. Apr 2004 17:56

Ex. 2.4: Lazy Evaluation

Beitrag von sproksch »

By reading the slides I understood the difference between eager-evaluation and lazy-evaluation, but anyhow I have no idea how this task could be solved. Some "googling" provided some references to the Scheme keywords "delay" and "force", but I'm not sure if these should be used. Could someone please explain to me how to start? I'm a very unexperienced in Scheme-programming and it's still very hard for me to think the "Scheme"-way, so I would be grateful for any help provided.

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

Re: Ex. 2.4: Lazy Evaluation

Beitrag von sewe »

You don't need any more Scheme than you have seen already (procedure calls and conditionals). Also, it seems to me you are thinking about the wrong level, i.e., about the way Scheme interprets your program (delay, force, and friends). Think rather about the way your program interprets WAE. I hope this helps.

Nori
Erstie
Erstie
Beiträge: 22
Registriert: 15. Nov 2006 17:40
Kontaktdaten:

Re: Ex. 2.4: Lazy Evaluation

Beitrag von Nori »

I think I've implemented lazy-evaluation, but I cannot think of a test case for it.
The results of the two evaluations strategies should not differ (according to the book). The only thing I can think of, is that one strategy does not terminate. To test that I would need to define my own, recursive function, in WAE, but that is not yet possible in assigment-1.scm .

Nori
Erstie
Erstie
Beiträge: 22
Registriert: 15. Nov 2006 17:40
Kontaktdaten:

Re: Ex. 2.4: Lazy Evaluation

Beitrag von Nori »

got it, sorry.

BastiS
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 224
Registriert: 3. Nov 2005 19:12
Kontaktdaten:

Re: Ex. 2.4: Lazy Evaluation

Beitrag von BastiS »

In the assignment it's written "Then write a test case that succeeds when using lazy substitution, but fails with eager substitution."
Is an exception also a "fail" or do we have to have a "bad" as a result?

Benutzeravatar
sewe
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 295
Registriert: 16. Jan 2009 14:53
Kontaktdaten:

Re: Ex. 2.4: Lazy Evaluation

Beitrag von sewe »

Just an exception is fine. If you want to include a test, consider using test/exn. Note, however,that the correct, user-generated exception then generates a success, not a failure.

Antworten

Zurück zu „Archiv“