Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: ram@zedat.fu-berlin.de (Stefan Ram) Newsgroups: comp.lang.misc Subject: Re: Algol 68 (or generally) - arbitrarily nested arrays of arrays Date: 28 Dec 2025 14:45:37 GMT Organization: Stefan Ram Lines: 21 Expires: 1 Jan 2027 11:59:58 GMT Message-ID: References: <10ilrbc$25ihi$10@dont-email.me> <10ir98e$4b53$1@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 8Fis8f34KTHMVhSvRc0ZCQCZ8hiAxxIxzDMsZUD6DHzvAp Cancel-Lock: sha1:BP0BgSSB3BujQ4Lo3nTuDPAP6M4= sha256:wn3wmDXXbQyJwliMvHWTa6b3Y0GAeRB6zc7iqk76W5E= X-Copyright: (C) Copyright 2025 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. X-No-Html: yes Content-Language: en Xref: csiph.com comp.lang.misc:11717 ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted: >import itertools >import math >bases =[ 2, 3, 2, 2 ] >total_product = math.prod( bases ) >ranges =[ range( b ) for b in bases ] >for digits in itertools.product( *reversed( ranges )): > print( *digits ) "total_product" is not used, so it can be boiled down to two lines (plus imports): import itertools import math ranges =[ range( b ) for b in [ 2, 3, 2, 2 ]] for digits in itertools.product( *reversed( ranges )): print( *digits ) .