JavaBeat
Search JavaBeat

Groovy Links
Groovy
Groovy Articles
Groovy News
Groovy Books
JavaBeat
Home
Articles
Tips
Code
QnA
Forums

Groovy, functional programming and the curry method


I'm sure you have heard of functional programming, at least when you were sill a student (if you are, then you're probably digging into it). The Groovy language, built on top of Java, provides means of dealing with functional programming. Moreover, it offers a curry method which allows powerful recursion mechanisms.

For example, in maths, you'll want to define the sum function of a list as the sum of the first element and the (recursive) sum of the rest of the list. Going further, you'll want to define a meta function which defines the behaviour of the sum method :

f(x1, x2, ...) = f(x1, f(x2, ...))

That's currying. Here's a basic example which demonstrates this feature in Groovy. First, let's define a reduce closure which takes as the first argument the function to be applied on the list of arguments :

Read full article here

Read the full article here

Sponsors
Webmaster Hosting Forum
Java Jobs
MyVideoLib
India News
Internet Advances
Latest QnA
SCJD Tips
When we start a thread by applying start() method on it ,how does it knows that to execute run()method?
About Wrapper class in Java
How to configure weblogic 7.0 in MyEclipse?
Static Block and Static Initializer in Java

JavaBeat Media (2004-2008), India
javabeat | planetoss | links directory | advertise
Copyright (2004 - 2008), JavaBeat