From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: making a thunk out of a list Date: Tue, 18 Sep 2007 23:16:26 +0100 Message-ID: <877imn62md.fsf@ossau.uklinux.net> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1190153801 23913 80.91.229.12 (18 Sep 2007 22:16:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Sep 2007 22:16:41 +0000 (UTC) Cc: guile-user To: "Marco Maggi" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Sep 19 00:16:40 2007 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IXlN1-0000j8-SI for guile-user@m.gmane.org; Wed, 19 Sep 2007 00:16:40 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IXlN0-0004cq-Ad for guile-user@m.gmane.org; Tue, 18 Sep 2007 18:16:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IXlMw-0004cb-A9 for guile-user@gnu.org; Tue, 18 Sep 2007 18:16:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IXlMu-0004cH-5u for guile-user@gnu.org; Tue, 18 Sep 2007 18:16:33 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IXlMu-0004cE-02 for guile-user@gnu.org; Tue, 18 Sep 2007 18:16:32 -0400 Original-Received: from mail3.uklinux.net ([80.84.72.33]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IXlMt-000304-P3 for guile-user@gnu.org; Tue, 18 Sep 2007 18:16:31 -0400 Original-Received: from arudy (host86-145-176-36.range86-145.btcentralplus.com [86.145.176.36]) by mail3.uklinux.net (Postfix) with ESMTP id 2B36F1F7C87; Tue, 18 Sep 2007 23:16:27 +0100 (BST) Original-Received: from laruns (unknown [192.168.0.10]) by arudy (Postfix) with ESMTP id A9BDD38009; Tue, 18 Sep 2007 23:16:26 +0100 (BST) In-Reply-To: (Marco Maggi's message of "Tue, 24 Jul 2007 16:06:31 +0200") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-Detected-Kernel: Linux 2.4-2.6 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6154 Archived-At: "Marco Maggi" writes: > Ciao, > > maybe this is simple, but today I cannot find a solution; > while iterating over the nodes of a graph I can accumulate > in a list the sequence of function invocations upon each > node (pseudo-code): > > (let ((result '())) > ;; for each node in the iteration: > (set! result (cons (list action-upon-node node) > result)) > ;; at the end > (reverse result)) > > I do it in a method to memoize the iteration; now I > would like to make a thunk out of the list, the following > works: > > (lambda () (for-each primitive-eval result)) > > but I would like a thunk that does not use FOR-EACH. I fail > to see how to do it with a macro, and I cannot APPLY a > LAMBDA, for example the following does not work: > > ((list lambda '() result)) > > Ideas? You've probably solved this by now, but I found your question curious, so... You have a list of nodes, and you have a procedure f that you want to apply to each node. So that's just `(map f nodes)', isn't it? But then you want to delay the f calls, and wrap the whole thing up in a thunk. So: (define (make-delayed-map-thunk f nodes) (lambda () (map f nodes))) I guess it can't really be this simple, so what am I missing? Regards, Neil _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user