> I failed miserably trying to join the #concatenative IRC channel (I
> could join and read, but couldn't post, "Cannot send to channel"... I
> can post to other channels alright).

You need to register to be allowed to talk on #concatenative. You can
find instructions here for example :
http://meta.wikimedia.org/wiki/IRC/Instructions#Register_your_nickname_and_identify

>  Is there a way, or a "word", like file-lines that is lazy, like a
> lazy iterator/generator in other languages? I was thinking of a file
> with hundreds of thousands of lines, where I'm only interested in the
> first 10, and which would potentially overload the stack if all lines
> would be placed on it before '10 head' could run.
>
You can always open the file for reading and then read the lines that you want :
 "data.txt" utf8 [ A ] with-file-reader
where A can call readln or read to read the file lines. For example,
 "data.txt" utf8 [ 10 [ readln ] replicate ] with-file-reader

Or you can use the lazylists vocab which defines lazy IO operations :
http://docs.factorcode.org/content/article-lists.lazy,io.html

> * In the same code example, the recursive invocation in the
> tail-factorial word definition reads
>
>  [ [ * ] [ 1 - ] bi tail-factorial ]
>
> I get that bi is actually '{ [ * ] [ 1 - ] } cleave'. But '*' is
> dyadic, so consumes 2 elements from the stack, where cleave is said to
> operate only on a single value (apart from the array of quotations)!?

This is called row-polymorphism. If you look at the docs for bi
(http://docs.factorcode.org/content/word-bi,kernel.html), you'll see
that the stack effect for the input quotations is ( ..a x -- ..b ).
This syntax is explained here :
http://docs.factorcode.org/content/article-effects-variables.html
http://duriansoftware.com/joe/Improving-Factor's-error-messages.html

Since this feature is rather new, all pages have not been updated yet,
but the quotations for cleave have the same stack effect ( ..a x --
..b )

I hope this helps :)
Jon



On Thu, Dec 23, 2010 at 10:38 AM, thomas_h <the...@googlemail.com> wrote:
> Hi all,
>

>
> I fiddled a bit with both Forth and Factor, and now I'm making my way
> through the excellent DLS2010 paper which I find quite instructive. I
> would like to post a few questions concerning this:
>
> * The first code example, Figure 1, says
>
>  "data.txt" utf8 file-lines 10 head
>
> * In the tail-recursive factorial example, Figure 3, shouldn't the
> second word read
>
>  : factorial ( n -- n! )
>      1 swap (tail-factorial)  ;
>
> rather than '1 swap (factorial)'?! And why is the factorial word in parens?
>

>
> Thanks,
> Thomas
>
> ------------------------------------------------------------------------------
> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> to consolidate database storage, standardize their database environment, and,
> should the need arise, upgrade to a full multi-node Oracle RAC database
> without downtime or disruption
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to