title: Creating a method that generates all permutations of string in kotlin using recursion
body: <p>trying to write some code that generates all permutations of an input string as a recursion 
  exercise but can't figure out why I get a stack overflow error.</p>
  
  <pre><code>fun main() {
      println(subSet(listOf("abcd")))
  }
  
  fun subSet(s: List&lt;String&gt;): List&lt;String&gt;{
      return listOf&lt;String&gt;() + createSubSets(s)
  }
  
  fun createSubSets(s: List&lt;String&gt;): List&lt;String&gt;{
      if(s.isEmpty()){
          return listOf()
      }
      return s.mapIndexed{i, elem -&gt;
          elem + createSubSets(s.drop(i))
      }
  }
  </code></pre>