Guest User

Untitled

a guest
Oct 25th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. --- 1 ---
  2. val myScoreList = listOf(12,60,0,38)
  3. val sum = 0
  4. for(score: Int in myScoreList){
  5. sum += score //same as sum = sum+score
  6. }
  7. Log.i("",sum.toString()) //returns 100
  8.  
  9. --- 2 ---
  10. val name = "Doge"
  11. for(character: Char in name){
  12. Log.i("",character.toString())
  13. } //logs "D","o","g","e"
  14.  
  15. --- 3 ---
  16. val myEmailList = arrayListOf("john.doe@dogemail.com",
  17. "muhammad.li@dogemail.com",
  18. "xoxoILoVeKoTLiNxoxo@notdogemail.com",
  19. "totallyNotScammer@doggiemail.com",
  20. "eehoohoohoohahh@dogemail.com")
  21. val myDogemailList = arrayListOf<String>()
  22. for(email: String in myEmailList){
  23. val atSignIndex = email.indexOf("@")
  24. if(email.substring(atSignIndex+1) == "dogemail.com"){ //substring from after the "@" sign, to the end of the string
  25. myDogemailList.add(email)
  26. }
  27. } //now myDogemailList = ["john.doe@dogemail.com", "muhammad.li@dogemail.com", "eehoohoohoohahh@dogemail.com"]
  28.  
  29. --- 4 ---
  30. val myPictureBitmap: ArrayList<ArrayList<ArrayList<Int>>> = arrayListOf(
  31. arrayListOf( arrayListOf(255,0,0), arrayListOf(255,127,0), arrayListOf(255,255,0) ), //row 0
  32. arrayListOf( arrayListOf(0,255,0), arrayListOf(0,255,255), arrayListOf(0,0,255) ), //row 1
  33. arrayListOf( arrayListOf(127,0,255), arrayListOf(255,255,255), arrayListOf(0,0,0) ) //row 2
  34. ) //column 0 //column 1 //column 2
  35. for(row: ArrayList<ArrayList<Int>> in myPictureBitmap){ //for each row of the picture
  36. for(pixel: ArrayList<Int> in row){ //for each column (pixel) in the row
  37. pixel[0] = 255-pixel[0]
  38. pixel[1] = 255-pixel[1]
  39. pixel[2] = 255-pixel[2] //color inversion
  40. }
  41. }
  42.  
  43. /*from [ [ [255,0,0],[255,127,0],[255,255,0] ],
  44. [ [0,255,0],[0,255,255],[0,0,255] ],
  45. [ [127,0,255],[255,255,255],[0,0,0] ] ]
  46.  
  47. turns to [ [ [0,255,255],[0,128,255],[0,0,255] ],
  48. [ [255,0,255],[255,0,0],[255,255,0] ],
  49. [ [128,255,0],[0,0,0],[255,255,255] ] ]
  50. */
Add Comment
Please, Sign In to add comment