Theiling Online    Sitemap    Conlang Mailing List HQ   

Re: what is a loglang?

From:Mark J. Reed <markjreed@...>
Date:Friday, May 7, 2004, 20:20
On Fri, May 07, 2004 at 03:40:35PM -0400, jcowan@REUTERSHEALTH.COM wrote:
> Reducing multi-argument predicates is done by currying (named after > Haskell Curry, nothing to do with curry): we rewrite "father(X,Y)" as > "(father'(X))(Y)".
Currying is perhaps easier to understand in terms of functions than predicates, so let's consider something simple, like addition. A typical functional representation of the addition operation would be a function add(X, Y), which takes two numbers as arguments and returns their sum: add(X, Y) -> X + Y add(3, 2) -> 5 Suppose that instead of a function add(X,Y) which takes two numbers and returns a number, we have a function add'(X) which takes a single number and returns a *function* - which, when called, adds that number to its argument. add'(3) -> add3 (add'(3))(2) -> add3(2) -> 5 Every call to add'(X) with a different value of X returns a (slightly) different function, so we have added the ability to increase our repertoire of functions indefinitely. The system becomes even more powerful when we have functions whose *arguments* can be functions, which return various compositions and other combinations of the argument functions. Imagine that you have a function div(X, Y) which, instead of or in addition to taking two numbers and returning a number, can take two functions and return a function. Then you can define, for instance, tangent as the function returned by div(sine, cosine). The ability to have a function return a function as its value, or take a function as an argument, is the basis of all "higher-level function" work in mathematics and computer science. Lisp, Pascal, C, Perl, etc. programmers will be familiar with the idea of passing around functions (or pointers or references to functions) as data; currying is an extension of that idea. -Mark