in reply to Re^2: retain longest multi words units from hash
in thread retain longest multi words units from hash

Yeah, pretty similar, but doesn't impose a predetermined maximum word length on the hash keys. I also optimize by skipping single-word hash keys.

  • Comment on Re^3: retain longest multi words units from hash

Replies are listed 'Best First'.
Re^4: retain longest multi words units from hash
by LanX (Saint) on Jul 30, 2018 at 22:46 UTC
    > but doesn't impose a predetermined maximum word length on the hash keys.

    That was my intention. I could have easily dynamically added a new level of slice if needed, but the check would have cost time. OTOH it's very likely the OP can assume a maximum word length, which is still very cheap if generously chosen.

    > I also optimize by skipping single-word hash keys.

    Again I thought checking for single words might cost more than just deleting an empty slice.

    I have to admit I could have put the body of partitions() into the delete-slice , but preferred clarity here and left optimization to the OP.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice