From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: lloda Newsgroups: gmane.lisp.guile.user Subject: Re: Python slices in Scheme Date: Mon, 19 Jun 2023 18:36:09 +0200 Message-ID: <5A5012F2-7712-49AD-9337-D688F0F2CC27@sarc.name> References: Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19816"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: Jay Sulzberger Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon Jun 19 18:36:52 2023 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBHs4-0004yR-BS for guile-user@m.gmane-mx.org; Mon, 19 Jun 2023 18:36:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBHrh-00033Z-RR; Mon, 19 Jun 2023 12:36:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBHre-00032Y-K8 for guile-user@gnu.org; Mon, 19 Jun 2023 12:36:27 -0400 Original-Received: from mta-09-4.privateemail.com ([198.54.127.118]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBHrb-00084l-DZ for guile-user@gnu.org; Mon, 19 Jun 2023 12:36:26 -0400 Original-Received: from mta-09.privateemail.com (localhost [127.0.0.1]) by mta-09.privateemail.com (Postfix) with ESMTP id 4A2B318000A7; Mon, 19 Jun 2023 12:36:13 -0400 (EDT) Original-Received: from [192.168.1.4] (unknown [51.154.167.214]) by mta-09.privateemail.com (Postfix) with ESMTPA id 8B2241800203; Mon, 19 Jun 2023 12:36:11 -0400 (EDT) In-Reply-To: X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP Received-SPF: pass client-ip=198.54.127.118; envelope-from=lloda@sarc.name; helo=MTA-09-4.privateemail.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19051 Archived-At: My library guile-newra (1) has quite general multidimensional array = slicing. The indices can be linear ranges or arbitrary integer arrays = and they can have any rank. You can also use the indexed array as write = target. If all the indices are linear ranges then the operation is done = without copies. It also has placeholders, so you can skip axes, like : = and ... in numpy. guile-newra's arrays are applicative, so you can do = (thearray firstindex secondindex ...), without special brackets. You need wrappers to use it with Guile's native array types, so it may = not be as convenient. Or maybe you don't need to handle arbitrary rank, = then it might not be the best option. It's also far from finished, = although the stuff I mentioned above does work. I didn't adopt Pythons -1 =3D end convention because in Guile arrays can = have any base index, not necessarily 0 (whether that's a good idea or = not). (1) https://lloda.github.io/guile-newra/#Slicing = https://github.com/lloda/guile-newra/ = https://notabug.org/lloda/guile-newra =