Re: [Factor-talk] What is a good definition ?

2008-04-25 Thread Jean-François Bigot
Hi, Eric nicely gave me his solution : DEFER: combinations : (combinations) [ 1 tail ] dip combinations ; : prefix-each [ prefix ] curry map ; : combinations ( seq n -- seqs ) { { [ dup 0 = ] [ 2drop { { } } ] } { [ over empty? ] [ 2drop { } ] } { [ t ] [

Re: [Factor-talk] What is a good definition ?

2008-04-25 Thread Justin DeVries
Hi, Your code is faster because it short-cuts sooner when you know the result of an operation. Because of your condition, { [ 2dup = ] [ 3drop 1array ] } your code can jump to the conclusion that { 1 2 3 } 3 among is { { 1 2 3 } }, whereas Eric's word must compute the combinations