Mar. 27th, 2006

juan_gandhi: (Default)

  public <T> Iterable<T> iterate(final Iterator<T> iterator) {
    return new Iterable<T>() {
      public Iterator<T> iterator() {
        return iterator;
      }
    };
  }

java stuff

Mar. 27th, 2006 03:29 pm
juan_gandhi: (Default)
A File, a Url are an Iterables, a stream, a reader are Iterators. A directory is an iterable.

A name is an iterable, a value is an iterator. We need them for lazy evaluation. Encapsulation is a kind of lazy evaluation.
juan_gandhi: (Default)
I know already that in Haskell, the language of the future, it is all expressed as a one-liner.
But there are 2 million poor old Java programmers that are having hard time reading even this; we have to be kind to them. I am one of them.

So, I rewrote sieve again, this time it is a little bit more beautiful.

Note that if sieve() could return a pair (prime, itsnumber), life would be easier. But returning tuples is something Java will never do (probably). (Instead, it has NavigableMap now.)

Read more... )

puzzle

Mar. 27th, 2006 03:51 pm
juan_gandhi: (Default)
1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999 - what is it?

Read more... )

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

September 2025

S M T W T F S
 1 2345 6
78 9 10 111213
14 151617181920
21222324252627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 18th, 2025 02:39 am
Powered by Dreamwidth Studios