Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: Knight's Tour Problem in Perl

by ptoulis (Scribe)
on Dec 01, 2008 at 04:47 UTC ( [id://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, $_))
    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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-07-24 21:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.