Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Re: Shortest -return index of element in array- sub

by mr_mischief (Monsignor)
on Apr 04, 2001 at 08:10 UTC ( [id://69545]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Shortest -return index of element in array- sub
in thread Shortest -return index of element in array- sub

Now that I've taken a closer look, this is the shortest iterative version I could find (and also the shortest I could make it and have it run under strictures and warnings, although those aren't really prerequisites in golf):
sub indexArray3{ 1while$_[0]ne pop;$#_ }
I'd say that's pretty obfuscated, too. It can be done in a couple fewer characters recursively, if you use a one-character subroutine name and eliminate any unnecessary whitespace. I'd like to know hoe to do it in fewer iteratively, but I just can't figure anything out. Please point it out to me if there's a way.

Chris Stith

Replies are listed 'Best First'.
Re (tilly) 4: Shortest -return index of element in array- sub
by tilly (Archbishop) on Apr 04, 2001 at 18:41 UTC
      Apology accepted. In golf, I like to play with what the parser recognizes with whitespace and without. I'll try to credit other people from now on when I use their ideas. I thought the thread was short enough that it would be obvious where the idea was from. I don't intend to steal ideas, just borrow. I'll make it more clear that's what I'm doing. BTW, I'm not fond of trolls, either. You can find me remarking on such osts over on clpmisc quite a bit. Come to think of it, you can find me on clpmisc quite a bit in general. Chris BTW, here's my first JAPh, just so there'll be some code in my node. Comments welcome.
      $z = int(rand(1000)+1); $y = 'reverse ' x $z; eval eval qq{$y "@{['\"n\\\\.rekcaH','lreP','rehtonA','tsuJ\"','tnirp' +]}"}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://69545]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found