# ca2e4b9ef7cedbb0b22d90761b4b9b8cf7de837204fc5bac237da828841a20fb Elan 1.6.1 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
