unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Kyle Siehl <krsiehl@gmail.com>
To: Arun Isaac <arunisaac@systemreboot.net>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Anaphoric macros like when-let
Date: Sat, 26 Aug 2017 15:40:24 -0700	[thread overview]
Message-ID: <20170826224024.GA10588@wintermute.lan> (raw)
In-Reply-To: <1a0f67f3.AEAAO93SX5gAAAAAAAAAAAPWCvIAAAACwQwAAAAAAAW9WABZodBb@mailjet.com>

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))))



  parent reply	other threads:[~2017-08-26 22:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-26 19:47 Anaphoric macros like when-let Arun Isaac
2017-08-26 19:50 ` Matt Wette
2017-08-26 19:54   ` Matt Wette
2017-08-27 12:28   ` Arun Isaac
2017-08-26 22:40 ` Kyle Siehl [this message]
2017-08-27 20:24 ` Mark H Weaver
2017-08-28  9:41   ` Arun Isaac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170826224024.GA10588@wintermute.lan \
    --to=krsiehl@gmail.com \
    --cc=arunisaac@systemreboot.net \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).