Questions about Assignment 01

Dennis Albrecht
Sonntagsinformatiker
Sonntagsinformatiker
Beiträge: 222
Registriert: 4. Okt 2010 18:15

Questions about Assignment 01

Beitrag von Dennis Albrecht »

Hey guys!

I just wanted to solve the assignment but the task-descriptions of the part "scala warm-up" is quite confusing (and it's not scala that causes the confusions - I already know and used scala):

reverse:
Ok, all right, it's obvious why we aren't supposed to use reverse but List does not define a method append, so what does that mean for the task? Is this a paraphrase for all methods that append to the end of the given list? Or does this even include prepend-methods like ::?

flatten:
This task description is even more imprecise. Same as before, why not using flatten is obvious. But without using any method of List this task is imho not solvable (and the task would even forbid using head and tail, because they are also "members" of List). To be more concrete: What about using :: and :::?

kim
Neuling
Neuling
Beiträge: 5
Registriert: 15. Okt 2011 22:05

Re: Questions about Assignment 01

Beitrag von kim »

I suppose that methods like :+ and ::: which append lists and elements to lists are not allowed since any more complicated methods should be implemented by ourselves.

In contrast I guess :: is alright since it is the most native way of constructing and de-constructing a list.


Nevertheless it would be nice if some tutor could make all this a bit clearer. Which methods exactly are we allowed to use? Should we prefer if-else to pattern matching or even the other way round? Thanks in advance.

Greetings
Kim

Oliver B.
Windoof-User
Windoof-User
Beiträge: 31
Registriert: 14. Okt 2013 09:54

Re: Questions about Assignment 01

Beitrag von Oliver B. »

kim hat geschrieben:I suppose that methods like :+ and ::: which append lists and elements to lists are not allowed since any more complicated methods should be implemented by ourselves.

In contrast I guess :: is alright since it is the most native way of constructing and de-constructing a list.
This is correct. You should restrict yourself to list construction (List(...), ::, Nil), test for emptiness, data extraction with head, tail or pattern matching.
Methods like :+, ++, ::: etc. are considered non-trivial. This applies to both reverse and flatten.
We want you to write your solution using recursion on the structure of lists. So don't use any higher-order functions like map, fold or similar.
I hope this makes it more clear.

Cheers
Oliver

Antworten

Zurück zu „Archiv“