Maxim_Leo

Untitled

Feb 23rd, 2022
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. val x: List[Any]=List(1, List('a, 'b, 'c, 'd))
  2.  
  3. def LoopRemoveAt(k:Int):Unit= {
  4. var y:List[Symbol]=List('a, 'b, 'c, 'd)
  5. var list=List[Any]()
  6. var blist=List[Symbol]()
  7. var f:Symbol=Symbol(1.toString)
  8. var n:Int=0
  9. for (i <-x) {
  10. if (i==y) {
  11. for(m<-y){
  12. n+=1
  13. if (n==k){f=m}
  14. if (n!=k) blist = blist.:+(m)
  15. }
  16. }
  17.  
  18. }
  19. list=list.::(f)
  20. list=list.::(blist)
  21. print(list)
  22. }
  23. def RecRemoveAt(x: List[Int]): Int = {
  24. if (x.isEmpty) throw new Exception("Empty list")
  25. else if (x.tail.isEmpty) x.head
  26. else RecRemoveAt(x.tail)
  27. }
  28. LoopRemoveAt(3)
  29. RecRemoveAt
Advertisement
Add Comment
Please, Sign In to add comment