guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Anaphoric macros like when-let


From: Kyle Siehl
Subject: Re: Anaphoric macros like when-let
Date: Sat, 26 Aug 2017 15:40:24 -0700
User-agent: Mutt/1.8.3 (2017-05-23)

On Sun, Aug 27, 2017 at 01:17:13AM +0530, Arun Isaac wrote:
> 
> Is there a Scheme or Guile equivalent to Emacs Lisp's `when-let' ?
> 
> Basically, I'm looking for a shorthand to express this:
> 
> (let ((x (foo))
>   (when x
>     (bar x))))
> 
> as this:
> 
> (when-let (x (foo))
>   (bar x))

(cond
 ((foo) => bar))

Or, in general:

(cond
 ((foo)
  => (lambda (x)
       (bar x))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]