Curried Sanskrit, the secret of India's outsourcing success. Obscurity, linux


Those of us who are prefer functional and logic programming look at Sanskrit as the first functional logic language.

After all, which other language has currying as a native word ?

Currying in Functional Languages

Functional languages such as Haskell and ML enjoy the benefits of function currying. Currying is the incomplete application of arguments to a function. For example, in Haskell we could write the function mult which takes two integers and returns their product

mult x y = x * y Evaluating mult 2 6 would yield 12, as expected. To curry a function, one needs only to leave off one or more of the rightmost arguments. (Argument application must occur in a left-to-right order.) Evaluating mult 2 would yield the curried function (mult 2), which is a function of arity 1 (meaning it expects 1 argument). An argument can be applied to this function by evaluating (mult 2) 6, for instance. The inclusion of parentheses is important because it distinguishes the application of one argument to a curried function from the application of two arguments to a non-curried function.

Functions can be built of curried functions as

EDS bullish on India, plans to double workforce over next year
CHENNAI, MAY 13: The $21 billion Electronic Data Systems (EDS) plans to ramp up its employee strength in India to 4,000 from 2,000...

double = mult 2 (or equivalently)

India's outsourcing trend changing the world: SachsAdd to Clippings
NEW DELHI: India is teaching the world a crucial lesson about division of labour - where data from the West is crunched and processed in the East through outsourcing - and that is changing...

double = (*) 2 where (*) is the prefix application of the infix multiplication operator. The expression (2 *) is equivalent to (*) 2, but prefix operators are better for understanding function currying. Evaluating double 6 then yields 12.

 



List | Previous | Next