Maximum Segment Sum, Monadically (distilled tutorial, with solutions)

arXiv:1109.0782 First posted 2011-09-05 v2 Cited by 1 Revision of the article in Proceedings DSL 2011, EPTCS 66, arXiv:1109.0323, to provide solutions to the exercises
Cite this paper ×
BibTeX
@misc{oxford2011maximum,
  title = {Maximum Segment Sum, Monadically (distilled tutorial, with solutions)},
  author = {Jeremy Gibbons (University of Oxford)},
  year = {2011},
  eprint = {1109.0782},
  archivePrefix = {arXiv},
  primaryClass = {cs.DS},
  url = {https://arxiv.org/abs/1109.0782}
}
APA
Oxford), J. G. (. O. (2011). Maximum Segment Sum, Monadically (distilled tutorial, with solutions) [Preprint]. arXiv. https://doi.org/10.48550/arXiv.1109.0782
GB/T 7714
OXFORD) JG(O. Maximum Segment Sum, Monadically (distilled tutorial, with solutions)[EB/OL]. (2011-09-05)[2026-11-29]. https://arxiv.org/abs/1109.0782.

Abstract

The maximum segment sum problem is to compute, given a list of integers, the largest of the sums of the contiguous segments of that list. This problem specification maps directly onto a cubic-time algorithm; however, there is a very elegant linear-time solution too. The problem is a classic exercise in the mathematics of program construction, illustrating important principles such as calculational development, pointfree reasoning, algebraic structure, and datatype-genericity. Here, we take a sideways look at the datatype-generic version of the problem in terms of monadic functional programming, instead of the traditional relational approach; the presentation is tutorial in style, and leavened with exercises for the reader.

Post #1 · the paper

Discussion

No comments yet. Start the discussion!