results of SPLIT when keys not unique

Monte Goulding monte at appisle.net
Thu Nov 2 18:39:47 EDT 2017


A quick test and it looks like split will clobber any new elements with the same key as those previously parsed. The docs state that only one element will be created but are unclear about which element value will be retained.

It would probably be nice to have some explicit syntax to govern this behavior so that you could explicitly declare you want clobbering behavior or first come best dressed.

From the docs:
> 
> Important: Using the split command can discard data if any of the keys in the original variable are duplicated. If more than one part of the variable delimited by the primaryDelimiter has the same first portion delimited by the secondaryDelimiter, only the element corresponding to the first part is created. (For example, if you are splitting a variable by return and space, and two lines happen to have the same first word, only one of the lines is retained in the array.) Only one element is created for each unique key.

> On 3 Nov 2017, at 9:24 am, Dr. Hawkins via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> If I use split such that keys are not unique, will that have the
> effect of filtering out duplicates?
> 
> For example, if I have
>  dog 3
>  dog 5
>  cat 8
> 
> and SPLIT it, will I end up with 5 in entry dog?
> 
> More specifically, is this a defined behavior, or "just how it currently works"
> 
> I'm trying to find a quick & clean way around SQLite's lack of
> "DISTINCT ON"--I need to keep those numbered keys attached to work
> with, and DISTINCT alone won't due that.
> 
> -- 
> Dr. Richard E. Hawkins, Esq.
> (702) 508-8462
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list