From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Lennart Borgman <lennart.borgman@gmail.com>
Newsgroups: gmane.emacs.help
Subject: Re: How do lisp gurus truncate?
Date: Thu, 23 Jul 2009 20:11:01 +0200
Message-ID: <e01d8a50907231111l53f27495hda2651be698a318e@mail.gmail.com>
References: <mailman.2999.1248330784.2239.help-gnu-emacs@gnu.org>
	<87hbx31gah.fsf@kobe.laptop>
NNTP-Posting-Host: lo.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1248372758 28793 80.91.229.12 (23 Jul 2009 18:12:38 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 23 Jul 2009 18:12:38 +0000 (UTC)
Cc: help-gnu-emacs@gnu.org
To: Giorgos Keramidas <keramida@ceid.upatras.gr>
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 23 20:12:31 2009
Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geh-help-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([199.232.76.165])
	by lo.gmane.org with esmtp (Exim 4.50)
	id 1MU2mM-0003M9-N1
	for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Jul 2009 20:12:31 +0200
Original-Received: from localhost ([127.0.0.1]:44112 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1MU2mL-0003NY-VQ
	for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Jul 2009 14:12:30 -0400
Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1MU2l2-00037K-2O
	for help-gnu-emacs@gnu.org; Thu, 23 Jul 2009 14:11:08 -0400
Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1MU2kw-00033Y-Fe
	for help-gnu-emacs@gnu.org; Thu, 23 Jul 2009 14:11:06 -0400
Original-Received: from [199.232.76.173] (port=56658 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1MU2kw-00033R-Ae
	for help-gnu-emacs@gnu.org; Thu, 23 Jul 2009 14:11:02 -0400
Original-Received: from mail-yx0-f172.google.com ([209.85.210.172]:42076)
	by monty-python.gnu.org with esmtp (Exim 4.60)
	(envelope-from <lennart.borgman@gmail.com>) id 1MU2kw-000363-1R
	for help-gnu-emacs@gnu.org; Thu, 23 Jul 2009 14:11:02 -0400
Original-Received: by yxe2 with SMTP id 2so1977045yxe.14
	for <help-gnu-emacs@gnu.org>; Thu, 23 Jul 2009 11:11:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:received:in-reply-to:references
	:date:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=qAEaaz1yjC1brb3NLS7Fu5qFttigADkKq8cNb3FWK64=;
	b=i3ao3F6FChEqV3uMLHslF1auwBbPK9plsizgNcNllqNXS86heDQRqSvI+C6WlOinLN
	uN6qL5k1UZjKSSTGB8B6kRalwROvtw67rDMzQtinq3PhYWqbAg6tUmz0G0Zhtm9NJx35
	UfT3E7usMS4qvf9m7A8BCZYicQQEydg27jauw=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	b=QisDcj6v7akFw2RyiIWk7MEdRQCbK/niIWIUnAQL88EgdH4sj7VSQ9CpPUsxeuGvRa
	Gi/P9a7e5//s0LctsBxyUMqBgCmhjMc8mNdYugTTNVzO8a0iVAkymGVeb61X3lDqq/yk
	ui6pTN6wF7uEwPFyPHEv06t2t0yjOS69VAWGw=
Original-Received: by 10.100.248.4 with SMTP id v4mr3311016anh.57.1248372661670; Thu, 
	23 Jul 2009 11:11:01 -0700 (PDT)
In-Reply-To: <87hbx31gah.fsf@kobe.laptop>
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2)
X-BeenThere: help-gnu-emacs@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Users list for the GNU Emacs text editor <help-gnu-emacs.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/help-gnu-emacs>
List-Post: <mailto:help-gnu-emacs@gnu.org>
List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=subscribe>
Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.help:66366
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/66366>

On Thu, Jul 23, 2009 at 7:05 PM, Giorgos
Keramidas<keramida@ceid.upatras.gr> wrote:
> On Thu, 23 Jul 2009 08:32:56 +0200, Lennart Borgman <lennart.borgman@gmai=
l.com> wrote:
>> I want to truncate an ordered list if the rest of the values are
>> bigger than some limit. I just wrote some code like this one to do
>> that, but there must be some more standard way of doing that, or?
>>
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when nxml-where-first-change-pos
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq nxml-where-path 'dummy n=
xml-where-path)
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((path nxml-where-path))
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (while (cdr path)
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (> (nth 1 =
(nth 1 path)) nxml-where-first-change-pos)
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setcdr p=
ath nil))
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq path (cdr =
path))))
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq nxml-where-path (cdr nxm=
l-where-path)))
>
> I'd probably use `every' to perform the test and start iterating over
> the list at the first location returned by `member' or `find', i.e. from
> a CLISP session:
>
> =C2=A0 =C2=A0[9]> (every (lambda (number)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(> number 3=
))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list 4 5 6))
> =C2=A0 =C2=A0T
>
> =C2=A0 =C2=A0[10]> (member 3 (list 1 2 3 4 5 6 7))
> =C2=A0 =C2=A0(3 4 5 6 7)
>
> =C2=A0 =C2=A0[11]> (every (lambda (number)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (> number =
3))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(rest (member 3 (list 1 2 3 4 5 =
6 7 8 9))))
> =C2=A0 =C2=A0T
>
> Locating the first item that is probably easier to do with `find' than
> with `member', because it lets you find the first number *larger* than
> the value you are looking for, i.e.:

Thanks, but I do not know the elements in the list, just that it is
sorted so using find or member does not work as far as I can see.

(Otherwise would of course "member" do the job.)