Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103712

Re: General computer language, syntax question.

Newsgroups comp.lang.python
Date 2016-02-29 06:05 -0800
References <5b619ffa-aae6-4fa8-9f62-58532668ec93@googlegroups.com> <f6536a77-6f32-4af7-bf2d-126b92ec5649@googlegroups.com>
Message-ID <b03495c3-bef8-4060-be15-bf96cedf072b@googlegroups.com> (permalink)
Subject Re: General computer language, syntax question.
From jonas.thornvall@gmail.com

Show all headers | View raw


Den måndag 29 februari 2016 kl. 14:57:04 UTC+1 skrev jonas.t...@gmail.com:
> Den måndag 29 februari 2016 kl. 14:45:37 UTC+1 skrev jonas.t...@gmail.com:
> > 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.
> 
> I mean for for example Javascript
> if (typeof array[index] !== 'undefined' && array[index] !== null) {
> or this one
> if (array[index] != null) {
> 
> I mean how do they come up with such convoluted syntax, do they pull it out of ass? Well one can always say it is needed because undefined not equal to null.
> 
> But would not if (array[index]==empty) suffice and be alot clearer?

Sorry but would not if (array==empty) suffice and be alot clearer?

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

General computer language, syntax question. jonas.thornvall@gmail.com - 2016-02-29 05:45 -0800
  Re: General computer language, syntax question. jonas.thornvall@gmail.com - 2016-02-29 05:56 -0800
    Re: General computer language, syntax question. jonas.thornvall@gmail.com - 2016-02-29 06:05 -0800
      Re: General computer language, syntax question. Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-29 09:38 -0500
      Re: General computer language, syntax question. Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-29 07:54 -0700
    Re: General computer language, syntax question. Steven D'Aprano <steve@pearwood.info> - 2016-03-01 22:42 +1100
  Re: General computer language, syntax question. Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-29 08:55 -0500
  Re: General computer language, syntax question. MRAB <python@mrabarnett.plus.com> - 2016-02-29 14:07 +0000
  Re: General computer language, syntax question. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-02-29 14:39 +0000
  Re: General computer language, syntax question. Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-29 09:48 -0500

csiph-web