Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Try the Moo Shu Pork. It is especially good today.


comp / comp.lang.lisp / Re: make a list of different random numbers

SubjectAuthor
* Re: make a list of different random numbersB. Pym
+- Re: make a list of different random numbersKaz Kylheku
`* Re: make a list of different random numbersGeorge Neuner
 `* Re: make a list of different random numbersHenHanna
  `- Re: make a list of different random numbersKaz Kylheku

1
Subject: Re: make a list of different random numbers
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 16 Jul 2024 18:55 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: make a list of different random numbers
Date: Tue, 16 Jul 2024 18:55:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <v76fmu$1d3tm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Tue, 16 Jul 2024 20:55:30 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5730bdcd22b644933384107bd30ba9a2";
logging-data="1478582"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/i847aJjRcTrR3/TxVJkEw"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:pICbOc9GU0FichAajEQnWs0rQtk=
View all headers

Pascal J. Bourguignon wrote:

> > i would like to get a list of 4 different random numbers.
> > (wk wn wb bk)
> > i started this code :
> >
> > (defun random-position () (1+ (random 64)))
> >
> > (defparameter wk (random-position))
> >
> > (excl:until (not (= wb wk)) (setf wb (random-position)))
> >
> > but it is not working. i just need to ensure that none of the
> > positions
> > are the same. please to help.
> >
> > thanks, david
>
>
> (do ((results '() results)
> (alea (random-position) (random-position)))
> ((<= 4 (length results))
> results)
> (pushnew alea results))
>
> or:
>
> (loop
> :with results = '()
> :for alea = (random-position)
> :while (< (length results) 4)
> :do (pushnew alea results)
> :finally (return results))

Pascal hasn't yet mastered "do"; perhaps he never will.

Gauche Scheme

(use srfi-1) ;; lset-adjoin (To act as "pushnew".)
(use srfi-27) ;; random-integer

(define (random-position) (+ 1 (random-integer 64)))

(do ((results '() (lset-adjoin = results (random-position))))
((> (length results) 3) results))

===>
(26 31 48 49)

Check for duplication:

(length (delete-duplicates
(do ((results '() (lset-adjoin = results (random-position))))
((> (length results) 63) results))))

===>
64

Subject: Re: make a list of different random numbers
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 16 Jul 2024 19:24 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: make a list of different random numbers
Date: Tue, 16 Jul 2024 19:24:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <20240716121710.763@kylheku.com>
References: <v76fmu$1d3tm$1@dont-email.me>
Injection-Date: Tue, 16 Jul 2024 21:24:16 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ce357bc76c882e1ee63521671b53ee1f";
logging-data="1485674"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/PQPwxqyipJt2gTmWP6vqEitd+Tf6de5s="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:ik0dtl4wGV4WQv6TvLv9mgeY9Ws=
View all headers

On 2024-07-16, B. Pym <Nobody447095@here-nor-there.org> wrote:
> Gauche Scheme
>
> (use srfi-1) ;; lset-adjoin (To act as "pushnew".)
> (use srfi-27) ;; random-integer
>
> (define (random-position) (+ 1 (random-integer 64)))
>
> (do ((results '() (lset-adjoin = results (random-position))))
> ((> (length results) 3) results))
>
> ===>
> (26 31 48 49)
>
> Check for duplication:
>
> (length (delete-duplicates
> (do ((results '() (lset-adjoin = results (random-position))))
> ((> (length results) 63) results))))
>
> ===>
> 64

Since the range of the numbers is so tiny, it seems nicer
to implement it as a lottery draw:

1> (take 4 (nshuffle (vec-seq 1..65)))
#(32 31 23 39)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: make a list of different random numbers
From: George Neuner
Newsgroups: comp.lang.lisp
Organization: i2pn2 (i2pn.org)
Date: Tue, 16 Jul 2024 19:31 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: gneuner2@comcast.net (George Neuner)
Newsgroups: comp.lang.lisp
Subject: Re: make a list of different random numbers
Date: Tue, 16 Jul 2024 15:31:49 -0400
Organization: i2pn2 (i2pn.org)
Message-ID: <90id9j1i7gpch1rj21lc03dtcsb6h7ri9o@4ax.com>
References: <v76fmu$1d3tm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: i2pn2.org;
logging-data="3519111"; mail-complaints-to="usenet@i2pn2.org";
posting-account="h5eMH71iFfocGZucc+SnA0y5I+72/ecoTCcIjMd3Uww";
User-Agent: ForteAgent/8.00.32.1272
X-Spam-Checker-Version: SpamAssassin 4.0.0
View all headers

On Tue, 16 Jul 2024 18:55:30 -0000 (UTC), "B. Pym"
<Nobody447095@here-nor-there.org> wrote:

>Pascal J. Bourguignon wrote:

First, Pascal B. hasn't posted anything here for almost 5 years. Why
are you dredging up ancient discussions?

Second, most Usenet forums frown on proselytizing - it is considered
rude. This is a Lisp forum - Scheme code belongs in comp.lang.scheme.

Subject: Re: make a list of different random numbers
From: HenHanna
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Tue, 16 Jul 2024 22:47 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.lisp
Subject: Re: make a list of different random numbers
Date: Tue, 16 Jul 2024 15:47:09 -0700
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <v76t9e$1fhr5$1@dont-email.me>
References: <v76fmu$1d3tm$1@dont-email.me>
<90id9j1i7gpch1rj21lc03dtcsb6h7ri9o@4ax.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 17 Jul 2024 00:47:10 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9ea1727d6e64375775f4a7de4e28858c";
logging-data="1558373"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19esMJO2ri5ufrPazIIR3si4Dlmln+asDI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:uxAcnQaGRL9/t/ZJCucbWaR/xak=
In-Reply-To: <90id9j1i7gpch1rj21lc03dtcsb6h7ri9o@4ax.com>
Content-Language: en-US
View all headers

>>> most Usenet forums frown on proselytizing

really???

Subject: Re: make a list of different random numbers
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Wed, 17 Jul 2024 00:29 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: make a list of different random numbers
Date: Wed, 17 Jul 2024 00:29:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <20240716172821.164@kylheku.com>
References: <v76fmu$1d3tm$1@dont-email.me>
<90id9j1i7gpch1rj21lc03dtcsb6h7ri9o@4ax.com> <v76t9e$1fhr5$1@dont-email.me>
Injection-Date: Wed, 17 Jul 2024 02:29:10 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4ccb6694187f732fe63bf91f29e67960";
logging-data="1590411"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hr4+q9k9rpn221myZEiIfrikYOAFExlw="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:EI76xxOYQvr7ayO7FTWLBtaXLng=
View all headers

On 2024-07-16, HenHanna <HenHanna@devnull.tb> wrote:
>
>
>>>> most Usenet forums frown on proselytizing
>
>
> really???

Text-to-speach typo; George was surely saying "are founded upon".

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

1

rocksolid light 0.9.8
clearnet tor