From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Amar Singh Newsgroups: gmane.lisp.guile.devel Subject: Add procedure list->hook in Guile Date: Fri, 30 Aug 2019 07:22:50 +0530 Message-ID: <85zhjr1kst.fsf@disroot.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="240439"; mail-complaints-to="usenet@blaine.gmane.org" To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Aug 30 03:53:57 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i3W6v-0010Pk-4Y for guile-devel@m.gmane.org; Fri, 30 Aug 2019 03:53:57 +0200 Original-Received: from localhost ([::1]:55824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3W6s-0006iC-Fn for guile-devel@m.gmane.org; Thu, 29 Aug 2019 21:53:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47971) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3W6h-0006gy-M0 for guile-devel@gnu.org; Thu, 29 Aug 2019 21:53:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3W6c-0001Jn-2g for guile-devel@gnu.org; Thu, 29 Aug 2019 21:53:40 -0400 Original-Received: from knopi.disroot.org ([178.21.23.139]:58444) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i3W6W-0000kD-1V for guile-devel@gnu.org; Thu, 29 Aug 2019 21:53:32 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C39C82A330 for ; Fri, 30 Aug 2019 03:53:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at disroot.org Original-Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lX9wINrXURUf for ; Fri, 30 Aug 2019 03:53:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1567130004; bh=ZVGGOK5HFu4ugazpGf9l7f5wZKWRDlytMlszYH9ewPI=; h=From:To:Subject:Date; b=OTbualSdpbOYKNJ8jc41/4fu0aaoMiio0o98uf2GkkTNgWscxWlIWQbo/+nUzGIQY M86OICbl4nZjNZ83c+nOauq8DMDvqTJnbDVQtrZbYKcp9CEVADQBvY83HhCcBsVUAX Lv/FrczjaQ8ArsbFxucA/avG5meuvsTs+woO0ObVjvP8Q63JaWo+370pKtjmDDgI62 eCdsxAAvlxnnJ4xaUqcloDdiGb3ftyo40q5IQi2o7T7bYSu05sgQACa8ay7giKhVXY RYr7AAitW6mbymgE42E1S8LVOHHl3g+3+vYYeT45HhbQByfROzBjjKM8WudX1eBxMl 5dQtaS3vwDGSg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 178.21.23.139 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.org gmane.lisp.guile.devel:20055 Archived-At: Scheme procedure - list->hook lst Convert the procedure list of LST to a hook. It will compliment the hook->list procedure already there. :) I found the hook->list procedure in C but I cannot find a good place to add list->hook. Thoughts? Cheers, amar -------------------------------------------------------------------------------- ;;; Full procedure (define (list->hook lst) "Convert the procedure list of LST to a hook." (define (adder h lst arity) (if (null? lst) h (let ((proc (car lst))) (if (procedure? proc) (if (equal? arity (car (procedure-minimum-arity proc))) (begin (add-hook! h proc #t) (adder h (cdr lst) arity)) (error (format #f "In procedure list->hook: Wrong number of arguments to ~s, expected arity ~s" proc arity))) (error (format #f "In procedure list->hook: Wrong type argument ~s, expecting a procedure." proc)))))) (if (null? lst) (make-hook) (let ((proc (car lst))) (if (procedure? proc) (let* ((arity (car (procedure-minimum-arity proc))) (hook (make-hook arity))) (adder hook lst arity)) (error (format #f "In procedure list->hook: Wrong type argument: ~s in list, expected a procedure." proc))))))