[Factor-talk] multi dimensional arrays and console

2010-06-02 Thread Kobi Lurie
  Hi guys,
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.

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.


Please point me to the right directions if these exist,
Thanks, Kobi

-- 
China: stop persecuting Falun Gong!
http://faluninfo.net

URGENT: Innocent people are being persecuted for their belief inside Communist 
China.


--

___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] multi dimensional arrays and console

2010-06-02 Thread Slava Pestov
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


Re: [Factor-talk] multi dimensional arrays and console

2010-06-02 Thread Jon Harper
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


Re: [Factor-talk] multi dimensional arrays and console

2010-06-02 Thread Joe Groff
On Wed, Jun 2, 2010 at 10:03 AM, Jon Harper jon.harpe...@gmail.com wrote:
 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 ?

I think because arrays-of-arrays have been sufficient so far.
Two-dimensional arrays aren't needed all that often, and
higher-dimensional arrays hardly at all.

 - 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 ?

Changing the sequence protocol is a bad idea--it's pretty deeply
ingrained that nth and set-nth should take an integer between 0 and
length-1, and breaking that invariant would make the sequence protocol
useless. If you want a packed multidimensional array type, it would be
more robust to implement it as a virtual sequence over a
single-dimensional array, where each element would be a slice of that
array representing a row (or column). Then you could have new words to
perform nth-of-nth operations on either these packed arrays or
arrays-of-arrays:

: nth2 ( x y seq -- elt ) nth nth ; inline
: set-nth2 ( elt x y seq -- ) nth set-nth ; inline

-Joe

--

___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] DLS paper: section 2.1.5 and 2.1.6

2010-06-02 Thread Eduardo Cavazos
Guys,

Let me clarify a couple of things.

I do not want to be listed as an author on the paper. What I meant in my 
last note is that, if the dataflow combinators and partial application 
syntax are presented as they are:

 New abstractions for managing the flow of data in
 stack-based languages

 two original contributions

 We propose a syntax for the construction of point-free
 closures in a stack-based language.

i.e. as somehow (which I don't think they are) contrbutions to the 
literature or in anyway new results, then proper attribution is 
required, since they're my contrbutions to Factor.

I agree that these topics need to be introduced so that examples in the 
paper can be understood. The problem that I see is that they are being 
presented as more than just incidental syntax and mechanism.

They are not new abstractions. I'd like to think that the referees 
would catch this.

Partial application and the combinators are not
original contributions. Well, if I were writing the paper, I certainly 
wouldn't go that far in describing my work. If this wording gets 
through, it's going to set a precedent that all one needs to do is port 
an old idea to a concatenative language and you can get published and 
claim new results.

Finally, the third excerpt above, we propose a syntax ... is inacurate 
as long as my name isn't on the authors list. So I suggest changing this 
part of the paper.

Oh yeah, I also designed Factor's module system:

http://factor-language.blogspot.com/2006/12/factor-module-system-considered.html

http://factor-language.blogspot.com/2007/05/work-begins-on-new-module-system.html

however, at least that's not presented as a New Kind of Feature in the 
paper.

Ed

First, you know, a new theory is attacked as absurd; then it is admitted 
to be true, but obvious and insignificant; finally it is seen to be so 
important that its adversaries claim that they themselves discovered it.

-- William James. Pragmatism, lecture 6. 1907

--

___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] multi dimensional arrays and console

2010-06-02 Thread William Tanksley, Jr
Joe Groff arc...@gmail.com wrote:
 Jon Harper jon.harpe...@gmail.com wrote:
 - Why isn't already in the library ? Do multi-dimensional arrays
 I think because arrays-of-arrays have been sufficient so far.
 Two-dimensional arrays aren't needed all that often, and
 higher-dimensional arrays hardly at all.

APL, J, and K programmers would disagree :-). If we don't have a
hammer, nothing looks like a nail.

I hope the answer is because we're waiting for someone who really
knows multidimensional arrays to design the API. I can't help there,
but I know a couple of people who can, if they're willing (extensive
previous experience with array and concatenative languages).

 useless. If you want a packed multidimensional array type, it would be
 more robust to implement it as a virtual sequence over a
 single-dimensional array, where each element would be a slice of that
 array representing a row (or column).

The array language J stores multidimensional arrays as a shape
array, followed by a flattened array accessed by multiplying the
indices by the appropriate parts of the shape -- or, when one is
iterating over an array, by simply iterating over the flattened
version of the array (most operations in those array languages iterate
in that way).

(I don't know how K does this, because K supports ragged arrays, where
different elements can have different lengths; obviously, ragged
arrays can't be stored in that particular compact format.)

 -Joe

-Wm

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] multi dimensional arrays and console

2010-06-02 Thread Joe Groff
 The array language J stores multidimensional arrays as a shape
 array, followed by a flattened array accessed by multiplying the
 indices by the appropriate parts of the shape -- or, when one is
 iterating over an array, by simply iterating over the flattened
 version of the array (most operations in those array languages iterate
 in that way).

That sounds like an interesting solution, William. It would be easy to
implement in Factor as well.

-Joe

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor causes kernel crash on Lenovo S10

2010-06-02 Thread Joe Groff
On Tue, Jun 1, 2010 at 1:00 PM, Slava Pestov sl...@factorcode.org wrote:
 This doesn't sound like its the same bug, Joe. If opening a second
 window always crashes X11, then I bet the problem is that the driver
 simply doesn't properly handle the case of two GL contexts per server
 connection.

On my slowass Eee PC, I've been getting sporadic Failed to set GLX
context errors from Factor too when Factor is compiling in the
background and I have another application open in the foreground.
Maybe the attempt to set the GLX context can fail in cases when the
window isn't frontmost or the CPU is too busy to set the context in
time, and we need to handle failures to set the GLX context more
robustly as nonfatal errors.

-Joe

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor causes kernel crash on Lenovo S10

2010-06-02 Thread Slava Pestov
Can you reproduce this reliably? Have you tried with the Gtk backend?

On Wed, Jun 2, 2010 at 3:03 PM, Joe Groff arc...@gmail.com wrote:
 On my slowass Eee PC, I've been getting sporadic Failed to set GLX
 context errors from Factor too when Factor is compiling in the
 background and I have another application open in the foreground.
 Maybe the attempt to set the GLX context can fail in cases when the
 window isn't frontmost or the CPU is too busy to set the context in
 time, and we need to handle failures to set the GLX context more
 robustly as nonfatal errors.

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk