1

Can read about augment( here: http://tibasicdev.wikidot.com/augment

I'd like a program that is sort of the inverse of augment. What I want to do is take a list, say L1, then partition it into equal length sublists and stores them into L1, ..., Lk for some arbitrary k. If need to be I can add the number 23 several times to L1 until I can partition it. I would like for each list to have n elements.

Example:

Take L1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

I'd like to partition it into equal sublists of length n = 3

L1 has 10 elements which is not a multiple of 3 so I add 23 twice to it to get:

L1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 23, 23}

Then I partition it into equal sublists of length 3 and get:

L2 = {1, 2, 3}

L3 = {4, 5, 6}

L4 = {7, 8, 9}

L5 = {10, 23, 23}

However this is one specific example but I'd like my program to work for any n so that I can go N->T:prgrParttition and it runs.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
Adam Staples
  • 396
  • 2
  • 7
  • 19
  • I've never found a good way to partition or split a list in TI-Basic, so I'm hoping someone posts a good response. In the mean time, I'll post an answer with my preferred technique. – ankh-morpork Feb 28 '15 at 12:46

1 Answers1

0

This is the most obvious answer for this question, but it's what I've always used when needing to split a list into multiple sub-lists.

The program prompts the user for a list (L1) and a row size (A) then splits the list list into dim(L1)/A lists with A elements each. The results are returned in the Ans variable in the form a matrix.

DelVar [A]Prompt L₁,A
{int(dim(L₁)/A),A→dim([A]
For(B,1,Aˉ¹dim(L₁
For(C,1,A
L₁(AB-A+C→[A](B,C
End
End
ankh-morpork
  • 1,732
  • 1
  • 19
  • 28