Author | Message |
---|---|
rabbott
Posts: 1649
|
Posted 09:33 Nov 10, 2016 |
The following has been added to Project 9.
As the text noted, repeatedly summing the distances in a Unnamed fields: Named fields: Then revise the rest of the code so that it works with the modified Field names are used as setters when you create a new instance of a type. For example, the
When you are done, you will have two revised files for this project. They should be the same except for how See the project description for more details. Last edited by rabbott at
10:40 Nov 10, 2016.
|
lishenyu
Posts: 103
|
Posted 22:47 Nov 12, 2016 |
Hi professor, I want to use splitOn, so I import Data.List.Split but winGhci gave me an error :can't find this module. is there any way to use it? or could you tell me some other function that does the same job as this function? thanks! |
rabbott
Posts: 1649
|
Posted 22:52 Nov 12, 2016 |
Do you mean the function |
lishenyu
Posts: 103
|
Posted 23:49 Nov 12, 2016 |
no, it's splitOn, which takes a string as delimeter for example, splitOn " " "1 2 3 4 5" will return ["1","2","3","4","5"]. And I googled it, it says I need to import Data.Text . But winghici doesn't allow me to import it either. |
rabbott
Posts: 1649
|
Posted 09:38 Nov 13, 2016 |
Here's one way to do it.
If you use it, I'll expect you to explain how it works. Is this for Project 8? Last edited by rabbott at
08:04 Nov 14, 2016.
|
rabbott
Posts: 1649
|
Posted 10:09 Nov 13, 2016 |
Deleted Last edited by rabbott at
07:59 Nov 14, 2016.
|
rabbott
Posts: 1649
|
Posted 13:17 Nov 13, 2016 |
This version is tail recursive both in collecting the elements into sequences and in collecting the sequences. Uses the same
If you use it, I'll expect you to explain how it works. Last edited by rabbott at
08:00 Nov 14, 2016.
|
rabbott
Posts: 1649
|
Posted 08:02 Nov 14, 2016 |
The code for the two versions of splitOn is available here. |