Diddy Arrays.CreateArray?
Monkey Forums/Monkey Programming/Diddy Arrays.CreateArray?
| ||
How do I access Diddys Arrays? I prefer Diddy's method than my own hack version but I get 'Arrays not found'. I'm just trying to access the 2D arrays feature for setting up a 2D array. |
| ||
Hmmm... try this:Strict Import diddy Function Main:Int() ' create the array Local arr:Int[][] = Arrays<Int>.CreateArray(128,64) ' populate the array For Local x:Int = 0 Until 128 For Local y:Int = 0 Until 64 arr[x][y] = x + y Next Next ' print out the array For Local x:Int = 0 Until 128 For Local y:Int = 0 Until 64 Print arr[x][y] Next Next Return 0 End |
| ||
Thanks! Works Fine! :) |
| ||
Don't you have something like that in your code libray you posted a few days ago? It works exactly in the same way. |
| ||
Don't you have something like that in your code libray you posted a few days ago? I do but it's not the same. The code is muddyshoes' code. This method is built in to Diddy with all the nice features! In a sense it doesn't work exactly the same! Diddy's is better. Plus I only use the code library I have when quickly prototyping. I use Diddy for the main projects. |
| ||
if you look at the source code you will find out that it is the same with some extra method for extra functionality. but what ever puts you in your comfort zone. :) |
| ||
Honk honk! Resurrecting a dead thread I'm attempting to port TimSort<T> to Monkey. Since Monkey doesn't appear to have built in Array copy methods, I'm planning on using diddy.arrays to do this. Would it be useful to have an Arrays<T>.Sort method built directly into diddy.arrays? The class would probably also require importing a Comparator<T> Interface (and due to the lack of wildcards, this might be a bit limited)... Edit: trans: "Interfaces can't be generic." hnnnnng. |
| ||
Hmm I could probably do this. The current Comparator stuff in the collections module doesn't use generics (obviously) so you need to cast it yourself. Limitation of the language, unfortunately. I'll see if I can clean it up a bit. |
| ||
Samah: I'd encourage you to check this out if you haven't already. I attempted to port the aforementioned sort (which is now Java's new default sort, because in theory it should be fast) to Monkey over the past couple days, but ran into some strange stuff that I figured you or revills might be particularly interested in, if not for the bug itself, then for the class (if someone can get the damn thing to compile!) http://www.monkeycoder.co.nz/Community/posts.php?topic=4931 I didn't realize that diddy already had a comparator class and comparable interface. Not having generic interfaces may be a limitation, but it doesn't seem like a huge/crippling one, or one that can't be worked around. I should probably check out the code that's been done to that framework since I last took a look at it! |