Length of a list

866 views
Skip to first unread message

Jay Timotheus

unread,
Apr 13, 2012, 7:08:39 AM4/13/12
to tins...@googlegroups.com
Does anyone know if there is a function to find the length of a list?

Jay

Andy Kemp

unread,
Apr 13, 2012, 7:12:06 AM4/13/12
to tins...@googlegroups.com
If the list is called 'list' then dim(list) should do what you want...

Cheers
Andy

Sent from my iPhone

On 13 Apr 2012, at 12:08, Jay Timotheus <j.tim...@btinternet.com> wrote:

Does anyone know if there is a function to find the length of a list?

Jay

--
To post to this group, send email to tins...@googlegroups.com
To unsubscribe send email to tinspire+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com.au/group/tinspire?hl=en-GB?hl=en-GB
The tns documents shared by group members are archived at
https://sites.google.com/site/tinspiregroup/classroom-news/welcome-abouttime

Jay Timotheus

unread,
Apr 13, 2012, 3:56:00 PM4/13/12
to tins...@googlegroups.com
Thanks Andy,

I do have a further question... if you or anyone else can help I'd be grateful...

I'm trying to create a simulation of a relative frequency graph... That's fairly straightforward.  I can animate a number and as the number increases, the data can be captured and a live relative frequency graph can be created.

...but I now want to set the animation so that every time the counter increments by 1, the list of random integers is augmented by a further 100 random numbers... so the next 100 points are immediately plotted.

Any ideas?

Jay

Andy Kemp

unread,
Apr 13, 2012, 4:02:17 PM4/13/12
to tins...@googlegroups.com
My guess would be the simples method would be to use a program which is then placed in a MathBox.  So every time n increments it just runs a for loop from dim(list) to dim(list) making each intermediate value randInt()…

Does that make sense?

Jay Timotheus

unread,
Apr 13, 2012, 4:05:38 PM4/13/12
to tins...@googlegroups.com
Not done any programming in TI-Nspire yet.. will give it a go... but if you have any further pointers I'd be grateful.

Jay

Andy Kemp

unread,
Apr 13, 2012, 4:08:14 PM4/13/12
to tins...@googlegroups.com
Have a go, but if you get stuck post what've you got and someone will take look!

Eric Findlay

unread,
Apr 13, 2012, 4:29:12 PM4/13/12
to tins...@googlegroups.com
Hi Jay,

I don't think that Andy's code will do what you want.  What you want to do is create a program that makes a new list of 100 random integers, then augment it to the original list.  (putting it in a mathbox is still the right idea).  What you want is the following:

In mathbox: (assuming your graphing list is called randlist.  Also, I made the number of ints a variable so you can change it easily)

Randlist:=augment(randlist, newrandlist(100))

In a function:
Define newrandlist(size) :=
Func
 Local i, newlist

 Newlist:={ }
 For i, 1, size
  Newlist:=augment(newlist, {randInt()})
 Endfor

 Return newlist
Endfunc

Now, this may not be 100% because I'm doing this from memory, but it's close.  You could also generate the new list like this: newlist:=seq(randint(),i,1,size) but I wanted to show you something more basic/fundamental since you haven't done much programming.

Good luck.

  --Eric
Reply all
Reply to author
Forward
0 new messages