To explain the error you got, though, the problem with

home
[ 0 [ file-info size>> + ] each ]
with-directory-files

1. `home` is pushed to the stack
2. `[ 0 [ file-info size>> + ] each ]` is pushed to the stack
3. `with-directory-files` executes `[ 0 [ file-info size>> + ] each ]` on
the sequence of directory files for `home`
4. So effectively this is like doing `seq 0 [ file-info size>> + ] each`
where `seq` is your sequence of files
5. `each` tries to call `[ file-info size>> + ]` on each item in the
"sequence" `0`!
6. `0` does not respond to the word `length` (which `each` uses to iterate
over sequences)

I don't have Factor installed on this machine so I can't check, but I think
the following would work (though not recursively on your directory):

home
[ 0 swap [ file-info size>> + ] each ]
with-directory-files

Interestingly, because arguments are passed around on the stack, `0 swap [
... ] each` is equivalent to `0 [ ... ] reduce`. Not just intuitively,
that's the actual definition of `reduce`:
http://docs.factorcode.org/content/word-reduce,sequences.html

Welcome to Factor!

On Fri, Jan 16, 2015 at 7:27 AM, Marc Hanisch <marc.hani...@googlemail.com>
wrote:

> Thanks,
>
> USING: io.directories.search io.files.info
> home f recursive-directory-files [ link-info size>> ] map sum
>
> did it! Better idea is to test with a small directory ;-)
>
> Best regards,
> Marc
>
> 2015-01-16 15:19 GMT+01:00 mr wzrd <wzr...@gmail.com>:
>
>> On 01/16/2015 04:46 AM, Marc Hanisch wrote:
>> > I'm trying to create a word which recursive loops over all files in a
>> > directory and sums the filesizes. I entered the following steps into
>> > the listener:
>> Try this ...
>>
>> home f recursive-directory-files [ link-info size>> ] map sum
>>
>>   - mrw
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
>> GigeNET is offering a free month of service with a new server in Ashburn.
>> Choose from 2 high performing configs, both with 100TB of bandwidth.
>> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
>> http://p.sf.net/sfu/gigenet
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>
>
>
> --
> ★ Esperanto - Lingvo internacia ▪ http://www.esperanto.de ▪
> http://www.esperanto.berlin ★
>
>
> ------------------------------------------------------------------------------
> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
> GigeNET is offering a free month of service with a new server in Ashburn.
> Choose from 2 high performing configs, both with 100TB of bandwidth.
> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
> http://p.sf.net/sfu/gigenet
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to