Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def insertAt (l: List[Int], i: Int, x: Int): List[Int] = {
- val neu:List [Int] = List()
- val v : Int = length(l)
- if (i==0 && x ==0) reverse(l)
- cutList(l, neu, i, x, v, neu)
- }
- def cutList(l:List[Int], m: List[Int], i: Int, x: Int, v: Int, empty: List[Int] ): List[Int]={
- val neu :List [Int] = List(x)
- if (length(l) != v-i){
- cutList(l.tail, l.head::m, i, x, v, empty)
- }
- else{
- insertAt (l ::: empty :::m , 0,0)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement