Skip to main navigation Skip to search Skip to main content

Sublist assertions for listless and lazy evaluation

Research output: Contribution to journal › Article › peer-review

Abstract

This paper introduces a new logical form, called the sublist assertion, and shows its many uses for list processing, especially listless and lazy evaluation, features that are traditionally absent in programming languages such as Prolog. The basic technique involves the use of one or more sublist assertions for specifying the elements of a list-valued function, and also a new form of list-matching and unification for iterating over the elements of a list. A sublist assertion can take one of two forms: f (terms) {square original of or equal to} expressionf (terms) {square original of or equal to} list :- condition When multiple sublist assertions define some given function f, the corresponding lists defined by their bodies are appended together; hence the order of sublist assertions is significant. Three types of goals are provided, each with a different operational effect: (i) f(terms) = answer defines answer to be list of all elements, and corresponds to eager evaluation; (ii) f(terms) {square original of or equal to} [answer] defines answer to be an element of the resulting list, and corresponds to listless evaluation, where intermediate lists are avoided; (iii) f(terms) {square original of or equal to} answer defines answer to be the list of all elements, but the elements are generated by lazy evaluation. The paper also discusses a novel list pattern, [ x t], meaning that x is an element of the matching list and t is the remainder. It is shown that this facilitates clear, concise, and efficient list operations. The integration of the sublist assertion with relational assertions is also discussed, as it provides a way to define a listof operation (analogous to bagof) and also offers the benefits of lazy, nondeterministic evaluation.

Original languageEnglish
Pages (from-to)133-146
Number of pages14
JournalComputer Languages
Volume17
Issue number2
DOIs
StatePublished - Apr 1992

Keywords

  • Lazy evaluation
  • List processing
  • Listless evaluation
  • Pattern-matching and unification
  • Prolog programming

Fingerprint

Dive into the research topics of 'Sublist assertions for listless and lazy evaluation'. Together they form a unique fingerprint.

Cite this