#!/usr/bin/newlisp

# matrix - benchmark

# since version 9.0 mtarix finctions can also be used on array types,
# additionally to lists.

(set 'size 30)

(define (mkmatrix rows cols)
 	(map (fn (i) (sequence (+ (* i cols) 1)  (+ (* i cols) cols))) (sequence 0 (- rows 1))))
 	
 
(define (main n)
	(set 'm1 (mkmatrix size size))
	(set 'm2 m1)
	(dotimes (i n) 
		(set 'm3 (multiply m1 m2)))
	(println (m3 0 0) " " (m3 2 3) " " (m3 3 2) " " (m3 4 4)))
	

(set 'n (integer (main-args 2)))
	
(main n)

(exit)

 	


syntax highlighting with newLISP and syntax.cgi