Arc Forumnew | comments | leaders | submitlogin
6 points by kennytilton 6139 days ago | link | parent

"Would anyone really care if they just went away?"

You mean a cons cell only has a CAR slot, there is no CDR? :)

Or that you would ban me from storing anything other than nil or another cons in the cdr?

ie, dotted lists are not really "there", so they cannot go away.



2 points by nzc 6139 days ago | link

Neh, what I meant was, you can have a thing that quacks like a list and never see the need for a dotted pair.

That can be hidden below the abstraction. See, case in point, lists/arrays in Ruby, which are more or less lists without the car and cdr part. Although, you do get a 'nil' if you access beyond the end of the array. ;-)

-----

9 points by kennytilton 6139 days ago | link

Ruby lists can quack? Bah, let me know when they can mate, that's when you know you have the same species: ie, can two Ruby more-or-less lists have shared structure, formed say by ruby-consing a different element onto the same list?

And ducks can nest. How about Ruby lists? I have always thought the language should have been called Trep, for Tree Processing language. Can I build a Ruby tree and then quickly flatten by juggling some Ruby ducktails?

As for "That can be hidden below the abstraction", OK, now you have a duck: moving smoothly on the surface and paddling like crazy beneath.

The whole comparison just seems (sorry on more levels than one) daffy.

-----

3 points by absz 6139 days ago | link

Indeed, you are correct. Ruby[1] doesn't have "native" lists, it has native arrays. Observe:

  irb(main):001:0> [].class
  => Array
There is no Ruby cons, nor Ruby car, nor Ruby cdr. There is y.unshift x or [x] + y for cons (though these cannot constructed "dotted Arrays"), arr[0] or arr.first for car, and arr[1..-1] for cdr, but they denote no structure-sharing. However, flattening would merely be arr.flatten—of course it doesn't work by cdr-juggling, but that's because there are no cdrs.

I'm not really sure what the grandparent post means: "lists without the car and cdr part"? That sounds to me like a very good definition of an... array![2]

Also, that set of duck puns/references was fantastic. Well done.

[1]: Which is a very nice language.

[2]: Well, without the O(1) access time, but I digress.

-----

5 points by kennytilton 6138 days ago | link

"that set of duck puns/references was fantastic."

I can take no credit -- they just popped out of my keyboard. There must be some poorly understood connection between algorithms, data structures, and waterfowl.

-----

3 points by absz 6138 days ago | link

I smell a Ph.D. thesis afoot... awing?

Actually, they (the infamous "they") did a study, and apparently, ducks are the funniest animal. Take that with as large a grain of salt as you think is appropriate :)

-----

1 point by vincenz 6123 days ago | link

This is directly related to the existence of "daffy duck"

-----