Author Topic: NSpire Basic Arrays  (Read 6921 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
NSpire Basic Arrays
« on: March 09, 2011, 05:35:58 pm »
Hey there,

I was wondering if I have an array, how to add something to it:

Code: [Select]
{2,4,6,7,8,142}->myArray
Disp myArray
Disp myArray.count()

I want to add the number 666 to my array how can I do it?

Thanks.

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 Basic Arrays
« Reply #1 on: March 09, 2011, 05:50:20 pm »
In the program, right? :P I think array + {666} should work as an append-style function, but it might not, I'm not sure. I know it does in python and might in C++

Offline Goplat

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 289
  • Rating: +82/-0
    • View Profile
Re: NSpire Basic Arrays
« Reply #2 on: March 09, 2011, 05:57:24 pm »
I think what you're looking for is augment(myArray,{666}).
A way to do it "in-place" is 666→myArray[7]. This might be faster, but I haven't tested.
Numquam te deseram; numquam te deficiam; numquam circa curram et te desolabo
Numquam te plorare faciam; numquam valedicam; numquam mendacium dicam et te vulnerabo

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: NSpire Basic Arrays
« Reply #3 on: March 09, 2011, 05:58:36 pm »
myArray[7] won't work, I tested it.

Offline Goplat

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 289
  • Rating: +82/-0
    • View Profile
Re: NSpire Basic Arrays
« Reply #4 on: March 09, 2011, 06:18:05 pm »
It worked when I tested it. What OS are you using? (I have 2.0.1)
Numquam te deseram; numquam te deficiam; numquam circa curram et te desolabo
Numquam te plorare faciam; numquam valedicam; numquam mendacium dicam et te vulnerabo

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: NSpire Basic Arrays
« Reply #5 on: March 09, 2011, 06:20:53 pm »
It worked when I tested it. What OS are you using? (I have 2.0.1)

I have the same OS, but I did something different, thanks!