Theiling Online    Sitemap    Conlang Mailing List HQ   

Re: OT: How to do a reverse word list in Perl

From:Henrik Theiling <theiling@...>
Date:Friday, October 27, 2006, 15:11
Hi!

Mark Reed writes:
> Well, you could do it that way in perl, too: > > map { reverse } > sort > map { reverse } > <>; > > But I suspect keeping the original and reverting to it is more > efficient than re-reversing it. >...
Ah, is this about efficiency? I don't really care unless it improves the readability of the program or at least reduces the theoretical computational complexity. Readability and simplicity are much more important to me than plain efficiency. Unless it is really, really, really necessary to speed the program up for the given purpose, I would think invoking a function twice as many times does not justify writing complex indexing of temporary arrays, for example. So in Perl, I'd indeed prefer sort { reverse($a) cmp reverse($b) }, because it's much more readable (for me). But this is just my personal idea of programming, of course. **Henrik

Reply

Mark J. Reed <markjreed@...>