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

> This is probably no worse or no better…

Looks like the same approach like in Re^2: retain longest multi words units from hash.

I'm just speeding up the creation of @word_combos by pre-calculating the indices for an array slice.

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

Replies are listed 'Best First'.
Re^3: retain longest multi words units from hash
by tobyink (Canon) on Jul 30, 2018 at 10:43 UTC

    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.

      > 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