赞成HIFLY兄的意见,矩阵用LISP求解虽然效率不差,但是经常遇到精度问题,简易程序可以采用,大型程序不推荐。 - ;;;将表a中元素按b个元素组成一个子表,返回总表;递归写法大表时效率较低
- ;;;By GSLS(SS)
- (defun list-comp (a b / mid rslt)
- (repeat (/ (length a) b)
- (setq mid nil)
- (repeat b
- (setq mid (cons (car a) mid)
- a (cdr a)
- )
- )
- (setq rslt (cons (reverse mid) rslt))
- )
- (if a (reverse (cons a rslt))
- (reverse rslt))
- )
|