CO545 Spring Term 2018–19 Assessment 2
This assessment is a text processing case study, and a partial implementation is provided in the file a2.erl.
You should submit your solutions to Moodle in a single Erlang file by 23:55, Monday 25 February.
Types and specs
This assessment uses the type and spec declarations described in the terminal class 4 worksheet.
Macros
We use an Erlang macro to specify the constant line length, LINELEN. When we want to use this we have to write LINELEN.
What should the functions do?
While the -spec declarations and comments in the file give you some idea of what the functions should do, here’s some more information about some of the definitions that you need to complete.
get_word/1get_word(St) will take the longest word from the beginning of the string St: that is the longest initial string up to the first whitespace character. There is an example in the file.
drop_word/1drop_word(St) drops characters from the string St up to the first whitespace character.
drop_wsp/1drop_wsp(St) drops characters from the string St up to the first non-
whitespace character.
words/1words(St) splits the string St into a lost of words.
get_line/2To build a line, take as many words as possible, keeping the total length (including a single inter-word space between adjacent words) below the specified length, which is the second parameter of get_line.
drop_line/2Drop words corresponding to the line got by get_line.
lines/1Repeatedly apply get_line and drop_line to turn a lost of words into a list of lines i.e. a list of list of words.
continued over the page …
Simon Thompson10, 11 February 2019
Marking scheme
Marks are awarded for functional correctness. Up to 10% of the marks will be deducted for solutions which are overly complicated, obscure or difficult to read.
While we would encourage you to talk to others about generalities of the work, the work that you submit should be identifiably your own. Please consult the university guidelines on plagiarism for more details.
FunctionMarks
get_word/110
drop_word/110
drop_wsp/15
words/110
get_line/210
drop_line/210
lines/110
check/15
show_line_right/110
replicate/25
print_line_right/15
show_doc_right/15
print_doc_right/15
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。