From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?U2pvZXJkIHZhbiBMZWVudCBQcml2w6k=?= Newsgroups: gmane.lisp.guile.devel Subject: Re: regexp-split for Guile Date: Tue, 18 Sep 2012 09:06:55 +0200 Message-ID: <50581D8F.2070703@gmail.com> References: <20120917140133.GA6315@yarrow> <87lig830ox.fsf@zigzag.favinet> <20120917200603.GB6315@yarrow> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1347952028 19498 80.91.229.3 (18 Sep 2012 07:07:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Sep 2012 07:07:08 +0000 (UTC) To: "Chris K. Jester-Young" , guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Sep 18 09:07:11 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TDrtm-0005ye-Qn for guile-devel@m.gmane.org; Tue, 18 Sep 2012 09:07:10 +0200 Original-Received: from localhost ([::1]:36713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDrti-0004LM-1R for guile-devel@m.gmane.org; Tue, 18 Sep 2012 03:07:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDrtc-0004LE-9N for guile-devel@gnu.org; Tue, 18 Sep 2012 03:07:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDrtb-0004vn-9Y for guile-devel@gnu.org; Tue, 18 Sep 2012 03:07:00 -0400 Original-Received: from mail-ee0-f41.google.com ([74.125.83.41]:59017) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDrtb-0004vh-3B for guile-devel@gnu.org; Tue, 18 Sep 2012 03:06:59 -0400 Original-Received: by eeke49 with SMTP id e49so4425537eek.0 for ; Tue, 18 Sep 2012 00:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=i4UoWZQh1svCIaCYhjf/+EWp1WyOOOk+HgG63Lq9JMo=; b=Y5Uo5sWx7tlHdmnvi/mgIS61bryR7EmyXLfj8/ZvJ7F3z9/oeFNcTc0mVe1ZdfGiLy hnxo4qMEcu6SB9aCvkV6+E6rX8MS80Km8YHvbXzG6aPLZLvHO3UiUCHidWA1TEqtkoRV jA/Io+RpI1J4wsNSdQ8I048XJHUcTxlriCSR/4x/UkwyUiu75VA+rQxl5UGLMycrRNC1 0xTVVABW021QpimoUtRdO1ixeUPP3nef/8E26Nq2jVERJyilnSH8n83SgW6nGKVBwsYF BAljYddOyMvBEn8LSvObO6bALf+m1GVrESOiueqqPJZB8TpizgG3q3q1DPKDAJP54io3 QAbg== Original-Received: by 10.14.173.131 with SMTP id v3mr16141235eel.15.1347952017996; Tue, 18 Sep 2012 00:06:57 -0700 (PDT) Original-Received: from [172.16.3.219] (5352DA6A.cm-6-3d.dynamic.ziggo.nl. [83.82.218.106]) by mx.google.com with ESMTPS id h2sm33745491eeo.3.2012.09.18.00.06.56 (version=SSLv3 cipher=OTHER); Tue, 18 Sep 2012 00:06:57 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 In-Reply-To: <20120917200603.GB6315@yarrow> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.83.41 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14892 Archived-At: Hi Chris, I have been following your thread about regexp-split. I do have some thoughts about this to make the interface more versalite. > So, basically, the Perl split's limit is used this way: > > 1. Positive limit: Return this many fields at most: > > (regexp-split ":" "foo:bar:baz:qux:" 3) > => ("foo" "bar" "baz:qux:") > > 2. Negative limit: Return all fields: > > (regexp-split ":" "foo:bar:baz:qux:" -1) > => ("foo" "bar" "baz" "qux" "") It might just be me, but would it not be more sensible for scheme to just perform the opposite. Return the same amount of fields at most, but starting from the end, thus: (regexp-split ":" "foo:bar:baz:qux:" -3) => ("foo:bar" "baz" "qux" "") This is practical for paths etc. The problem described in your second case could be solved by using a symbol, such as #:all, or something similar. > > 3. Zero limit: Return all fields, after removing trailing blank fields: > > (regexp-split ":" "foo:bar:baz:qux:" 0) > => ("foo" "bar" "baz" "qux") > Regards, Sjoerd