]> git.eshelyaron.com Git - emacs.git/commitdiff
(mapthread): Delete it.
authorKenichi Handa <handa@m17n.org>
Mon, 24 Aug 2009 11:43:59 +0000 (11:43 +0000)
committerKenichi Handa <handa@m17n.org>
Mon, 24 Aug 2009 11:43:59 +0000 (11:43 +0000)
(combinatorial): New function.
(indian--puthash-cv): Use combinatorial instead of mapthread.

lisp/ChangeLog
lisp/language/ind-util.el

index 84b343032231e701e46a9da7b939ce173f6d2192..99f0cf80fea1ba687156948a4d86ff7bd88f6e1a 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-24  Kenichi Handa  <handa@m17n.org>
+
+       * language/ind-util.el (mapthread): Delete it.
+       (combinatorial): New function.
+       (indian--puthash-cv): Use combinatorial instead of mapthread.
+
 2009-08-22  Kevin Ryde  <user42@zip.com.au>
 
        * emacs-lisp/checkdoc.el (checkdoc-force-history-flag)
index 59e3c834087477a6b0e1023d249ea9eb129436e2..e47884baa94a639feddf9a9d2855534b06bfe6fe 100644 (file)
     (;; 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 @@ FUNCTION will be called 15 times."
          (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))