Groups | Search | Server Info | Login | Register
Groups > comp.lang.scheme > #6540
| From | "B. Pym" <Nobody447095@here-nor-there.org> |
|---|---|
| Newsgroups | comp.lang.lisp, comp.lang.scheme |
| Subject | Re: Lisp for ANN programming |
| Date | 2025-08-07 16:24 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <1072jva$3osf$1@dont-email.me> (permalink) |
Cross-posted to 2 groups.
> 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
Back to comp.lang.scheme | Previous | Next | Find similar
Re: Lisp for ANN programming "B. Pym" <Nobody447095@here-nor-there.org> - 2025-08-07 16:24 +0000
csiph-web