Hello All,
I'm new with programming factor and have a problem.
The first variant works:
==
( scratchpad ) [ clear ]
( scratchpad ) 10 3 sliceIndices .
V{
{ 0 3 }
{ 1 4 }
{ 2 5 }
{ 3 6 }
{ 4 7 }
{ 5 8 }
{ 6 9 }
{ 7 10 }
}
==
but the second not:
==
( scratchpad ) 10 3 sliceIndicesn .
( scratchpad )
==
the error is:
==
Sequence is immutable
immutable-seq 0
==
My code for both:
: sliceIndices ( seqLen sliceLen -- indices )
V{ } clone "res" set 2dup swap [a,b] >r - 0 swap [a,b] r> [ 2array "res"
get ?push drop ] 2each "res" get ;
! this variant does not work: don't know, why
: sliceIndicesn ( seqLen sliceLen -- indices )
f >r 2dup swap [a,b] >r - 0 swap [a,b] r> [ 2array r> ?push >r ] 2each r> ;
I don't understand, why the '>r', 'r>' mechanism in the second variant fails:
probably because "Concretely, a quotation is an immutable sequence of
objects,..." (from the docs).
Is there a better alternative to the first variant?
Regards,
Stephan
--
Stephan Rudlof
"Genius doesn't work on an assembly line basis.
You can't simply say, 'Today I will be brilliant.'"
-- Kirk, "The Ultimate Computer", stardate 4731.3
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk