Has anyone attempted to create a shortcuts binary search algorithm? I’ve been kicking it around but it’s just not working.
Here is my test Shortcut.
https://www.icloud.com/shortcuts/53c2a0940acc4a3da3a48b39f507ff15
Has anyone attempted to create a shortcuts binary search algorithm? I’ve been kicking it around but it’s just not working.
Here is my test Shortcut.
https://www.icloud.com/shortcuts/53c2a0940acc4a3da3a48b39f507ff15
I’ve not attempted to create one, until you posted this, but maybe something like this?
I’ve tried to use some more explicitly named variables, some comments and even a bit of extra code for debugging to try and help anyone reading it make sense of it. As a result of all of the extra cruft, I’m sure it is running slower.
If you wanted to speed things up, it might make sense to look at a recursive shortcut that splits the list or simply keeps passing it along and effectively turn it into a function / parameter based subroutine.
Alternatively, I’m pretty sure that if your data set was large enough to warrant such a search for performance reasons, that it would further be worth applying JavaScript to the approach as it could then take advantage of browser optimisations. I posted a solution to something else recently that takes exactly that sort of thing to consideration…
Hope that helps.
Thanks again Sylumer, You really showed my that Shortcuts can be used in ways I never thought possible.