Feb 7, 2008

Closure of JavaScript and C#.

A closure is a function that is evaluated in an environment containing one or more bound variables.

JavaScript.

function closure(init) {
var cnt = init;

return function() {
return ++cnt;
}
}

var r = closure(10);

alert(r());
alert(r());
alert(r());



C#.

Func<int, Func<int>> closure = init =>
{
int cnt = init;
return () => ++cnt;
};

var r = closure(10);

Console.WriteLine(r());
Console.WriteLine(r());
Console.WriteLine(r());



Output.

11
12
13

Feb 6, 2008

16GB iPhone and 32GB iPod touch.

Macworld | Apple offers 16GB iPhone, 32GB iPod touch

Apple on Tuesday added new models of the iPhone and iPod touch with more storage capacity. The company is now offering a 16GB version of the iPhone for $499, and a 32GB version of the iPod touch for $499. Both new devices are available immediately.


New iPod touch is applied the software update.
It includes five applications and home customize.

Feb 5, 2008

Scheme program for prime numbers.

I wrote a Scheme program that make a list of prime numbers.


(define (prime)
(define (prime-loop n pr)
(define (p? i p)
(if (= (length p) 0)
#t
(if (= (remainder i (car p)) 0)
#f
(p? i (cdr p)))))
(if (<= n 1000)
(prime-loop (+ n 1)
(if (p? n pr)
(append pr (list n))
pr))
pr))
(prime-loop 2 '()))


You write a faster program if you use Sieve of Eratosthenes.
Sieve of Eratosthenes - Wikipedia, the free encyclopedia

Feb 4, 2008

"prototype" of JavaScript.

I decided to learn "prototype" of JavaScript.
Prototype-base object oriented programming seems to be interesting.

Feb 3, 2008

Lambda calculus.

I'm interested in Lambda calculus.
It's too difficult for me.
But I do the best to understand it.

Feb 2, 2008

Many programming languages for .NET.

Many .NET languages are introduced in this page.

.NET Languages

I have used Ruby for .NET.
I'm interesting in Scheme for .NET.

I want to make Scheme.NET.

Feb 1, 2008

Combination of Ruby and Silverlight.

A Ruby CGI program outputs JavaScript for Silverlight.

http://tech.upper.jp/droptext/word/(a word you like)

Example:
http://tech.upper.jp/droptext/word/Hello,%20world%21