comparison src/fns.c @ 14091:34911b128a47

(Frandom, Flength, Felt, Fsort, Fchar_table_subtype, Fchar_table_parent, Fset_char_table_parent, Fchar_table_extra_slot, Fset_char_table_extra_slot, Fchar_table_range, Fset_char_table_range, Fmap_char_table, Fmapconcat, Fmapcar): Harmonize arguments with documentation.
author Erik Naggum <erik@naggum.no>
date Tue, 09 Jan 1996 02:03:13 +0000
parents 7f7e97f219ce
children 91c55574973f
comparison
equal deleted inserted replaced
14090:24b93860d392 14091:34911b128a47
59 "Return a pseudo-random number.\n\ 59 "Return a pseudo-random number.\n\
60 All integers representable in Lisp are equally likely.\n\ 60 All integers representable in Lisp are equally likely.\n\
61 On most systems, this is 28 bits' worth.\n\ 61 On most systems, this is 28 bits' worth.\n\
62 With positive integer argument N, return random number in interval [0,N).\n\ 62 With positive integer argument N, return random number in interval [0,N).\n\
63 With argument t, set the random number seed from the current time and pid.") 63 With argument t, set the random number seed from the current time and pid.")
64 (limit) 64 (n)
65 Lisp_Object limit; 65 Lisp_Object n;
66 { 66 {
67 EMACS_INT val; 67 EMACS_INT val;
68 Lisp_Object lispy_val; 68 Lisp_Object lispy_val;
69 unsigned long denominator; 69 unsigned long denominator;
70 70
71 if (EQ (limit, Qt)) 71 if (EQ (n, Qt))
72 seed_random (getpid () + time (NULL)); 72 seed_random (getpid () + time (NULL));
73 if (NATNUMP (limit) && XFASTINT (limit) != 0) 73 if (NATNUMP (n) && XFASTINT (n) != 0)
74 { 74 {
75 /* Try to take our random number from the higher bits of VAL, 75 /* Try to take our random number from the higher bits of VAL,
76 not the lower, since (says Gentzel) the low bits of `random' 76 not the lower, since (says Gentzel) the low bits of `random'
77 are less random than the higher ones. We do this by using the 77 are less random than the higher ones. We do this by using the
78 quotient rather than the remainder. At the high end of the RNG 78 quotient rather than the remainder. At the high end of the RNG
79 it's possible to get a quotient larger than limit; discarding 79 it's possible to get a quotient larger than n; discarding
80 these values eliminates the bias that would otherwise appear 80 these values eliminates the bias that would otherwise appear
81 when using a large limit. */ 81 when using a large n. */
82 denominator = ((unsigned long)1 << VALBITS) / XFASTINT (limit); 82 denominator = ((unsigned long)1 << VALBITS) / XFASTINT (n);
83 do 83 do
84 val = get_random () / denominator; 84 val = get_random () / denominator;
85 while (val >= XFASTINT (limit)); 85 while (val >= XFASTINT (n));
86 } 86 }
87 else 87 else
88 val = get_random (); 88 val = get_random ();
89 XSETINT (lispy_val, val); 89 XSETINT (lispy_val, val);
90 return lispy_val; 90 return lispy_val;
93 /* Random data-structure functions */ 93 /* Random data-structure functions */
94 94
95 DEFUN ("length", Flength, Slength, 1, 1, 0, 95 DEFUN ("length", Flength, Slength, 1, 1, 0,
96 "Return the length of vector, list or string SEQUENCE.\n\ 96 "Return the length of vector, list or string SEQUENCE.\n\
97 A byte-code function object is also allowed.") 97 A byte-code function object is also allowed.")
98 (obj) 98 (sequence)
99 register Lisp_Object obj; 99 register Lisp_Object sequence;
100 { 100 {
101 register Lisp_Object tail, val; 101 register Lisp_Object tail, val;
102 register int i; 102 register int i;
103 103
104 retry: 104 retry:
105 if (STRINGP (obj)) 105 if (STRINGP (sequence))
106 XSETFASTINT (val, XSTRING (obj)->size); 106 XSETFASTINT (val, XSTRING (sequence)->size);
107 else if (VECTORP (obj)) 107 else if (VECTORP (sequence))
108 XSETFASTINT (val, XVECTOR (obj)->size); 108 XSETFASTINT (val, XVECTOR (sequence)->size);
109 else if (CHAR_TABLE_P (obj)) 109 else if (CHAR_TABLE_P (sequence))
110 XSETFASTINT (val, CHAR_TABLE_ORDINARY_SLOTS); 110 XSETFASTINT (val, CHAR_TABLE_ORDINARY_SLOTS);
111 else if (BOOL_VECTOR_P (obj)) 111 else if (BOOL_VECTOR_P (sequence))
112 XSETFASTINT (val, XBOOL_VECTOR (obj)->size); 112 XSETFASTINT (val, XBOOL_VECTOR (sequence)->size);
113 else if (COMPILEDP (obj)) 113 else if (COMPILEDP (sequence))
114 XSETFASTINT (val, XVECTOR (obj)->size & PSEUDOVECTOR_SIZE_MASK); 114 XSETFASTINT (val, XVECTOR (sequence)->size & PSEUDOVECTOR_SIZE_MASK);
115 else if (CONSP (obj)) 115 else if (CONSP (sequence))
116 { 116 {
117 for (i = 0, tail = obj; !NILP (tail); i++) 117 for (i = 0, tail = sequence; !NILP (tail); i++)
118 { 118 {
119 QUIT; 119 QUIT;
120 tail = Fcdr (tail); 120 tail = Fcdr (tail);
121 } 121 }
122 122
123 XSETFASTINT (val, i); 123 XSETFASTINT (val, i);
124 } 124 }
125 else if (NILP (obj)) 125 else if (NILP (sequence))
126 XSETFASTINT (val, 0); 126 XSETFASTINT (val, 0);
127 else 127 else
128 { 128 {
129 obj = wrong_type_argument (Qsequencep, obj); 129 sequence = wrong_type_argument (Qsequencep, sequence);
130 goto retry; 130 goto retry;
131 } 131 }
132 return val; 132 return val;
133 } 133 }
134 134
561 return Fcar (Fnthcdr (n, list)); 561 return Fcar (Fnthcdr (n, list));
562 } 562 }
563 563
564 DEFUN ("elt", Felt, Selt, 2, 2, 0, 564 DEFUN ("elt", Felt, Selt, 2, 2, 0,
565 "Return element of SEQUENCE at index N.") 565 "Return element of SEQUENCE at index N.")
566 (seq, n) 566 (sequence, n)
567 register Lisp_Object seq, n; 567 register Lisp_Object sequence, n;
568 { 568 {
569 CHECK_NUMBER (n, 0); 569 CHECK_NUMBER (n, 0);
570 while (1) 570 while (1)
571 { 571 {
572 if (CONSP (seq) || NILP (seq)) 572 if (CONSP (sequence) || NILP (sequence))
573 return Fcar (Fnthcdr (n, seq)); 573 return Fcar (Fnthcdr (n, sequence));
574 else if (STRINGP (seq) || VECTORP (seq) || BOOL_VECTOR_P (seq) 574 else if (STRINGP (sequence) || VECTORP (sequence)
575 || CHAR_TABLE_P (seq)) 575 || BOOL_VECTOR_P (sequence) || CHAR_TABLE_P (sequence))
576 return Faref (seq, n); 576 return Faref (sequence, n);
577 else 577 else
578 seq = wrong_type_argument (Qsequencep, seq); 578 sequence = wrong_type_argument (Qsequencep, sequence);
579 } 579 }
580 } 580 }
581 581
582 DEFUN ("member", Fmember, Smember, 2, 2, 0, 582 DEFUN ("member", Fmember, Smember, 2, 2, 0,
583 "Return non-nil if ELT is an element of LIST. Comparison done with `equal'.\n\ 583 "Return non-nil if ELT is an element of LIST. Comparison done with `equal'.\n\
830 DEFUN ("sort", Fsort, Ssort, 2, 2, 0, 830 DEFUN ("sort", Fsort, Ssort, 2, 2, 0,
831 "Sort LIST, stably, comparing elements using PREDICATE.\n\ 831 "Sort LIST, stably, comparing elements using PREDICATE.\n\
832 Returns the sorted list. LIST is modified by side effects.\n\ 832 Returns the sorted list. LIST is modified by side effects.\n\
833 PREDICATE is called with two elements of LIST, and should return T\n\ 833 PREDICATE is called with two elements of LIST, and should return T\n\
834 if the first element is \"less\" than the second.") 834 if the first element is \"less\" than the second.")
835 (list, pred) 835 (list, predicate)
836 Lisp_Object list, pred; 836 Lisp_Object list, predicate;
837 { 837 {
838 Lisp_Object front, back; 838 Lisp_Object front, back;
839 register Lisp_Object len, tem; 839 register Lisp_Object len, tem;
840 struct gcpro gcpro1, gcpro2; 840 struct gcpro gcpro1, gcpro2;
841 register int length; 841 register int length;
850 tem = Fnthcdr (len, list); 850 tem = Fnthcdr (len, list);
851 back = Fcdr (tem); 851 back = Fcdr (tem);
852 Fsetcdr (tem, Qnil); 852 Fsetcdr (tem, Qnil);
853 853
854 GCPRO2 (front, back); 854 GCPRO2 (front, back);
855 front = Fsort (front, pred); 855 front = Fsort (front, predicate);
856 back = Fsort (back, pred); 856 back = Fsort (back, predicate);
857 UNGCPRO; 857 UNGCPRO;
858 return merge (front, back, pred); 858 return merge (front, back, predicate);
859 } 859 }
860 860
861 Lisp_Object 861 Lisp_Object
862 merge (org_l1, org_l2, pred) 862 merge (org_l1, org_l2, pred)
863 Lisp_Object org_l1, org_l2; 863 Lisp_Object org_l1, org_l2;
1173 } 1173 }
1174 1174
1175 DEFUN ("char-table-subtype", Fchar_table_subtype, Schar_table_subtype, 1175 DEFUN ("char-table-subtype", Fchar_table_subtype, Schar_table_subtype,
1176 1, 1, 0, 1176 1, 1, 0,
1177 "Return the subtype of char-table CHAR-TABLE. The value is a symbol.") 1177 "Return the subtype of char-table CHAR-TABLE. The value is a symbol.")
1178 (chartable) 1178 (char_table)
1179 Lisp_Object chartable; 1179 Lisp_Object char_table;
1180 { 1180 {
1181 CHECK_CHAR_TABLE (chartable, 0); 1181 CHECK_CHAR_TABLE (char_table, 0);
1182 1182
1183 return XCHAR_TABLE (chartable)->purpose; 1183 return XCHAR_TABLE (char_table)->purpose;
1184 } 1184 }
1185 1185
1186 DEFUN ("char-table-parent", Fchar_table_parent, Schar_table_parent, 1186 DEFUN ("char-table-parent", Fchar_table_parent, Schar_table_parent,
1187 1, 1, 0, 1187 1, 1, 0,
1188 "Return the parent char-table of CHAR-TABLE.\n\ 1188 "Return the parent char-table of CHAR-TABLE.\n\
1189 The value is either nil or another char-table.\n\ 1189 The value is either nil or another char-table.\n\
1190 If CHAR-TABLE holds nil for a given character,\n\ 1190 If CHAR-TABLE holds nil for a given character,\n\
1191 then the actual applicable value is inherited from the parent char-table\n\ 1191 then the actual applicable value is inherited from the parent char-table\n\
1192 \(or from its parents, if necessary).") 1192 \(or from its parents, if necessary).")
1193 (chartable) 1193 (char_table)
1194 Lisp_Object chartable; 1194 Lisp_Object char_table;
1195 { 1195 {
1196 CHECK_CHAR_TABLE (chartable, 0); 1196 CHECK_CHAR_TABLE (char_table, 0);
1197 1197
1198 return XCHAR_TABLE (chartable)->parent; 1198 return XCHAR_TABLE (char_table)->parent;
1199 } 1199 }
1200 1200
1201 DEFUN ("set-char-table-parent", Fset_char_table_parent, Sset_char_table_parent, 1201 DEFUN ("set-char-table-parent", Fset_char_table_parent, Sset_char_table_parent,
1202 2, 2, 0, 1202 2, 2, 0,
1203 "Set the parent char-table of CHAR-TABLE to PARENT.\n\ 1203 "Set the parent char-table of CHAR-TABLE to PARENT.\n\
1204 PARENT must be either nil or another char-table.") 1204 PARENT must be either nil or another char-table.")
1205 (chartable, parent) 1205 (char_table, parent)
1206 Lisp_Object chartable, parent; 1206 Lisp_Object char_table, parent;
1207 { 1207 {
1208 Lisp_Object temp; 1208 Lisp_Object temp;
1209 1209
1210 CHECK_CHAR_TABLE (chartable, 0); 1210 CHECK_CHAR_TABLE (char_table, 0);
1211 1211
1212 if (!NILP (parent)) 1212 if (!NILP (parent))
1213 { 1213 {
1214 CHECK_CHAR_TABLE (parent, 0); 1214 CHECK_CHAR_TABLE (parent, 0);
1215 1215
1216 for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent) 1216 for (temp = parent; !NILP (temp); temp = XCHAR_TABLE (temp)->parent)
1217 if (EQ (temp, chartable)) 1217 if (EQ (temp, chartable))
1218 error ("Attempt to make a chartable be its own parent"); 1218 error ("Attempt to make a chartable be its own parent");
1219 } 1219 }
1220 1220
1221 XCHAR_TABLE (chartable)->parent = parent; 1221 XCHAR_TABLE (char_table)->parent = parent;
1222 1222
1223 return parent; 1223 return parent;
1224 } 1224 }
1225 1225
1226 DEFUN ("char-table-extra-slot", Fchar_table_extra_slot, Schar_table_extra_slot, 1226 DEFUN ("char-table-extra-slot", Fchar_table_extra_slot, Schar_table_extra_slot,
1227 2, 2, 0, 1227 2, 2, 0,
1228 "Return the value in extra-slot number N of char-table CHAR-TABLE.") 1228 "Return the value in extra-slot number N of char-table CHAR-TABLE.")
1229 (chartable, n) 1229 (char_table, n)
1230 Lisp_Object chartable, n; 1230 Lisp_Object char_table, n;
1231 { 1231 {
1232 CHECK_CHAR_TABLE (chartable, 1); 1232 CHECK_CHAR_TABLE (char_table, 1);
1233 CHECK_NUMBER (n, 2); 1233 CHECK_NUMBER (n, 2);
1234 if (XINT (n) < 0 1234 if (XINT (n) < 0
1235 || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (chartable))) 1235 || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table)))
1236 args_out_of_range (chartable, n); 1236 args_out_of_range (char_table, n);
1237 1237
1238 return XCHAR_TABLE (chartable)->extras[XINT (n)]; 1238 return XCHAR_TABLE (char_table)->extras[XINT (n)];
1239 } 1239 }
1240 1240
1241 DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot, 1241 DEFUN ("set-char-table-extra-slot", Fset_char_table_extra_slot,
1242 Sset_char_table_extra_slot, 1242 Sset_char_table_extra_slot,
1243 3, 3, 0, 1243 3, 3, 0,
1244 "Set extra-slot number N of CHAR-TABLE to VALUE.") 1244 "Set extra-slot number N of CHAR-TABLE to VALUE.")
1245 (chartable, n, value) 1245 (char_table, n, value)
1246 Lisp_Object chartable, n, value; 1246 Lisp_Object char_table, n, value;
1247 { 1247 {
1248 CHECK_CHAR_TABLE (chartable, 1); 1248 CHECK_CHAR_TABLE (char_table, 1);
1249 CHECK_NUMBER (n, 2); 1249 CHECK_NUMBER (n, 2);
1250 if (XINT (n) < 0 1250 if (XINT (n) < 0
1251 || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (chartable))) 1251 || XINT (n) >= CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (char_table)))
1252 args_out_of_range (chartable, n); 1252 args_out_of_range (char_table, n);
1253 1253
1254 return XCHAR_TABLE (chartable)->extras[XINT (n)] = value; 1254 return XCHAR_TABLE (char_table)->extras[XINT (n)] = value;
1255 } 1255 }
1256 1256
1257 DEFUN ("char-table-range", Fchar_table_range, Schar_table_range, 1257 DEFUN ("char-table-range", Fchar_table_range, Schar_table_range,
1258 2, 2, 0, 1258 2, 2, 0,
1259 "Return the value in CHARTABLE for a range of characters RANGE.\n\ 1259 "Return the value in CHAR-TABLE for a range of characters RANGE.\n\
1260 RANGE should be t (for all characters), nil (for the default value)\n\ 1260 RANGE should be t (for all characters), nil (for the default value)\n\
1261 a vector which identifies a character set or a row of a character set,\n\ 1261 a vector which identifies a character set or a row of a character set,\n\
1262 or a character code.") 1262 or a character code.")
1263 (chartable, range) 1263 (char_table, range)
1264 Lisp_Object chartable, range; 1264 Lisp_Object char_table, range;
1265 { 1265 {
1266 int i; 1266 int i;
1267 1267
1268 CHECK_CHAR_TABLE (chartable, 0); 1268 CHECK_CHAR_TABLE (char_table, 0);
1269 1269
1270 if (EQ (range, Qnil)) 1270 if (EQ (range, Qnil))
1271 return XCHAR_TABLE (chartable)->defalt; 1271 return XCHAR_TABLE (char_table)->defalt;
1272 else if (INTEGERP (range)) 1272 else if (INTEGERP (range))
1273 return Faref (chartable, range); 1273 return Faref (char_table, range);
1274 else if (VECTORP (range)) 1274 else if (VECTORP (range))
1275 { 1275 {
1276 for (i = 0; i < XVECTOR (range)->size - 1; i++) 1276 for (i = 0; i < XVECTOR (range)->size - 1; i++)
1277 chartable = Faref (chartable, XVECTOR (range)->contents[i]); 1277 char_table = Faref (char_table, XVECTOR (range)->contents[i]);
1278 1278
1279 if (EQ (XVECTOR (range)->contents[i], Qnil)) 1279 if (EQ (XVECTOR (range)->contents[i], Qnil))
1280 return XCHAR_TABLE (chartable)->defalt; 1280 return XCHAR_TABLE (char_table)->defalt;
1281 else 1281 else
1282 return Faref (chartable, XVECTOR (range)->contents[i]); 1282 return Faref (char_table, XVECTOR (range)->contents[i]);
1283 } 1283 }
1284 else 1284 else
1285 error ("Invalid RANGE argument to `char-table-range'"); 1285 error ("Invalid RANGE argument to `char-table-range'");
1286 } 1286 }
1287 1287
1288 DEFUN ("set-char-table-range", Fset_char_table_range, Sset_char_table_range, 1288 DEFUN ("set-char-table-range", Fset_char_table_range, Sset_char_table_range,
1289 3, 3, 0, 1289 3, 3, 0,
1290 "Set the value in CHARTABLE for a range of characters RANGE to VALUE.\n\ 1290 "Set the value in CHAR-TABLE for a range of characters RANGE to VALUE.\n\
1291 RANGE should be t (for all characters), nil (for the default value)\n\ 1291 RANGE should be t (for all characters), nil (for the default value)\n\
1292 a vector which identifies a character set or a row of a character set,\n\ 1292 a vector which identifies a character set or a row of a character set,\n\
1293 or a character code.") 1293 or a character code.")
1294 (chartable, range, value) 1294 (char_table, range, value)
1295 Lisp_Object chartable, range, value; 1295 Lisp_Object char_table, range, value;
1296 { 1296 {
1297 int i; 1297 int i;
1298 1298
1299 CHECK_CHAR_TABLE (chartable, 0); 1299 CHECK_CHAR_TABLE (char_table, 0);
1300 1300
1301 if (EQ (range, Qt)) 1301 if (EQ (range, Qt))
1302 for (i = 0; i < CHAR_TABLE_ORDINARY_SLOTS; i++) 1302 for (i = 0; i < CHAR_TABLE_ORDINARY_SLOTS; i++)
1303 XCHAR_TABLE (chartable)->contents[i] = value; 1303 XCHAR_TABLE (char_table)->contents[i] = value;
1304 else if (EQ (range, Qnil)) 1304 else if (EQ (range, Qnil))
1305 XCHAR_TABLE (chartable)->defalt = value; 1305 XCHAR_TABLE (char_table)->defalt = value;
1306 else if (INTEGERP (range)) 1306 else if (INTEGERP (range))
1307 Faset (chartable, range, value); 1307 Faset (char_table, range, value);
1308 else if (VECTORP (range)) 1308 else if (VECTORP (range))
1309 { 1309 {
1310 for (i = 0; i < XVECTOR (range)->size - 1; i++) 1310 for (i = 0; i < XVECTOR (range)->size - 1; i++)
1311 chartable = Faref (chartable, XVECTOR (range)->contents[i]); 1311 char_table = Faref (char_table, XVECTOR (range)->contents[i]);
1312 1312
1313 if (EQ (XVECTOR (range)->contents[i], Qnil)) 1313 if (EQ (XVECTOR (range)->contents[i], Qnil))
1314 XCHAR_TABLE (chartable)->defalt = value; 1314 XCHAR_TABLE (char_table)->defalt = value;
1315 else 1315 else
1316 Faset (chartable, XVECTOR (range)->contents[i], value); 1316 Faset (char_table, XVECTOR (range)->contents[i], value);
1317 } 1317 }
1318 else 1318 else
1319 error ("Invalid RANGE argument to `set-char-table-range'"); 1319 error ("Invalid RANGE argument to `set-char-table-range'");
1320 1320
1321 return value; 1321 return value;
1362 } 1362 }
1363 } 1363 }
1364 1364
1365 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table, 1365 DEFUN ("map-char-table", Fmap_char_table, Smap_char_table,
1366 2, 2, 0, 1366 2, 2, 0,
1367 "Call FUNCTION for each range of like characters in CHARTABLE.\n\ 1367 "Call FUNCTION for each range of like characters in CHAR-TABLE.\n\
1368 FUNCTION is called with two arguments--a key and a value.\n\ 1368 FUNCTION is called with two arguments--a key and a value.\n\
1369 The key is always a possible RANGE argument to `set-char-table-range'.") 1369 The key is always a possible RANGE argument to `set-char-table-range'.")
1370 (function, chartable) 1370 (function, char_table)
1371 Lisp_Object function, chartable; 1371 Lisp_Object function, char_table;
1372 { 1372 {
1373 Lisp_Object keyvec; 1373 Lisp_Object keyvec;
1374 Lisp_Object *indices = (Lisp_Object *) alloca (10 * sizeof (Lisp_Object)); 1374 Lisp_Object *indices = (Lisp_Object *) alloca (10 * sizeof (Lisp_Object));
1375 1375
1376 map_char_table (NULL, function, chartable, 0, indices); 1376 map_char_table (NULL, function, char_table, 0, indices);
1377 return Qnil; 1377 return Qnil;
1378 } 1378 }
1379 1379
1380 /* ARGSUSED */ 1380 /* ARGSUSED */
1381 Lisp_Object 1381 Lisp_Object
1487 1487
1488 UNGCPRO; 1488 UNGCPRO;
1489 } 1489 }
1490 1490
1491 DEFUN ("mapconcat", Fmapconcat, Smapconcat, 3, 3, 0, 1491 DEFUN ("mapconcat", Fmapconcat, Smapconcat, 3, 3, 0,
1492 "Apply FN to each element of SEQ, and concat the results as strings.\n\ 1492 "Apply FUNCTION to each element of SEQUENCE, and concat the results as strings.\n\
1493 In between each pair of results, stick in SEP.\n\ 1493 In between each pair of results, stick in SEPARATOR. Thus, \" \" as\n\
1494 Thus, \" \" as SEP results in spaces between the values returned by FN.") 1494 SEPARATOR results in spaces between the values returned by FUNCTION.")
1495 (fn, seq, sep) 1495 (function, sequence, separator)
1496 Lisp_Object fn, seq, sep; 1496 Lisp_Object function, sequence, separator;
1497 { 1497 {
1498 Lisp_Object len; 1498 Lisp_Object len;
1499 register int leni; 1499 register int leni;
1500 int nargs; 1500 int nargs;
1501 register Lisp_Object *args; 1501 register Lisp_Object *args;
1502 register int i; 1502 register int i;
1503 struct gcpro gcpro1; 1503 struct gcpro gcpro1;
1504 1504
1505 len = Flength (seq); 1505 len = Flength (sequence);
1506 leni = XINT (len); 1506 leni = XINT (len);
1507 nargs = leni + leni - 1; 1507 nargs = leni + leni - 1;
1508 if (nargs < 0) return build_string (""); 1508 if (nargs < 0) return build_string ("");
1509 1509
1510 args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object)); 1510 args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object));
1511 1511
1512 GCPRO1 (sep); 1512 GCPRO1 (separator);
1513 mapcar1 (leni, args, fn, seq); 1513 mapcar1 (leni, args, function, sequence);
1514 UNGCPRO; 1514 UNGCPRO;
1515 1515
1516 for (i = leni - 1; i >= 0; i--) 1516 for (i = leni - 1; i >= 0; i--)
1517 args[i + i] = args[i]; 1517 args[i + i] = args[i];
1518 1518
1519 for (i = 1; i < nargs; i += 2) 1519 for (i = 1; i < nargs; i += 2)
1520 args[i] = sep; 1520 args[i] = separator;
1521 1521
1522 return Fconcat (nargs, args); 1522 return Fconcat (nargs, args);
1523 } 1523 }
1524 1524
1525 DEFUN ("mapcar", Fmapcar, Smapcar, 2, 2, 0, 1525 DEFUN ("mapcar", Fmapcar, Smapcar, 2, 2, 0,
1526 "Apply FUNCTION to each element of SEQUENCE, and make a list of the results.\n\ 1526 "Apply FUNCTION to each element of SEQUENCE, and make a list of the results.\n\
1527 The result is a list just as long as SEQUENCE.\n\ 1527 The result is a list just as long as SEQUENCE.\n\
1528 SEQUENCE may be a list, a vector or a string.") 1528 SEQUENCE may be a list, a vector or a string.")
1529 (fn, seq) 1529 (function, sequence)
1530 Lisp_Object fn, seq; 1530 Lisp_Object function, sequence;
1531 { 1531 {
1532 register Lisp_Object len; 1532 register Lisp_Object len;
1533 register int leni; 1533 register int leni;
1534 register Lisp_Object *args; 1534 register Lisp_Object *args;
1535 1535
1536 len = Flength (seq); 1536 len = Flength (sequence);
1537 leni = XFASTINT (len); 1537 leni = XFASTINT (len);
1538 args = (Lisp_Object *) alloca (leni * sizeof (Lisp_Object)); 1538 args = (Lisp_Object *) alloca (leni * sizeof (Lisp_Object));
1539 1539
1540 mapcar1 (leni, args, fn, seq); 1540 mapcar1 (leni, args, function, sequence);
1541 1541
1542 return Flist (leni, args); 1542 return Flist (leni, args);
1543 } 1543 }
1544 1544
1545 /* Anything that calls this function must protect from GC! */ 1545 /* Anything that calls this function must protect from GC! */