On Mon, Feb 29, 2016 at 8:45 AM, <jonas.thornv...@gmail.com> wrote: > I have a problem programming uniform networks, "x nodes with y links" that > turn out to be really hairy to solve for me and i feel i really lack the > programming features > > "Actually i program in javascript" but the problem seem general for all > programming languages including Pyhton. > > For a beautiful solution it would require "If in list/array return > boolean" "If not in list/array return boolean". > > But there is no such feature Python nor Javascript, so instead i set > boolean value "inlist" to false and loop thru, to see if it is already in > list. If not it is added to list. > > So if the current node i generate links for is x and i try to generate a > link to node z, and z's links exhausted i will add it to exhausted list. > > And if there is node-x exhausted entries in list, well then script should > break because it will lock into a cycle. The cyclic lockup is due to only a > subset of the networks on the form (links*deep)+1=nodes is possible. > > So what i need is to know howto write "if list/array ***empty*** do > {something}" > > I sure know howto check if an array have 1 element 2,3,4 but how do you > check for empty. > > I think it is crazy that you can not do general comparissons of the type > If in list/array > If not in list/array > > But it is even more crazy that you can not check if list/array is empty, > that is just madness. > -- > https://mail.python.org/mailman/listinfo/python-list >
>>> l = [1,2,3,4] >>> if 1 in l: ... print 1 ... 1 >>> if 6 in l: ... print 1 ... >>> >>> l = [] >>> if len(l) == 0: ... print 'empty' ... empty -- Joel Goldstick http://joelgoldstick.com/ <http://joelgoldstick.com/stats/birthdays> http://cc-baseballstats.info/ -- https://mail.python.org/mailman/listinfo/python-list