On Thu, Oct 12, 2017 at 11:57 PM, john lynch <mjohnly...@gmail.com> wrote:
>
> I've been implementing some Python code in Go to learn the language.  In
> Python this will generate a Set Partition.  The Go equivalent follows.
>
> The Go runs fine for list element sizes 2 and 3 (which means the recursion
> is running properly). Also 4 but at 5 and above it generates the intial sets
> and then just stops. So on my machine I get 25 partitions for 5 elements and
> it should continue to 52. Similar results for larger number, with 9
> generating 213 sets against Python's 21147. So, I got over the lack of lists
> by using slices, I got used to the global nature of variables.  I love the
> language but this has me confused. Any thoughts please?

I don't know what you are trying to do but if I were you I would look
closely at the way you are passing slices around.  When you pass the
slice `out` in the recursive call, it will be modified by the function
you are calling.  So you seem to be trying to build partitions in out
while also passing it down in a recursive call that clobbers some
elements.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to