From chapter 2, we begin to learn about represent data in Scheme. It's quite different from non-functional languages.
I get two ways of deal with data:
1. use cons/car/cdr.
2. use procedures.
The first one is more or less 'normal', while using procedures to represent data kind of startles me :)
The second method shows the power of lisp (again) and it proves to be a good exercise for my brain. And, it's elegant, surely.
However, both methods appear too primitive, maybe in the futher there will be something more advanced, like the 'list' in the name of lisp?
What is 'data'?
This is an excellent question from section 2.1.23-
The author defines data to be something defined by some procedures, which have to and only have to fulfill some given conditions.
Then they give a surprising definition of 'pair', the procedural representation of pairs.
In the end, some points are given, like:
procedural representations of data will play a central role in our programming repertoire. This style of programming is often called message passing.

0 comments:
Post a Comment