Array#rest

Hello David,

then we can even define Array#cadr and so on :wink:

What problem would this solve?

$USERDEFINED problem. In Lisp there are car, cdr and often(?) cddr
cadr,... which access members of lists (cadr acesses the second
element, cddr the third, fourth .... element). Absolutely no need to
put this into ruby itself though. Its more a mnemonic and shorter to
type. Example (setq mylist '((1 a))) then (car (cdr 'mylist)) is the
same as (caar 'mylist) which is 1.

Patrick

Hi --

···

On Fri, 11 Jun 2004, Patrick Gundlach wrote:

Hello David,

>> then we can even define Array#cadr and so on :wink:
>
> What problem would this solve?

$USERDEFINED problem. In Lisp there are car, cdr and often(?) cddr
cadr,... which access members of lists (cadr acesses the second
element, cddr the third, fourth .... element). Absolutely no need to
put this into ruby itself though. Its more a mnemonic and shorter to
type. Example (setq mylist '((1 a))) then (car (cdr 'mylist)) is the
same as (caar 'mylist) which is 1.

I know about it from Lisp, just wondering how/whether it would enhance
Ruby. I can see 'rest' as a companion to 'first' and 'last', but
going down the road of car, cdr and friends seems like a language
pastiche.

David

--
David A. Black
dblack@wobblini.net

"Patrick Gundlach" <clr1.10.randomuser@spamgourmet.com> schrieb im
Newsbeitrag news:m2r7smqm83.fsf@levana.de...

Hello David,

>> then we can even define Array#cadr and so on :wink:
>
> What problem would this solve?

$USERDEFINED problem. In Lisp there are car, cdr and often(?) cddr
cadr,... which access members of lists (cadr acesses the second
element, cddr the third, fourth .... element). Absolutely no need to
put this into ruby itself though. Its more a mnemonic and shorter to
type. Example (setq mylist '((1 a))) then (car (cdr 'mylist)) is the
same as (caar 'mylist) which is 1.

Huh? What am I missing here? It seems (caar x) is short for (car (car
x))...

[1]> (setq mylist '((1 a)))
((1 A))
[2]> (car (cdr 'mylist))

*** - CDR: MYLIST is not a LIST
Break 1 [3]>
[4]> (car (cdr mylist))
NIL
[5]> (caar 'mylist)

*** - CAAR: MYLIST is not a LIST
Break 1 [6]>
[7]> (caar mylist)
1
[8]> (car (car mylist))
1

GNU clisp

    robert

"David A. Black" <dblack@wobblini.net> schrieb im Newsbeitrag
news:Pine.LNX.4.44.0406111136400.19371-100000@wobblini...

Hi --

> Hello David,
>
> >> then we can even define Array#cadr and so on :wink:
> >
> > What problem would this solve?
>
> $USERDEFINED problem. In Lisp there are car, cdr and often(?) cddr
> cadr,... which access members of lists (cadr acesses the second
> element, cddr the third, fourth .... element). Absolutely no need to
> put this into ruby itself though. Its more a mnemonic and shorter to
> type. Example (setq mylist '((1 a))) then (car (cdr 'mylist)) is the
> same as (caar 'mylist) which is 1.

I know about it from Lisp, just wondering how/whether it would enhance
Ruby. I can see 'rest' as a companion to 'first' and 'last', but
going down the road of car, cdr and friends seems like a language
pastiche.

Sounds like a good suggestion for an RAA project "rlisp" to make lispers
feel at home with Ruby. :slight_smile:

    robert

···

On Fri, 11 Jun 2004, Patrick Gundlach wrote:

Hello Robert,

"Patrick Gundlach" <clr1.10.randomuser@spamgourmet.com> schrieb im
Newsbeitrag news:m2r7smqm83.fsf@levana.de...

type. Example (setq mylist '((1 a))) then (car (cdr 'mylist)) is the
same as (caar 'mylist) which is 1.

"Robert Klemme" <bob.news@gmx.net> writes:

Huh? What am I missing here? It seems (caar x) is short for (car (car
x))...

sorry, two stupid typos in one row. :frowning: I can't put it on the late
hour, it was afternoon when I wrote my reply.

You're right. it should be (car (car ...)) = (caar ..) and not
'mylist but unquoted mylist.

Patrick