cons 1.1.2 → 1.1.3
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 +23 -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: 6fc1264739f0ef0a44ae89584fe730894635a84e
|
4
|
+
data.tar.gz: aa2cd8cc42e95bfcf9b4b189d585dcaefa3ec2e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a4e3bfcb1e435c1eff543e655c111844c561e1bcf992b9cc0b9940a72e29ca743c1e56af65a5cf4b07f02be9278cc6e5682da1d01bb2359f3a865003f06772d
|
7
|
+
data.tar.gz: 0ff6132cc51d44f13e161beade6a40faf0a190cbc1aacf2578506eeb1f830b0da7ea7e7794460aa307164554d6517f8ed8999dcb0c026819d2c3e2b0e4f39e2e
|
data/lib/cons.rb
CHANGED
@@ -256,6 +256,29 @@ class Cons
|
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
259
|
+
# The pop method reads the value of place, remembers the car of the list which
|
260
|
+
# was retrieved, writes the cdr of the list back into the place, and finally
|
261
|
+
# yields the car of the originally retrieved list.
|
262
|
+
#
|
263
|
+
# Cf. <http://clhs.lisp.se/Body/m_pop.htm>
|
264
|
+
def pop
|
265
|
+
result = @car
|
266
|
+
n = @cdr
|
267
|
+
@car = n.car
|
268
|
+
@cdr = n.cdr
|
269
|
+
return result
|
270
|
+
end
|
271
|
+
|
272
|
+
# push prepends item to the list that is stored in place, stores the resulting
|
273
|
+
# list in place, and returns the list.
|
274
|
+
#
|
275
|
+
# Cf. <http://clhs.lisp.se/Body/m_push.htm>
|
276
|
+
def push value
|
277
|
+
@cdr = Cons[@car,@cdr]
|
278
|
+
@car = value
|
279
|
+
return self
|
280
|
+
end
|
281
|
+
|
259
282
|
## Lots of TODOs from the CLHS
|
260
283
|
|
261
284
|
# TODO - (n)butlast - http://clhs.lisp.se/Body/f_butlas.htm
|
@@ -268,8 +291,6 @@ class Cons
|
|
268
291
|
# TODO - member, member-if, member-if-not - http://clhs.lisp.se/Body/f_mem_m.htm
|
269
292
|
# TODO - nconc - http://clhs.lisp.se/Body/f_nconc.htm
|
270
293
|
# TODO - revappend, nreconc - http://clhs.lisp.se/Body/f_revapp.htm
|
271
|
-
# TODO - pop - http://clhs.lisp.se/Body/m_pop.htm
|
272
|
-
# TODO - push - http://clhs.lisp.se/Body/m_push.htm
|
273
294
|
# TODO - pushnew - http://clhs.lisp.se/Body/m_pshnew.htm
|
274
295
|
# TODO - (n)subst, (n)subst-if, (n)subst-if-not - http://clhs.lisp.se/Body/f_substc.htm
|
275
296
|
# TODO - (n)sublis - http://clhs.lisp.se/Body/f_sublis.htm
|