unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#49316: Add apply-partially's right version
@ 2021-07-01 12:40 daanturo
  2021-07-01 13:11 ` Basil L. Contovounesios
  2021-07-01 22:34 ` Michael Heerdegen
  0 siblings, 2 replies; 28+ messages in thread
From: daanturo @ 2021-07-01 12:40 UTC (permalink / raw)
  To: 49316

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


--=-=-=
Content-Type: text/plain

Tags: patch


Define apply-rpartial.

The equivalent function in dash.el is widely used by other packages so
it's beneficial to include it by default.



In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.24.29, cairo version 1.17.4)
of 2021-06-25 built on c6
Repository revision: e288348c0a785537d95b7ef2fff0cda729a29677
Repository branch: makepkg
Windowing system distributor 'System Description: Arch Linux

Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
--with-sound=alsa --with-modules --without-gconf --without-gsettings
--with-native-compilation --with-pgtk --with-x-toolkit=gtk3
--without-xaw3d --without-m17n-flt --with-cairo --with-xwidgets
--without-compress-install 'CFLAGS=-march=x86-64 -mtune=generic -O2
-pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat
-Werror=format-security -fstack-clash-protection -fcf-protection -g
-fuse-ld=gold -g -fuse-ld=gold'
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment; filename=0001-Define-apply-rpatially.patch

 From c594d6fc396b80019c48e63918f8c5e485f2782f Mon Sep 17 00:00:00 2001
From: Daanturo <daanturo@gmail.com>
Date: Thu, 1 Jul 2021 19:21:08 +0700
Subject: [PATCH] Define apply-rpatially

Which is analogous to `apply-partially` but arguments are aligned on the 
right
instead.
---
lisp/subr.el | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/lisp/subr.el b/lisp/subr.el
index e49c277335..5965655d48 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -465,6 +465,15 @@ was called."
(lambda (&rest args2)
(apply fun (append args args2))))

+(defun apply-rpartially (fun &rest args)
+ "Return a function that is a partial application of FUN to ARGS to the 
right.
+ARGS is a list of the last N arguments to pass to FUN.
+The result is a new function which does the same as FUN, except
+that the last N arguments are fixed at the values with which this
+function was called."
+ (lambda (&rest args1)
+ (apply fun (append args1 args))))
+
(defun zerop (number)
"Return t if NUMBER is zero."
;; Used to be in C, but it's pointless since (= 0 n) is faster anyway 
because
-- 
2.32.0


--=-=-=--

-- 
Daanturo.


[-- Attachment #2: 0001-Define-apply-rpatially.patch --]
[-- Type: text/x-patch, Size: 1103 bytes --]

From c594d6fc396b80019c48e63918f8c5e485f2782f Mon Sep 17 00:00:00 2001
From: Daanturo <daanturo@gmail.com>
Date: Thu, 1 Jul 2021 19:21:08 +0700
Subject: [PATCH] Define apply-rpatially

Which is analogous to `apply-partially` but arguments are aligned on the right
instead.
---
 lisp/subr.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lisp/subr.el b/lisp/subr.el
index e49c277335..5965655d48 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -465,6 +465,15 @@ was called."
   (lambda (&rest args2)
     (apply fun (append args args2))))
 
+(defun apply-rpartially (fun &rest args)
+  "Return a function that is a partial application of FUN to ARGS to the right.
+ARGS is a list of the last N arguments to pass to FUN.
+The result is a new function which does the same as FUN, except
+that the last N arguments are fixed at the values with which this
+function was called."
+  (lambda (&rest args1)
+    (apply fun (append args1 args))))
+
 (defun zerop (number)
   "Return t if NUMBER is zero."
   ;; Used to be in C, but it's pointless since (= 0 n) is faster anyway because
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2021-10-25 12:50 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-01 12:40 bug#49316: Add apply-partially's right version daanturo
2021-07-01 13:11 ` Basil L. Contovounesios
2021-07-01 16:24   ` daanturo
2021-07-01 17:06     ` daanturo
2021-07-01 17:16       ` daanturo
2021-07-01 18:45       ` Eli Zaretskii
2021-07-02  2:49         ` daanturo
2021-07-03  7:03           ` Eli Zaretskii
2021-10-24  6:55             ` Stefan Kangas
2021-10-24 10:49               ` daanturo
2021-10-24 11:18                 ` Stefan Kangas
2021-10-24 12:13                   ` Eli Zaretskii
2021-10-24 13:47                     ` Lars Ingebrigtsen
2021-10-24 14:10                       ` Stefan Kangas
2021-10-24 14:28                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-25 12:50                         ` Lars Ingebrigtsen
2021-10-24 13:38               ` Lars Ingebrigtsen
2021-07-02 16:32         ` daanturo
2021-07-03  7:03           ` Eli Zaretskii
2021-07-01 22:34 ` Michael Heerdegen
2021-07-02  4:39   ` daanturo
2021-07-03  3:06     ` Michael Heerdegen
2021-07-03  6:17       ` daanturo
2021-07-03 14:13       ` Phil Sainty
2021-07-05  4:29         ` daanturo
2021-07-05 12:02           ` Phil Sainty
2021-07-06  4:33           ` Michael Heerdegen
2021-07-07 16:30             ` daanturo

Code repositories for project(s) associated with this public inbox

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

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