---
// PrintThreeFromCommandLine.java
// chapter 2, exercise 7import java.util.*;
class PrintThreeFromCommandLine {
public static void main( String[] args ) {
// no error checking
System.out.println( "Arg 1: " + args[ 0 ] );
System.out.println( "Arg 2: " + args[ 1 ] );
System.out.println( "Arg 3: " + args[ 2 ] );
}
}
---
---
;;;; chapter 2, ex 7
(defun print-three-from-command-line (args)
(print (first args))
(print (second args))
(print (third args)))
---
(print-three-from-command-line (cdr extensions:*command-line-strings*))and it'll print the first three command line arguments.
21:20 -- starting 2.8, Java version
21:23 -- done
---
// AllTheColorsOfTheRainbow.java
// chapter 2, ex 8class AllTheColorsOfTheRainbow {
int anIntegerRepresentingColors;
void changeTheHueOfTheColor(int newHue) {
anIntegerRepresentingColors = newHue;
}public static void main( String[] args ) {
AllTheColorsOfTheRainbow atcotr = new AllTheColorsOfTheRainbow();
atcotr.changeTheHueOfTheColor( 10 );
}
}
---
---
;;;; chapter 2, ex 8
(defclass all-the-colors-of-the-rainbow ()
((an-integer-representing-colors :type integer :accessor color)))
(defmethod change-the-hue-of-the-color ((r all-the-colors-of-the-rainbow) (hue integer))
(setf (color r) hue))
(defun 2.8.main ()
(let ((atcotr (make-instance 'all-the-colors-of-the-rainbow)))
(change-the-hue-of-the-color atcotr 10)))
---
21:39
I downloaded the code and ran javadoc on the specified file, and viewed the output, as required in the exercise. It looks pretty cool. I wonder if anybody's written anything similar for CL. I guess I'll just have to look around. :)
21:56
Lisp.org lists a few here: http://www.alu.org/table/tools.htm#case