Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. pragma solidity ^0.5.4;
  2.  
  3. contract AddressSetHaver {
  4. uint[] public testList = [1,2,3,4,5,6];
  5. uint[] public smallList = [5];
  6.  
  7. function emptySmallList() public {
  8. smallList.length --;
  9. }
  10.  
  11. function wontonlyLengthenTheSmallList() public {
  12. smallList.length ++;
  13. }
  14.  
  15. function pumpSmallList(uint x) public {
  16. smallList.push(x);
  17. }
  18.  
  19. function smallListLength() public returns(uint) {
  20. return smallList.length;
  21. }
  22.  
  23. function yee(uint [] memory bacon) public returns(bool[] memory) {
  24. bool[] memory copy = new bool[](bacon.length);
  25. copy[bacon.length -1] = true;
  26. return copy;
  27. }
  28.  
  29. function add(uint element) public returns (uint) {
  30. if ( contains(element) ) {
  31. return testList.length;
  32. } else {
  33. return testList.push(element);
  34. }
  35. }
  36.  
  37. function contains(uint element) public view returns (bool) {
  38. uint len = testList.length;
  39. for(uint i = 0; i < len; i++) {
  40. if(testList[i] == element) {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46.  
  47. function length() public view returns (uint) {
  48. return testList.length;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement