all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Petton <nicolas@petton.fr>
To: Michael Heerdegen <michael_heerdegen@web.de>, emacs-devel@gnu.org
Subject: Re: Semantic of pcase `seq' and `map' patterns (was: pcase-setq)
Date: Mon, 12 Oct 2015 15:50:51 +0200	[thread overview]
Message-ID: <87wpuskxfo.fsf@petton.fr> (raw)
In-Reply-To: <874mhwxne8.fsf_-_@web.de>

[-- Attachment #1: Type: text/plain, Size: 1398 bytes --]

Michael Heerdegen <michael_heerdegen@web.de> writes:

> After reading the doc of the `seq' pcase pattern:
>
> --8<---------------cut here---------------start------------->8---
> -- (seq &rest ARGS)
>
> pcase pattern matching sequence elements.
> Matches if the object is a sequence (list, string or vector), and
> binds each element of ARGS to the corresponding element of the
> sequence.
> --8<---------------cut here---------------end--------------->8---
>
> it was not obvious to me how this example would look like using pcase -
> especially, what "are" the "ARGS"?
>
> AFAIU the "ARGS" are just normal (pcase) patterns - they are not limited
> to variables, and matching can fail for them as well even if the number
> of sequence arguments would match.
>
> I think the semantic would be better described like this:
>
> --8<---------------cut here---------------start------------->8---
> -- (seq &rest PATTERNS)
>
> pcase pattern matching sequence elements.
> Matches if the object is a sequence (list, string or vector), and
> each PATTERN matches the corresponding element of the
> sequence.
> --8<---------------cut here---------------end--------------->8---
>
> Does that make sense?  Likewise `map', I guess.

Yes, it does. You could for example do:

    (pcase [1 2 3 4]
      ...
      ((seq (pred oddp) (pred evenp)) 'matched)
      ...)

I will update the documentation, thanks!

Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

  parent reply	other threads:[~2015-10-12 13:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 12:20 pcase-dolist Michael Heerdegen
2015-07-08 13:54 ` pcase-dolist Stefan Monnier
2015-07-08 17:32   ` pcase-dolist Michael Heerdegen
2015-07-08 18:26     ` pcase-dolist Tassilo Horn
2015-07-08 21:27       ` pcase-dolist Stefan Monnier
2015-07-09  6:05         ` pcase-dolist Tassilo Horn
2015-07-09  9:55           ` pcase-dolist Thierry Volpiatto
2015-07-09 10:17             ` pcase-dolist Tassilo Horn
2015-07-09 12:19               ` pcase-dolist Thierry Volpiatto
2015-07-09 13:34                 ` pcase-dolist Tassilo Horn
2015-07-09 13:40                   ` pcase-dolist Thierry Volpiatto
2015-07-09 19:26           ` pcase-dolist Stefan Monnier
2015-07-09 20:27             ` pcase-dolist Michael Heerdegen
2015-07-10 18:51               ` pcase-dolist Stefan Monnier
2015-10-12 11:27               ` pcase-setq (was: pcase-dolist) Michael Heerdegen
2015-10-12 11:54                 ` pcase-setq Michael Heerdegen
2015-10-12 12:01                 ` pcase-setq (was: pcase-dolist) Nicolas Petton
2015-10-12 12:36                   ` pcase-setq Michael Heerdegen
2015-10-12 12:49                   ` Semantic of pcase `seq' and `map' patterns (was: pcase-setq) Michael Heerdegen
2015-10-12 13:41                     ` Semantic of pcase `seq' and `map' patterns Michael Heerdegen
2015-10-12 13:55                       ` Nicolas Petton
2015-10-12 14:02                         ` Michael Heerdegen
2015-10-17 12:21                           ` Michael Heerdegen
2015-10-17 13:31                             ` Nicolas Petton
2015-10-12 13:50                     ` Nicolas Petton [this message]
2015-10-13  0:59                 ` pcase-setq Stefan Monnier
2015-10-13 13:52                   ` pcase-setq Michael Heerdegen
2015-10-13 14:02                     ` pcase-setq Michael Heerdegen
2015-10-13 15:52                       ` pcase-setq Michael Heerdegen
     [not found]                         ` <jwvfv1eboo8.fsf-monnier+emacs@gnu.org>
     [not found]                           ` <87d1wh36as.fsf@web.de>
2015-10-14 15:49                             ` pcase-setq Stefan Monnier
2015-07-10 14:44             ` pcase-dolist Tassilo Horn
2015-07-10 19:04               ` pcase-dolist Stefan Monnier
2015-07-08 19:44     ` pcase-dolist Artur Malabarba
2015-07-08 20:50       ` pcase-dolist Michael Heerdegen

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

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

  git send-email \
    --in-reply-to=87wpuskxfo.fsf@petton.fr \
    --to=nicolas@petton.fr \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.