From Newsgroup: comp.lang.lisp
CL-USER 2 > (defvar a (make-array 10 :initial-element 1))
A
CL-USER 3 > (defun increment-every-third-elt (arr)
(loop for elt across arr
for i upfrom 1 do
(when (= 0 (mod i 3))
(incf (aref arr (1- i))))))
INCREMENT-EVERY-THIRD-ELT
CL-USER 4 > (increment-every-third-elt a)
NIL
CL-USER 5 > a
#(1 1 2 1 1 2 1 1 2 1)
Gauche Scheme
(define (inc-every-nth vec n)
(do ((i (- n 1) (+ i n)))
((>= i (vector-length vec)))
(inc! (~ vec i))))
(define v (make-vector 23 0))
(inc-every-nth v 3)
v
===>
#(0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0)
--
[T]he problem is that lispniks are as cultish as any other devout group and basically fall down frothing at the mouth if they see [heterodoxy].
--- Kenny Tilton
The good news is, it's not Lisp that sucks, but Common Lisp. --- Paul Graham --- Synchronet 3.21a-Linux NewsLink 1.2