Satimage Previous
Sorting, reversing, and editing values in lists
Home Documentation Smile Computing AppleScript maths Computing on lists Sorting, reversing, and editing values in lists  
  • To sort a list of numbers (as well as a list of strings), use the sortlist command.
    set the_rnds to (randomarray 1000) as list of real
    set the_list to sortlist the_rnds
      --  {0.001198402373, 0.001300571254, 0.002213005442, etc.}
  • To reverse a list use the special reverse property of lists.
    set the_rnds to (randomarray 1000) as list of real
    set the_list to sortlist the_rnds
    set the_rev to reverse of the_list
      --  {0.999669373035, 0.998593389988, 0.996168971062, etc.}
  • To access an item in a list use its index: you read a value with get, you change a value with set.
    set item 2 of the_rev to (get item 2 of the_list)
    the_rev
      --  {0.999669373035, 0.001300571254, 0.996168971062, etc.}
Version française
Copyright ©2008 Paris, Satimage