comparison src/fns.c @ 163:0132846995bd r20-3b8

Import from CVS: tag r20-3b8
author cvs
date Mon, 13 Aug 2007 09:43:35 +0200
parents 538048ae2ab8
children 5a88923fcbfe
comparison
equal deleted inserted replaced
162:4de2936b4e77 163:0132846995bd
3269 mapcar1 (len, args, fn, seq); 3269 mapcar1 (len, args, fn, seq);
3270 3270
3271 return Flist (len, args); 3271 return Flist (len, args);
3272 } 3272 }
3273 3273
3274 DEFUN ("mapvector", Fmapvector, 2, 2, 0, /*
3275 Apply FUNCTION to each element of SEQUENCE, making a vector of the results.
3276 The result is a vector of the same length as SEQUENCE.
3277 SEQUENCE may be a list, a vector or a string.
3278 */
3279 (fn, seq))
3280 {
3281 int len = XINT (Flength (seq));
3282 Lisp_Object *args = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
3283
3284 mapcar1 (len, args, fn, seq);
3285
3286 return Fvector (len, args);
3287 }
3288
3274 DEFUN ("mapc-internal", Fmapc_internal, 2, 2, 0, /* 3289 DEFUN ("mapc-internal", Fmapc_internal, 2, 2, 0, /*
3275 Apply FUNCTION to each element of SEQUENCE. 3290 Apply FUNCTION to each element of SEQUENCE.
3276 SEQUENCE may be a list, a vector, a bit vector, or a string. 3291 SEQUENCE may be a list, a vector, a bit vector, or a string.
3277 This function is like `mapcar' but does not accumulate the results, 3292 This function is like `mapcar' but does not accumulate the results,
3278 which is more efficient if you do not use the results. 3293 which is more efficient if you do not use the results.
3329 */ 3344 */
3330 (feature)) 3345 (feature))
3331 { 3346 {
3332 CHECK_SYMBOL (feature); 3347 CHECK_SYMBOL (feature);
3333 return NILP (Fmemq (feature, Vfeatures)) ? Qnil : Qt; 3348 return NILP (Fmemq (feature, Vfeatures)) ? Qnil : Qt;
3349 }
3350 #else
3351 extern int emacs_major_version, emacs_minor_version;
3352
3353 DEFUN ("featurep", Ffeaturep, 1, 1, 0, /*
3354 Return non-nil if feature expression FEXP is true.
3355 */
3356 (fexp))
3357 {
3358 static double featurep_emacs_version;
3359
3360 /* Brute force translation from Erik Naggum's lisp function. */
3361 if (SYMBOLP(fexp))
3362 {
3363 /* Original definition */
3364 return NILP (Fmemq (fexp, Vfeatures)) ? Qnil : Qt;
3365 }
3366 else if (INTP(fexp) || FLOATP(fexp))
3367 {
3368 double d = extract_float(fexp);
3369
3370 if (featurep_emacs_version == 0.0)
3371 {
3372 featurep_emacs_version = emacs_major_version +
3373 (emacs_minor_version / 100.0);
3374 }
3375 return (featurep_emacs_version >= d) ? Qt : Qnil;
3376 }
3377 else if (CONSP(fexp))
3378 {
3379 Lisp_Object tem;
3380
3381 tem = XCAR(fexp);
3382 if (EQ(tem, Qnot))
3383 {
3384 Lisp_Object negate = XCDR(fexp);
3385
3386 if (!NILP(XCDR(fexp)))
3387 {
3388 return Fsignal(Qinvalid_read_syntax, list1(XCDR(fexp)));
3389 }
3390 else
3391 {
3392 return NILP(Ffeaturep(negate)) ? Qt : Qnil;
3393 }
3394 }
3395 else if (EQ(tem, Qand))
3396 {
3397 tem = XCDR(fexp);
3398 while (!NILP(tem) && !NILP(Ffeaturep(XCAR(tem))))
3399 {
3400 tem = XCDR(tem);
3401 }
3402 return NILP(tem) ? Qt : Qnil;
3403 }
3404 else if (EQ(tem, Qor))
3405 {
3406 tem = XCDR(fexp);
3407 while (!NILP(tem) && NILP(Ffeaturep(XCAR(tem))))
3408 {
3409 tem = XCDR(tem);
3410 }
3411 return NILP(tem) ? Qnil : Qt;
3412 }
3413 else
3414 {
3415 return Fsignal(Qinvalid_read_syntax, list1(XCDR(fexp)));
3416 }
3417 }
3418 else
3419 {
3420 return Fsignal(Qinvalid_read_syntax, list1 (fexp));
3421 }
3334 } 3422 }
3335 #endif 3423 #endif
3336 3424
3337 DEFUN ("provide", Fprovide, 1, 1, 0, /* 3425 DEFUN ("provide", Fprovide, 1, 1, 0, /*
3338 Announce that FEATURE is a feature of the current Emacs. 3426 Announce that FEATURE is a feature of the current Emacs.
3463 DEFSUBR (Fequal); 3551 DEFSUBR (Fequal);
3464 DEFSUBR (Fold_equal); 3552 DEFSUBR (Fold_equal);
3465 DEFSUBR (Ffillarray); 3553 DEFSUBR (Ffillarray);
3466 DEFSUBR (Fnconc); 3554 DEFSUBR (Fnconc);
3467 DEFSUBR (Fmapcar); 3555 DEFSUBR (Fmapcar);
3556 DEFSUBR (Fmapvector);
3468 DEFSUBR (Fmapc_internal); 3557 DEFSUBR (Fmapc_internal);
3469 DEFSUBR (Fmapconcat); 3558 DEFSUBR (Fmapconcat);
3470 DEFSUBR (Fload_average); 3559 DEFSUBR (Fload_average);
3471 #ifndef FEATUREP_SYNTAX 3560 /*#ifndef FEATUREP_SYNTAX*/
3472 DEFSUBR (Ffeaturep); 3561 DEFSUBR (Ffeaturep);
3473 #endif 3562 /*#endif*/
3474 DEFSUBR (Frequire); 3563 DEFSUBR (Frequire);
3475 DEFSUBR (Fprovide); 3564 DEFSUBR (Fprovide);
3476 } 3565 }
3477 3566
3478 void 3567 void