min() and array
bonnmike at gmail.com
Thu May 5 19:33:31 CEST 2016
Ah cool. Thanks for the array info.
In that case, the example above "put min(tArray[i][v]" doesn't work because
there are no subkeys of [i]["v"], only a value.
In your example tarray["v"] has subkeys which contain values.
So in the first case, the only thing min() can see is 15 (the value of
min(tArray[i]) wouldn't work because there would only be one subkey ["v"]
for i in the first example, right? Off to experiment. Thanks!
On Thu, May 5, 2016 at 10:45 AM, Richard Gaskin <ambassador at fourthworld.com>
> Mike Bonner wrote:
> > You're only looking at a single value, so its returning it.
> D'oh! Yes, now that I've had my coffee that makes perfect sense.
> > To get the minimum value across array entries you need to iterate
> > through them.
> The Dict says:
> The ability to use an array was introduced in version 1.1.
> In previous versions, only lists of numbers could be used
> with the min function.
> Is that not the case?
> This seems to work here, and satisfies Ludovic's request to work on a
> second-level array (here putting "v" in quotes to make it more explicitly
> clear that it's not a variable itself but a single string, something
> apparently missed in earlier posts in this thread, as you noted):
> on mouseUp
> repeat with i=1 to 5
> put 10 + i into tarray["v"][i]
> end repeat
> put min(tarray["v"])
> end mouseUp
> Richard Gaskin
> Fourth World Systems
> Software Design and Development for the Desktop, Mobile, and the Web
> Ambassador at FourthWorld.com http://www.FourthWorld.com
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
More information about the use-livecode