Author Topic: Nspire lists  (Read 6456 times)

0 Members and 2 Guests are viewing this topic.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Nspire lists
« on: July 05, 2010, 11:25:02 pm »
I just started coding Nspire BASIC, and it's been pretty easy since there are many areas where it's similar to TI-83 Plus BASIC. What I couldn't figure out, though, was how to access the elements of a list. I tried the 83+ syntax of parvar(3) where parvar is the list, but it only multiplies the list by three.

I've finished the program I was working on by using a combination of sum( and mid, as in sum(mid(parvar,3,1)), which, as you can probably tell, is really unoptimized, since it's basically taking the sum of a 1-element subset of the list, but it's the only way I've found to get what I want. It doesn't really matter, though, since the Nspire's speed more than accounts for the horrible improvisation, but I'm still wondering: Is there a way to access the list element directly? There aren't many guides on Nspire BASIC out there, and none of them explain lists very well.




Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Nspire lists
« Reply #1 on: July 05, 2010, 11:27:04 pm »
listname[n] retrieves the nth element of a list.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Nspire lists
« Reply #2 on: July 05, 2010, 11:35:56 pm »
Aug, I hate it when it's that simple >:( Thanks, though.




Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Nspire lists
« Reply #3 on: July 06, 2010, 01:04:59 am »
yeah, you'll find a lot of things replace parentheses with brackets. Same with matrixes (I think that was my first thread on here :P)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Nspire lists
« Reply #4 on: July 06, 2010, 01:12:47 am »
I hate when i cant figure out how to do something and then its super easy :P When i was first learning to program i accessed lists with Prod(L1,N,N) XD

Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Nspire lists
« Reply #5 on: July 06, 2010, 01:34:56 am »
I hate when i cant figure out how to do something and then its super easy :P When i was first learning to program i accessed lists with Prod(L1,N,N) XD
LOL, I used to do that to.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Nspire lists
« Reply #6 on: July 06, 2010, 01:40:00 am »
I hate when i cant figure out how to do something and then its super easy :P

Same here. When I made my first game using string input, instead of If Str1=Str2, I used If inString(Str1,Str2) and inString(Str2,Str1) :P Never thought of the easiest things :)




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Nspire lists
« Reply #7 on: July 06, 2010, 01:45:33 am »
yeah for me, when I do mistakes, it's often small stupid stuff. SOmetimes I'll also miss some obvious optimizations x.x

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Nspire lists
« Reply #8 on: July 06, 2010, 02:16:58 pm »
Interestingly, the 89/92/200 also uses brackets to index lists/matrices. :)
« Last Edit: July 06, 2010, 02:18:54 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Nspire lists
« Reply #9 on: July 06, 2010, 02:21:19 pm »
Interestingly, the 89/92/200 also uses brackets to index lists/matrices. :)

I think Nspire basic is a lot closer to 68k basic that it is to Z80.  Another similarity is that you can end a for loop on a Z80 calc with "End" but on the Nspire and 68k, you have to use "EndFor".  The only major differences are the lack of dialog boxes and any commands that can be used to make a decent basic game on the Nspire.


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Nspire lists
« Reply #10 on: July 06, 2010, 04:51:40 pm »
Yeah true, I gave both 68k and Nspire basic a try before and they looked quite similar.

I wish both series had an input command that looked like Command Prompt/Consoles. It can be pretty handy if you make an old skool ASCII RPG like Medieva. ON 68k and Nspire the boxes that appears when using Input ruins everything...

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Nspire lists
« Reply #11 on: July 06, 2010, 11:04:16 pm »
ON 68k and Nspire the boxes that appears when using Input ruins everything...

Nspire has a form of input? :o How do I use it? I was trying to find a command for it, but none of the 83+ style input commands (Prompt , Input , getKey, etc.) existed.

listname[n] retrieves the nth element of a list.

Now I have to remember to go back and change the code for every instance where the program accesses a list >:( At least the Nspire has a Find/Replace function.




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Nspire lists
« Reply #12 on: July 06, 2010, 11:07:11 pm »
ON 68k and Nspire the boxes that appears when using Input ruins everything...

Nspire has a form of input? :o How do I use it? I was trying to find a command for it, but none of the 83+ style input commands (Prompt , Input , getKey, etc.) existed.
It was added in OS 2.0. I forgot the command name and syntax, though.

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Nspire lists
« Reply #13 on: July 06, 2010, 11:11:31 pm »
ON 68k and Nspire the boxes that appears when using Input ruins everything...


Nspire has a form of input? :o How do I use it? I was trying to find a command for it, but none of the 83+ style input commands (Prompt , Input , getKey, etc.) existed.
It was added in OS 2.0. I forgot the command name and syntax, though.

On the Nspire, you can use the Request or RequestStr (I think) command for input.  The syntax for both is:

Request [Text to display in dialog box (string)],[Variable you want to store it to (variable)]

Also, this will only work on OS 2.0 and above, as stated earlier
« Last Edit: July 06, 2010, 11:13:01 pm by apcalc »


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Nspire lists
« Reply #14 on: July 06, 2010, 11:12:57 pm »
Thanks for the command name ^^