Hi, I had the same problem a few months ago : I expected multi-dimensional arrays to be part of the library. I decided to try and implement it. The challenge is to not rewrite everything and use existing code. Look at this paste to see the result : http://paste.factorcode.org/paste?id=1711
It's not finished at all, I only tested nth, set-nth, each, map, each-index and map-index. At this point I have questions: - Why isn't already in the library ? Do multi-dimensional arrays somehow go against factor's idioms ? Would you want such functionality in the library ? - To reuse code from the sequence vocabulary, I have changed bounds-check? into a generic. Is it okay to do so ? - I had to create special words for each-index and map-index. Is it important to not have new words (meach-index, mmap-index), meaning that each-index and map-index should work on multiarrays also ? What are your thoughts ? Jon Harper On Wed, Jun 2, 2010 at 8:10 AM, Slava Pestov <sl...@factorcode.org> wrote: > On Wed, Jun 2, 2010 at 1:47 AM, Kobi Lurie <k_lu...@gbrener.org.il> wrote: >> 1) In C sharp, multi dimensional arrays are built into the language, and >> I find them very useful for representing a board, or a board with a few >> layers. >> the syntax is also pretty nice: int[,,] cube = new int[3,3,3]; for example. >> but you can also do int[,,,,,,,,] (if you have the ram ;-) >> >> Does factor have something similar? (matrices with as many dimensions as >> I want) >> I don't know how to implement such a thing, or even how to access the >> elements in factor. > > Factor has the nth and set-nth words; you can cook up a > multiple-dimensional abstraction on top, either by representing it as > array of arrays, or one big array in row (or column) major order with > some arithmetic to convert indices into row (column) major indices. > >> 2) Does factor have support for command line windows, reading one key at >> a time? >> this can be useful for little games, or in tutorials for learning how to >> program. > > There is a curses binding in the curses vocabulary. It is > Unix-specific. We don't have anything for console access on Windows, > but you're welcome to add the relevant bindings to the > windows.kernel32 vocabulary and contribute your changes. > > Slava > > ------------------------------------------------------------------------------ > > _______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > ------------------------------------------------------------------------------ _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk