Posts tagged with ‘functional programming’
Learning with Open Source: Reviewing SVN commits log
kinow @ Feb 10, 2013 13:02:45Tweet
Last year I became an Apache committer, and dedicated most of my time learning the Apache way, reading different mailing lists and getting used to the things a committer is supposed to know (voting process, keeping everything in the mailing list, and so it goes) and getting used to [functor] API.
In 2013 I hope I can help in the release of [functor], since Java and functional programming are getting a lot more of attention recently, probably due to the project lambda. But I also want to start contributing with the other components from commons (like math, io, jcs) and other top level projects (hadoop, nutch, lucene).
Reviewing SVN commits log
FUNCTOR-14 was created to enhance the generators API in [functor]. I’d worked on a branch for this issue, but needed some review in order to be able to merge it with the trunk. That’s where you can see why Open Source is so awesome. Another Apache member, Matt Benson, created another branch to work on the project structure, but also to review the generator API.
( Read more … )
Using Apache Commons Functor functional interfaces with Java 8 lambdas
kinow @ Dec 21, 2012 15:08:14Tweet
Apache Commons Functor (hereon [functor]) is an Apache Commons component that provides a functional programming API and several patterns implemented (visitor, generator, aggregator, etc). Java 8 has several nice new features, including lambda expressions and functional interfaces. In Java 8, lambdas or lambdas expressions are closures that can be evaluated and behave like anonymous methods.
Functional interfaces are interfaces with only one method. These interfaces can be used in lambdas and save you a lot of time from writing anonymous classes or even implementing the interfaces. [functor] provides several functional interfaces (thanks to Matt Benson). It hasn’t been released yet, but there are some new examples in the project site, in the trunk of the SVN. I will use one of these examples to show how [functor] functional interfaces can be used in conjunction with Java 8 lambdas.
After the example with [functor] in Java 8, I will explain how I am running Java 8 in Eclipse (it’s kind of a gambiarra, but works well).
( Read more … )
Ranges in Apache Commons Functor
kinow @ Jan 22, 2012 19:54:36Tweet
This is a long post. So here is a TL;DR:
- Apache Commons Functor has no Double or Float Range (yet)
- Apache Commons Functor IntegerRange and LongRange treat the low value as inclusive, and the high value as exclusive. How does that compare to other languages/APIs? (you will have to read to see some comparison)
- Perl has support for characters ranges, perhaps we could implement it in Functor too?
- In case we implemented a CharacterRange, it would have to be inclusive for both low and high limits. With ‘z’ being the last character, there wouldn’t have a way to include Z with the current approach. Or we would have to make the CharacterRange a special one. What would go against Liskov Substitution Principle.
- You can see a comparison table with Apache Commons Functor, other Java API’s and other programming languages for ranges clicking here.
- It would be nice to have a clear distinction in Functor documentation among a Sequence, a Generator and a Range. While I was gathering material for this post, I found places using range, others using sequence, and in Apache Commons Functor, an IntegerRange is a Generator.
( Read more … )