Mercurial > emacs
comparison src/fns.c @ 20992:d2366423bc00
(mapcar1): Handle bool-vectors.
(Fmapconcat, Fmapcar): Doc fixes.
(Flength): For char-table, length is based on max valid char code.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Fri, 27 Feb 1998 21:52:08 +0000 |
parents | 7ad239d7020b |
children | 7be2384fabdc |
comparison
equal
deleted
inserted
replaced
20991:0cd10d49b777 | 20992:d2366423bc00 |
---|---|
123 if (STRINGP (sequence)) | 123 if (STRINGP (sequence)) |
124 XSETFASTINT (val, XSTRING (sequence)->size); | 124 XSETFASTINT (val, XSTRING (sequence)->size); |
125 else if (VECTORP (sequence)) | 125 else if (VECTORP (sequence)) |
126 XSETFASTINT (val, XVECTOR (sequence)->size); | 126 XSETFASTINT (val, XVECTOR (sequence)->size); |
127 else if (CHAR_TABLE_P (sequence)) | 127 else if (CHAR_TABLE_P (sequence)) |
128 XSETFASTINT (val, CHAR_TABLE_ORDINARY_SLOTS); | 128 XSETFASTINT (val, (MIN_CHAR_COMPOSITION |
129 + (CHAR_FIELD2_MASK | CHAR_FIELD3_MASK) | |
130 - 1)); | |
129 else if (BOOL_VECTOR_P (sequence)) | 131 else if (BOOL_VECTOR_P (sequence)) |
130 XSETFASTINT (val, XBOOL_VECTOR (sequence)->size); | 132 XSETFASTINT (val, XBOOL_VECTOR (sequence)->size); |
131 else if (COMPILEDP (sequence)) | 133 else if (COMPILEDP (sequence)) |
132 XSETFASTINT (val, XVECTOR (sequence)->size & PSEUDOVECTOR_SIZE_MASK); | 134 XSETFASTINT (val, XVECTOR (sequence)->size & PSEUDOVECTOR_SIZE_MASK); |
133 else if (CONSP (sequence)) | 135 else if (CONSP (sequence)) |
2057 { | 2059 { |
2058 dummy = XVECTOR (seq)->contents[i]; | 2060 dummy = XVECTOR (seq)->contents[i]; |
2059 vals[i] = call1 (fn, dummy); | 2061 vals[i] = call1 (fn, dummy); |
2060 } | 2062 } |
2061 } | 2063 } |
2064 else if (BOOL_VECTOR_P (seq)) | |
2065 { | |
2066 for (i = 0; i < leni; i++) | |
2067 { | |
2068 int byte; | |
2069 byte = XBOOL_VECTOR (seq)->data[i / BITS_PER_CHAR]; | |
2070 if (byte & (1 << (i % BITS_PER_CHAR))) | |
2071 dummy = Qt; | |
2072 else | |
2073 dummy = Qnil; | |
2074 | |
2075 vals[i] = call1 (fn, dummy); | |
2076 } | |
2077 } | |
2062 else if (STRINGP (seq) && ! STRING_MULTIBYTE (seq)) | 2078 else if (STRINGP (seq) && ! STRING_MULTIBYTE (seq)) |
2063 { | 2079 { |
2064 /* Single-byte string. */ | 2080 /* Single-byte string. */ |
2065 for (i = 0; i < leni; i++) | 2081 for (i = 0; i < leni; i++) |
2066 { | 2082 { |
2098 } | 2114 } |
2099 | 2115 |
2100 DEFUN ("mapconcat", Fmapconcat, Smapconcat, 3, 3, 0, | 2116 DEFUN ("mapconcat", Fmapconcat, Smapconcat, 3, 3, 0, |
2101 "Apply FUNCTION to each element of SEQUENCE, and concat the results as strings.\n\ | 2117 "Apply FUNCTION to each element of SEQUENCE, and concat the results as strings.\n\ |
2102 In between each pair of results, stick in SEPARATOR. Thus, \" \" as\n\ | 2118 In between each pair of results, stick in SEPARATOR. Thus, \" \" as\n\ |
2103 SEPARATOR results in spaces between the values returned by FUNCTION.") | 2119 SEPARATOR results in spaces between the values returned by FUNCTION.\n\ |
2120 SEQUENCE may be a list, a vector, a bool-vector, or a string.") | |
2104 (function, sequence, separator) | 2121 (function, sequence, separator) |
2105 Lisp_Object function, sequence, separator; | 2122 Lisp_Object function, sequence, separator; |
2106 { | 2123 { |
2107 Lisp_Object len; | 2124 Lisp_Object len; |
2108 register int leni; | 2125 register int leni; |
2132 } | 2149 } |
2133 | 2150 |
2134 DEFUN ("mapcar", Fmapcar, Smapcar, 2, 2, 0, | 2151 DEFUN ("mapcar", Fmapcar, Smapcar, 2, 2, 0, |
2135 "Apply FUNCTION to each element of SEQUENCE, and make a list of the results.\n\ | 2152 "Apply FUNCTION to each element of SEQUENCE, and make a list of the results.\n\ |
2136 The result is a list just as long as SEQUENCE.\n\ | 2153 The result is a list just as long as SEQUENCE.\n\ |
2137 SEQUENCE may be a list, a vector or a string.") | 2154 SEQUENCE may be a list, a vector, a bool-vector, or a string.") |
2138 (function, sequence) | 2155 (function, sequence) |
2139 Lisp_Object function, sequence; | 2156 Lisp_Object function, sequence; |
2140 { | 2157 { |
2141 register Lisp_Object len; | 2158 register Lisp_Object len; |
2142 register int leni; | 2159 register int leni; |