Welcome to uiboss.com on July 10 2009.
This is an internet experiment running to monitor browsing habbits of individuals through wikipedia contents.

Tacit programming

From Wikipedia, the free encyclopedia

Jump to: navigation, search

Tacit programming is a programming paradigm in which a function definition does not include information regarding its arguments, using combinators and function composition (but not λ-abstraction) instead of variables. The simplicity behind this idea allows its use on several programming languages, such as J programming language and APL. Outside of the APL and J communities, tacit programming is referred to as point-free style[1], or more pithily as pointless programming. This is because of the relation between how definitions are done in pointless topology and how they are done in this style.

The key idea in tacit programming is to assist in operating at the appropriate level of abstraction. That is, to translate the natural transformation given by currying:

 \hom(A\times B, C) \equiv \hom(A,\hom(B,C))

into computer functions, where the left represents the uncurried form of a function and the right the curried.

Contents

[edit] Examples

[edit] Functional Programming

A simple example (in Haskell) is a program which takes a sum of a list. A programmer might define a sum recursively using a pointed method as:

sum (x:xs) = x + (sum xs)
sum [] = 0

However by noting this is a fold the programmer could replace this with:

 sum xs = foldr (+) 0 xs

and then the argument is not needed so this can be replaced with

 sum  = foldr (+) 0

which is point-free.

Another example is the use of the dot operator

p x y z = f (g x y) z

we can simple group

f (g x y) z = f ((g x) y) z = (f .) (g x) y z = ((f .) . g) x y z

so

p = (f .) . g

Finally to see a complex example imagine a map filter program which: takes a list, applies a function to it and then filters the elements based on a criteria

mf criteria operator list = filter criteria (map operator list)

can be expressed point-free[2] as

mf = (. map) . (.) . filter 

[edit] APL (family)

In J one can see the same sort of point-free code in a function designed to compute the average of a list (array) of numbers:

 avg=: +/ % #

# counts the number of items in the array. +/ sums the items of the array. % divides the sum by the number of items

[edit] Stack Based

In stack-oriented programming languages point-free methods are often commonly used. For example a procedure to compute the Fibonacci numbers might look like:

/fib
{
   dup dup 1 eq exch 0 eq or not
   {
      dup 1 sub fib
      exch 2 sub fib
      add
   } if
} def

[edit] See also

[edit] References

  1. ^ "Pointfree". HaskellWiki. http://www.haskell.org/haskellwiki/Pointfree. Retrieved on 2008-05-09. 
  2. ^ pipermill

[edit] External links

Personal tools

Visit joltnews for the latest headlines
Visit bloit.com for company information
Geed Media does computer consulting on long island.
This page viewed times. See Logs