Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Don't think; let the machine do it for you!" -- E. C. Berkeley


devel / comp.lang.lisp / .Re: SETF and variable issues in Self Similar program.

SubjectAuthor
o .Re: SETF and variable issues in Self Similar program.Robert L.

1
.Re: SETF and variable issues in Self Similar program.

<t0tsge$qc0$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16972&group=comp.lang.lisp#16972

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!FJv/bGwhGSz/196zv+MMkA.user.46.165.242.75.POSTED!not-for-mail
From: No_spamming@noWhere_7073.org (Robert L.)
Newsgroups: comp.lang.lisp
Subject: .Re: SETF and variable issues in Self Similar program.
Date: Wed, 16 Mar 2022 23:40:00 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t0tsge$qc0$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Info: gioia.aioe.org; logging-data="27008"; posting-host="FJv/bGwhGSz/196zv+MMkA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.18.1.6
X-Notice: Filtered by postfilter v. 0.9.2
 by: Robert L. - Wed, 16 Mar 2022 23:40 UTC

Ken Tilton wrote:

> > Say I want to create a function that fills a list of length n with a
> > sequence that counts from 1 to n, at a given interval r and returns
> > the list. And this process being generalized for any given length or
> > interval. Of course the length and interval have to be relatively
> > prime.
> >
> > For example: If the interval is 3 and the length is 17, the list
> > returned would be...
> > (1 7 13 2 8 14 3 9 15 4 10 16 5 11 17 6 12)
> > You can see that, since the interval is 3, if you read every 3 in the
> > final list you will see 1 2 3 4...etc.
> >
> > I have done this several different ways, but ran into some
> > limitations, and am now back to work on a better way. Any
> > suggestions? I have a feeling it is much simpler than I am making it.
>
> Maybe?:
>
> (let ((n 17)(i 3))
> (loop with a = (make-array n)
> for x below n
> do (setf (svref a (mod (* i x) n)) (1+ x))
> finally (return (coerce a 'list))))
Gauche Scheme:

(define (foo top interval)
(define len (ceiling (/ top interval)))
(take
(apply append-map list
(map (lambda (i) (iota len (+ 1 (* i len)))) (iota interval)))
top))

(foo 17 3)
===>
(1 7 13 2 8 14 3 9 15 4 10 16 5 11 17 6 12)

(foo 18 3)
===>
(1 7 13 2 8 14 3 9 15 4 10 16 5 11 17 6 12 18)


devel / comp.lang.lisp / .Re: SETF and variable issues in Self Similar program.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor