changeset 104562:d89a78ae1c54

(mapthread): Delete it. (combinatorial): New function. (indian--puthash-cv): Use combinatorial instead of mapthread.
author Kenichi Handa <handa@m17n.org>
date Mon, 24 Aug 2009 11:42:12 +0000
parents 0a6b066cacd4
children 73bc53392b92
files lisp/language/ind-util.el
diffstat 1 files changed, 8 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/language/ind-util.el	Mon Aug 24 04:50:07 2009 +0000
+++ b/lisp/language/ind-util.el	Mon Aug 24 11:42:12 2009 +0000
@@ -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))