Combine array in key order

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Combine array in key order

Post by RobertC » Wed Feb 04, 2015 9:36 pm

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.
The Old Rant Robert.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Combine array in key order

Post by FourthWorld » Wed Feb 04, 2015 10:13 pm

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Re: Combine array in key order

Post by RobertC » Fri Feb 06, 2015 10:53 am

Thanks Richard.
The Old Rant Robert.

Post Reply