ryan
2016-3-14 02:26:16

So I’m learning Racket and the concept of cons cells is confusing me. The way it’s described in Realm of Racket makes it sound like these are pretty much the same thing as a linked list. So are list in Racket just linked list or am I missing something?


cky
2016-3-14 02:33:01

@ryan: All lists in Racket are linked lists.


cky
2016-3-14 02:33:10

In particular, singly-linked lists made up of cons cells.


cky
2016-3-14 02:34:21

Cons cells are the individual units of a linked list.


cky
2016-3-14 02:34:39

So, for example, consider the list (1 2 3 4). This is made up of 4 cons cells:


cky
2016-3-14 02:34:52
  1. (4 . ())

cky
2016-3-14 02:35:01
  1. (3 . #1#)

cky
2016-3-14 02:35:10
  1. (2 . #2#)

cky
2016-3-14 02:35:20
  1. (1 . #3#)

cky
2016-3-14 02:35:49

(where #1#, etc. are backreferences to the cons cells I listed above)


ryan
2016-3-14 02:36:01

Gotcha. Thanks for explaining.


cky
2016-3-14 02:38:04

Someone, perhaps me, should port PasteRack to a Slackbot. Kind of like the now-defunct rudybot.


cky
2016-3-14 02:38:32

I really miss being able to eval stuff on the go, to demonstrate stuff.


florence
2016-3-14 02:45:52

rudybot went defunct…?