develooper Front page | perl.perl6.language | Postings from August 2005

Re: $pair[0]?

Thread Previous | Thread Next
From:
Yuval Kogman
Date:
August 5, 2005 13:25
Subject:
Re: $pair[0]?
On Fri, Aug 05, 2005 at 11:36:16 -0700, Larry Wall wrote:

> There's something to be said for having a way of indexing into that
> using numeric subscripts.  Certainly Lisp's extensible car/cdr notation
> is the wrong way to do it, but cdddr is certainly shorter than
> 
>     $pair.value.value.value
> 
> But maybe that's worth being dehuffmanized like that...

Haskell has !! :

sub infix:<!!> (Pair $x, 0) { $x.key }
sub infix:<!!> (Pair $x, Int $index) { $x.value !! ($index - 1) }

-- 
 ()  Yuval Kogman <nothingmuch@woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: /me supports the ASCII Ribbon Campaign: neeyah!!!



Thread Previous | Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About