Feb 14, 2008

Lambda Expression for maximum value.

When I don't use Lambda Expression.

int[] list = { 3, 1, 4, 1, 5, 9, 2 };

int max = 0;

for (int i = 0; i < list.Length; i++)
{
if (max < list[i])
{
max = list[i];
}
}

Console.WriteLine(max);


When I use Lambda Expression.

int[] list = { 3, 1, 4, 1, 5, 9, 2 };

Func fmax = null;
fmax = (l, x, i) => (i == l.Length) ? x : fmax(l, (x > l[i]) ? x : l[i], i + 1);

Console.WriteLine(fmax(list, 0, 0));


I can write functional program with Lambda Expression.

Feb 13, 2008

C# derives from...

C# is C++++.
By the way, the code name of C# was COOL (C like Object Oriented Language).

Feb 12, 2008

(SICP) 1 Building Abstractions with Procedures

I'm trying to read "Structure and Interpretation of Computer Programs" (SICP).
Today, I read "1 Building Abstractions with Procedures".
It's be summarized as follows.
Programming in Lisp is great fun.

Feb 11, 2008

Foreword of SICP.

I'm trying to read "Structure and Interpretation of Computer Programs" (SICP).
Today, I read "Foreword".
It's described about programming, Lisp and so on.

Feb 10, 2008

The SICP Web Site.

We can read "Structure and Interpretation of Computer Programs" (SICP) on web.

Welcome to the SICP Web Site

I'll try to read it.
But I'm not good at English...

Feb 9, 2008

How to read web pages offline on iPhone/iPod touch.

You can read web pages on iPhone/iPod touch when you are offline.

Read Offline for iPhone/iPod touch

This is a bookmarklet.

It's very convenient to read web pages offline.

Feb 8, 2008

Prototype chain of JavaScrit.

Prototype chain is a inheritance system of JavaScript.
Prototype of sub class is instance of base class.


var Person = function() {};
Person.prototype = {
name : "hoge",
toString : function() {
window.alert(this.name);
}
};

var Programmer = function() {};
Programmer.prototype = new Person();

var shunsuk = new Programmer();
shunsuk.name = "shunsuk";
shunsuk.toString();