emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp/language ind-util.el


From: Kenichi Handa
Subject: [Emacs-diffs] emacs/lisp/language ind-util.el
Date: Mon, 24 Aug 2009 11:42:13 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Kenichi Handa <handa>   09/08/24 11:42:13

Modified files:
        lisp/language  : ind-util.el 

Log message:
        (mapthread): Delete it.
        (combinatorial): New function.
        (indian--puthash-cv): Use combinatorial instead of mapthread.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/language/ind-util.el?cvsroot=emacs&r1=1.23&r2=1.24

Patches:
Index: ind-util.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/language/ind-util.el,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- ind-util.el 5 Jan 2009 03:22:26 -0000       1.23
+++ ind-util.el 24 Aug 2009 11:42:12 -0000      1.24
@@ -382,21 +382,12 @@
     (;; misc
      nil   ".m"  ".h"  "'"   nil   "." nil)))
 
-(defun mapthread (function seq1 &rest seqrest)
-  "Apply FUNCTION to each element of SEQ1 and return result list.
-If there are several SEQRESTs, FUNCTION is called with that many
-arguments, with all possible combinations of these multiple SEQUENCES.
-Thus, if SEQ1 contains 3 elements and SEQ2 contains 5 elements, then
-FUNCTION will be called 15 times."
-  (if seqrest
-      (mapcar
-       (lambda (x)
-         (apply
-          'mapthread
-          `(lambda (&rest y) (apply ',function x y))
-          seqrest))
-       seq1)
-  (mapcar function seq1)))
+(defun combinatorial (head &rest tail)
+  (if tail
+      (apply 'append
+            (mapcar (lambda (y) (mapcar (lambda (x) (cons x y)) head))
+                    (apply 'combinatorial tail)))
+    (mapcar 'list head)))
 
 (defun indian--puthash-char (char trans-char hashtbls)
   (let ((encode-hash (car hashtbls))  ;; char -> trans
@@ -446,8 +437,8 @@
          (if (stringp trans-v) (setq trans-v (list trans-v)))
          (indian--puthash-char
           (concat c v)
-          (apply 'append
-                 (mapthread 'concat trans-c trans-v))
+          (mapcar (lambda (x) (apply 'concat x))
+                 (combinatorial trans-c trans-v))
           hashtbls)))
       v trans-v))
    c trans-c))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]