<?xml version="1.0" encoding="ISO-8859-1"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Bruno P. Kinoshita</title> <atom:link href="http://www.kinoshita.eti.br/feed/" rel="self" type="application/rss+xml" /><link>http://www.kinoshita.eti.br</link> <description>A paulistano geek website</description> <lastBuildDate>Fri, 03 Feb 2012 14:28:24 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Ranges in Apache Commons Functor</title><link>http://www.kinoshita.eti.br/2012/01/22/ranges-in-apache-functor/</link> <comments>http://www.kinoshita.eti.br/2012/01/22/ranges-in-apache-functor/#comments</comments> <pubDate>Sun, 22 Jan 2012 22:54:36 +0000</pubDate> <dc:creator>Bruno Kinoshita</dc:creator> <category><![CDATA[Blog]]></category> <category><![CDATA[Software]]></category> <guid
isPermaLink="false">http://www.kinoshita.eti.br/?p=903</guid> <description><![CDATA[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 [...]]]></description> <content:encoded><![CDATA[<p>This is a long post. So here is a <strong>TL;DR</strong>:</p><ul><li>Apache Commons Functor has no Double or Float Range (yet)</li><li>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)</li><li>Perl has support for characters ranges, perhaps we could implement it in Functor too?</li><li>In case we implemented a CharacterRange, it would have to be inclusive for both low and high limits. With &#8216;z&#8217; being the last character, there wouldn&#8217;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 <a
title="Liskov Substitution Principle" href="http://en.wikipedia.org/wiki/Liskov_substitution_principle">Liskov Substitution Principle</a>.</li><li>You can see a comparison table with Apache Commons Functor, other Java API&#8217;s and other programming languages for ranges clicking <a
href="#ctable" title="Comparison table">here</a>.</li><li>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.</li></ul><p>Now, if you have some spare time or curiosity, keep reading <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p><p><span
id="more-903"></span></p><p>This post is about ranges in <a
title="Apache Commons Functor" href="http://commons.apache.org/sandbox/functor/">Apache Commons Functor</a> but first let me explain the context. I am working on <a
title="nebular Java Fuzzy API" href="http://nebular.sourceforge.net/">nebular</a>, an open source fuzzy logic API. This API is written in pure Java, and has <a
title="Matlab Fuzzy Toolbox" href="http://www.mathworks.com/products/fuzzy-logic/index.html">Matlab Fuzzy Toolbox</a> as reference for the initial release. Nebular will use functional programming to let the user to model his/her membership functions. The API chosen for functional programming is Apache Commons Functor.</p><p>Yesterday I finished to port <a
title="Matlab sigmf membership function" href="http://www.mathworks.com/help/toolbox/fuzzy/sigmf.html">sigmf</a> function to nebular, including some tests that compare nebular&#8217;s output to Matlab sigmf function. However, here comes the issue with ranges, sequences and generators. The idea is to plot a graph similar to the one below.</p><p
style="text-align: center;"><a
href="http://www.kinoshita.eti.br/wp-content/uploads/2012/01/sigmf.gif" rel="lightbox[903]" title="sigmf"><img
class="aligncenter size-medium wp-image-904" title="sigmf" src="http://www.kinoshita.eti.br/wp-content/uploads/2012/01/sigmf-300x160.gif" alt="" width="300" height="160" /></a></p><p>The x axis contains values from 0 to 10, increasing by 0.1. In Matlab, I would execute the following command to produce the x vector.</p><pre class="brush: python; title: ; notranslate">x = 0:0.1:10;</pre><p>The : is the range operator in Matlab. It would create a vector with 101 elements. Yup, 101. That&#8217;s because in Matlab the low and high value used creating the range are inclusive. Now let&#8217;s look at how I create similar vector in Apache Commons Functor.</p><pre class="brush: java; title: ; notranslate">IntegerRange range = new IntegerRange(0, 11, 1 /* step */);</pre><p>So now one can realize two things: there is no Double or Float Range, and the high value in the range is exclusive. It means that in order to create an array (I will use vector and array interchangeably here for simplicity) with Functor from 0 to 10, including both values, you have to create a range using 0 and 11.</p><h3>Comparing with other Java functional programming API&#8217;s</h3><p>There are other API&#8217;s to include functional programming features to Java code. In this comparison I will include <a
title="Google Guava" href="http://code.google.com/p/guava-libraries/">Google Guava</a>, <a
title="fun4J" href="http://www.fun4j.org/">fun4j</a>, <a
title="Functional Java" href="http://functionaljava.org/">functionaljava</a>, <a
title="lambdaj" href="http://code.google.com/p/lambdaj/">lambdaj</a> and <a
title="op4j" href="http://www.op4j.org/">op4j</a> (got the list from the fun4f project page).</p><h4>Google Guava</h4><p>Google Guava provides the Range and Ranges classes. The Ranges contains several static methods for creating Range&#8217;s, that can be used as collections. The Ranges class contains methods for creating Range&#8217;s with open, closed, openClosed and closedOpen intervals.</p><pre class="brush: java; title: ; notranslate">public static void main(String[] args) {
 Range&lt;Integer&gt; values = Ranges.closed(0, 10);
 System.out.print(&quot;[ &quot;);
 for(Integer value : values.asSet(DiscreteDomains.integers())) {
 System.out.print(value + &quot; &quot;);
 }
 System.out.print(&quot;]&quot;);
 }</pre><pre class="brush: python; title: ; notranslate">[ 0 1 2 3 4 5 6 7 8 9 10 ]</pre><p>The Google Guava API does not provide a way to create ranges of floats. And I will have to find some time to read about the asSet method and on discrete domains. I am much more comfortable putting Apache Commons Functor API in my code for creating ranges. Specially since it makes the code more readable and easy to understand, helping to receive contributions in nebular from newcomers.</p><h4>fun4j</h4><p>fun4j contains classes to model functions, lambdas and bind LISP code to Java. However it has no objects for ranges.</p><h4>functionaljava</h4><p>Although there is the <a
title="Functional Java Seq class" href="http://code.google.com/p/functionaljava/source/browse/trunk/src/main/fj/data/Seq.java?r=358">Seq</a> class, I don&#8217;t know if that can be used for Ranges. So I will have to skip functionaljava <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /></p><h4>lambdaj</h4><p>Couldn&#8217;t find a way to create ranges with lambdaj. Not sure if they support it or not.</p><h4>op4j</h4><p>Same as lambdaj, couldn&#8217;t find a way to create ranges with op4j. Not sure if they support it or not.</p><h3>Comparing with other programming languages</h3><p>So let&#8217;s see how we could generate a similar array using other programming languages.</p><h4>Python</h4><p>Python is one of my favorite languages, and has some functional programming features [1]. However it has no built-in mechanism for ranges with floats, only with integers. The functions that I know in Python use low value as inclusive, and high value as exclusive. The built in range functions in 2.7 looks like the following.</p><pre class="brush: python; title: ; notranslate">x = range(0, 11, 1) #inclusive/exclusive
print x;
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</pre><p>Or you could write something like (remember Perl&#8217;s motto, TIMTOWTDI [2])</p><pre class="brush: python; title: ; notranslate">x = [x * 0.1 for x in range(0, 101)]; #inclusive/exclusive
print len(x);
 print x;
101
 [0.0, 0.1, 0.2, 0.30000000000000004, 0.4, ..., 10.0]</pre><p>There are API&#8217;s in Python too, like numpy, that has arange. However it is complicated specify a range to give similar array as the one produced by Matlab.</p><pre class="brush: python; title: ; notranslate">from numpy import arange;
x = arange(0, 10.1, .1); #inclusive/exclusive
print len(x);
 print x;
101
 [ 0. 0.1 0.2 ... 10.0]</pre><h4>Perl</h4><p>As we mentioned Perl in last section, let&#8217;s see how it works in Perl. First of all, I won&#8217;t use many modules here. Probably Perl is the language with more modules, or at least with a plethora of modules in <a
title="CPAN" href="http://www.cpan.org">CPAN</a> (wait to see <a
title="CJAN" href="http://www.cjan.org">CJAN</a> <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . There are books on Perl and Functional programming [3], and Perl has a built in mechanism for ranges. I used Perl 5 built in range operator and List::Gen range function. Both use the low and high value inclusive. It&#8217;s important to point out that Larry Wall and the programmers behind Perl are always keeping an eye on usability, ease of use, and Larry&#8217;s laziness. So that&#8217;s why Perl is a good language for comparisons of this type.</p><pre class="brush: perl; title: ; notranslate">#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
print &quot;[ &quot;;
for(0..10) { #inclusive/inclusive
 print $_, &quot; &quot;;
}
print &quot; ]&quot;</pre><pre class="brush: python; title: ; notranslate">[ 0 1 2 3 4 5 6 7 8 9 10 ]</pre><p>Or to use floats, we could use <a
title="List::Gen" href="http://search.cpan.org/dist/List-Gen/">List::Gen</a> module.</p><pre class="brush: perl; title: ; notranslate">#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use List::Gen;
my $range = range 0, 10, 0.1; #inclusive/inclusive
print &quot;[ &quot;;
print $_, &quot; &quot; for @$range;
print &quot; ]&quot;</pre><pre class="brush: python; title: ; notranslate">[ 0 0.1 0.2 0.3 0.4 ... 10 ]</pre><p>Perl also has support to range of characters. Look at the examples from Perldoc.</p><pre class="brush: perl; title: ; notranslate"> @alphabet = (&quot;A&quot; .. &quot;Z&quot;); # inclusive/inclusive... how would it work if the last argument was not inclusive?
</pre><p>That would be cool if Functor had this feature too <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p><h4>Scala</h4><p>Scala is a language that runs on the Java Virtual Machine, it has some functional programming features as anonymous functions, higher order functions, among others. It has a built in mechanism for ranges with integers or floats. It uses the low value as inclusive, and the high value as exclusive, however when using floats you may have trouble if you don&#8217;t pay attention to float precision.</p><pre class="brush: java; title: ; notranslate">object Test {
def main(args: Array[String]) {
var range = 0.0 until 10.0 by 0.1;
println(range);
}
}</pre><p>&nbsp;</p><pre class="brush: python; title: ; notranslate">NumericRange(0.0, 0.1, 0.2, ..., 9.99999999999998)</pre><h4>Matlab</h4><p>Why, yes sir, we will compare Matlab too. It has built in operator for ranges, and both values, low and high, are inclusive.</p><pre class="brush: python; title: ; notranslate">x=0:0.1:10;
display(x);
x =
Columns 1 through 9
0 0.1000 ...
... 10.0000
</pre><h4>PHP</h4><p>Although famous for its web applications, PHP can be an interesting language for scripting or creating handy utilities. I may be wrong, but I believe the scm_bot in Jenkins project, that posts messages to JIRA when someone commits to a SCM with a special string, is written in PHP. It has a built in function for ranges in 5.3, and both values are inclusive.</p><pre class="brush: php; title: ; notranslate">$range = range(0, 10, 0.1);
 echo &quot;[ &quot;;
 foreach($range as $number) {
 echo $number . &quot; &quot;;
 }
 echo &quot;]&quot;;
[ 0 0.1 0.2 0.3 ... 9.9 10 ]
</pre><h4>Haskell</h4><p>Haskell has gained more attention lately with web frameworks. It has features such as monads, functors and high order function. And also has a built-in range operator. Both, left and right values of the range are inclusive in Haskell&#8217;s range operator.</p><pre class="brush: python; title: ; notranslate">[0 .. 10]
=&gt; [0,1,2,3,4,5,6,7,8,9,10]</pre><p>Unfortunately I don&#8217;t know Haskell so well, and couldn&#8217;t make it work with floats, nor find out whether it is possible or not <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /></p><h4>lua</h4><p>While lua has no built-in support to ranges, if you search for lua and range functions or operators, probably you will find an entry in lua&#8217;s Wiki with a range function, contributed by a user. The function implemented uses the low and high value inclusively and has support for both integer and floats.</p><pre class="brush: cpp; title: ; notranslate">-- http://lua-users.org/wiki/RangeIterator
function range(from, to, step)
 step = step or 1
 return function(_, lastvalue)
 local nextvalue = lastvalue + step
 if step &gt; 0 and nextvalue &lt;= to or step &lt; 0 and nextvalue &gt;= to or
 step == 0
 then
 return nextvalue
 end
 end, nil, from - step
end
function f() return 0, 10, 0.1 end
io.write(&quot;[ &quot;);
for i in range(f()) do
 io.write(i, &quot; &quot;)
end
io.write(&quot;]&quot;);</pre><pre class="brush: python; title: ; notranslate">[ 0 0.1 0.2 0.3 ...  9.9 10 ]</pre><h4>LISP</h4><p>Lisp is probably one of the oldest programming languages with functional features. Every time I read something about functional programming and collections it reminds me of Lisp recursion with lists. In Lisp you can use loop to iterate over a range of integers or floats, and both values are included for integers, for float, there is some precision problem that I couldn&#8217;t overcome. For integers the following code would do.</p><pre class="brush: python; title: ; notranslate">&gt;(loop for i from 0 to 10 do (print i))
0
1
2
...
10
NIL</pre><p>And for floats.</p><pre class="brush: python; title: ; notranslate">&gt;(loop for i from 0.0 to 10.0 by 0.1 do (print i))
0.0
0.1
0.2
...
9.900002
NIL</pre><p>Again, issues with precision.</p><h4>Clojure</h4><p>Although Clojure is quite similar to LISP, I had some trouble setting up an example for this. My first try was with loop, but as it didn&#8217;t work, I used dorun. It uses the low value as inclusive, and the high value as exclusive. Strange, I thought it would have similar behavior to the loop in LISP. But I only know the very basics of each language, and the explanation is beyond my knowledge. Anyway, it&#8217;s interesting I guess.</p><pre class="brush: python; title: ; notranslate">(dorun (for [i (range 0 10 1)] (println i)))
0
1
...
9
nil</pre><h3><a
name="ctable">Comparison Table</a></h3><p>To simplify the understanding, here is a comparison table.</p><style type="text/css">table {
border: 1px solid #CCCCCC;
}
table tr {
border: 1px solid #CCCCCC;
}
table tr th {
border: 1px solid #EEEEEE;
background-color: #CCCCCC;
}
table tr td {
border: 1px solid #CCCCCC;
}</style><div
class="column span-17" style="overflow: auto;border: 1px solid #CCCCCC;"><table
border="0" cellspacing="0" cellpadding="0" class="ta1"><colgroup><col
width="180"/><col
width="130"/><col
width="134"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="135"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="99"/><col
width="99"/></colgroup><tr
class="ro1"><th
style="text-align:left;width:1.6252in; " class="Default"> </th><th
style="text-align:left;width:1.1728in; " class="Default"><p>Apache Commons Functor</p></th><th
style="text-align:left;width:1.2047in; " class="Default"><p>Google Guava</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>fun4j</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>functionaljava</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>lambdaj</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>op4j</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>Python</p></th><th
style="text-align:left;width:1.2161in; " class="Default"><p>Python – numpy.arange</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>Perl</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>Perl List::Gen</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>Scala</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>Matlab</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>PHP</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>Haskell</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>lua (Wiki contrib)</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>LISP</p></th><th
style="text-align:left;width:0.8925in; " class="Default"><p>Clojure</p></th></tr><tr
class="ro1"><td
style="text-align:left;width:1.6252in; " class="Default"><p>Integer range</p></td><td
style="text-align:left;width:1.1728in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:1.2047in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:1.2161in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td></tr><tr
class="ro1"><td
style="text-align:left;width:1.6252in; " class="Default"><p>Float range</p></td><td
style="text-align:left;width:1.1728in; " class="Default"><p>NO</p></td><td
style="text-align:left;width:1.2047in; " class="Default"><p>NO</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>NO</p></td><td
style="text-align:left;width:1.2161in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>NO</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>NO?</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>NO?</p></td></tr><tr
class="ro1"><td
style="text-align:left;width:1.6252in; " class="Default"><p>Includes low limit</p></td><td
style="text-align:left;width:1.1728in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:1.2047in; " class="Default"><p>YES/NO</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:1.2161in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td></tr><tr
class="ro1"><td
style="text-align:left;width:1.6252in; " class="Default"><p>Includes high limit</p></td><td
style="text-align:left;width:1.1728in; " class="Default"><p>NO</p></td><td
style="text-align:left;width:1.2047in; " class="Default"><p>YES/NO</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>N/A</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>NO</p></td><td
style="text-align:left;width:1.2161in; " class="Default"><p>NO</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>NO</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>YES?</p></td><td
style="text-align:left;width:0.8925in; " class="Default"><p>NO</p></td></tr></table></div><hr
class="space" /><p>That&#8217;s it, I will ping some guys from Apache dev-list to see what they think about the bullets in TL;DR. After writing this post I realized I need to change this blog&#8217;s layout to give more space for code and tables <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /></p><p>Cheers</p><p>[1] <a
href="http://docs.python.org/howto/functional.html">http://docs.python.org/howto/functional.html</a></p><p>[2] <a
href="http://c2.com/cgi/wiki?ThereIsMoreThanOneWayToDoIt">http://c2.com/cgi/wiki?ThereIsMoreThanOneWayToDoIt</a></p><p>[3] <a
href="http://perl.plover.com/yak/fp/">http://perl.plover.com/yak/fp/</a></p> <a
class="wpptopdf" target="_blank" rel="noindex,nofollow" href="http://www.kinoshita.eti.br/2012/01/22/ranges-in-apache-functor/?format=pdf" title="Download PDF"><img
alt="Download PDF" src="http://www.kinoshita.eti.br/wp-content/plugins/wp-post-to-pdf/asset/images/pdf.png"></a>]]></content:encoded> <wfw:commentRss>http://www.kinoshita.eti.br/2012/01/22/ranges-in-apache-functor/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Testing shell code and producing TAP using Jenkins?</title><link>http://www.kinoshita.eti.br/2011/12/30/testing-shell-code-and-producing-tap-using-jenkins/</link> <comments>http://www.kinoshita.eti.br/2011/12/30/testing-shell-code-and-producing-tap-using-jenkins/#comments</comments> <pubDate>Sat, 31 Dec 2011 01:41:40 +0000</pubDate> <dc:creator>Bruno Kinoshita</dc:creator> <category><![CDATA[Blog]]></category> <category><![CDATA[Hudson]]></category> <category><![CDATA[TAP]]></category> <category><![CDATA[Testing]]></category> <guid
isPermaLink="false">http://www.kinoshita.eti.br/?p=880</guid> <description><![CDATA[Definitely reading Hacker News before going to bed is a bad idea Same goes for Reddit. So, I found a link about Bats, a tool to execute tests in Shell and output TAP &#8211; Test Anything Protocol. Then I thought; why not ask the author to include Bats under the list of Producers in testanything.org? [...]]]></description> <content:encoded><![CDATA[<p>Definitely reading <a
title="Hacker News" href="http://news.ycombinator.com/">Hacker News</a> before going to bed is a bad idea <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> Same goes for <a
title="Reddit" href="http://www.reddit.com">Reddit</a>. So, I found a link about <a
title="Bats" href="https://github.com/sstephenson/bats">Bats</a>, a tool to execute tests in Shell and output <a
title="Test Anything Protocol" href="http://testanything.org">TAP</a> &#8211; Test Anything Protocol. Then I thought; why not ask the author to include Bats under the list of <a
title="TAP Producers" href="http://testanything.org/wiki/index.php/TAP_Producers#SH_.2F_Shell_Script">Producers</a> in <a
title="Test Anything Protocol" href="http://testanything.org">testanything.org</a>?</p><p>But you know what? Why not execute execute locally first to check if that&#8217;s working&#8230; moreover, why not use <a
title="Jenkins TAP Plug-in" href="https://wiki.jenkins-ci.org/display/JENKINS/TAP+Plugin">Jenkins TAP Plug-in</a> and see what happens?</p><p>Here&#8217;s what is necessary.</p><ul><li><a
title="Jenkins CI" href="http://www.jenkins-ci.org">Jenkins</a> (duh)</li><li><a
title="Jenkins TAP Plug-in" href="https://wiki.jenkins-ci.org/display/JENKINS/TAP+Plugin">tap plug-in</a></li><li><a
title="Jenkins Git Plugin" href="https://wiki.jenkins-ci.org/display/JENKINS/git+Plugin">git plug-in</a></li><li><a
title="Bast git repository" href="https://github.com/sstephenson/bats">Bats git repository URL</a></li><li><a
title="Baden Baden" href="http://www.badenbaden.com.br/">Baden Baden Red Ale beer</a> (it&#8217;s Friday, almost new years&#8217; eve, c&#8217;mon)</li></ul><p>Install Jenkins, tap plug-in and git plug-in. Create a new free style build. Add Bats git repository url under SCM. This way Jenkins will retrieve Bats code from Github (you don&#8217;t need to install it if you don&#8217;t want to). Add a build step which executes the following shell code: <tt>./bin/bats test/bats.bats &gt; test.t</tt></p><p
style="text-align: center;"><a
href="http://www.kinoshita.eti.br/wp-content/uploads/2011/12/Screenshot-at-2011-12-30-233256.png" rel="lightbox[880]" title="Screenshot at 2011-12-30 23:32:56"><img
class="size-medium wp-image-883 aligncenter" title="Screenshot at 2011-12-30 23:32:56" src="http://www.kinoshita.eti.br/wp-content/uploads/2011/12/Screenshot-at-2011-12-30-233256-300x198.png" alt="" width="300" height="198" /></a></p><p>Before executing the build, you have to check the option to publish TAP results in the end of the configuration screen. That&#8217;s it. Execute your job, chug the remaining of your beer and now you can go to bed&#8230; or just refresh Hacker News and Reddit once more&#8230;</p><p
style="text-align: center;"><a
href="http://www.kinoshita.eti.br/wp-content/uploads/2011/12/Screenshot-at-2011-12-30-233313.png" rel="lightbox[880]" title="Screenshot at 2011-12-30 23:33:13"><img
class="size-medium wp-image-884 aligncenter" title="Screenshot at 2011-12-30 23:33:13" src="http://www.kinoshita.eti.br/wp-content/uploads/2011/12/Screenshot-at-2011-12-30-233313-300x198.png" alt="" width="300" height="198" /></a></p><p
style="text-align: center;"><a
href="http://www.kinoshita.eti.br/wp-content/uploads/2011/12/Screenshot-at-2011-12-30-233323.png" rel="lightbox[880]" title="Screenshot at 2011-12-30 23:33:23"><img
class="aligncenter size-medium wp-image-894" title="Screenshot at 2011-12-30 23:33:23" src="http://www.kinoshita.eti.br/wp-content/uploads/2011/12/Screenshot-at-2011-12-30-233323-300x198.png" alt="" width="300" height="198" /></a></p><p>Bats is a very nice TAP producer for Shell. Haven&#8217;t had time to play with the other producers for Shell, or explore Bats thoroughly, but it looks very promising. Hope to see more people writing tests for shell code.</p><p>Cheers -B</p> <a
class="wpptopdf" target="_blank" rel="noindex,nofollow" href="http://www.kinoshita.eti.br/2011/12/30/testing-shell-code-and-producing-tap-using-jenkins/?format=pdf" title="Download PDF"><img
alt="Download PDF" src="http://www.kinoshita.eti.br/wp-content/plugins/wp-post-to-pdf/asset/images/pdf.png"></a>]]></content:encoded> <wfw:commentRss>http://www.kinoshita.eti.br/2011/12/30/testing-shell-code-and-producing-tap-using-jenkins/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Listing of current projects, achievements and my New Year&#8217;s resolutions</title><link>http://www.kinoshita.eti.br/2011/12/24/listing-of-current-projects-achievements-and-my-new-years-resolutions/</link> <comments>http://www.kinoshita.eti.br/2011/12/24/listing-of-current-projects-achievements-and-my-new-years-resolutions/#comments</comments> <pubDate>Sat, 24 Dec 2011 17:08:56 +0000</pubDate> <dc:creator>Bruno Kinoshita</dc:creator> <category><![CDATA[Blog]]></category> <category><![CDATA[Software]]></category> <guid
isPermaLink="false">http://www.kinoshita.eti.br/?p=873</guid> <description><![CDATA[Tis&#8217; the end of 2011! Yay! Throughout this year I&#8217;ve heard people repeatedly saying that I had too much on my plate, and that I should quit some projects, stop giving talks, start surfing again amongst other things. Now, looking back, although I&#8217;m quite happy with my achievements in 2011, I can see their point. [...]]]></description> <content:encoded><![CDATA[<p>Tis&#8217; the end of 2011! Yay! Throughout this year I&#8217;ve heard people repeatedly saying that I had too much on my plate, and that I should quit some projects, stop giving talks, start surfing again amongst other things. Now, looking back, although I&#8217;m quite happy with my achievements in 2011, I can see their point.</p><p>In 2010 I started working as Software Quality Engineer with <a
title="Anderson Santos" href="http://andersonxp.tumblr.com/">Anderson Santos</a>. He was the greatest supporter of many of my ideas, so although we stopped working together in 2011, I&#8217;m still grateful to him for all he taught, for his advices and for spending some time guiding me.</p><p>He motivated me to start giving talks, going to more conferences and contributing more actively to Open Source projects. Since then, I&#8217;ve given almost 10 talks, including one in <a
title="Belgium Testing Days" href="http://www.belgiumtestingdays.com">Belgium Testing Days</a>, another one in<a
title="Oracle JavaOne" href="http://www.oracle.com/javaone/lad-pt/"> Oracle JavaOne</a> and in March next year I will be in America for a talk in <a
title="STP Con" href="http://www.stpcon.com/">STPCON</a>. I also missed <a
title="JCertif" href="http://www.jcertif.com">JCertif</a> conference in Congo due to visa problems and learned some lessons from it (so sorry Max <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>I&#8217;ve also joined few Open Source projects, including <a
title="TestLink" href="http://www.teamst.org">TestLink</a>, <a
title="Jenkins CI" href="http://www.jenkins-ci.org">Jenkins</a>, created <a
title="tap4j" href="http://www.tap4j.org">tap4j</a>, <a
title="TestLink Java API" href="http://testlinkjavaapi.sourceforge.net">testlink-java-api</a>, Jenkins <a
title="Jenkins CCM Plug-in" href="http://wiki.jenkins-ci.org/display/JENKINS/CCM+Plugin">CCM</a>, <a
title="Jenkins TestLink Plug-in" href="http://wiki.jenkins-ci.org/display/JENKINS/TestLink+Plugin">TestLink</a> and <a
title="Jenkins TAP Plug-in" href="http://wiki.jenkins-ci.org/display/JENKINS/TAP+Plugin">TAP</a> plug-ins. Was included as contributor to <a
title="Apache Functor" href="http://commons.apache.org/sandbox/functor/">Apache Functor</a> project due to some minor contributions. And what is the most important thing: I had a lot of fun doing all of this! And learned so much!</p><p>There are also the articles! About ten papers, for German, American and Brazilian computer magazines. Most of them written in English (I still have a lot to learn, I know). This helped me to achieve IELTS 7 band score few days ago!</p><p>I&#8217;ve also completed three years since I met Cibele, and probably will be a proud husband in 2012 <img
src='http://www.kinoshita.eti.br/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> Couldn&#8217;t have done none of these items mentioned here without her by my side. As well as friends like <a
title="Cesar Fernandes" href="http://cesinha.com">Cesar Fernandes</a> and <a
title="Brian Patrick Bourke Lattes" href="http://buscatextual.cnpq.br/buscatextual/visualizacv.do?metodo=apresentar&amp;id=S4337403&amp;tipo=completo&amp;idiomaExibicao=2">Brian P. Bourke</a>. Thanks mates!</p><p>In 2011 I jumped parachutes for the very first time, started practicing slack line, surfing, climbing, went to Europe and Africa for the first time. And I started drawing again! Even illustrated two of my articles.</p><p>Finally, I&#8217;m founding <a
title="TupiLabs" href="http://www.tupilabs.com">TupiLabs</a> with Cesar Fernandes. It&#8217;ll be a company to work and create solutions using other Open Source tools (Hadoop, Biojava, TestLink, Jenkins, Chef, Apache, etc). Although there are plenty companies like that in US and Europe, there ain&#8217;t many here in Brazil and South American in general; yet! We are still finishing some projects to release in January 2012 together with a new TupiLabs website.</p><p>Righto so&#8230; what&#8217;s next for 2012? Here is a list of my current projects, followed by my new year&#8217;s resolution list for 2012.</p><p>Current projects (or short time TODO list)</p><ul><li>Fix Jenkins TestLink Plug-in issues</li><li>Update Jenkins TestLink Plug-in documentation</li><li>Finish some issues (includes testing) in TestLink</li><li>Enhance reporting in TestLink</li><li>Enable themes and templates in TestLink</li><li>Document TestLink XML-RPC API (with Andre and Mario Fuentes)</li><li>Propose a DocBook for TestLink documentation</li><li>Release a new version of CCM plug-in</li><li><del>Finish first public project of TupiLabs (PHP website using CodeIgniter)</del> @see <a
title="Garagem Vaga" href="http://www.garagemvaga.com.br">www.garagemvaga.com.br</a>, a website to find and rent parking places</li><li>Update GoogleTest TAP Listener (create configure, makefile, test with trunk version)</li><li>Rewrite tap4j parser as a recursive descent parser, like SnakeYAML&#8217;s one. So the user will be able to see the line + column of the error, as well as the next expected production.</li><li><del>Write a parser for MrBayes blocks in BioJava phylo module.</del> @see <a
href="https://github.com/biojava/biojava-legacy/pulls">https://github.com/biojava/biojava-legacy/pulls</a></li><li>Write set of bioinformatics plug-ins for Jenkins and tools, to enable any ordinary computer user to create his/her biology workflow system (I&#8217;m calling this project temporarily BioUno)</li><li>Finish to set up my home Beowulf cluster (have to go to St. Efigenia to buy the missing boards and cables)</li><li>Finish presentation for STPCon</li><li>Send two contributions for GMapEz (first one is the dynamically add markers, second is an option to expose globally the GMap2 object, useful when the map is not automatically rendered on the page)</li><li><del>Finish writing Nebular, a pure Java fuzzy API, which will support traditional fuzzy logic, as well as Type2 Fuzzy Logic. It will use Apache Functor and Apache Math.</del></li><li><del>Contribute to Apache Functor with more tests, address each item pointed by Emmanuel Bourg during vote for release 1.0 in the mailing list.</del></li></ul><p>And for 2012:</p><ul><li>Parachutes course and international license</li><li>Diving license</li><li>Become an Apache committer</li><li>Deploy a biology workflow system using Jenkins and a cloud provider (Amazon?, CloudBees?, Heroku?, OpenStack?, &#8230;) in a national university</li><li>Take this biology deployment to Kumamoto (my family&#8217;s province in Japan), with the help of Sao Paulo Kumamoto Kenjinkai</li><li>Catch a fish with more than 20 kilos</li><li>Add Fuzzy Logic to Jenkins, using Nebular</li><li><del>Become a part time illustrator</del></li><li>Make more plushes</li><li>Play guitar, bodhran and whistles more regularly</li><li>Take some classes in Irish dancing (looks like there is a <a
title="Irish Dancing" href="http://www.irishdancebrasil.blogspot.com/">place</a> in Sao Paulo&#8230;)</li><li>Go to <a
title="Naga Cable Park" href="http://nagacp.com.br/">Naga Cable Park</a> in Jaguariuna to practice wake board.</li><li>Surf more regularly</li><li>Buy a slack line and find a place to practice more frequently</li><li><del>Go back to Nihongaku</del> 13.Jan &#8211; Am now taking private classes with Fukuda Sensei in a Starbucks near Paraiso station, yay!</li><li>Learn more! The more I read and learn, the more I realize I still need to learn :-O</li><li><del>Have <a
title="TupiLabs" href="http://www.tupilabs.com">TupiLabs</a> as only job, not as a side project anymore</del></li><li>Go to Chile. They have good wine and I would like to check out one of the best places to live in South America</li></ul><p>See you in 2012!</p><p>Cheers, -B</p> <a
class="wpptopdf" target="_blank" rel="noindex,nofollow" href="http://www.kinoshita.eti.br/2011/12/24/listing-of-current-projects-achievements-and-my-new-years-resolutions/?format=pdf" title="Download PDF"><img
alt="Download PDF" src="http://www.kinoshita.eti.br/wp-content/plugins/wp-post-to-pdf/asset/images/pdf.png"></a>]]></content:encoded> <wfw:commentRss>http://www.kinoshita.eti.br/2011/12/24/listing-of-current-projects-achievements-and-my-new-years-resolutions/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic
Object Caching 513/553 objects using disk: basic

Served from: www.kinoshita.eti.br @ 2012-02-08 15:59:29 -->
