Re: rosettacode 500 milestone passed

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...

That seems pretty good, not that I've analysed it in any detail.
I have to ask, are you quite certain there are no data sets that might ever need a treble or quadruple (etc) swap?

I am quietly confident that swapping just 1 or 2 elements is enough to eventually reach the optimal choice. But having a pathological data set (rather than some Rosetta Code toy..) to experiment with would be prudent.

said...

Just for a laugh, and because I can do so fairly trivially, I had a bash at supporting those orac idioms in Phix.
(All under control of a new "global ORAC = 1" flag so that I can disable/locate them easily.)
Admittedly dot subscripting affected more places and raised more questions than first anticipated, but seems done.
Documenting them is a whole different beanbag, of course.

That raised me a few questions:
I assume that q.2.3 would be treated as q[2.3], not q[2][3] (please say yes!).

Sorry to disappoint. q.2.3 means q[2][3] which is as sophisticated as it gets. Most of the other examples you suggest would just fail under Orac.

said...

The dot notation also precludes ever treating ".4" as a number (must be written as 0.4 - no biggie).

The dot notation only kicks in when lead by a label. The syntax is simple enough so that there is never any ambiguity between fp numbers and sequence subscripts.

said...

sort(t, 4) seems like something worthwhile, but I skipped that for now, ditto assert.

Sorting by column is very useful when handling 2d data sets. Particularly for business apps where just about everything is structured by rows/columns. In my work I pair the (heavy) data set with an index. When sorting only the index is actually altered. I use a virtual listview for viewing the data so even massive sets are trivial to explore from different angles without ever changing the actual data source.

said...

Lastly, your scope rules are off, you allow eg:

for i=1 to ~s do  
   int w 
end for 
w = 0  

which in Phix terminates with "w has not been declared" (obvs. fixed by declaring w before the loop)

Pete

I once analysed the distributions of variables declared inside routines. So few private variables are used on average that it seemed to me scopes are pointless inside routines - particularly when realising that routines should be kept short and single purpose. I made the conscious decision to not include them. However I think it is useful to be able to declare variables at the point in code when they become needed, rather than interrupting the typing flow by inserting them at an earlier point in the text. YMMV but I just don't see the need to have any structural scopes inside routines. Perhaps someone could point out just where i got it wrong.

Spock


Forked into: rant // OE scope
forked out of 500 Rosetta

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu