How to form subset form a set of numbers in Netlogo
问题 Dear Netlogo community, I am looking to generate subset of a set of numbers. for example if a set is [1 2 3 4 5] then subset would be [1 2] [1 3] [1 4] [1 5] [ 1 2 3] [1 2 4]....... I know we can generate very easily by using bit manipulation in java. But I have no idea how to implement in Netlogo. I am doomed. Any help would be really appreciated. Thanks 回答1: This is easiest to solve using recursion: to-report subsets [xs] if empty? xs [ report [[]] ] let recurse subsets butfirst xs report