def permutations(l):
  """ Generate the permutations of l using recursion. """
  if not l:
    return [[]]
  result = []
  for i in range(len(l)):
    item = l.pop(i)
    temp_result = permutations(l)
    l.insert(i,item)
    for res in temp_result:
      res.append(item)
    result.extend(temp_result)
  return result