cons 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cons.rb +23 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03bf0fb5c5ddae8eb049455c8d4a66673563cdb9
4
- data.tar.gz: 628c0f196d8fe9a0c819d7741969ff457c8f3d1d
3
+ metadata.gz: 6fc1264739f0ef0a44ae89584fe730894635a84e
4
+ data.tar.gz: aa2cd8cc42e95bfcf9b4b189d585dcaefa3ec2e1
5
5
  SHA512:
6
- metadata.gz: 751c698c4b92cca312aa11abad0739ff10fdf20dc9a992fa86a35d4b7f70c04002a57044c19e32afa7cccd7ae6474833f1ac468a19e61cdd51efe45d59b0968e
7
- data.tar.gz: 5ef764711df875cff7a415bc3c9a39045fdc40bcb4b47c0c41aada4841f3cd8110cc4cf18dc78ca5c5062dd019a6622bd56a2c918b0e09d36bd07ed666962c3c
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
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.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mark Gore