Mailing List Archive: 49091 messages

# All Combinaisons Fonction

### [1/10] from: info:id-net:ch at: 26-Aug-2003 9:16

Hi, I can't find a good algorithm to make this : i.e combine: func [bk [block! of integer] number-max-elements [integer!]][ .... .... ] The Result must be.. combine [1 2 3 4 5] 3 [ [123] [124] [125] [134] [135] [145] [234] [245] [345] ] Did alread someone that function ??

### [2/10] from: DNess:comcast at: 26-Aug-2003 3:22

You don't want [235]? Assuming this is just a typo, you'll find that Roger Hui and Ken Iverson have published some excellent algorithms. You should be able to find them on JForum. I think Apter and Whitney have also done so on the K-List. 8/26/2003 3:16:24 AM, Philippe Oehler <[info--id-net--ch]> wrote:

### [3/10] from: joel:neely:fedex at: 26-Aug-2003 7:42

Hi, Philippe, Assuming that you meant [ [1 2 3] [1 2 4] ...] here's a QAD solution: 8<==================================================================== combine: func [ values [block!] size [integer!] /local combine1 result ][ result: copy [] if size <= length? values [ do .combine: func [ .values [block!] partial [block!] ][ either size > length? partial [ forall .values [ .combine next .values join partial first .values ] ][ insert/only tail result partial ] ] values copy [] ] result ] 8<==================================================================== -jn- Philippe Oehler wrote:

### [4/10] from: info:id-net:ch at: 26-Aug-2003 15:30

Thanks Joel works fine !! What is QAD ?

### [5/10] from: info:id-net:ch at: 26-Aug-2003 15:31

Thanks Joel works fine !! What is QAD solution, I am not english-native..

### [6/10] from: greggirwin:mindspring at: 26-Aug-2003 8:52

Hi Philippe, PO> What is QAD solution, I am not english-native.. Quick And Dirty. -- Gregg

### [7/10] from: joel:neely:fedex at: 26-Aug-2003 11:12

Hi, Philippe, Philippe Oehler wrote:
> What is QAD ? >
Quick And Dirty - - - In other words, everyone is welcome to suggest improvements of any kind! (I just "whomped it up" using the most obvious strategy I could think of at the moment.) I'd actually welcome any ideas for enhancement... Thanks to Gregg for covering my acronym while I was out of touch! -jn- -- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446 Counting lines of code is to software development as counting bricks is to urban development.

### [8/10] from: andrew::martin::colenso::school::nz at: 27-Aug-2003 11:01

jn wrote: do .combine: func [ .values [block!] partial [block!] ][ either size > length? partial [ forall .values [ .combine next .values join partial first .values I'm intrigued by the use of "." in the names. Joel, can you tell us more about this, please? Andrew J Martin Attendance Officer & Information Systems Trouble Shooter Colenso High School Arnold Street, Napier. Tel: 64-6-8310180 ext 826 Fax: 64-6-8336759 http://colenso.net/scripts/Wiki.r?AJM http://www.colenso.school.nz/

### [9/10] from: joel:neely:fedex at: 26-Aug-2003 18:50

Hi, Andrew, It's a more-or-less-arbitrary convention I got in the habit of using as a reminder of "inner function" names and parameters that are related to those in the enclosing function. In the case at hand, .COMBINE is internal to COMBINE (with the addition of the accumulator argument, which would be annoying for the caller of COMBINE to have to remember). .COMBINE must be named in order to invoke itself recursively. Looked at another way, .COMBINE is the "real" function, and COMBINE is a public wrapper around it. .VALUES is the argument to .COMBINE that corresponds to the VALUES argument of COMBINE . In some programming cultures (e.g., LISP), .COMBINE would be called a "helper" function, and various cultures have various conventions for how to name them in a way that emphasizes the relationship. (See http://www.rebolforces.com/articles/ria/ for more examples of this convention.) -jn- Andrew Martin wrote: