MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Best way to determine # of entries in a list?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42004] Best way to determine # of entries in a list?
  • From: a_cjones at hotmail.com (cdj)
  • Date: Mon, 16 Jun 2003 03:57:24 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

Example problem:

To streamline the input of systems of linear equations, i'm setting up
a function that accepts simply a flat list as argument. The first nxn
entries are the rows of the matrix, and the last n are the target
point (= b). This gives the length of the argument list as n^2 + n.

I'd like to have a little bit of input error/type checking in the
function. For this example, given a list, I'd like to test whether or
not there exists an n such that length(list) = n^2 + n.

The quickest/easiest way I know how to do it for this example problem
is to test for integer-hood on sqrt[4*length(list) + 1] (yes = good
data type).

Q1: Does anybody know of a quicker/better/more elegant way to perform
this test?

Q2: In general, suppose i want to test (the length of) my list against
an arbitrary polynomial P(n). What's the best way to do this?

thanks for any insights,

cdj


  • Prev by Date: About Abel Type Differential Equation
  • Next by Date: Remove help
  • Previous by thread: Re: About Abel Type Differential Equation
  • Next by thread: Re: Best way to determine # of entries in a list?