From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, NORMAL_HTTP_TO_IP,NUMERIC_HTTP_ADDR,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id fae77a5b for ; Sun, 1 Dec 2019 21:30:44 +0000 (UTC) Received: (qmail 16616 invoked by alias); 1 Dec 2019 21:30:38 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24486 Received: (qmail 12975 invoked by uid 1010); 1 Dec 2019 21:30:38 -0000 X-Qmail-Scanner-Diagnostics: from 195-159-176-226.customer.powertech.no by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25649. spamassassin: 3.4.2. Clear:RC:0(195.159.176.226):SA:0(1.0/5.0):. Processed in 0.659605 secs); 01 Dec 2019 21:30:38 -0000 X-Envelope-From: gcszu-zsh-users@m.gmane.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at m.gmane.org does not designate permitted sender hosts) X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: zsh-users@zsh.org To: zsh-users@zsh.org From: Emanuel Berg Subject: Re: shuffle array Date: Sun, 01 Dec 2019 22:25:00 +0100 Message-ID: <86r21npwlv.fsf@zoho.eu> References: <867e3jxtao.fsf@zoho.eu> <20191129064215.GA14095@prometheus.u-strasbg.fr> <8636e7w0w9.fsf__36104.0529723809$1575015640$gmane$org@zoho.eu> <20191201200719.anzbs27c7phgdnmm@chaz.gmail.com> <86v9qzpwq4.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Mail-Copies-To: never Cancel-Lock: sha1:MMaYaggHAP/cUZpPxgsqPKPSlWw= >> You could do things like: >> >> array=("${(0@)$(printf '%s\0' "$array[@]" | shuf -z)[1,-2]}") > > It seems I always get the same shuffle > for that? > > (1 2 3 a b c) -> (c 1 a 3 b 2) > > and > > (x y z 1 2 3) -> (3 x 1 z 2 y) > > - the same. Sorry, I had a typo, as for the shuffling, it works fine. -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal