RosettaCodeData/Task/Arrays/Retro/arrays.retro

35 lines
827 B
Plaintext

needs array'
( Create an array with four elements )
^array'new{ 1 2 3 4 } constant a
( Add 10 to each element in an array and update the array with the results )
a [ 10 + ] ^array'map
( Apply a quote to each element in an array; leaves the contents alone )
a [ 10 + putn cr ] ^array'apply
( Display an array )
a ^array'display
( Look for a value in an array )
3 a ^array'in?
6 a ^array'in?
( Look for a string in an array )
"hello" a ^array'stringIn?
( Reverse the order of items in an array )
a ^array'reverse
( Append two arrays and return a new one )
^array'new{ 1 2 3 } constant a
^array'new{ 4 5 6 } constant b
a b ^array'append constant c
( Create an array from the values returned by a quote )
[ 1 2 "hello" "world" ] ^array'fromQuote constant d
( Create a quote from the values in an array )
d ^array'toQuote