komputerwiz / csp-solver

A Ruby library for solving any type of constraint satisfaction problem (CSP)
http://komputerwiz.net/apps/csp-solver
MIT License
39 stars 9 forks source link

API/source-code discrepancy #1

Closed xuanwu closed 9 years ago

xuanwu commented 9 years ago

Hi, thanks for writing this library!

In the API reference at http://komputerwiz.net/apps/csp-solver, it shows all_pairs, all_same, and all_different as having a splat operator in the argument, but the source code doesn't have it. I assume that instead of calling csp.all_different(:x, :y, :z) for example, it should be csp.all_different([:x, :y, :z]), correct?

Thanks again!

komputerwiz commented 9 years ago

Thank you for bringing this to my attention!

You are correct. The code expects the vars parameter to all_pairs, all_same, and all_different to be an array, not variable arguments (splat): the Sudoku and Mathdoku classes use CSP#all_different in this way.

I have updated the API reference to reflect the current state of the code.

That said, which way do you think would be better? Splats or Arrays?

I think splats would be more convenient and natural for hand-coded CSP's, but the presently-used arrays are more convenient for coding (no extra step to convert from an array to a splat).

I'm just happy to see others using this library. :-)

xuanwu commented 9 years ago

Thanks for the quick response!

I actually like arrays better than splats, since I'm generating the variables dynamically.

I have a separate question. Should I create a new issue for it? Or can I email you directly?

komputerwiz commented 9 years ago

Apologies for the delayed response this time.

Either way is fine with me. If you think other people might have the same question, I'd recommend creating a new issue.

I'll go ahead and close this issue. If you have any more questions or concerns, feel free to reopen it.