Advertisement
Guest User

WEB: Scala InsertAT - ESS

a guest
May 1st, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.50 KB | None | 0 0
  1.    def insertAt (l: List[Int], i: Int, x: Int): List[Int] = {
  2.      val neu:List [Int] = List()
  3.      val v : Int = length(l)
  4.      if (i==0 && x ==0) reverse(l)
  5.      cutList(l, neu, i, x, v, neu)
  6.    }
  7.    def cutList(l:List[Int], m: List[Int], i: Int, x: Int, v: Int, empty: List[Int] ): List[Int]={
  8.         val neu :List [Int] = List(x)
  9.        if (length(l) != v-i){
  10.        cutList(l.tail, l.head::m, i, x, v, empty)
  11.        }
  12.        else{
  13.         insertAt (l ::: empty :::m , 0,0)
  14.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement