Re: Have we got a numeric sort yet?
- --- In firstname.lastname@example.org, "Paul" <xboa721@...> wrote:
>Possibly what you're after is how to use linebreaks instead of semicolons to separate items in an array. You can do that by using:
> I want to sort an array of numbers primarily for the purpose of deleting duplicates, so it's okay to treat as strings of numeric characters.
> e.g. ^!SetArray %myarray%=5;2;4;6;2;43;4
> if i end up with 5;2;4;6;43 then that helps (de-duped).
> Ordered from highest to lowest would be an advantage.
> Should this line work:
> ^!Info ^$StrSort(^%myarray%;No;Yes;Yes)$
> ^!SetArray %MySortedArray%=^$StrSort(^%myarray%;No;Yes;Yes)$
> More importantly, why doesn't it! How to fix it?
> Additional info: %myarray% may be very long. the numbers in myarray are usually less than 20 although at a stretch could be up to 100. The numbers in the array need to be used for subsequent ^$Calc operations referenced by index, e.g. ^%MySortedArray3% (=4)
> Because ^$StrSort("^$GetClipboard$";False;True;True)$ DOES work how do you iteratively write sequential lines to the clipboard?
before building the array.
You should have better luck in string sorting numbers if you first pad them with zeros, so they're all the same length. Have a look at ^$StrFill.
Not sure what you're getting at re the clipboard, but instead of trying to append lines directly to the clipboard, you could make a variable that contains multiple lines, and then use ^!SetClipboard to put the evaluated variable onto the clipboard.
^!Set %myvar%="first line^%NL%"
^!Set %myvar%="^%myvar%second line^%NL%"
I suspect that would be more efficient than something like
^!SetClipboard first line^%NL%
^!SetClipboard ^$GetClipboard$second line^%NL%
which should also work.
- --- In email@example.com, "Eb" <ebbtidalflats@...> wrote:
>... NoteTab is an interpreter, not a compiler. That means any complex algorithm you build in clip code is going to be much slower, than it would be as a compiled (built-in) function.I'm still impressed how quick clips run. Reminds me of writing good old Advanced Basic code running on an XT. You know, a 5.1 gogigahertz machine still processes a spreadsheet about as fast as it used to!
> Bubble sort requires (n squared) iterations in the worst-case scenario.That sounds better. Thanks for the reminder.
> On the other hand, it might be a good exercise to code in clip code. <grin>Just for comparison</grin>.Gone are the days of the lazy uni student where time was a misspent luxury... <sigh> ... although I can't complain.. I had an entire half a Sunday to sit and relax this week. :)
My current project needed a 'calculate by hand' style multiplication routine to handle ridiculously large numbers. To be honest, I don't mind the 7 seconds it takes to multiply two - one hundred digit -numbers.
Fascinating really and the exciting bit is that we seem to have come full circle and once again the computer is doing exactly what the user wants... without the OOP, "compiler declares headache" syndrome. <smile> </b>