in reply to Re^5: Converting python list range expressions to perl
in thread Converting python list range expressions to perl
In my OP I mentioned needing help from "bilingual" (i.e. Perl and Python) people; otherwise I'd have included a description of Python's slice notation. I'm sorry if this was negligence on my part, but I assumed that anyone answering would be familiar with Python's oddball slice semantics. [a:b] means "the characters starting at offset a and ending at offset b-1". Unless a or b is negative in which case .. hell, I don't remember ;-)[\@test_array, '[3:4]', 'd'],
The code I posted correctly slices arrays using Pythonic parameters, although it doesn't attempt to handle the optional third argument, a step value. And I'm happy to say that the translation effort has succeeded and Perl is now churning out gibberish sonnets at a much faster rate than its Python equivalent.
Update:
It correctly slices arrays if the arguments aren't nonsensical -- like being out of range, which Python forgives. It needs a few more sanity tests to handle those cases.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Converting python list range expressions to perl
by LanX (Saint) on Dec 05, 2022 at 22:11 UTC | |
by ibm1620 (Hermit) on Dec 05, 2022 at 22:58 UTC |