Numbering lines
hh
hh at hyperhh.de
Sun Oct 28 16:06:35 EDT 2018
> Alex T. wrote:
> You require to keep the line ordering completely unchanged -
> and Hermann's superfast method can't meet that need.
> JLG wrote:
> You're right, split deletes duplicates. In fact, I use it as a quick way
> to do just that.
You are both spendidly wrong:
Could you please simply try my functions and read the dictionary in order
to understand why you are wrong? Please!
Is it not yet Halloween ...
-- D is the separator for numbers and text lines, usually space or ": "
-- T is the input text, delimited with return
-- prepends the number and separator to each line:
function addLineNumbers D,T
split T by return
put the keys of T into K
sort K numeric
repeat for each line L in K
put cr & L & D & T[L] after S
end repeat
return char 2 to -1 of S
end addLineNumbers
-- D is the separator for numbers and text lines, usually space or ": "
-- T is the input text, delimited with return
-- removes the number and separator from each line:
function removeLineNumbers D,T
split T by return and D
put the keys of T into K
sort K numeric
repeat for each line L in K
put cr & T[L] after S
end repeat
return char 2 to -1 of S
end removeLineNumbers
More information about the use-livecode
mailing list