# 30e8268de669eba4bd6162b3a1ed7f85ce3dd9f072001b0d48a8c86451db28b1 Elan 1.6.2 guest default_profile valid

main
  let li be [1, 2, 3, 4, 5]
  print li.map(lambda n as Int => n^3)
  let names be ["Tom", "Dick", "Harriet"]
  print names.map(lambda s as String => s.upperCase())
  print names.map(lambda s as String => reverseString(s))
  print reverseStringsInList(names)
end main

function reverseStringsInList(l as List<of String>) returns List<of String>
  variable lReversed set to new List<of String>()
  variable sl set to 0
  each s in l
    set lReversed to lReversed.withAppend(reverseString(s))
  end each
  return lReversed
end function

function reverseString(s as String) returns String
  variable stringReversed set to ""
  for i from 0 to s.length() - 1 step 1
    set stringReversed to s[i] + stringReversed
  end for
  return stringReversed
end function

test 
  assert reverseString("abcdefg") is "gfedcba"
  assert reverseStringsInList(["ab", "cde"]) is ["ba", "edc"]
end test
