I find livecode's "do" command something like magic.
Is there something like it in Python, or JavaScript?
Something like "do" in python?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Something like "do" in python?
what's magic for me is the [each] iterator... don't think there's anything like it in other languages and it makes such easy work of it...
-
- VIP Livecode Opensource Backer
- Posts: 9579
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Something like "do" in python?
Stam.
And FAST, if you mean in the "Repeat for each..." form.
But just as cool is the "each" local variable, which allows one to, say:
Magic, as you say.
Craig
And FAST, if you mean in the "Repeat for each..." form.
But just as cool is the "each" local variable, which allows one to, say:
Code: Select all
sort lines of myHugeList by word 3 of each & item 5 of each
Craig
Re: Something like "do" in python?
Actually repeat for each is a common pattern across several languages... (and until we get compiled scripts, all of these are faster...)dunbarx wrote: ↑Wed Sep 21, 2022 9:29 pmStam.
And FAST, if you mean in the "Repeat for each..." form.
But just as cool is the "each" local variable, which allows one to, say:Magic, as you say.Code: Select all
sort lines of myHugeList by word 3 and item 5 of each
Craig
i meant the second form you mention - also when filtering arrays, so versatile
Code: Select all
filter elements of tArray where each["someKey"] = "xyz"
Re: Something like "do" in python?
In both javascript and python the "do" equivalent is
In both javascript and python this function is discouraged because it can enable arbitrary code to run, which may be a big security risk. The same risk is applicable in LiveCode but I dare say there is a smaller possibility of attack through this vector.
Code: Select all
eval()