From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: Check for redundancy Date: Sun, 28 Jun 2015 04:40:17 +0200 Message-ID: <871tgwlfn2.fsf@nl106-137-147.student.uu.se> References: <558A7875.4050905@easy-emacs.de> <24a1b328-82a8-44ff-8f8d-1425ab89ab67@default> <877fqolhe4.fsf@nl106-137-147.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1435459328 21954 80.91.229.3 (28 Jun 2015 02:42:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 28 Jun 2015 02:42:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 28 04:41:57 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z92Xc-0002m3-4V for geh-help-gnu-emacs@m.gmane.org; Sun, 28 Jun 2015 04:41:56 +0200 Original-Received: from localhost ([::1]:37858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z92Xb-0003QD-8J for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Jun 2015 22:41:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z92XR-0003Q6-07 for help-gnu-emacs@gnu.org; Sat, 27 Jun 2015 22:41:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z92XM-0000J5-0U for help-gnu-emacs@gnu.org; Sat, 27 Jun 2015 22:41:44 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:58530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z92XL-0000Iv-QB for help-gnu-emacs@gnu.org; Sat, 27 Jun 2015 22:41:39 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Z92XJ-0002Ul-6b for help-gnu-emacs@gnu.org; Sun, 28 Jun 2015 04:41:37 +0200 Original-Received: from nl106-137-246.student.uu.se ([130.243.137.246]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 28 Jun 2015 04:41:37 +0200 Original-Received: from embe8573 by nl106-137-246.student.uu.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 28 Jun 2015 04:41:37 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 100 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: nl106-137-246.student.uu.se Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:ZM5NdZc/umPv0W7WRQ42dNve6F0= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:105240 Archived-At: Emanuel Berg 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