cons 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cons.rb +26 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 991e2750c6a71c9463006e5a71066687ecdb9b47
|
4
|
+
data.tar.gz: d38f6398455cdcfccf8f5224dea54399523c6394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d2cf5e7df474aeed2e20a956bc5c82964ae4993561bc6777e623d448505b26e3f61b57c720348457960b322b2018c55fa5632b592485d3511fbb6941e64b18d
|
7
|
+
data.tar.gz: b2ce3dcd7a1491561782408faea3c40ce13bd7dd1846a39df60ccf5642a81618fe903f84395f16bd654f2d648889880d940ddc6fdafc67b56b91381ffe0854db
|
data/lib/cons.rb
CHANGED
@@ -194,6 +194,31 @@ class Cons
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
+
# Returns a copy of list. If list is a dotted list, the resulting list will
|
198
|
+
# also be a dotted list.
|
199
|
+
#
|
200
|
+
# Cf. <http://clhs.lisp.se/Body/f_cp_lis.htm>
|
201
|
+
def copy_list
|
202
|
+
new_cdr = if cdr.kind_of? Cons
|
203
|
+
cdr.copy_list
|
204
|
+
else
|
205
|
+
cdr
|
206
|
+
end
|
207
|
+
Cons[@car,new_cdr]
|
208
|
+
end
|
209
|
+
|
210
|
+
alias list_copy copy_list
|
211
|
+
|
212
|
+
# Creates a copy of a tree of conses.
|
213
|
+
#
|
214
|
+
# If tree is not a cons, it is returned; otherwise, the result is a new cons
|
215
|
+
# of the results of calling copy-tree on the car and cdr of tree. In other
|
216
|
+
# words, all conses in the tree represented by tree are copied recursively,
|
217
|
+
# stopping only when non-conses are encountered.
|
218
|
+
#
|
219
|
+
# copy-tree does not preserve circularities and the sharing of substructure.
|
220
|
+
#
|
221
|
+
# Cf. <http://clhs.lisp.se/Body/f_cp_tre.htm>
|
197
222
|
def copy_tree
|
198
223
|
new_car = if car.kind_of? Cons
|
199
224
|
car.copy_tree
|
@@ -282,8 +307,6 @@ class Cons
|
|
282
307
|
## Lots of TODOs from the CLHS
|
283
308
|
|
284
309
|
# TODO - (n)butlast - http://clhs.lisp.se/Body/f_butlas.htm
|
285
|
-
# TODO - copy-alist - http://clhs.lisp.se/Body/f_cp_ali.htm
|
286
|
-
# TODO - copy-list - http://clhs.lisp.se/Body/f_cp_lis.htm
|
287
310
|
# TODO - endp - http://clhs.lisp.se/Body/f_endp.htm
|
288
311
|
# TODO - ldiff, tailp - http://clhs.lisp.se/Body/f_ldiffc.htm
|
289
312
|
# TODO - list* - http://clhs.lisp.se/Body/f_list_.htm
|
@@ -296,6 +319,7 @@ class Cons
|
|
296
319
|
# TODO - (n)sublis - http://clhs.lisp.se/Body/f_sublis.htm
|
297
320
|
|
298
321
|
## Alist stuff
|
322
|
+
# TODO - copy-alist - http://clhs.lisp.se/Body/f_cp_ali.htm
|
299
323
|
# TODO - acons - http://clhs.lisp.se/Body/f_acons.htm
|
300
324
|
# TODO - assoc, assoc-if, assoc-if-not - http://clhs.lisp.se/Body/f_assocc.htm
|
301
325
|
# TODO - pairlis - http://clhs.lisp.se/Body/f_pairli.htm
|