comparison src/sequence.c @ 5752:70a3f4ff8da8

Improve coding style, variable names, data.c, sequence.c src/ChangeLog addition: 2013-08-05 Aidan Kehoe <kehoea@parhasard.net> * data.c: * data.c (Fcar): * data.c (Fcdr): * data.c (Fmake_weak_box): * data.c (Fweak_box_ref): * data.c (init_marking_ephemerons): * data.c (continue_marking_ephemerons): * data.c (finish_marking_ephemerons): * data.c (prune_ephemerons): * data.c (zap_finalize_list): * data.c (ephemeron_equal): * data.c (ephemeron_hash): * data.c (Fmake_ephemeron): * data.c (Fephemeron_ref): * data.c (Fephemeronp): * sequence.c: * sequence.c (Fcopy_tree): * sequence.c (Freplace): Improve coding style here; #'car and #'cdr accept lists, not just cons cells, update their argument names to reflect that. Follow coding conventions in the weak box and ephemeron code. Don't needlessly abbreviate in copy-tree, use argument names from Common Lisp in #'merge and #'replace. Document ALIST better in #'nsublis, #'sublis.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 05 Aug 2013 17:20:16 +0100
parents 37479d841681
children cd4f5f1f1f4c
comparison
equal deleted inserted replaced
5751:2b8edd304c2b 5752:70a3f4ff8da8
1159 1159
1160 DEFUN ("copy-tree", Fcopy_tree, 1, 2, 0, /* 1160 DEFUN ("copy-tree", Fcopy_tree, 1, 2, 0, /*
1161 Return a copy of a list and substructures. 1161 Return a copy of a list and substructures.
1162 The argument is copied, and any lists contained within it are copied 1162 The argument is copied, and any lists contained within it are copied
1163 recursively. Circularities and shared substructures are not preserved. 1163 recursively. Circularities and shared substructures are not preserved.
1164 Second arg VECP causes vectors to be copied, too. Strings and bit vectors 1164 Second arg VECTORP causes vectors to be copied, too. Strings and bit
1165 are not copied. 1165 vectors are not copied.
1166 */ 1166 */
1167 (arg, vecp)) 1167 (arg, vectorp))
1168 { 1168 {
1169 return safe_copy_tree (arg, vecp, 0); 1169 return safe_copy_tree (arg, vectorp, 0);
1170 } 1170 }
1171 1171
1172 Lisp_Object 1172 Lisp_Object
1173 safe_copy_tree (Lisp_Object arg, Lisp_Object vecp, int depth) 1173 safe_copy_tree (Lisp_Object arg, Lisp_Object vecp, int depth)
1174 { 1174 {
3721 c_array[counter] = make_fixnum (bit_vector_bit (v, counter)); \ 3721 c_array[counter] = make_fixnum (bit_vector_bit (v, counter)); \
3722 } \ 3722 } \
3723 } while (0) 3723 } while (0)
3724 3724
3725 DEFUN ("merge", Fmerge, 4, MANY, 0, /* 3725 DEFUN ("merge", Fmerge, 4, MANY, 0, /*
3726 Destructively merge SEQUENCE-ONE and SEQUENCE-TWO, producing a new sequence. 3726 Destructively merge SEQUENCE1 and SEQUENCE2, producing a new sequence.
3727 3727
3728 TYPE is the type of sequence to return. PREDICATE is a `less-than' 3728 TYPE is the type of sequence to return. PREDICATE is a `less-than'
3729 predicate on the elements. 3729 predicate on the elements.
3730 3730
3731 Optional keyword argument KEY is a function used to extract an object to be 3731 Optional keyword argument KEY is a function used to extract an object to be
3732 used for comparison from each element of SEQUENCE-ONE and SEQUENCE-TWO. 3732 used for comparison from each element of SEQUENCE1 and SEQUENCE2.
3733 3733
3734 arguments: (TYPE SEQUENCE-ONE SEQUENCE-TWO PREDICATE &key (KEY #'IDENTITY)) 3734 arguments: (TYPE SEQUENCE1 SEQUENCE2 PREDICATE &key (KEY #'IDENTITY))
3735 */ 3735 */
3736 (int nargs, Lisp_Object *args)) 3736 (int nargs, Lisp_Object *args))
3737 { 3737 {
3738 Lisp_Object type = args[0], sequence_one = args[1], sequence_two = args[2], 3738 Lisp_Object type = args[0], sequence_one = args[1], sequence_two = args[2],
3739 predicate = args[3], result = Qnil; 3739 predicate = args[3], result = Qnil;
5268 5268
5269 return dest; 5269 return dest;
5270 } 5270 }
5271 5271
5272 DEFUN ("replace", Freplace, 2, MANY, 0, /* 5272 DEFUN ("replace", Freplace, 2, MANY, 0, /*
5273 Replace the elements of SEQUENCE-ONE with the elements of SEQUENCE-TWO. 5273 Replace the elements of SEQUENCE1 with the elements of SEQUENCE2.
5274 5274
5275 SEQUENCE-ONE is destructively modified, and returned. Its length is not 5275 SEQUENCE1 is destructively modified, and returned. Its length is not
5276 changed. 5276 changed.
5277 5277
5278 Keywords :start1 and :end1 specify a subsequence of SEQUENCE-ONE, and 5278 Keywords :start1 and :end1 specify a subsequence of SEQUENCE1, and
5279 :start2 and :end2 a subsequence of SEQUENCE-TWO. See `search' for more 5279 :start2 and :end2 a subsequence of SEQUENCE2. See `search' for more
5280 information. 5280 information.
5281 5281
5282 arguments: (SEQUENCE-ONE SEQUENCE-TWO &key (START1 0) (END1 (length SEQUENCE-ONE)) (START2 0) (END2 (length SEQUENCE-TWO))) 5282 arguments: (SEQUENCE1 SEQUENCE2 &key (START1 0) (END1 (length SEQUENCE1)) (START2 0) (END2 (length SEQUENCE2)))
5283 */ 5283 */
5284 (int nargs, Lisp_Object *args)) 5284 (int nargs, Lisp_Object *args))
5285 { 5285 {
5286 Lisp_Object sequence1 = args[0], sequence2 = args[1], 5286 Lisp_Object sequence1 = args[0], sequence2 = args[1],
5287 result = sequence1; 5287 result = sequence1;
6232 6232
6233 DEFUN ("sublis", Fsublis, 2, MANY, 0, /* 6233 DEFUN ("sublis", Fsublis, 2, MANY, 0, /*
6234 Perform substitutions indicated by ALIST in TREE (non-destructively). 6234 Perform substitutions indicated by ALIST in TREE (non-destructively).
6235 Return a copy of TREE with all matching elements replaced. 6235 Return a copy of TREE with all matching elements replaced.
6236 6236
6237 Each dotted pair in ALIST describes a map from an old value (the car) to be
6238 replaced by a new value (the cdr).
6239
6237 See `member*' for the meaning of :test, :test-not and :key. 6240 See `member*' for the meaning of :test, :test-not and :key.
6238 6241
6239 arguments: (ALIST TREE &key (TEST #'eql) (KEY #'identity) TEST-NOT) 6242 arguments: (ALIST TREE &key (TEST #'eql) (KEY #'identity) TEST-NOT)
6240 */ 6243 */
6241 (int nargs, Lisp_Object *args)) 6244 (int nargs, Lisp_Object *args))
6359 } 6362 }
6360 6363
6361 DEFUN ("nsublis", Fnsublis, 2, MANY, 0, /* 6364 DEFUN ("nsublis", Fnsublis, 2, MANY, 0, /*
6362 Perform substitutions indicated by ALIST in TREE (destructively). 6365 Perform substitutions indicated by ALIST in TREE (destructively).
6363 Any matching element of TREE is changed via a call to `setcar'. 6366 Any matching element of TREE is changed via a call to `setcar'.
6367
6368 Each dotted pair in ALIST describes a map from an old value (the car) to be
6369 replaced by a new value (the cdr).
6364 6370
6365 See `member*' for the meaning of :test, :test-not and :key. 6371 See `member*' for the meaning of :test, :test-not and :key.
6366 6372
6367 arguments: (ALIST TREE &key (TEST #'eql) (KEY #'identity) TEST-NOT) 6373 arguments: (ALIST TREE &key (TEST #'eql) (KEY #'identity) TEST-NOT)
6368 */ 6374 */