FACTOID # 58: Looking for geniuses? Head straight to Iceland. There are more than 3 Nobel Prize Winners for every million Icelanders.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Function composition (computer science)

In computer science, function composition is an act or mechanism to combine simple functions to build more complicated ones. Like the usual composition of functions in mathematics, the result of the composed function is passed to the composing one via a parameter. Because of this similarity, the syntax in program code tends to closely follow that in mathematics. As a subroutine, the feature appears in most programming languages. Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ... In computer science, a subroutine (function, method, procedure, or subprogram) is a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code. ... In mathematics, a composite function, formed by the composition of one function on another, represents the application of the former to the result of the application of the latter to the argument of the composite. ... For other meanings of mathematics or math, see mathematics (disambiguation). ... In computer science, a subroutine (function, method, procedure, or subprogram) is a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code. ... A programming language is an artificial language that can be used to control the behavior of a machine (often a computer). ...


For example, suppose we have two arithmetic functions f and g, as in z = f(x) and y = g(x). One way of composing these two functions would be to first compute y, and then to compute z from y, as in y = g(x) followed by z = f(y). In a programming context, the only obvious difference from mathematics involves notation. Here is the same example but implemented in the C programming language: Partial plot of a function f. ... Wikibooks has a book on the topic of C Programming The C programming language (often, just C) is a general-purpose, procedural, imperative computer programming language developed in the early 1970s by Dennis Ritchie for use on the Unix operating system. ...

 float foo (float x){ float y, z; y=g(x); z=f(y); return(z); } 

One could get the same result with the one line composition in mathematics f(g(x)), by the corresponding one line function in C: Wikibooks has a book on the topic of C Programming The C programming language (often, just C) is a general-purpose, procedural, imperative computer programming language developed in the early 1970s by Dennis Ritchie for use on the Unix operating system. ...

 float foo (float x) {return(f(g(x));} 

Despite differences in length, these two implementations compute the same result (providing their data types are the same). The first implementation, the one having more surface area, is also known as a "single-assignment" form of function composition. This form is useful in the areas of parallel programming and embedding logic onto field programmable gate array devices (see Hammes, et. al). The example above illustrates a type of functional composition known as "sequential composition" (Abadi and Lamport pg 96), since the result of the second function depends on the result of the first. Another type of functional composition known as "parallel composition" (Pierce and Turner pg 2) (Abadi and Lamport pg 96), enables a developer to compose two or more functions so that each runs in parallel on its own separate computer. Data type is a type of data in a type system in computer programming. ... Parallel programming is a computer programming technique that provides for the execution of operations in parallel, either within a single computer, or across a number of systems. ... A field-programmable gate array or FPGA is a gate array that can be reprogrammed after it is manufactured, rather than having its programming fixed during the manufacturing — a programmable logic device. ... Parallel computing is the simultaneous execution of the same task (split up and specially adapted) on multiple processors in order to obtain results faster. ... A Lego RCX Computer is an example of an embedded computer used to control mechanical devices. ...


The second implementation requires only one line of code and is colloquially referred to as a "highly composed" form. Readability and hence maintainability is one advantage of highly composed forms, since they require fewer lines of code, minimizing a program's "surface area" (Cox pp 15-17). DeMarco empirically verifies an inverse relationship between surface area and maintainability (DeMarco pp 133-135). On the other hand, it may be possible to overuse highly composed forms. A nesting of, say, seven (see Miller) or more functions may have the opposite effect, making the code less maintainable.


A related issue is the dilemma of whether to compose (put together) or "factor" (break apart) functions for maintainability and code reuse. A similar dilemma faces Wikipedians as to whether to merge together or to break apart certain articles. In computer science, a subroutine (function, method, procedure, or subprogram) is a portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code. ... A computer programming paradigm in which one writes small bits of code to accomplish a common task. ...


In a functional programming language, such as Haskell, function composition can be expressed in a naturally. The example give above becomes: Haskell is a standardized pure functional programming language with non-strict semantics, named after the logician Haskell Curry. ...

 f . g 

using the composition operator (.) :: (b -> c) -> (a -> b) -> a -> c, which can be read as f after g or g composed with f.


Research Survey

Notions of composition, including the principle of compositionality and composability, are so ubiquitous that numerous strands of research have separately evolved. The following paragraph is a sampling of the kind of research in which the notion of composition is central. In mathematics, semantics, and philosophy of language, the Principle of Compositionality is the principle that the meaning of a complex expression is determined by the meanings of its constituent expressions and the rules used to combine them. ...


Steele directly applied function composition to the assemblage of building blocks known as 'monads' in the Haskell programming language. Bertrand Meyer addressed the software reuse problem in terms of composability. Martín Abadi and Leslie Lamport formally defined a proof rule for functional composition that assures a program's safety and liveness. Marcus Kracht identified a strengthened form of compositionality by placing it into a semiotic system and applying it to the problem of structural ambiguity frequently encountered in computational linguistics. Timothy van Gelder and Robert Port examined the role of compositionality in analog aspects of natural language processing. According to a review by Jeremy Gibbons, formal treatment of composition underlies validation of component assembly in visual programming languages like IBM's Visual Age for the Java programming language. Haskell is a standardized pure functional programming language with non-strict semantics, named after the logician Haskell Curry. ... Bertrand Meyer developed the Eiffel programming language, and is an author, academic and consultant in the field of computer languages. ... A computer programming paradigm in which one writes small bits of code to accomplish a common task. ... Leslie Lamport Dr. Leslie Lamport (born 1941) is an American computer scientist. ... Computational semiotics is an interdisciplinary field that applies, conducts, and draws on research in logic, mathematics, the theory and practice of computation, formal and natural language studies, the cognitive sciences generally, and semiotics proper. ... Look up ambiguity in Wiktionary, the free dictionary. ... Computational linguistics is an interdisciplinary field dealing with the statistical and logical modeling of natural language from a computational perspective. ... Tim van Gelder is an associate professor of philosophy and a fellow of the Philosophy Department at the University of Melbourne. ... Java is an object-oriented programming language developed by James Gosling and colleagues at Sun Microsystems in the early 1990s. ...


References

  • Henry Korn and Albert Liberi, An Elementary Approach to Functions, New York, McGraw-Hill, 1974, ISBN 0-07-035339-5.
  • Hal Daume III, "Yet another Haskell Tutorial", available at http://www.isi.edu/~hdaume/htut/tutorial.pdf.
  • Tom DeMarco and Tim Lister,"Software Development: State of the Art vs. State of the Practice", in Why Does Software Cost So Much, and other puzzles of the Information Age, Tom DeMarco (Ed.), 1995, New York City: Dorset House, ISBN 0-932633-34-X
  • Brad Cox, Object-oriented Programming, an Evolutionary Approach, Reading Mass,:Addison-Wesley, 1986.
  • George Miller, "The Magical Number Seven, Plus or Minus Two: Some Limits on Our Capacity for Processing Information",Psychological Review, 1956, vol. 63, pp. 81-97.
  • Jeffrey Hammes, Bruce Draper, and Willem Böhm, "Sassy: A Language and Optimizing Compiler for Image Processing on Reconfigurable Computing Systems", Proceedings of the International Conference on Vision Systems, Las Palmas de Gran Canaria, Spain, Jan 11-13, 1999.
  • Martín Abadi and Leslie Lamport, "Composing Specifications", ACM Transactions on Programming Languages and Systems, Vol 15. No. 1, January 1993. Pages 73-132.
  • Benjamin C. Pierce and David N. Turner. "Pict: A programming language based on the pi-calculus". Technical report, Computer Science Department, Indiana University, 1997
  • Guy L. Steele, Jr. "Building interpreters by composing monads". In Proceedings of the Twenty-First Annual ACM Symposium on Principles of Programming Languages, Portland, Oregon, January 1994.
  • Bertrand Meyer, Object-oriented Software Construction, New York, Prentice Hall, 1988, pp 13-15, ISBN 0-13-629049-3
  • Marcus Kracht, "Strict Compositionality and Literal Movement Grammars", LNCS, vol. 2014, 2001, pp 126-143.
  • Timothy van Gelder and Robert Port, "Beyond Symbolic: Prolegomena to a Kama-Sutra of Compositionality", Symbol Processing and Connectionist Models in Artificial Intelligence and Cognition: Steps Toward Integration, Vasant Honavar and Leonard Uhr (Eds.), Academic Press, 1993.
  • Jeremy Gibbons, "Towards a Colimit-Based Semantics for Visual Programming", Proceedings of COORDINATION 2002, LNCS 2315, Farhad Arbab and Carolyn Talcott (Eds.), 2002 Springer-Verlag Berlin-Heidelberg, pp. 167-173.

Tom DeMarco is a well-known author, teacher, and speaker on software engineering topics. ... Brad Cox is a computer scientist and Ph. ... Leslie Lamport Dr. Leslie Lamport (born 1941) is an American computer scientist. ... Bertrand Meyer developed the Eiffel programming language, and is an author, academic and consultant in the field of computer languages. ... Tim van Gelder is an associate professor of philosophy and a fellow of the Philosophy Department at the University of Melbourne. ... Professor Vasant Honavar is an American computer scientist, specializing in artificial intelligence. ... Professor Leonard Uhr was an American computer scientist, and one of the early pioneers in computer vision, pattern recognition, machine learning, and cognitive science. ...

See also


  Results from FactBites:
 
Function composition - Wikipedia, the free encyclopedia (530 words)
In mathematics, a composite function, formed by the composition of one function on another, represents the application of the former to the result of the application of the latter to the argument of the composite.
Repeated composition of a function with itself is called function iteration.
Composition operators are studied in the field of operator theory.
  More results at FactBites »


 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m