Thanks Louis, nice acknowledgement considering the source.
One thing I do want to say about this function (and a few others I've offered lately) --
(defun MatrixOmatic ( m n / *error* foo )
(defun *error* (msg)
(princ
(strcat
"Syntax: "
(chr 40)
"MakeMatrix m n"
(chr 41)
" where m and n are positive integers."
)
)
(princ)
)
(if
(not
(vl-every
'(lambda (x)
(and
(eq 'int (type x))
(< 0 x)
)
)
(list m n)
)
)
(exit)
)
(defun foo ( x / result )
( (lambda (k)
(repeat x
(setq result
(cons
(setq k (1- k))
result
)
)
)
)
(+ 0.5 (/ x 2.0))
)
)
(apply 'append
(mapcar
'(lambda (y)
(mapcar
'(lambda (x) (list x y))
(foo m)
)
)
(foo n)
)
)
)
I normally don't provide the kind of hand holding, caller protected code you see therein and I would never place something like that in my libraries. It's good when you're starting out 'cause it identifies where you may have supplied invalid arguments; precisley why I penned it this way.
However, =in my opinion= code like this has no place in a library. Library code should be lean and mean -- if it gets passed invalid arguments it should crash; calling (hi level) code should deal with errors, not low level functions.
Do native lisp functions hand hold or crash I ask rhetorically? Put this in a lisp program and see what happens: (/ 1 0).
So my point is this, what I'd put in my library would be more like this:
(defun MatrixOmatic ( m n / foo )
(defun foo ( x / result )
( (lambda (k)
(repeat x
(setq result
(cons
(setq k (1- k))
result
)
)
)
)
(+ 0.5 (/ x 2.0))
)
)
(apply 'append
(mapcar
'(lambda (y)
(mapcar
'(lambda (x) (list x y))
(foo m)
)
)
(foo n)
)
)
)
It's eactly what it needs to be
and no more.
