Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Knight's Tour Problem in Perl

by ptoulis (Scribe)
on Dec 01, 2008 at 04:47 UTC ( #727009=note: print w/replies, xml ) Need Help??


in reply to Re: Knight's Tour Problem in Perl
in thread Knight's Tour Problem in Perl

I can't see which statement should span to more lines. Perhaps the most obscure is the init() function, but this is called once to initialize the board based on hard-wired if-else and so there is no point in making it more 'verbal'. There are also some (a,b,c...)=(func1(), func2 ,func3(),...) statements which I find very handy if done carefully.

I am not much familiar with Python but I can't see how the equivalent Python code is more readable than this. Even Peter Norvig "former-Lisp-legend", now "Googley-Python-Evangelist", seems to admit there is no real improvement in program readability

Anyway, I will agree this 'competition' is just for fun (or to keep our teeth sharp!)

Replies are listed 'Best First'.
Re^3: Knight's Tour Problem in Perl
by Erez (Priest) on Dec 01, 2008 at 08:49 UTC

    I can't see which statement should span to more lines

    Seeing as you have

    foreach(@moves) { if(my $finalPos = inRange($moved_to, $_))
    and
    for my $i (0..$N-1)  { $board[$i][$_] = init($i,$_) for (0..$N-1);},
    I'd say you do.

    Since all "more lines" statements in Perl are conventions, you could just as well mash all into a one long line and claim yourself the winner. Regardless of anything, counting SLOC in Python have an actual meaning, since the syntax is forcing itself on your style. In Perl, every GNU-style coding is just a K&R away from 30% "improvement".

    "A core tenant of the greater Perl philosophy is to trust that the developer knows enough to solve the problem" - Jay Shirley, A case for Catalyst.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://727009]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2017-11-19 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (282 votes). Check out past polls.

    Notices?