RosettaCodeData/Task/Arrays/Lambdatalk/arrays.lambdatalk
2023-07-01 13:44:08 -04:00

24 lines
525 B
Text

// Create a new array with length 0
{def myArray1 {A.new}}
-> []
// Create an array with 2 members (length is 2)
{def myArray2 {A.new Item1 Item2}}
-> [Item1,Item2]
// Edit a value in an array
{def myArray3 {A.new 1 2 3}}
{A.set! 1 hello {myArray3}}
-> [1,hello,3]
// Add a value at the head of an array
{def myArray4 {A.new 1 2 3}}-> myArray4
{A.addfirst! hello {myArray4}}
-> [hello,1,2,3]
// Add a value at the tail of an array
{def myArray5 {A.new 1 2 3}}
{A.addlast! hello {myArray5}}
-> [1,2,3,hello]
and so on...