Advertisement
wavec022

MList notes

Feb 5th, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. MList-- kinda like SList except the parameters are vars instead of vals, so the list is mutable
  2.  
  3. case class MList(var item, var next: MList)
  4.  
  5. The MList is basically the same except the header node contains the size of the list which is different.
  6.  
  7. ======
  8.  
  9. def take(list: MList, n: Int): Unit {
  10.  
  11. }
  12.  
  13. (5,1,2,3,4,5) take 3
  14. 5,1 D (2,3,4,5)
  15. list.item,list.next.item | list.next.next
  16. (3,1,2,3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement