combine array at present gives unexpected results. Extending the command to make it look like the sort command would be useful.
Example: I had to mark up each line of a long text with html tags, depending on the content of the line and also the contents of the two adjacent lines. The original algorithm became very slow after the introduction of unicode. The time taken was reduced by a factor of 200 by first using split to get an array of lines, then doing the markup using the array. However, using combine to put the lines back together into a single marked-up text produced unexpected results (as is in fact documented in the Dictionary: the order in which the elements are combined depends on internals of array handling).
It was not possible to sort the lines of text after the combine operation.
Proposal:
there is a useful form of the sort command:
sort lines of tData descending numeric by item 1 of each
a similar clause could help in many cases of combine:
combine myArray ascending numeric
would have given the desired result.
Perhaps this should even be the default: if the keys are numbers then combine should produce a result corresponding to using the keys in ascending order.
LiveCode's aim of programming in a natural language has as a corollary that its commands should produce as few unexpected results as possible.
Combine array in key order
Moderator: Klaus
Combine array in key order
The Old Rant Robert.
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Combine array in key order
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn