Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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

by mr_mischief (Monsignor)
on Apr 04, 2001 at 08:10 UTC ( #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

Comment on Re: Re: Re: Shortest -return index of element in array- sub
Download Code
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?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2015-11-30 05:04 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (758 votes), past polls