input: Write a function to generate all permutations of a list.
  assert permutations([1, 2, 3])==[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
  assert permutations([1, 2])==[[1, 2], [2, 1]]
  assert permutations([1])==[[1]]
  assert permutations([])==[]
output: def permutations(lst):
      if len(lst) == 0:
          return [[]]
      elif len(lst) == 1:
          return [lst]
      else:
          result = []
          for i in range(len(lst)):
              elem = lst[i]
              rest = lst[:i] + lst[i+1:]
              for p in permutations(rest):
                  result.append([elem] + p)
          return result