[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] The Powers of Annoy



miku@onlinehome.de (miku) wrote:
>Thanks! Yes, the irony must have gotten lost somewhere in the deep spaces of
>unquestioned mind-reading, it seems... :) Youčre certainly right about the
>unnecessary assignments. What I was aiming at originally was to improve the
>non-recursive algorithm (which was originally developed/discovered at Bell
>Laboratories). I would have loved to get some comments like "use this
>not-so-common perl construct, namely ......., and your code will be more
>compact/snappier/faster/transparent/elegant..." or the like. 

I've been thinking about a different implementation.  It seems to me that if
we're moving objects around inside another object, we should at least _try_ to
use regular expressions.  So if we represent the current state with a string
like $_ = "65:321:4", the first operation (moving the smallest disk) can be
easily coded:

    s/1:(\w*)/:${1}1/ or chop && s/^(\w*)/${1}1/;

I haven't figured out the second operation yet.

  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org