From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: Check for redundancy
Date: Sun, 28 Jun 2015 04:40:17 +0200 [thread overview]
Message-ID: <871tgwlfn2.fsf@nl106-137-147.student.uu.se> (raw)
In-Reply-To: 877fqolhe4.fsf@nl106-137-147.student.uu.se
Emanuel Berg <embe8573@student.uu.se> writes:
> I just got and idea - stay tuned...
(defun make-backrefs (total)
(if (> total 0)
(format "%s\\\\%s" (make-backrefs (1- total)) total)
"") )
(defun make-backrefs-while (total)
(let ((refs ""))
(while (> total 0)
(setq refs (format "\\\\%s%s" total refs))
(cl-decf total) )
refs) )
(defun make-backrefs-tail (total &optional refs)
(unless refs (setq refs ""))
(if (> total 0)
(make-backrefs-tail (1- total) (format "\\\\%s%s" total refs))
refs) )
;; test they produce the same output at least :)
(let ((num-refs 5))
(insert "\n\n")
(insert ";; " (make-backrefs num-refs) "\n")
(insert ";; " (make-backrefs-while num-refs) "\n")
(insert ";; " (make-backrefs-tail num-refs) "\n") )
;; \\1\\2\\3\\4\\5
;; \\1\\2\\3\\4\\5
;; \\1\\2\\3\\4\\5
(disassemble (byte-compile 'make-backrefs))
0 varref total
1 constant 0
2 gtr
3 goto-if-nil 1
6 constant format
7 constant "%s\\\\%s"
8 constant make-backrefs
9 varref total
10 sub1
11 call 1
12 varref total
13 call 3
14 return
15:1 constant ""
16 return
(disassemble (byte-compile 'make-backrefs-while))
0 constant ""
1 varbind refs
2 varref total
3:1 constant 0
4 gtr
5 goto-if-nil 2
8 constant format
9 constant "\\\\%s%s"
10 varref total
11 varref refs
12 call 3
13 varset refs
14 varref total
15 sub1
16 dup
17 varset total
18 goto 1
21:2 varref refs
22 unbind 1
23 return
(disassemble (byte-compile 'make-backrefs-tail))
0 varref refs
1 goto-if-not-nil 1
4 constant ""
5 varset refs
6:1 varref total
7 constant 0
8 gtr
9 goto-if-nil 2
12 constant make-backrefs-tail
13 varref total
14 sub1
15 constant format
16 constant "\\\\%s%s"
17 varref total
18 varref refs
19 call 3
20 call 2
21 return
22:2 varref refs
23 return
--
underground experts united
http://user.it.uu.se/~embe8573
next prev parent reply other threads:[~2015-06-28 2:40 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-24 9:29 Check for redundancy Andreas Röhler
2015-06-24 13:23 ` Drew Adams
2015-06-24 14:55 ` Andreas Röhler
[not found] ` <mailman.5580.1435157733.904.help-gnu-emacs@gnu.org>
2015-06-24 18:21 ` Stefan Monnier
2015-06-24 21:10 ` tomas
2015-06-25 3:23 ` Stefan Monnier
2015-06-25 7:47 ` tomas
2015-06-26 15:01 ` Emanuel Berg
2015-06-26 20:25 ` Marcin Borkowski
2015-06-26 22:48 ` Emanuel Berg
2015-06-27 12:11 ` Robert Thorpe
2015-06-27 13:12 ` tomas
2015-06-27 23:02 ` Emanuel Berg
2015-06-28 11:07 ` tomas
2015-06-28 15:50 ` Emanuel Berg
2015-06-28 16:35 ` Yuri Khan
2015-06-28 20:03 ` Emanuel Berg
2015-06-28 21:38 ` Robert Thorpe
2015-06-28 23:47 ` Emanuel Berg
2015-07-02 23:37 ` Robert Thorpe
2015-07-03 3:36 ` Yuri Khan
2015-07-03 6:41 ` Eli Zaretskii
2015-07-03 11:48 ` Yuri Khan
2015-07-03 12:16 ` Eli Zaretskii
2015-07-03 22:59 ` Robert Thorpe
2015-07-03 6:09 ` tomas
2015-07-03 19:56 ` Emanuel Berg
[not found] ` <mailman.6215.1435903802.904.help-gnu-emacs@gnu.org>
2015-07-03 6:38 ` Rusi
2015-07-03 7:54 ` tomas
2015-07-03 8:55 ` Loris Bennett
2015-06-24 23:31 ` Emanuel Berg
2015-06-25 2:03 ` Óscar Fuentes
2015-06-25 2:07 ` Emanuel Berg
2015-06-25 2:53 ` Óscar Fuentes
2015-06-25 3:21 ` Emanuel Berg
[not found] ` <mailman.5603.1435188769.904.help-gnu-emacs@gnu.org>
2015-06-25 7:43 ` Stefan Nobis
2015-06-25 8:52 ` Andreas Röhler
2015-06-26 14:51 ` Emanuel Berg
2015-06-26 14:39 ` Emanuel Berg
[not found] ` <mailman.5719.1435329683.904.help-gnu-emacs@gnu.org>
2015-06-27 7:40 ` Stefan Nobis
2015-06-28 2:02 ` Emanuel Berg
2015-06-28 2:40 ` Emanuel Berg [this message]
[not found] <mailman.6209.1435880273.904.help-gnu-emacs@gnu.org>
2015-07-03 8:40 ` Pascal J. Bourguignon
2015-07-03 20:04 ` Emanuel Berg
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=871tgwlfn2.fsf@nl106-137-147.student.uu.se \
--to=embe8573@student.uu.se \
--cc=help-gnu-emacs@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.
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.