Clint Jeffery wrote:
>
> I offer up the following examples of picking the third result without
> resorting to "every". I am not advocating people write code like this:
>
> write( 2(i:=0, ("a"|"b"|"c"|"d") , (i +:= 1)=3))
>
> Nor am I advocating people write code like this:
>
> write(put([], ("a"|"b"|"c"|"d"))[3])
>
> But they work! Bwa ha ha ha! (insert your own evil laugh here)
>
Well, as long as we're writing code we wouldn't wish on our own
mothers, here's a PDCO-based solution that performs some nifty
tricks:
procedure Nth(L)
suspend 1( |@L[1], n:=^L[2], (*L[1]=|@n) )
end
Free M&M's (shipping and handling extra) to the first person who figures
out how this differs (behaviorally) from the previously posted:
procedure Nth(L)
n := @L[2] | 1 # default to first
return 1( |@L[1], *L[1]=n )
end
and how it differs (behaviorally) from IndexPDCO{e1,e2} also mentioned
in a previous post.
And, no, I don't write code like this outside of this list
--
Steve Wampler- SOLIS Project, National Solar Observatory
[EMAIL PROTECTED]
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unicon-group