Your order of arguments is wrong. The initial value is taken as the
middle parameter for reduce. Here's the code you want:

{ { 1 2 } { 3 4 } } { } [ append ] reduce

But what you really want is the word concat, for this particular case.
It's linear rather than quadratic time overhead.

Dan

On Thu, Feb 5, 2009 at 1:47 AM, Jong-Hyouk Yun <[email protected]> wrote:
> Hi,
>
>
> I'm very confused with 'reduce' word.
>
> in CommonLisp I could flatten depth-2 list '((1 2) (3 4) ..) into '(1
> 2 3 4 ...) with #'reduce...
>
> <code>
> (reduce #'append '((1 2) (3 4)) :initial-value '())
> </code>
>
> but, Factor give me unexpected results
>
> <code>
> ( scratchpad ) { 1 2 } { 3 4 } append .
> { 1 2 3 4 }
> ( scratchpad ) { } { 1 2 } append .
> { 1 2 }
> ( scratchpad ) { } { { 1 2 } { 3 4 } } [ append ] reduce .
> { { 1 2 } { 3 4 } }
> </code>
>
> I expected those snippets give me "{ 1 2 3 4 }" but isn't.
> Am I misunderstood concepts?
>
>
> Thanks.
>
>
>
> ps. recently (really!) I'm falling love with Factor language, awesome
> language and ultimate Emacs+FUEL environment gave me new programming
> life. Thanks to every guys on Factor and their wonderful works!
>
> ------------------------------------------------------------------------------
> Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
> software. With Adobe AIR, Ajax developers can use existing skills and code to
> build responsive, highly engaging applications that combine the power of local
> resources and data with the reach of the web. Download the Adobe AIR SDK and
> Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to