Here is a little program that will insert "0s" into a list. So if I send it

Code:
`{1,3,5,7,9}→⌊OVER1`

it will return

Code:
`{1,0,3,0,5,0,7,0,9}→⌊OVER1`

This is the little program

Code:
```0→R seq(0,J,1,16→⌊TEMP5 For(R,1,dim(⌊OVER1 ⌊OVER1(R→⌊TEMP5(⌊OVER1(R End ⌊TEMP5→⌊OVER1 ```

If I give it consecutive numbers like

Code:
`{1,2,3}→⌊OVER1`

it throws an invalid dim error. Is there a way to modify the code so that it will accommodate both the "0s" and consecutive numbers? Like

Code:
`{1,2,4,5,6,7}→⌊OVER1`

Just a bit of clarification. When in the original code the "0s" were used to skip a problem. In the new code when the two numbers in the list are consecutive we want these two problems to be displayed.

In the example above we want problems 1 & 2 which are consecutive to be displayed. Since there is no number 3 in the list we want problem 3 to be skipped & problem 4 displayed. Finally we want problems 5,6,7 to be consecutively displayed
sounds like the dimensions of the lists are not the same. Try making both lists the same length (amount of slots) and see if that takes care of the problem.
Those were just examples. Both lists will have 16.
here's another way to do it that does not have the dimension problem

Code:
```:augment(⌊OVER1,⌊OVER1 → ⌊OVER1 :SortA(⌊OVER1 :seq(⌊OVER1(X)2fPart(X/2),X,1,dim(⌊OVER1)-1-->⌊OVER1 ```
I gave

Code:
`{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}→⌊OVER1`

I got back

Code:
`{1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,16,0}→⌊OVER1`

Those "0s' above say skip. We must deal with combinations where we want to skip by adding a "0" when there is a missing number in the sequence and not skip when there are consecutive numbers in the sequence. The list length will always be 16 elements.
sorry, I misunderstood you question. Here's a simple solution.

Code:
`:seq(X(not(prod(⌊OVER1-X))),X,1,16→⌊OVER1`
I have some test results which I do not understand. When I give your one line of code

Code:
`seq(X(not(prod(⌊OVER1-X))),X,1,16→⌊OVER1`

this

Code:
`{1,3,5,7,9}→OVER1`

It returned

Code:
`{1,0,3,0,5,0,7,0,9,0,0,0,0,0,0,0}→OVER1`

which is correct

when I give your one line of code this

Code:
`{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}→OVER1`

It gives me all the answers that I expected but when finished give me "done" on the home.
john massey wrote:
It gives me all the answers that I expected but when finished give me "done" on the home.

Whenever you finish running a TIBasic program, it (usually) alerts you that it is done. I won't go into detail about it... just use that one line of code in your program, and it'll be fine; you won't see the "Done" message while running your program.
John, the one line code was tailored to your REAL WORLD situation of using 16 dimension lists, not necessarally ones that were smaller. I would assume it needs to be altered to accept any list you want to throw at it. But if all you are using is a single size of list, then why need it to accept more than that?
When it is done it should call REDUE22 again. I does not do that.

When the program is finished with 16 problems I put

If J=17:STOP

and I still get the done
CDI wrote:
I would assume it needs to be altered to accept any list you want to throw at it. But if all you are using is a single size of list, then why need it to accept more than that?

Yep. Keep in mind, all he would need to do is swap "16" with "dim(LOVER1)"

john massey wrote:

When the program is finished with 16 problems I put

If J=17:STOP

and I still get the done

Using the "Stop" command does that... try replacing that line with this:

Code:
```:if J=17 :Then :Output(1,1," :Return :End```

Better yet, get rid of the whole "if J=17" thing, and let the program end when it finishes the "For(J,1,16" loop
rthprog wrote:
Using the "Stop" command does that... try replacing that line with this:

Code:
```:if J=17 :Then :Output(1,1," :Return :End```

Better yet, get rid of the whole "if J=17" thing, and let the program end when it finishes the "For(J,1,16" loop

Point to note. In 2.53MP Output(1,1," no longer works. It still says Done. [ BrandonW in #ti ]
Got rid of the J=17 thing with the same results.
CDI wrote:
Point to note. In 2.53MP Output(1,1," no longer works. It still says Done. [ BrandonW in #ti ]

Grr, that's annoying.

john massey wrote:
Got rid of the J=17 thing with the same results.

Do you have a STOP or Return command in your program?
I have a little test plan that gives values for OVER1 as follows

Code:
`{1,3,4,5,8,9,10,12,14,16}→⌊OVER1`

Code:
`seq(X(not(prod(⌊OVER1-X))),X,1,16→⌊OVER1`

Returns

Code:
`{1 0 3 4 5 0 0 8 9 10 0 12 0 14 0 16}→⌊OVER1`

I used to exit the code

Code:
```If J=17 Then prgmREDUE22 End```

I checked J on the home screen it was 17. but I still got a "DONE" I also checked the various values of lists on the home screen and those values were as they were supposed to be. You have been very good at trouble shooting techniques in the past. Anything I can do, I will do
at the very end of the program containing
Code:
`seq(X(not(prod(⌊OVER1-X))),X,1,16→⌊OVER1`

Code:
```:ClrHome :Output(1,1," "```
I found the bug .This is the code under discussion

Code:
```For(J,1,dim(⌊OVER1// this is the loop If J=17 Then prgmTEST217// this is the program call End If ⌊OVER1(J)=0//this code skips that J number. End```

XXX

I just moved

Code:
```If J=17 Then prgmTEST217// this is the program call End```

From it's location to where the xxx are shown above. I have no idea why it works it just does.

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» All times are UTC - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum