cons 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cons.rb +26 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a26a2155d3d263ecd52bb230db131f9619a1e5a4
4
- data.tar.gz: 11378411b0f10c870551495f2624409fbbf8720b
3
+ metadata.gz: 991e2750c6a71c9463006e5a71066687ecdb9b47
4
+ data.tar.gz: d38f6398455cdcfccf8f5224dea54399523c6394
5
5
  SHA512:
6
- metadata.gz: d1154b04fe6aebcdd1c122c66702e358e172528b307e134716695bbe9e7a596f1dd19a91637efd3b294475e629b64d8a0566512696cbf7e125a3579ee0c09a01
7
- data.tar.gz: 821a3ae01029c14e04f0c258a3e7343e67a24e7abc1d37db909a6f71a6dec77c8c3ebc5fc7711087a01c252ad011ade31ef5dc43d4e0e30e5bdf2d99454ed8bb
6
+ metadata.gz: 8d2cf5e7df474aeed2e20a956bc5c82964ae4993561bc6777e623d448505b26e3f61b57c720348457960b322b2018c55fa5632b592485d3511fbb6941e64b18d
7
+ data.tar.gz: b2ce3dcd7a1491561782408faea3c40ce13bd7dd1846a39df60ccf5642a81618fe903f84395f16bd654f2d648889880d940ddc6fdafc67b56b91381ffe0854db
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mark Gore