Deutsch   English   Français   Italiano  
<20240716121710.763@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
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=
Bytes: 1708

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