This is all only true if you decide to go out of your way to make it obscure and convoluted. Of course I am probably only taking the bait, but here goes....
#!/usr/bin/perl -w use strict; my $pat = '"%d %s %d is %d" if (%d %s %d == %d)'; matchIf($pat, 3, '+', 4, 7); matchIf($pat, 5, '*', 4, 20); matchIf($pat, 5, '%', 4, 20); matchIf($pat, 5, '-', 4, 20); sub matchIf { my ($pat, $x, $op, $y, $z) = @_; my $foo = sprintf($pat, $x, $op, $y, $z, $x, $op, $y, $z); print eval ($foo),"\n"; }
Not even golfed.

Not nearly as wacky as you made it out to be. BTW, I spent 3 semesters doing Artificial intelligence work with Lisp in college and I actually love working with it; But your arguement here just shows that either you didn't bother to learn the tool (Perl) well enough to do the job right, or you intentionally misrepresented things to serve your point.

And as a note: Most people do not consider the Lisp method of using Reverse Polish notation for conditionals and mathmatics particularly simple. Most people would understand "x op y = z" but only a programmer (or maybe a mathematician) could love "op op x y z".

Update Figured I would add that the development time on this was ~5 minutes.

Update And just a couple more showed that we can do this....

#!/usr/bin/perl -w use strict; my $pat = '"%d %s %d is %d" if (%d %s %d == %d)'; my $order = '[$_[0], $_[1], $_[2], $_[3]]'; matchIf($pat, $order, 3, '+', 4, 7); matchIf($pat, $order, 5, '*', 4, 20); matchIf($pat, $order, 5, '%', 4, 20); matchIf($pat, $order, 5, '-', 4, 20); sub matchIf { my ($pat, $order) = (shift, shift); print eval sprintf($pat, @{eval $order}, @{eval $order}), "\n" +; }
To make the ordering configurable as well.
Update Got rid of the maps, because well.... they were complete useless.

In reply to Re: Lisp vs. Perl Round 3: Operator Associativity and Manipulation by Sifmole
in thread Lisp vs. Perl Round 3: Operator Associativity and Manipulation by princepawn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.