# Extending a list in Softanza

11 views

### Mansour Ayouni

May 13, 2022, 4:16:29 PMMay 13
to The Ring Programming Language
Hello All,

In Softanza you can extend a list to a given position, by a given value, in many ways...

See the following code:

# Extending a list of numbers to a given position

o1 = new stzList([ 1, 2, 3 ])
o1.ExtendTo(5)
? @@( o1.Content() )
#--> [ 1, 2, 3, 0, 0 ]

# Extending a list of strings to a given position

o1 = new stzList([ "A", "B", "C" ])
o1.ExtendTo(5)
? @@( o1.Content() )
#--> [ "A", "B", "C", "", "" ]

# Extending a list by a given item

o1 = new stzList([ "A", "B", "C" ])
o1.ExtendToXT(5, :With = "♥")
? @@( o1.Content() )
#--> [ "A", "B", "C", "♥", "♥" ]

# Extending a list by its own items

o1 = new stzList([ "A", "B", "C" ])
o1.ExtendToXT(5, :With@ = "@items" )
? @@( o1.Content() )
#--> [ "A", "B", "C", "A", "B" ]

# Extending a list by the items of another list

o1 = new stzList([ "A", "B", "C" ])
o1.ExtendToXT(8, :With@ = [1, 2, 3] )
? @@( o1.Content() )
#--> [ "A", "B", "C", 1, 2, 3, 0, 0 ]

Here is a snapshot the code working on my machine:

PS: you will be able to try it in the next upgrade of the library package by the end of this week.

Best,

Mansour