Mercurial > hg > xemacs-beta
comparison src/fns.c @ 274:ca9a9ec9c1c1 r21-0b35
Import from CVS: tag r21-0b35
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:29:42 +0200 |
parents | c5d627a313b1 |
children | 6330739388db |
comparison
equal
deleted
inserted
replaced
273:411aac7253ef | 274:ca9a9ec9c1c1 |
---|---|
962 Take cdr N times on LIST, and return the result. | 962 Take cdr N times on LIST, and return the result. |
963 */ | 963 */ |
964 (n, list)) | 964 (n, list)) |
965 { | 965 { |
966 REGISTER int i; | 966 REGISTER int i; |
967 REGISTER Lisp_Object tail = list; | |
967 CHECK_NATNUM (n); | 968 CHECK_NATNUM (n); |
968 for (i = XINT (n); i; i--) | 969 for (i = XINT (n); i; i--) |
969 { | 970 { |
970 if (NILP (list)) | 971 if (CONSP (tail)) |
971 return list; | 972 tail = XCDR (tail); |
972 CHECK_CONS (list); | 973 else if (NILP (tail)) |
973 list = XCDR (list); | 974 return Qnil; |
974 QUIT; | 975 else |
975 } | 976 { |
976 return list; | 977 tail = wrong_type_argument (Qlistp, tail); |
978 i++; | |
979 } | |
980 } | |
981 return tail; | |
977 } | 982 } |
978 | 983 |
979 DEFUN ("nth", Fnth, 2, 2, 0, /* | 984 DEFUN ("nth", Fnth, 2, 2, 0, /* |
980 Return the Nth element of LIST. | 985 Return the Nth element of LIST. |
981 N counts from zero. If LIST is not that long, nil is returned. | 986 N counts from zero. If LIST is not that long, nil is returned. |
1004 else | 1009 else |
1005 #if 1 | 1010 #if 1 |
1006 /* This is The Way It Has Always Been. */ | 1011 /* This is The Way It Has Always Been. */ |
1007 return Qnil; | 1012 return Qnil; |
1008 #else | 1013 #else |
1009 /* This is The Way Mly Says It Should Be. */ | 1014 /* This is The Way Mly and Cltl2 say It Should Be. */ |
1010 args_out_of_range (sequence, n); | 1015 args_out_of_range (sequence, n); |
1011 #endif | 1016 #endif |
1012 } | 1017 } |
1013 else if (STRINGP (sequence) | 1018 else if (STRINGP (sequence) |
1014 || VECTORP (sequence) | 1019 || VECTORP (sequence) |