# 5aa40c4f67259a307762e807b829a13fbdacea67b4cceb035ccdb8bc56df36c2 Elan 1.8.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
