unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* patch to augment and=>
@ 2020-07-05  9:47 Christopher Lam
  0 siblings, 0 replies; only message in thread
From: Christopher Lam @ 2020-07-05  9:47 UTC (permalink / raw)
  To: guile-devel


[-- Attachment #1.1: Type: text/plain, Size: 66 bytes --]

Hi guilers!
Is this of any interest to merge into boot.scm?
Chris

[-- Attachment #1.2: Type: text/html, Size: 122 bytes --]

[-- Attachment #2: and-arrow.patch --]
[-- Type: text/x-patch, Size: 691 bytes --]

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 0d37f3d48..edb7e93cc 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -803,9 +803,13 @@ VALUE."
   (lambda _
     value))
 
-(define (and=> value procedure)
-  "When VALUE is #f, return #f.  Otherwise, return (PROC VALUE)."
-  (and value (procedure value)))
+(define (and=> value . procedures)
+  "When VALUE is #f, return #f.  Otherwise, return (PROC VALUE). Recurse
+with subsequent procedures."
+  (if (null? procedures)
+      value
+      (let ((result ((car procedures) value)))
+        (and result (apply and=> result (cdr procedures))))))
 
 (define call/cc call-with-current-continuation)
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-05  9:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-05  9:47 patch to augment and=> Christopher Lam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).