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

Hello,
I have a question concerning task 5 of the current assignment:
Is it allowed to use helper-functions?
And do we really have to implement the "subset" where the order of the elements doesn't play any role? (concrete: must something like (test (subset? '(b a a) '(a b c)) true) work?

I didn't find a solution yet with just one function where the order of the elements can be arbitrary - the test cases are constructed in a special way where the elements in the first list are in the same partial order like in the second list.

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

### Re: Task 5 (first exercise)

Yes, you are free to use helper functions. Either define one on the top-level or use a local definition.

Code: Alles auswählen

(test (subset? '(b a a) '(a b c)) true)
should work; I''ll add it to my test cases.

Daniel S.
Mausschubser
Beiträge: 87
Registriert: 25. Sep 2007 12:28
Wohnort: Mörfelden

### Re: Task 5 (first exercise)

sewe hat geschrieben:Yes, you are free to use helper functions. Either define one on the top-level or use a local definition.
Argh, that was the most difficult task (beside the correct syntax for task 7). There are no bonus points for a single function?

Edit: some more complex test cases, to test your solutions:

Code: Alles auswählen

(test (subset? '(a b c d e f) '(b a c g f e d e f)) true)
(test (subset? '(a b c d e f) '(b a g f e h d e f)) false)
(test (subset? '(f b d c e a) '(f a g f e h d e b)) false)
(test (subset? '(b b a c f d e e a) '(f a g f e h d e b c)) true)
(test (subset? '(f b d c e a) '(c a g f e h d e b)) true)
(if anybody finds an error in the test cases, please let me know )
Mit freundlichen Grüßen
Daniel