theclapp

Search theclapp.blog-city.com

 

Chapter 4, ex 4

posted Monday, 13-Jan-2003
4.4, Java version
---
// ch04_ex03.java

class ch04_ex04 {
public static void main(String[] args) {
ch04_ex02[] ar = new ch04_ex02[ 10 ];
for (int i = 0; i < ar.length; i++) {
ar[i] = new ch04_ex02("msg " + i);
}
}
}
---


11:28 -- 4.4, Lisp version
11:35 -- Done
This version assumes the existence of the ch04-ex02-class class from exercise 2, and also the after method on initialize-instance.
---
;;;; chapter 4, ex 4
(let ((ar (make-array 10
:element-type 'ch04-ex02-class)))
(loop for i below (length ar) do
(setf (aref ar i) (make-instance 'ch04-ex02-class :x i)))
ar)
---

links: digg this    del.icio.us    technorati    reddit