<snapdata remixID="12516241"><project name="SnapCon2023Cryptology" app="Snap! 9.0, https://snap.berkeley.edu" version="2"><notes></notes><thumbnail>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAgAElEQVR4Xu1dB3iUVdM9u8luKiSE3nuT3gWUpiJSbCgICCLSFAQb8AEiRSxgQ0WUzwZYEOm9996LNOk9hBJK2m52s/vPmSURwqLil2Tjn3eehych++6995177swtc+aa3CIwxNCAjzRgMgDoI80b1aoGDAAaQPCpBgwA+lT9RuUGAA0M+FQDBgB9qn6jcgOABgZ8qgEDgD5Vv1G5AUADAz7VgAFAn6rfqPw2APJgJCoqCpcvX4bD4TA0ZGggXTVwCwCPHDmC48ePo2DBgggKCoLJZErXylk463HYbQL2xHSvy6gg82kgBYBbt26F2WxGWFhYhrWS4Nsy8xuEbf0aYVZXhtVrVJR5NKAAPHv2rFq+XLlyZWjLggIDcGxEI9TKbcRDZKjiM1FlCsDVq1cjZ86cadIszhuvXbvmFcwbN25E5cqVERISonUFWC24+uFDqFCpCkxmPySd2gFzgQqAvxWuUzvhf89DcNvjkHR0A8yFqgAuJ1zn9sG/xlNwnf0NfkWqI+kMf1aDY9MPMBesBL/CVfV3S61n4Nj6i5R3D8y5Smh9SSe3wW2LgaVyKyRFHoApWy6YQiLg3DYVprD8WrcpIASmwOye58/sgevMbpjzltH6ndunpujIv8bT+pkr6pDnb9J+S402SDq+Ca5Lx+U7ZQFLoD5D8a/UXN/DX+rWso/JcxcOw694HS0fbhec+xbBHXvZ83zVx7VsV+R+mMIL6DNJv6+CuXA1wGGDOXdxOH9fCTgdsNRuB8eO6UBivEc3/J60XXUmwjboM7tme54R3biOb9Z2atPzl4c5Xzk4d8701F2rLZxbp2i9/uUeUL35Fa15o90b4XbY5Xlpz4Hl+jdLnWelrGPSppKqey2jZhs498yDpepjopMtcF086qlL+sccUQTO3XP0/yaXy+WeNWsWSpYsqX+4WeQzcF5YpkwZXLx4EUlJSQougpXW8tChQ8iePTsCAwORkJCAPHnyYMCAAXjyySdRr1490LKGh4cr4ObNm4chQ4Zg586dKVUECgCvffwwyucLRUj/NYgf0wxB3X+B7YceCGj1FtxxV2DKnkeAKd9xJsqLx8OcLS9MuYrBNqELQt4+iMRlnyKgWX/Ef9oMlpptYanXGbGDSyJk6B4kfN0OQV0mIeGbZ2HKURDWes/DHX9FyzMFZpPyEgQQLZA4/11Y6naEUzrI2nwwnHsXCCDcSDqyXurPC8u9HbRDCZb4sa0Q/NpyAcsS6ZQacO5fIp31C4JfXwHH9mnwL30/EteMl/LDFNyJyz7R9w3qMx/2X19D0IvT4dj4A/wrNIV94fvwL9tY63BdOCId2Q5xb9dAcO85nsGYr6y2le3ge8R/+oi21x1zUYFmm9QNgc98BudvC+BY/x2C/7NBO53tdO6aCacAJLjnNCQuHQO/Cg/B9uOLqmfHzllS/8Owz/iPDNqKMjhawHV6N/zKNUb8J00R8uZWxI++X9o6A/a5I2DOUxr+FZspEC212skzDyG432rEvVUelvu6wr+aDJbIgzCH50fi6i/FSOxH0EsC5iSHtoGGxDa5jzz3GPxkULguHhPdVZdyHvYA8Oeff0b58uVvA2DHjh3Rpk0bbNu2TRcmp0+fxsMPP4z9+/erJfv9999x/fp1BaWfnx/uuecezJ8/H82bN1egVa9eHcuXL0fPnj31uR07dqB3794gsLVTxAXHjnkE5XPIKKr9DKxN+8Gx+UfpwP+KotZJZ8hoF8sCVxKsD76qSqAliB1YXL+fDEB/UZxaF7EyppzFEDekLEJGHAQSrikYHOu+1ecDO3+nnZ3weUtYH3hFAZ10ZAMC23wM9/UoJHz7rCh2DZw7pikAnYfX6mcJE7vAfekE4GeFf5VW8C/TELZf+sAUnEOAt1w7H5YgJC7+QNpXGgGtR4s1meUVgIGdv0f8+/VkoDznscx+Fikn/AYAOyBBQBXQcggSxj1B+4DQUSeR8F0nBLQYLNZbvMGxDSkARJJTvULCl60FCC/ALO9OUFtqtZG/uwToE3VAWpsPQvx798rf24oSsiNx0Sgp2qxWN/Tdo4h96x4Z4HYEtB0jg28hAp/+UCzaCbWS9vkjPSArL5aQOpb3jx/7KALlWYd4BGujl3TgmgtWFq9FD3YPXNGntHz2l+pRrLNj048Ife+YGIfS2p/Ug2PVOA8AJ0+ejFKlSt0CQFq0wYMH45tvvlHr9vXXX6NYsWJo1KgR2rZti/r166Nr164YP348mjRpgsTEROzevRuXLl1SwLVr1w67du3C+++/j4iICLRq1QqjR4/WMpO3d0KCgxD/WQsFICV05CHEvinuKEAs4qBNiBtaUZRaFH4l6wlw8qnFccVcgOv873AIsJIBaArKLuB7BEmH14llaC0j8x5VrH32W7A06KGjGf4BCH5jBUz+gYj/qDEs9V9QADpWj0dgx/8K8H9G0qFVCkDHpkkeC3hss1iYTwVsL+uotj4yUF0iO8E2sau6bVqrRAGgOVsesRbD1cUEPPIfsUoL/xyA9Z/XdyOo6fbpAhMXj4br2nkFffyYhxWcoe8cRsL3neX9WspzweIu71Fg0QIm7V0kru5p2Ke+Ie6vFMwl6iBRLJa1xSCYwwqoB2BH05Lap74uLrkyzNnzSzuHeaY38VcR+MKPMiDqireJRmAn0cOWyWpVaR0DWo9CwqfN4XdPU/iVaSD6WS2WsxkSV3wu7y79Uby2gj5x5Vhtn33OEIQMlmnOldOI/+pp+AkYTeGFxLK3V5AGtHwLsSOqygBuIKDuAvu8kZ54QLpHb3NAWqty5cqpxSKIypYti1q1auH7778H542LFy9WlxsTE4Pz589j+PDhmD59OpxOJ3LkyKELmytXruDTTz9V0H344YcYNGiQglUBFxIMm7i0ZACGjDigZl2tVTt5yWy5PZ245CNVPAHj3D4dIeJq2EFBfReqCzbJXIuuiXM+64OvIG5YJXXB/BnQ5iNAlMtljkmsVNKJrQog19l9fwCw/Rc6QpOObfRYwAPL1DokHV6j37E2fUPmZpcU/PZf+iL45flwiZLN+cvBsXIcHOL2gl9ZLBZio1iKJrDNGKgAoGtKOrkd7quRApgnb7jgGdrJlsotYRNQ0P1xjuSW+RgtdNyo+upu3TJXM8scjHM7Djh2cOKSD/TdaZXUBX8vIJb5G60jpy/B4uZdl09Jp+eHS+rlPNPSsKcMxCEI7PAl4j9+8EY714t1egTxX4hLlLkddcYBxgFB6xby1g7RXWUZvN0VLM6Dq1S/fBfO6Ww/95LfdyBUpkAs23VN3o8AnPaG1iP7d+Lue8pUZanoW+aPYkDsc4bpvNEic1tThAw88WxxAkYFIC0XN5+5LXKzcB+wcOHCChhatty5cyuoRo0ahUcffRQ1a9bEmDFj1OU2btwYV69eRWxsLAoVKoTo6GgEBwfr/PDcuXMKyuT/8zN1wQEW4Nu2KBfuWQVzPuI6uzelCbR6bnGjkLkaf4c7Sd2PKUdhnV9wEUHXCZO4aRF33GV10VyocEHBn7AGeSb5IpzneOqppM+yDC1PFM+fnKDrs/IdLe9alJR/Xn/niHeLdUoWWj/P//9YwZtzl9D5jT4fklMUXcjzuJRLl+i6ckZBe3NbODeFLLRojUwyOde5rtSp72677vkuF0YyEN3Rp9Xq8hl129En5R2c+q5u+d1ti9XP9XtSpjlPKZ3zcmFjzlVcf/Izs8yh6WJTRAawKSg85V1TdEddFa4iFu2szqG13edl0SX9oXrk+16WNvD7ye0To8H+SNYb63XJ95HkMTq6wAsMVcvJtqTsA06dOlWtHOdyfya0hgQj53v8ScuXP7+89D+glnCbu8q52fDfLSs4Q7KkBlIASGDNnj0bNptNLV1GCTe+w/xle0WW9oZkPQ3cdhZMi0aXzK0Tf3//rKcR440zVANGNEyGqtuoLLUGDAAamPCpBgwA+lT9RuUGAA0M+FQDBgB9qn6jcgOABgZ8qgEDgD5Vv1G5AUADAz7VwB0ByNg/hlTxaI7nu/y/IYYG0loDXgHIwIQ9e/agRIkSGUJM4kvx1OVa1Glc3LYQFrdBUErrjs6s5d0GwLi4OGzYsAFFi0rITAYKg1M3DnoQzQrYGc1jSBbRwG0AXL9+vcbyZbRcPHsKBWe9gHyhfx6Nk9HtMupLXw3cAkDO8xhSX7y4J+T9f5UJEyZoZHRAQEBKUQzb6t69u/JJ+vfvjxYtWuhnl86dRpG53ZC/dCUN92aApeX+bhIPFwe/EnUlqFGidoWMY//1dQ0cpQQP3KjBqoy9Y4R0wGNva5g4Y++sTSUCWGL7EiV4k2Hm6uarPSExhHmEl1BZono/00DPkCESfPl2dSEBPQZrswFK4Elc9IGSbCx1O0lA54sSo7hHAi+HKo+DwZsMVk1c952GlFMC24/T8gI7jkf8Bw31e4zAJrnKKqHyjK52bPlZnhkrAaGLEP9hY406dl0+ruSj+M+aa/xe8BurYLIGCwVAwutJRJJgU41TlAhxvp/WJbqxzxnqiZOUOkJEB+Ro+Fd5VOPwTKE5PaH3Iu7rF5RTQyFXhBHi1AvJXAnfdFDuiLX5QI0S52dulwNBz3noCxTqJfDZLzWgllHfgYyQlu8lS0Ar0YnU69y/VCOorU1eFl5JE6UTBHb4QikLjg0T9T0Sl43Rr5mCwmAVvo9/6YZKYLoFgIxsXrVqlQahphZGQZMT8thjj+HAgQMaZMoFCoNSSUYioCIjIzWci+V06NABnTt3Rp8+fZAvXz4sXboUBQoUwFNPPYWDBw9qSH+vXr00pJ/fuRx5BsXm90D+stU1zN2x7hsNsHTbYyQcvJEA7UMJsCypLC3bTy9p80JG/o7EeW+L0nMr+YecBsfGSQh8apR00nBlhwWKQhMk6loBKMwwswR6miW0P3HhexqwGjrqlBJxAjt+JaSf5sp9IIAYaU2wJXzX0QMoBoZagjV83kHOyvC9iB0kRC7yGySsPVG4GEHdJ2sUNmkAJgsBGKCBpo7NPwnQt0sEcDWhGmwWQtNiKSdU38MqhCrIeyZJIK6l+hPwE14LCVAkLjFA1y1R2KaAbCnkJobYk9zEQFMGgjIq2bFjhnJKGGXsWPWlRh4HdZ/i4cKY/ZG46gshGkn9I2sqKYmcDfvUfgjuuwDxn4tuBPR8V9uE55UGwAFF1iEHTWCnr5WUFC88Gkapk09DsT70mgap2mcORsCjw5EkIKReqSvyT4J6/KqhutoeeY/EBe/q9wJaDZNo7zgN6w+UaPVbAMiIZgKQEc03C6Ogp0yZgrfeektZcj/99JNyPMgR+eKLL5QZ17JlS42OZrQ0OSYM55o7dy7IuCNDjqBl+D4ZdnXr1lXrN2LECKUC0PJeuXAOJRa8qAAky42EHefR9WKlDioAzTmL6OjhSHKs//4WAFpbDPFETQs44se3RXCvWYgdUEQU9pl0Rnm1EKkB6CeRvgQPI3nt04UdJv+3Tx+gnRgyTJS/5mv9Dhlyge3GCsdjviguAdaGPdQSMzo54b8eS/NnALTU7+Khk0YJt0NIT6Ej9mtksnPPXE+YeoGKCHjiHQUd62BYftLBFWr1OID+CoAENCOtGbWcRNCs/kooA2Lt5o3QCOuAh/vJIJaBLCAnGNSTMHJcQGEShmGCWF9SGxj9rl5H2IH+QhdIED1am/TWQUQPw+hlv1L3pQAwsMM4oVbOlbD27GLlu4qlmyCALCQGoolGSWsdpMimAiDD9BO+lTqEk2K5t9OtAGToPSOjU1M0L1y4oISifv36Ye/evWAWBTLmyJSjFSPjbeXKlepu+Y/zyNq1ayuhiW6YIftz5sxRPgh5JsOGDdPnihQpoittyrVL51FqUS8FIEcXzXOQdAYVSQA6hPjioWfaPZTLr1ojqOd0JfKktoB0DbQ6DO8Pen4CEn7oLh3RH84ja9Xd3GYBxW3SeiV89xz8SjfwUCuXC93zyffkuz2Ev9FCeBYFNYzdFBwmbflC+crWB/oomCz3Pqu0w2DpSIKdUwf3VQlDF8tCHjLfJUTcKxVPWqZyVgQ4CUItpaUJeVOIPEIPiH+vnrD59snPujK92KTfUwAKAEj8UWsrnAv7rDfFBUsIv7jc4AFrpdxOAro5sC/+UHnRDIe3i8WxCG/EJNwUba8AiBYMEsovuVDkORmA1hChwHaXQWdW15vwdXvxGN/IlKClWFihVMj7aAi+vAcplxyACeOf1v4iF9i/zP1C2Oqr5CUOIDIDad0IenJCLE36eEAvLt8ufBaaRGvjl5QSQAJXoHBxbluELFiwwGt6jrVr16qrpKXbvHmzkpNINJo4caIuWsgFfv3119VF06KROUfrR54JXfD27dtRoUIFDd8nVZPum5HXtIbx8fG4fjkKZZa8jPxFSsC/emvhsn6s3GCnEGv8xEqQc+sm3U/ET2iRFmG/OXaQSO1WfgRpkJb7uyp5m+DgSOYIJ7XQse1XWEUpptBcCiwlrd8oL1AAaiPrTFyvn3Bl3UKwIXg5fyKJ3K9sQyUkkQzFKQBZbMmkanIuCDaOeM4HSfQhFdEl33VIPSyPBCgKyVC0qnQ7tsmeuZJf8VriukcpeUnLlXZyzkX+LnUAPwkIFhfOqQOF3oBzYnORGh7rLBbTXwYMy7M27qWuVb+XLDJtUN6y6EYttbD/FHAiAY+PFJbbGhlw96mVc+5fJnwNCUKWOWmykDifOP8dz3fF9f+xPeFWQhSpoJxHcqCTSehX/kEdUJxn2mcM0jaxjZbGYkkp4qVsU16F9f7uYoErePjZqa9pOHPmjFowAuWvhLzgdevWYeDAgaCVpLXjnI8W8W4lMT4G5Zf0QpjFyBFzt7r7Nz/vdSN63759GpZPy5VRwjlIlewJCDy6UiyokRYuo/Tu63rueBR38uRJzYhAy8ZFhsUiFMoMEAIxI9LCZcCrGFX8DQ38rWAEzumS02n8jTKNRwwN/G0N/C0A/u3SjAcNDdylBgwA3qXCjMfTVgMGANNWn0Zpd6kBA4B3qTDj8bTVgAHAtNWnUdpdasAA4F0qzHg8bTVgADBt9WmUdpcaMAB4lwozHk9bDRgATFt9GqXdpQb+EoAMMk3OcMpc0Yb8/9MAs9gyap2xmQyRy0j5UwDyLJjnshl9gU1GKsCo6w8N8LYDUnAZIpdR5/F3BCBpmby6KzQ01OijLKQBxngyh3edOnUy5K29ApAJxXmrUerQ/H/SIr4Ms+mTI3JzQAPLZ+wgE5czcJVBrZs2bdIwsB49emhVDILNli0bqlatekvVDPt/7bXXMixC55+897/5O5xyVapUSaOg0lu8ApDRy8zdnDphOYlHvNSGfycAePMR3TPT+n755Zf45JNPNPx+3LhxGglN4DA49ddff9WrGniFA6OfGVXNCBtGSDOi+t5779UQfoKS/2ey9KZNm+qzDAM7evSougT+7NSpE9q3b698khMnTmjdvLukWTO5FMWQNNEAmYtMQM8+SW/xCsA1a9Z4tX5vv/02unTpAkZN8/6QBg0a6HVcDMUnAAhIEpZeeeUVtWqkdxJ85Jkw/J7Xdj333HOoWLGipv0gU47P8xkSoghA/hs6dKiG+BNYtJDkoPBvP/zwg3JIyE/hcyRGkQLAOUvp0qWN9CFpiBYmKKAVTG/xCkASjLythj7++GNtVPIcgUBbuHCh3oj0wgsv4NVXX1Vrxt9pKcn5JRBJveRNTFxREzBkx40cOVJJTu+8845GXpMCQFAdPnw4xcrRmlqtVmzZskWtKm9dIquOF96Qv0z2Ha0o6Z+0juSsGJI2GuBckEYmveWOAPTGDaZLJLD4GYFEl0pLZbfbFZh00QQQ52i8J+7BBx9U6ua3336rbperat7ETitILglBQ6H1pIWkZeU8keDnvJE/OQ8hFZTWjmQmlkfKAKcBfPbUqVPKMeZdd2yHIWmjAa4DfAbAFStWeCWn3+nV6Bq5YKHF47yMrvXZZ5/9R5fXpI36jFL+Vw0QgN4usPxfy039fa8WkAD0tgJOvlHdKXfUGvLv1kBczHUkue/Mv+Ei0WcApKvzBkBn7BVs++g5FPOXvCSG/Ks1QGNSpdsHuJC3jtfFGwHI69jSW7xaQAKQWQ9Sy9nlE1Hr5E8w30ifZjMH4khEPSSUk+Q6cgmdkVYtvbvrn5XvSHIjW+R2ZD+2FEXsnlvSkyX21S26A5FaOL/2KQCZSOg2AC77DnXOyFXu8kGUJT9O1umHkpVrpTwWICvWnQumwZogiXOykNjkjLxiK8kaFZQtU7/19avRiF41ATXOMaOERwhAXqmbWrgX6DMALlu2TDNZpZZzy79XANrMQfjt/tEoXr5yyiNcla76bCjK7Z2FMGvWyzBpzVtUsnUtQpzsFGRm4U5BzMyhKH/Vk+Iu5pXNXgHIz3wGwORUaqkVGbliggJwZ66mKNR60C0fM8XuoheboZHfH3fqZuaOSI+25Ry/B1FXrqccOXKexUiTzCanjh1BpWW9EOAWMAoAk+9vTt1O7rGmt3idAxKA3nLDnF85UQG4vv4YlK5QBceOHdM9Oe7REYCLXyIAo5Cz3QDYDkvix21LkePJl2E7tAP+OfLCWqi0vo/95AEkXb+M4EqSGEckKfYqrs4dj4g2ryP6V7nhXMSSrxgCSlRG0tUL+vv1Fb8grGknxGyYDVfsNfm9I5yXzyFu+3KtL1nif1uHwDLVcWXG5wgoVgHmbJLtVdxJcl3O6EhcWzxJH4946lUkHNwC/s2arzjidnjKYrvdcim0f0Q+BJaunpKUh2W77QkIqSnX3csc6eqcL+FKiE2pO+Kr3Th7MTolgIORJZkxmIPzu8s/9kVF215c77vpjgDkiVV6i1cALlmyxCsAo1ZNQu0zv2JD/U+Qq0ARPWLjmS8DDQjApb2bKwDLzIlG4unfcapfU5Sc9Duip0uqs+IVkbBvI+ynBHxXLiC0bktYxG3FrJ2BvL0/xekBzVB03GYcecrj+oOrNUbYA+1hP74PuToNwak3HkKenqMROfoFOK9Eodjn6+CXIx+OtCmkz4Y3f0GfJVCLfLAYRzuWQbZGbWDNz/RvbphDwxC/cxXyvz4eR9oVh7VwWeR7VVKHhYThRK+6KPnD7zj5WhMpdz2uzPtagUYQ5mz7Bs6+48kK6og8gQIDJyJm3UxNQGk/9htiN83/A4Bf7saZi5c1gIJCAPIoMTPKxckDUDlumwKQhwOphWfvPgWgt8REF1b/gFoCwG31P0DhcpKHTiwLj8MYHMCggZsBeG3xRDjOn0BYs84KCgLQWrA0XLY4BZ05KFQtmlMsnDkgGKek80v8eNgrAEPqNJO8fla1ZJGjuyDb/U/o77R0MetmSXkzkbub5PLbvwmx62ej9MwLCg6/bOG4vlJS9goAsz/QTi2nW3Lssa6cHQbCeekscjz2EiI/ksysAsy4LYs1T19IrYfls3OI+uoNFB+/XcuiXPxeUtwWLoM8Xd9D/N51YkXeVUufLDm+3KUWkBE9PELkPlpmBeCVXweiQsxWXOuz8Y4A9NlZMI/BvAHw4pofFYBb6o1GEQEgzwunTZumySZpAZf3aZliAS9NGIYIsR60fibJc0cAXlv2k7jj7WJd4pHj8d6SDzkQJslISkt47v3nUGraOa8ANFmsCChZBcFVG+Fk73ooOGwqLLkli6vJLC54Kc692/EWAJb88QhO9K6LbPUkv18YcyS7Ffg6BZAkiVFj+6L01LOaQpZtuzJLEiVKW8IeehYn+9yHQiPnCHhz4MgzRaVNZ3G8qyccjADO0bqvuPdPEfFkH50anP/0Ru47+Tx83E4FIIMuaAWZ0jgzA7Bi7DYFICNfUgvnrz4FYN68eW9r1KW1PykAN9/7vlpAblZyDli5cmW1gCv6tkoB4PGetVDko2WI+qyPzMXuUQCG1HhQ506cc8WsmqrWiHO+wqMW4ursr5DvNUmILZ9Trq+cDD/JRkq3SgDSohb/dg/Of9xd3G1XnB7kSfxYenokjnQoiVwdh6RYwJI/HLrNBdNtX1syCUXHrBKrtUuBd36MZOsMzo6SEw/gwreDkbvzMAFdMeSSn/4R+aWuHig966Kk5PXcWxI99SN1zbk6SUJv+du5955D/O5VKXoK/2KnumCGsuk7SChaZlyEsG1Xpw1CpdjtuPryhjsCkP2a3uJ1Drho0SJ4A+DldT8rADfVeU8BSKHl47khR8z2t55FLdux9G5zpi0/XOaA5y9fAVMdU+iGqZ/MKNemDUaluO240nu9VwByW81nAGSIlTcARq+frADcWPvdFADerNzc8ecR89mLSLp2u0nPjJ2Qlm3K0bYfrtZ+KgV8aVl2epRFAFaO36EAvHhRroJIJQRglSqSRzqdxasF/CsAbqj1DgqVvb1xdD1RJ44g7gpXVZxhZR3h1RScE1Ny5CuIfMVKqWfIrBIzY4gCMLrXujtaQJ8BkInKvVnAKxt+UQu4vsbbKHTDBScrmCPm6NLpCJr7EQoEmTOr3jOkXWYyCV//BpERpTKkvn9SCQFYJWGnAtCbBeTUwacA5OUzqeXqxikKwLXVR9zmgrkIWdf/aTQyR/4Tffy/+064rJYjeQuSHM1xT41bVplpRRwzcwiqJuzC5ZfW3hGAqclg6dFJXl0ww929AfDapl8VgGuqDUee4uV1I5qLD27DcMK9vv9TugoOb9EVVxd+D/+wXMjW8CndR3Ml2mS/L0hPDrgVk+PxXp7tD/lb9oZP64o4ZpVcp1CkHIIrN9B3Tdi/UU9RKNyC4eYx9xCTrl5E+KM9YT+8EwkHNiO8ZTfZ+D4kK9LVeuJhLV4JsfIcV75hD3WEOcTD7orbsUI2k49Jm1rDJVn5YzfMQ2A5CaaQ+EbbkZ0IlW0bluGKu47sjdsgMfI4bAe3yjO1EcTnRGxHdiFhr9ynd6P9gWVr6mexmxfqvmeyZJdtpvPVn1TgMaqbpP5kF50eHXm3ZcbNGvyjNZoAAApKSURBVIqqNg8AmQc8tdCg+BSADJFPLdc3T1UArq46DGt37EfPnj2Vm8GRTS7IhgFiAQWAJX86ihMv3YvC787FpR/f0W0Y2XGTk4vcCKnaGMd71kSZWZdw6PHcKDZuE+Kk8/wi8sIvNFyPwbI1aI34XasUBFHjXtfjsJBqTRD/21qEt+qBU680klOTTXKysQLnP+yOklNO6jZN4pnDukkdv3OlDoIzbz6OAoN+ROyWBQqq2M0LkKfHaB0Q3Ht0nD+OpJgrMijiZDCM1f3FC+MHyDHhJRT7bB2cMdFaF4/ngirWV+DxCPDM0NYoNnajnqAU+M8E3Qzn3493qyanJ555IAEYKXfT6e83AJi8Or5bsKTH83Fy9101225cenHNHQFYrVq19Kj6ljLvaAG9ZUOI2TJNAbiqylB1wRwlZMSRcsnRvWlg2xQA8pTBcfEMzo1sf+Os1gPAbPUeVevIIy4ev3H/jnt6OR57ERY5NuMRnr9sMnMjm+fItKLhLXvgaPsScMkGds72A/XGoBxPyd1mv2+Vzp8tZ7qvCHCXIPTeFjjZt4FayOTz4eyNn0kBIEFaePRi2ViuopbXT/YAeVJDC2eTM+HscnR3ZtjTUk5zz8a0nNScfetJHRDJAAxv2V3rKPHdbzjWpZIAcQNsR3frAIhZM/0WC3i2ymPqIXh/Srdu3ZQ0lVEZB/4KOfGzh6GafTcu9lztFYD0aD4D4Lx587ym44jdOl0BuKLSEBSQWy1JjyTDLfk2zM0Dn0Ejf48FjBr3KnJ3GYmoz/sgqDxZ9h4AOsRK8TSBwQkn+zZE/v7f4sSLtRUwEW1ew8VvBqcAkP83y+09Yc2eV2tmP7YHeV8WsJ89ioj2/5ETic8UJNdXTBY3G6buN+rzvuqWc3d5G0lxErTwQAdEz/xcgx8S9qxFsa+24qhsXBPs2eo/ppvctIaxWxcjpwRDnHu/s1jNH/RGTLpuHvNx85lTA1pouuBLE4frefdJsY7m4Gzwy54TEU/0wnnZdOcASraAZyo/quQpsgHJ5vMWd/dXQEmvzxPkMsfqiXsUgLygPLWwT30GQF4y6M0Cxm2boQBcXvFNzF62Tuc1bCgZb2XLlsWWQe1SAHjsOTkHlXlbnh6jELN6upyxOhWAOh8Ud5i/3zc49GiEHO5P0iMyfp509ZK4yfl6Ppt49ggCy9bAmYESaSNRKfn6fY3EUwcVaKf7N0MJOe1gYEJ++TvdZmDpauoKCw6W4z4BiSV3QQ2GKPLhcpweLFeKXjytOs7b53MEybyNZ9FRX7wq58k1bnHB15f9qBY38oOuCqxCI6aLxf5Oz56jp43Rs+FIOY0p/O48zzRDAh84T+RRIQeSS0CfDMDTlTxRQskumAuSzCK2uSMUgBd6rLojAMlsTG/x6oIJQGZKSi3x22cqAJdVGIziFWvqmSeF7jdW9sF2Du+MBqZzasGcF+WyPtkLpHVxy+V4XISY5OyWESZciOgcLOqkfp9WhLdUuiQsi8Bgx2u5Nz7X/8h3/cQdMzyLYslTBI4LpwTUeeTivji1ZJzPUQhYZ7QnLtE/VwHP7zeO+LQ+sWRsEy0bf+dnrni5DVKsMqR9XDiwLVqPtJMLFrdYRG2fPC9UHrWOye1LbsvN+goTK3+iXLNb3O7N9yand8f+VfkEYA3HbwpAZpdILTxC9BkAebOlNwAm7JilAFxafhAKlr39nDD/5UNI/O+rf/Xu//8/l22XsDcm4Jh/rkz7rna5Z7mmc68CkFOE1MIwO58CkPlZUott52wF4JLyA1GwzO0ApLvJmyc3km4c3mda7adzw/wkVvC8zKsYrJFZhTfJE4BR3VfeEYA1anhu5UxP8eqCZ8+WlaUXANp3zVEALio7wOtRXHo21Cj77jWwYcMGr/O7hx+Wa2RXfoxaSftwvtsKrwDk1prPAMh8Lt4AmCg3ZBOAC8v092oB715FxjfSUwNMdcL8PTdvNDOr2eOPPw7ngndQy7VfAch0bKmFN977FIDM15daHHvmKQAXlO5nADA9kZOGZTN7GfMwMuiUyaMIPopz4buoLQCM7Lr8jgCsWbNmGrbEe1FeXfDMmTM1YWRq4e3XBOD8Um8oALmxyo1WblpmdmEipdatb7pN/E8azPdikiWmkOvVqxcY6ZJamDKOh/j8x2xgmTnyhRbut99+A10vhXN1roLruA8oAAnS1EIyVaYF4Mzir8MGK2imCUDmkmN+vswsZPox2wM7glsMzKhFUHK1d9999+kmMVl+DKNnkiXuBJQsWVLfkX/r2rWr5jJ8/vnnNeaP4CQbkCnrevfu7fU0IbPpg6cwzGxGHYRsHIe6OIhzLyy7owWsVeuPpAPp9S5eLeCMGTO8WsCkvQuUlvlTkX5KEiKflBlLyaIrWrRoerUxTcol2Z4pf+vVqwfmP+zfv7+Shx566CHN5sUE3bR2gwcPxqBBgzTvIQE5fPhwzUf4xBNPKHBJ7E62dnv37sX+/fv/FQBMBh/3eCtXrgT7/HfQwHIUZ7sIp8bLHJAW0KcATN5kvrn3XfsWKgCXBj+AfeYSmsPv6aefVgqnt33DNEFOGhXCfDcE1LBhw7B582ZdZDFHIbO8MgHmgQMHFEjMxErAEYDMd8isr0w/zNMeblAnC9MYc5uFVtDbUVYaNTvNimGuRR6xNmzYEMckL2PtLUMQYY5XAN7JBfssRS9Xwcnc1ps14N6/SAF4Lik7poU/gxLiopjLecqUKZneBXMeR9fJuRvDjNghtOC0ajzJYZZXHpXRtY4dO1b/8bn7778f5Mgw2oeWkv/nESRBnHxvCkHobZ6YZuj5Hwuid2LUEgcb57bXNk9DB+sWLfXM80u8ApBn2EyRnN7i1QWzEzgqbmN0HVickpxoQ2xu7C3ZQeeAtJbecsmkd+PTsnxaQw46hqExJ4q3jFFpWV9GlUXwMcI9GXynty5B9yIX4HduTwoAuV1zs9Cycx+Qgy29xSsA6WomTZp0G6iSZBVcP2qGZseiHHFGYFdEE7jylEWO0ED4+2XtUPz07qx/Wn6szYlrwtPJf3q5hMvth99NfJ3TnRdrauSb5eTJkzq3z4jdjTteVENTzaThNxPUS4QkIt8COet13pqLmZk2o11BcMirGZK5NEBjkd1sQ4jp9qy2/lUexfai7XQXI1m4X0g6Zkak5WCdf3pVF0HIlSPD8xl8SilRojictswTVpS5uvvf0xp/CbiNvnotZarBlT1Xw7zyIqPA95cA5APMpMQbjMjyz4yZnv49XZ55W0oLyPk+90NTX06U3q3+y9sy07sBRvlZWwMGALN2//v87Q0A+rwLsnYDDABm7f73+dsbAPR5F2TtBhgAzNr97/O3NwDo8y7I2g0wAJi1+9/nb28A0OddkLUbYAAwa/e/z9/eAKDPuyBrN8AAYNbuf5+/vQFAn3dB1m6AAcCs3f8+f3sDgD7vgqzdAAOAWbv/ff72BgB93gVZuwEGALN2//v87Q0A+rwLsnYDDABm7f73+dsbAPR5F2TtBvwf6eGXKzx7rucAAAAASUVORK5CYII=</thumbnail><scenes select="1"><scene name="SnapCon2023Cryptology"><notes></notes><hidden></hidden><headers></headers><code></code><blocks><block-definition s="uppercase( %&apos;plain&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>alphabet</l><l>translation</l><l>letters</l></list></block><block s="doSetVar"><l>alphabet</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><l></l></block></autolambda><list></list></block><block s="reportNumbers"><l>65</l><l>90</l></block></block></block><block s="doSetVar"><l>letters</l><block s="reportConcatenatedLists"><list><block var="alphabet"/><block s="reportNewList"><list><l>Ä</l><l>Ö</l><l>Ü</l><l>ß</l></list></block></list></block></block><block s="doSetVar"><l>translation</l><block s="reportConcatenatedLists"><list><block var="alphabet"/><block s="reportNewList"><list><l>AE</l><l>OE</l><l>UE</l><l>SS</l></list></block></list></block></block><block s="doReport"><block s="reportPipe"><block var="plain"/><list><block s="reifyReporter"><autolambda><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportListContainsItem"><block var="letters"/><l></l></block></autolambda><list></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportListItem"><block s="reportListIndex"><l></l><block var="letters"/></block><block var="translation"/></block></autolambda><list></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><l></l></list></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="contactdata( %&apos;plain&apos; , %&apos;letter&apos; , %&apos;order&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%s"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><block var="order"/><custom-block s="fullAlphabet( %l , %l )"><custom-block s="before( %txt , %s )"><block var="plain"/><block var="letter"/></custom-block><block var="order"/></custom-block><custom-block s="fullAlphabet( %l , %l )"><custom-block s="after( %txt , %s )"><block var="plain"/><block var="letter"/></custom-block><block var="order"/></custom-block><block var="letter"/></list></block></block></script></block-definition><block-definition s="before( %&apos;plain&apos; , %&apos;letter&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportPipe"><l></l><list><block s="reifyReporter"><autolambda><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><block s="reportListItem"><block var="index"/><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>1</l></list></block><block var="list"/></block></list></block></autolambda><list><l>value</l><l>index</l><l>list</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportTextAttribute"><l><option>length</option></l><block var="value"/></block><l>2</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>2</l><block var="value"/></block><block var="letter"/></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportLetter"><l>1</l><l></l></block></autolambda><list></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportListAttribute"><l><option>distribution</option></l><l/></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="fullAlphabet( %&apos;data&apos; , %&apos;order&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>result</l><l>sum</l></list></block><block s="doSetVar"><l>result</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportMonadic"><l><option>abs</option></l><l>0</l></block></autolambda><list></list></block><block s="reportNumbers"><l>1</l><l>26</l></block></block></block><block s="doSetVar"><l>sum</l><block s="reportVariadicSum"><block s="reportListItem"><l>2</l><block s="reportListAttribute"><l><option>columns</option></l><block var="data"/></block></block></block></block><block s="doIf"><block s="reportVariadicGreaterThan"><list><block s="reportListAttribute"><l><option>length</option></l><block var="data"/></block><l>0</l></list></block><script><block s="doFor"><l>i</l><l>1</l><block s="reportListAttribute"><l><option>length</option></l><block var="data"/></block><script><block s="doReplaceInList"><block s="reportListIndex"><block s="reportListItem"><l>1</l><block s="reportListItem"><block var="i"/><block var="data"/></block></block><block var="order"/></block><block var="result"/><block s="reportRound"><block s="reportVariadicProduct"><list><block s="reportQuotient"><block s="reportListItem"><l>2</l><block s="reportListItem"><block var="i"/><block var="data"/></block></block><block var="sum"/></block><l>500</l></list></block></block></block></script></block></script><list></list></block><block s="doReport"><block var="result"/></block></script></block-definition><block-definition s="after( %&apos;plain&apos; , %&apos;letter&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportPipe"><l></l><list><block s="reifyReporter"><autolambda><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><block s="reportListItem"><block var="index"/><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>1</l></list></block><block var="list"/></block></list></block></autolambda><list><l>value</l><l>index</l><l>list</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportTextAttribute"><l><option>length</option></l><block var="value"/></block><l>2</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>1</l><block var="value"/></block><block var="letter"/></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportLetter"><l>2</l><l></l></block></autolambda><list></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportListAttribute"><l><option>distribution</option></l><l/></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="drawDiagram( %&apos;data&apos; )" type="command" category="pen"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doSetGlobalFlag"><l><option>flat line ends</option></l><block s="reportBoolean"><l><bool>true</bool></l></block></block><block s="clear"></block><block s="gotoXY"><l>-220</l><l>160</l></block><block s="write"><block s="reportJoinWords"><list><l>Contac Data for </l><block s="reportListItem"><l>4</l><block var="data"/></block></list></block><l>20</l></block><block s="gotoXY"><l>-220</l><l>-10</l></block><block s="write"><block s="reportJoinWords"><list><block s="reportListItem"><l>1</l><block var="data"/></block></list></block><l>31</l></block><block s="setSize"><l>13</l></block><block s="up"></block><block s="doFor"><l>i</l><l>1</l><l>26</l><script><block s="gotoXY"><block s="reportVariadicSum"><list><l>-226</l><block s="reportVariadicProduct"><list><block var="i"/><l>17</l></list></block></list></block><l>18</l></block><block s="down"></block><block s="gotoXY"><block s="reportVariadicSum"><list><l>-226</l><block s="reportVariadicProduct"><list><block var="i"/><l>17</l></list></block></list></block><block s="reportVariadicSum"><list><l>18</l><block s="reportListItem"><block var="i"/><block s="reportListItem"><l>2</l><block var="data"/></block></block></list></block></block><block s="up"></block><block s="gotoXY"><block s="reportVariadicSum"><list><l>-226</l><block s="reportVariadicProduct"><list><block var="i"/><l>17</l></list></block></list></block><l>-18</l></block><block s="down"></block><block s="gotoXY"><block s="reportVariadicSum"><list><l>-226</l><block s="reportVariadicProduct"><list><block var="i"/><l>17</l></list></block></list></block><block s="reportDifference"><l>-18</l><block s="reportListItem"><block var="i"/><block s="reportListItem"><l>3</l><block var="data"/></block></block></block></block><block s="up"></block></script></block><block s="hide"></block></script></block-definition><block-definition s="updateRules( %&apos;rules&apos; , %&apos;letter&apos; stands for %&apos;with&apos; )" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReplaceInList"><block s="reportDifference"><block s="reportUnicode"><block var="letter"/></block><l>64</l></block><block var="rules"/><block var="with"/></block><block s="doReport"><block var="rules"/></block></script></block-definition><block-definition s="updatePattern( %&apos;rules&apos; , %&apos;crypto&apos; , %&apos;with&apos; )" type="reporter" category="variables"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>result</l><l>i</l></list></block><block s="doIfElse"><block s="reportVariadicEquals"><list><block s="reportTextAttribute"><l><option>length</option></l><block var="crypto"/></block><block s="reportTextAttribute"><l><option>length</option></l><block var="with"/></block></list></block><script><block s="doSetVar"><l>result</l><block var="rules"/></block><block s="doFor"><l>i</l><l>1</l><block s="reportTextAttribute"><l><option>length</option></l><block var="crypto"/></block><script><block s="doSetVar"><l>result</l><custom-block s="updateRules( %l , %s stands for %s )"><block var="result"/><block s="reportLetter"><block var="i"/><block var="crypto"/></block><block s="reportLetter"><block var="i"/><block var="with"/></block></custom-block></block></script></block><block s="doReport"><block var="result"/></block></script><script><block s="doReport"><l>Crypto and With not same length!</l></block></script></block></script></block-definition><block-definition s="perm( %&apos;plain&apos; , %&apos;key&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%l"></input></inputs><script><block s="doReport"><block s="reportJoinWords"><list><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportListItem"><block s="reportDifference"><block s="reportUnicode"><l></l></block><l>64</l></block><block var="key"/></block></autolambda><list></list></block><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></block></list></block></block></script></block-definition><block-definition s="initKey( %&apos;key&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>result</l><l>i</l><l>temp</l><l>alphabet</l></list></block><block s="doSetVar"><l>alphabet</l><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicNotEquals"><list><block var="value"/><l>J</l></list></block></autolambda><list><l>value</l></list></block><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><l></l></block></autolambda><list></list></block><block s="reportNumbers"><l>65</l><l>90</l></block></block></block></block><block s="doSetVar"><l>temp</l><block s="reportNewList"><list></list></block></block><block s="doFor"><l>i</l><l>1</l><block s="reportTextAttribute"><l><option>length</option></l><block var="key"/></block><script><block s="doIf"><block s="reportListContainsItem"><block var="alphabet"/><block s="reportLetter"><block var="i"/><block var="key"/></block></block><script><block s="doAddToList"><block s="reportLetter"><block var="i"/><block var="key"/></block><block var="temp"/></block><block s="doDeleteFromList"><block s="reportListIndex"><block s="reportLetter"><block var="i"/><block var="key"/></block><block var="alphabet"/></block><block var="alphabet"/></block></script><list></list></block></script></block><block s="doSetVar"><l>temp</l><block s="reportConcatenatedLists"><list><block var="temp"/><block var="alphabet"/></list></block></block><block s="doSetVar"><l>result</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportNewList"><list><block var="value"/><block s="reportJoinWords"><list><block s="reportVariadicSum"><list><block s="reportModulus"><block s="reportDifference"><block var="index"/><l>1</l></block><l>5</l></block><l>1</l></list></block><block s="reportMonadic"><l><option>ceiling</option></l><block s="reportQuotient"><block var="index"/><l>5</l></block></block></list></block></list></block></autolambda><list><l>value</l><l>index</l></list></block><block var="temp"/></block></block><block s="doReport"><block var="result"/></block></script></block-definition><block-definition s="initPermutation" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doDeclareVariables"><list><l>result</l><l>alphabet</l><l>pos</l></list></block><block s="doSetVar"><l>alphabet</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><l></l></block></autolambda><list></list></block><block s="reportNumbers"><l>65</l><l>90</l></block></block></block><block s="doSetVar"><l>result</l><block s="reportNewList"><list></list></block></block><block s="doUntil"><block s="reportListIsEmpty"><block var="alphabet"/></block><script><block s="doSetVar"><l>pos</l><block s="reportRandom"><l>1</l><block s="reportListAttribute"><l><option>length</option></l><block var="alphabet"/></block></block></block><block s="doAddToList"><block s="reportListItem"><block var="pos"/><block var="alphabet"/></block><block var="result"/></block><block s="doDeleteFromList"><block var="pos"/><block var="alphabet"/></block></script></block><block s="doReport"><block var="result"/></block></script></block-definition><block-definition s="initRules" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doReport"><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><l>95</l></block></autolambda><list></list></block><block s="reportNumbers"><l>1</l><l>26</l></block></block></block></script></block-definition><block-definition s="honorHarrington( %&apos;data&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportPipe"><block var="data"/><list><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>1</l><block var="value"/></block><block s="reportLetter"><l>6</l><block var="value"/></block></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicAnd"><list><block s="reportVariadicEquals"><list><block s="reportLetter"><l>2</l><block var="value"/></block><block s="reportLetter"><l>4</l><block var="value"/></block></list></block><block s="reportVariadicEquals"><list><block s="reportLetter"><l>2</l><block var="value"/></block><block s="reportLetter"><l>14</l><block var="value"/></block></list></block></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicAnd"><list><block s="reportVariadicEquals"><list><block s="reportLetter"><l>3</l><block var="value"/></block><block s="reportLetter"><l>11</l><block var="value"/></block></list></block><block s="reportVariadicEquals"><list><block s="reportLetter"><l>3</l><block var="value"/></block><block s="reportLetter"><l>15</l><block var="value"/></block></list></block></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="extract15Letters( %&apos;plain&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="reportPipe"><l></l><list><block s="reifyReporter"><autolambda><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><block s="reportListItem"><block var="index"/><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>1</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>2</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>3</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>4</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>5</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>6</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>7</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>8</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>9</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>10</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>11</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>12</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>13</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>14</l></list></block><block var="list"/></block></list></block></autolambda><list><l>value</l><l>index</l><l>list</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicGreaterThan"><list><block s="reportTextAttribute"><l><option>length</option></l><block var="value"/></block><l>14</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="nextUnderline( %&apos;plain&apos; , %&apos;offset&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%n"></input></inputs><script><block s="doFor"><l>i</l><block var="offset"/><block s="reportTextAttribute"><l><option>length</option></l><block var="plain"/></block><script><block s="doIf"><block s="reportVariadicEquals"><list><block s="reportLetter"><block var="i"/><block var="plain"/></block><l>_</l></list></block><script><block s="doReport"><block var="i"/></block></script><list></list></block></script></block><block s="doReport"><l>0</l></block></script></block-definition><block-definition s="magnifier( %&apos;start&apos; , %&apos;input&apos; , %&apos;output&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportNewList"><list><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicAnd"><list><block s="reportVariadicGreaterThanOrEquals"><list><block var="index"/><block var="start"/></list></block><block s="reportVariadicLessThanOrEquals"><list><block var="index"/><block s="reportVariadicSum"><list><block var="start"/><l>10</l></list></block></list></block></list></block></autolambda><list><l>value</l><l>index</l></list></block><block s="reportTextSplit"><block var="input"/><l><option>letter</option></l></block></block><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicAnd"><list><block s="reportVariadicGreaterThanOrEquals"><list><block var="index"/><block var="start"/></list></block><block s="reportVariadicLessThanOrEquals"><list><block var="index"/><block s="reportVariadicSum"><list><block var="start"/><l>10</l></list></block></list></block></list></block></autolambda><list><l>value</l><l>index</l></list></block><block s="reportTextSplit"><block var="output"/><l><option>letter</option></l></block></block><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicAnd"><list><block s="reportVariadicGreaterThanOrEquals"><list><block var="index"/><block var="start"/></list></block><block s="reportVariadicLessThanOrEquals"><list><block var="index"/><block s="reportVariadicSum"><list><block var="start"/><l>10</l></list></block></list></block></list></block></autolambda><list><l>value</l><l>index</l></list></block><block s="reportNumbers"><l>1</l><block s="reportTextAttribute"><l><option>length</option></l><block var="input"/></block></block></block></list></block></block></script></block-definition><block-definition s="decodePerm( %&apos;crypto&apos; , %&apos;key&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>alphabet</l></list></block><block s="doSetVar"><l>alphabet</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><l></l></block></autolambda><list></list></block><block s="reportNumbers"><l>65</l><l>90</l></block></block></block><block s="doReport"><block s="reportJoinWords"><list><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportListItem"><block s="reportListIndex"><l></l><block var="key"/></block><block var="alphabet"/></block></autolambda><list></list></block><block s="reportTextSplit"><block var="crypto"/><l><option>letter</option></l></block></block></list></block></block></script></block-definition><block-definition s="decodePerm( %&apos;crypto&apos; , %&apos;key&apos; ) (2)" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>alphabet</l></list></block><block s="doSetVar"><l>alphabet</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><l></l></block></autolambda><list></list></block><block s="reportNumbers"><l>65</l><l>90</l></block></block></block><block s="doReport"><block s="reportPipe"><l></l><list><block s="reifyReporter"><autolambda><block s="reportTextSplit"><block var="crypto"/><l><option>letter</option></l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportIfElse"><block s="reportVariadicGreaterThan"><list><block s="reportListIndex"><l></l><block var="key"/></block><l>0</l></list></block><block s="reportListItem"><block s="reportListIndex"><l></l><block var="key"/></block><block var="alphabet"/></block><l>_</l></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><l></l></list></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="decodePerm( %&apos;crypto&apos; , %&apos;key&apos; ) withPartialRules" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>alphabet</l><l>result</l></list></block><block s="doSetVar"><l>alphabet</l><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><l></l></block></autolambda><list></list></block><block s="reportNumbers"><l>65</l><l>90</l></block></block></block><block s="doSetVar"><l>result</l><l></l></block><block s="doFor"><l>i</l><l>1</l><block s="reportTextAttribute"><l><option>length</option></l><block var="crypto"/></block><script><block s="doIfElse"><block s="reportListContainsItem"><block var="key"/><block s="reportLetter"><block var="i"/><block var="crypto"/></block></block><script><block s="doSetVar"><l>result</l><block s="reportJoinWords"><list><block var="result"/><block s="reportUnicodeAsLetter"><block s="reportVariadicSum"><list><block s="reportListIndex"><block s="reportLetter"><block var="i"/><block var="crypto"/></block><block var="key"/></block><l>64</l></list></block></block></list></block></block></script><script><block s="doSetVar"><l>result</l><block s="reportJoinWords"><list><block var="result"/><l>_</l></list></block></block></script></block></script></block><block s="doReport"><block var="result"/></block></script><scripts><script x="718.0695887297588" y="331.7407407407406"><block s="reportUnicode"><block s="reportLetter"><block var="i"/><block var="crypto"/></block></block></script></scripts></block-definition><block-definition s="extract9Letters( %&apos;plain&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="reportPipe"><l></l><list><block s="reifyReporter"><autolambda><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><block s="reportListItem"><block var="index"/><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>1</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>2</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>3</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>4</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>5</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>6</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>7</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>8</l></list></block><block var="list"/></block></list></block></autolambda><list><l>value</l><l>index</l><l>list</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicGreaterThan"><list><block s="reportTextAttribute"><l><option>length</option></l><block var="value"/></block><l>8</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="StarEmpire( %&apos;data&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportPipe"><block var="data"/><list><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportListAttribute"><l><option>length</option></l><block s="reportListAttribute"><l><option>distribution</option></l><block s="reportTextSplit"><block var="value"/><l><option>letter</option></l></block></block></block><l>8</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>4</l><block var="value"/></block><block s="reportLetter"><l>9</l><block var="value"/></block></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>5</l><block var="value"/></block><block s="reportLetter"><l>10</l><block var="value"/></block></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block></list></block></block></script><scripts><script x="15.228758169934647" y="363.806100217865"><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>2</l><block var="value"/></block><l>A</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block></script></scripts></block-definition><block-definition s="extract10Letters( %&apos;plain&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="reportPipe"><l></l><list><block s="reifyReporter"><autolambda><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><block s="reportListItem"><block var="index"/><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>1</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>2</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>3</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>4</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>5</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>6</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>7</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>8</l></list></block><block var="list"/></block><block s="reportListItem"><block s="reportVariadicSum"><list><block var="index"/><l>9</l></list></block><block var="list"/></block></list></block></autolambda><list><l>value</l><l>index</l><l>list</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicGreaterThan"><list><block s="reportTextAttribute"><l><option>length</option></l><block var="value"/></block><l>9</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="missingLetters %&apos;rules&apos; )" type="reporter" category="lists"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doDeclareVariables"><list><l>result</l><l>i</l></list></block><block s="doSetVar"><l>result</l><block s="reportNewList"><list></list></block></block><block s="doFor"><l>i</l><l>1</l><block s="reportListAttribute"><l><option>length</option></l><block var="rules"/></block><script><block s="doIf"><block s="reportVariadicEquals"><list><block s="reportListItem"><block var="i"/><block var="rules"/></block><l>_</l></list></block><script><block s="doAddToList"><block s="reportUnicodeAsLetter"><block s="reportVariadicSum"><list><block var="i"/><l>64</l></list></block></block><block var="result"/></block></script><list></list></block></script></block><block s="doReport"><block var="result"/></block></script></block-definition><block-definition s="50LettersPerLine( %&apos;plain&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input></inputs><script><block s="doReport"><block s="reportPipe"><l></l><list><block s="reifyReporter"><autolambda><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportIfElse"><block s="reportVariadicEquals"><list><block s="reportModulus"><block var="index"/><l>50</l></block><l>0</l></list></block><block s="reportJoinWords"><list><block var="value"/><block s="reportUnicodeAsLetter"><l>10</l></block></list></block><block var="value"/></block></autolambda><list><l>value</l><l>index</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportJoinWords"><list><l></l></list></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="drawFrequency( %&apos;data&apos; , %&apos;scale&apos; )" type="command" category="pen"><header></header><code></code><translations></translations><inputs><input type="%l"></input><input type="%n"></input></inputs><script><block s="doDeclareVariables"><list><l>i</l></list></block><block s="clear"></block><block s="gotoXY"><l>-210</l><l>-150</l></block><block s="setHeading"><l>90</l></block><block s="write"><l>ABCDEFGHIJKLMNOPQRSTUVWXYZ</l><l>31</l></block><block s="doSetGlobalFlag"><l><option>flat line ends</option></l><block s="reportBoolean"><l><bool>true</bool></l></block></block><block s="up"></block><block s="setHeading"><l>0</l></block><block s="doFor"><l>i</l><l>1</l><l>26</l><script><block s="gotoXY"><block s="reportVariadicSum"><list><l>-219</l><block s="reportVariadicProduct"><list><l>17</l><block var="i"/></list></block></list></block><l>-120</l></block><block s="down"></block><block s="gotoXY"><block s="reportVariadicSum"><list><l>-219</l><block s="reportVariadicProduct"><list><l>17</l><block var="i"/></list></block></list></block><block s="reportDifference"><block s="reportVariadicProduct"><list><block s="reportListItem"><block var="i"/><block var="data"/></block><block var="scale"/></list></block><l>120</l></block></block><block s="up"></block></script></block></script></block-definition><block-definition s="StarEmpire( %&apos;data&apos; ) (2)" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%l"></input></inputs><script><block s="doReport"><block s="reportPipe"><block var="data"/><list><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportListAttribute"><l><option>length</option></l><block s="reportListAttribute"><l><option>distribution</option></l><block s="reportTextSplit"><block var="value"/><l><option>letter</option></l></block></block></block><l>8</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>4</l><block var="value"/></block><block s="reportLetter"><l>9</l><block var="value"/></block></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>5</l><block var="value"/></block><block s="reportLetter"><l>10</l><block var="value"/></block></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportKeep"><block s="reifyPredicate"><autolambda><block s="reportVariadicEquals"><list><block s="reportLetter"><l>2</l><block var="value"/></block><l>A</l></list></block></autolambda><list><l>value</l></list></block><l/></block></autolambda><list></list></block></list></block></block></script></block-definition><block-definition s="caesar( %&apos;plain&apos; , %&apos;key&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>alphabet</l><l>cryptoalphabet</l><l>result</l><l>i</l></list></block><block s="doSetVar"><l>alphabet</l><block s="reportNewList"><list><l>A</l><l>B</l><l>C</l><l>D</l><l>E</l><l>F</l><l>G</l><l>H</l><l>I</l><l>J</l><l>K</l><l>L</l><l>M</l><l>N</l><l>O</l><l>P</l><l>Q</l><l>R</l><l>S</l><l>T</l><l>U</l><l>V</l><l>W</l><l>X</l><l>Y</l><l>Z</l></list></block></block><block s="doSetVar"><l>cryptoalphabet</l><block s="reportNewList"><list><l>A</l><l>B</l><l>C</l><l>D</l><l>E</l><l>F</l><l>G</l><l>H</l><l>I</l><l>J</l><l>K</l><l>L</l><l>M</l><l>N</l><l>O</l><l>P</l><l>Q</l><l>R</l><l>S</l><l>T</l><l>U</l><l>V</l><l>W</l><l>X</l><l>Y</l><l>Z</l></list></block></block><block s="doUntil"><block s="reportVariadicEquals"><list><block s="reportListItem"><l>1</l><block var="cryptoalphabet"/></block><block var="key"/></list></block><script><block s="doAddToList"><block s="reportListItem"><l>1</l><block var="cryptoalphabet"/></block><block var="cryptoalphabet"/></block><block s="doDeleteFromList"><l>1</l><block var="cryptoalphabet"/></block></script></block><block s="doSetVar"><l>result</l><l></l></block><block s="doFor"><l>i</l><l>1</l><block s="reportTextAttribute"><l><option>length</option></l><block var="plain"/></block><script><block s="doSetVar"><l>result</l><block s="reportJoinWords"><list><block var="result"/><block s="reportListItem"><block s="reportListIndex"><block s="reportLetter"><block var="i"/><block var="plain"/></block><block var="alphabet"/></block><block var="cryptoalphabet"/></block></list></block></block></script></block><block s="doReport"><block var="result"/></block></script></block-definition><block-definition s="decodeCaesar( %&apos;ciphertext&apos; , %&apos;key&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%s"></input></inputs><script><block s="doDeclareVariables"><list><l>newKey</l></list></block><block s="doSetVar"><l>newKey</l><block s="reportUnicodeAsLetter"><block s="reportVariadicSum"><list><block s="reportModulus"><block s="reportDifference"><l>91</l><block s="reportUnicode"><block var="key"/></block></block><l>26</l></block><l>65</l></list></block></block></block><block s="doReport"><custom-block s="caesar( %txt , %s )"><block var="ciphertext"/><block var="newKey"/></custom-block></block></script></block-definition><block-definition s="caesar( %&apos;plain&apos; , %&apos;key&apos; )" type="reporter" category="operators"><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%s"></input></inputs><script><block s="doReport"><block s="reportJoinWords"><list><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportUnicodeAsLetter"><block s="reportVariadicSum"><list><block s="reportModulus"><block s="reportDifference"><block s="reportVariadicSum"><list><block s="reportUnicode"><l></l></block><block s="reportUnicode"><block var="key"/></block></list></block><l>130</l></block><l>26</l></block><l>65</l></list></block></block></autolambda><list></list></block><block s="reportTextSplit"><block var="plain"/><l><option>letter</option></l></block></block></list></block></block></script></block-definition></blocks><stage name="Stage" width="480" height="360" costume="0" color="255,255,255,1" tempo="60" threadsafe="false" penlog="false" volume="100" pan="0" lines="flat" ternary="false" hyperops="true" codify="false" inheritance="true" sublistIDs="false" id="2430"><pentrails>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFoCAYAAACPNyggAAAOhUlEQVR4Xu3VwQkAAAjEMN1/abewn7jAQRC64wgQIECAAIF3gX1fNEiAAAECBAiMAHsCAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQICLAfIECAAAECgYAAB+gmCRAgQICAAPsBAgQIECAQCAhwgG6SAAECBAgIsB8gQIAAAQKBgAAH6CYJECBAgIAA+wECBAgQIBAICHCAbpIAAQIECAiwHyBAgAABAoGAAAfoJgkQIECAgAD7AQIECBAgEAgIcIBukgABAgQIHLFxAWmhEwHPAAAAAElFTkSuQmCC</pentrails><costumes><list struct="atomic" id="2431"></list></costumes><sounds><list struct="atomic" id="2432"></list></sounds><variables></variables><blocks></blocks><scripts></scripts><sprites select="1"><sprite name="Sprite" idx="1" x="216.00000000000026" y="-17.999999999999883" heading="90" scale="1" volume="100" pan="0" rotation="1" draggable="true" hidden="true" costume="0" color="80,80,80,1" pen="tip" id="2437"><costumes><list struct="atomic" id="2438"></list></costumes><sounds><list struct="atomic" id="2439"></list></sounds><blocks></blocks><variables></variables><scripts><script x="13.071895424836601" y="6.5359477124183005"><block s="doSetVar"><l>data</l><custom-block s="fullAlphabet( %l , %l )"><block s="reportListAttribute"><l><option>distribution</option></l><block s="reportTextSplit"><block var="SnapManual"/><l><option>letter</option></l></block></block><block var="Alphabet"/></custom-block></block><custom-block s="drawFrequency( %l , %n )"><block var="data"/><l>4</l></custom-block></script><script x="13.071895424836601" y="89.08278867102393"><block s="doSetVar"><l>data</l><custom-block s="fullAlphabet( %l , %l )"><block s="reportListAttribute"><l><option>distribution</option></l><block s="reportTextSplit"><block var="HonorCrypto"/><l><option>letter</option></l></block></block><block var="Alphabet"/></custom-block></block><custom-block s="drawFrequency( %l , %n )"><block var="data"/><l>4</l></custom-block></script><script x="13.071895424836601" y="171.62962962962956"><custom-block s="drawDiagram( %l )"><block var="ContacDataN"/></custom-block></script><script x="13.071895424836601" y="205.97821350762518"><block s="clear"></block></script><script x="13.071895424836601" y="236.32679738562086"><custom-block s="honorHarrington( %l )"><custom-block s="extract15Letters( %s )"><block var="HonorCrypto"/></custom-block></custom-block></script><script x="13.071895424836601" y="268.6753812636165"><custom-block s="StarEmpire( %l )"><custom-block s="extract10Letters( %s )"><block var="HonorCrypto"/></custom-block></custom-block></script><script x="13.071895424836601" y="301.02396514161217"><block s="receiveGo"></block></script><script x="13.071895424836601" y="348.4814814814815"><block s="doSetVar"><l>Rules</l><custom-block s="initRules"></custom-block></block><block s="doSetVar"><l>solution</l><block s="reportListItem"><l>1</l><custom-block s="honorHarrington( %l )"><custom-block s="extract15Letters( %s )"><block var="HonorCrypto"/></custom-block></custom-block></block></block><block s="doSetVar"><l>Rules</l><custom-block s="updatePattern( %s , %s , %s )"><block var="Rules"/><l>HONORHARRINGTON</l><block var="solution"/></custom-block></block><block s="doSetVar"><l>solution</l><block s="reportListItem"><l>1</l><custom-block s="StarEmpire( %l ) (2)"><custom-block s="extract10Letters( %s )"><block var="HonorCrypto"/></custom-block></custom-block></block></block><block s="doSetVar"><l>Rules</l><custom-block s="updatePattern( %s , %s , %s )"><block var="Rules"/><l>STAREMPIRE</l><block var="solution"/></custom-block></block><block s="doSetGlobalFlag"><l><option>turbo mode</option></l><block s="reportBoolean"><l><bool>true</bool></l></block></block><block s="doSetVar"><l>Export</l><custom-block s="decodePerm( %txt , %l ) withPartialRules"><block var="HonorCrypto"/><block var="Rules"/></custom-block></block></script><script x="13.071895424836601" y="581.9694989106755"><custom-block s="50LettersPerLine( %s )"><block var="Export"/></custom-block></script><script x="13.071895424836601" y="610.3180827886712"><block s="reportTextAttribute"><l><option>length</option></l><block var="HonorEN"/></block></script><script x="13.071895424836601" y="638.7755991285404"><custom-block s="50LettersPerLine( %s )"><block var="Export"/></custom-block></script><script x="13.071895424836601" y="667.1241830065364"><custom-block s="nextUnderline( %s , %n )"><block var="Export"/><l>30</l></custom-block></script><script x="13.071895424836601" y="695.4727668845325"><custom-block s="magnifier( %s , %s , %s )"><l>32</l><block var="HonorCrypto"/><block var="Export"/></custom-block></script><script x="13.071895424836601" y="723.8213507625278"><custom-block s="updateRules( %l , %s stands for %s )"><block var="Rules"/><l>L</l><l>S</l></custom-block></script><script x="13.071895424836601" y="752.1699346405236"><custom-block s="updateRules( %l , %s stands for %s )"><block var="Rules"/><l>Y</l><l>B</l></custom-block></script><script x="13.071895424836601" y="780.5185185185193"><block s="doSetVar"><l>Export</l><custom-block s="decodePerm( %txt , %l ) withPartialRules"><block var="HonorCrypto"/><block var="Rules"/></custom-block></block></script><script x="13.071895424836601" y="818.867102396515"><custom-block s="50LettersPerLine( %s )"><block var="Export"/></custom-block></script><script x="13.071895424836601" y="847.2156862745105"><custom-block s="missingLetters %l )"><block var="Rules"/></custom-block></script><script x="24.539022059222432" y="1354.3921568627459"><custom-block s="caesar( %s , %s )"><block var="C1Import"/><l>K</l></custom-block></script><script x="14.803921568627436" y="1288.300653594772"><block s="doSetVar"><l>C2Import</l><custom-block s="uppercase( %s )"><l></l></custom-block></block></script><script x="222.6470588235294" y="1335.2592592592594"><custom-block s="initKey( %s )"><l></l></custom-block></script><script x="20.032679738562077" y="1396.5424836601312"><block s="doSetVar"><l>crypto2</l><l>0</l></block></script><script x="250.85582563612195" y="1367.209150326798"><custom-block s="initPermutation"></custom-block></script><script x="26.67281910017423" y="1329.3006535947718"><custom-block s="perm( %txt , %l )"><block var="C2Import"/><block var="Temp"/></custom-block></script><script x="105.65359477124181" y="208.9259259259253"><custom-block s="contactdata( %txt , %s , %l )"><l></l><l></l><l/></custom-block></script><script x="10.882352941176455" y="886.3115468409596"><block s="doSetVar"><l>ContactDataE</l><custom-block s="contactdata( %txt , %s , %l )"><block var="SnapManual"/><l>E</l><block var="alphabetEN"/></custom-block></block></script></scripts></sprite><watcher var="Import" style="normal" x="9.99999999999884" y="10.000000000000023" color="243,118,29" hidden="true"/><watcher var="Time" style="normal" x="9.99999999999884" y="159.30000399999997" color="243,118,29" hidden="true"/><watcher var="alphabetEN" style="normal" x="11.960132890367184" y="11.96013289036553" color="243,118,29" hidden="true"/><watcher var="SnapManual" style="normal" x="11.960132890367184" y="47.42192930232569" color="243,118,29" hidden="true"/><watcher var="ContacDataE" style="normal" x="11.960132890367184" y="82.88372571428575" color="243,118,29" hidden="true"/><watcher var="ContacDataN" style="normal" x="11.960132890367184" y="276.30299720930185" color="243,118,29" hidden="true"/><watcher var="Dauer" style="normal" x="33.60434913923288" y="15.658215333778873" color="243,118,29" hidden="true"/><watcher var="PermKey" style="normal" x="11.960132890367184" y="47.42192930232569" color="243,118,29" hidden="true"/><watcher var="HonorCrypto" style="normal" x="11.960132890367184" y="214.4332273754154" color="243,118,29" hidden="true"/><watcher var="HonorSolved" style="normal" x="11.960132890367184" y="324.53820358804063" color="243,118,29" hidden="true"/><watcher var="solution" style="normal" x="14.058577405858113" y="226.1422553974893" color="243,118,29" hidden="true"/><watcher var="Alphabet" style="normal" x="24.87046632124591" y="24.87046632124356" color="243,118,29" hidden="true"/><watcher var="HonorEN" style="normal" x="7.240446237836072" y="65.27226201450519" color="243,118,29" hidden="true"/><watcher var="Export" style="normal" x="10.909090909090036" y="14.181818181818178" color="243,118,29" hidden="true"/><watcher var="Rules" style="normal" x="22.35143723819155" y="186.9696728812798" color="243,118,29" hidden="true"/><watcher var="data" style="normal" x="50.19297377535877" y="11.123206333498267" color="243,118,29" hidden="true"/><watcher var="ContactDataN" style="normal" x="18.604651162790645" y="239.25582883720932" color="243,118,29" hidden="true"/><watcher var="ContactDataE" style="normal" x="18.604651162790645" y="294.4186232558139" color="243,118,29" hidden="true"/><watcher var="crypto1" style="normal" x="2.971325355610533" y="31.71732139986449" color="243,118,29"/><watcher var="crypto2" style="normal" x="11.61435990065475" y="93.21924801083769" color="243,118,29"/><watcher var="crypto2 hints" style="normal" x="16.27455407541206" y="159.20613762023032" color="243,118,29" extX="278.39999999999986" extY="79.10000000000005"/></sprites></stage><variables><variable name="Import"><l>Acknowledgements&#xD;We have been extremely lucky in our mentors. Jens cut his teeth in the company of the Smalltalk pioneers:&#xD;Alan Kay, Dan Ingalls, and the rest of the gang who invented personal computing and object oriented&#xD;programming in the great days of Xerox PARC. He worked with John Maloney, of the MIT Scratch Team,&#xD;who developed the Morphic graphics framework that’s still at the heart of Snap!.&#xD;The brilliant design of Scratch, from the Lifelong Kindergarten Group at the MIT Media Lab, is crucial to&#xD;Snap!. Our earlier version, BYOB, was a direct modification of the Scratch source code. Snap! is a&#xD;complete rewrite, but its code structure and its user interface remain deeply indebted to Scratch. And&#xD;the Scratch Team, who could have seen us as rivals, have been entirely supportive and welcoming to us.&#xD;Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John&#xD;McCarthy, Scheme inventors Gerald J. Sussman and Guy Steele, and the authors of the world’s best computer&#xD;science book, Structure and Interpretation of Computer Programs, Hal Abelson and Gerald J. Sussman with Julie&#xD;Sussman, among many other heroes of computer science. (Brian was also lucky enough, while in high school, to&#xD;meet Kenneth Iverson, the inventor of APL.)&#xD;In the glory days of the MIT Logo Lab, we used to say, “Logo is Lisp disguised as BASIC.” Now, with its&#xD;first class procedures, lexical scope, and first class continuations, Snap! is Scheme disguised as Scratch.&#xD;Four people have made such massive contributions to the implementation of Snap! that we have officially&#xD;declared them members of the team: Michael Ball and Bernat Romagosa, in addition to contributions&#xD;throughout the project, have primary responsibility for the web site and cloud storage. Joan Guillén i Pelegay&#xD;has contributed very careful and wise analysis of outstanding issues, including help in taming the management&#xD;of translations to non-English languages. Jadga Hügle, has energetically contributed to online mini-courses&#xD;about Snap! and leading workshops for kids and for adults. Jens, Jadga, and Bernat are paid to work on Snap! by&#xD;SAP, which also supports our computing needs.&#xD;We have been fortunate to get to know an amazing group of brilliant middle school(!) and high school students&#xD;through the Scratch Advanced Topics forum, several of whom (since grown up) have contributed code to Snap!:&#xD;Kartik Chandra, Nathan Dinsmore, Connor Hudson, Ian Reynolds, and Deborah Servilla. Many more have&#xD;contributed ideas and alpha-testing bug reports. UC Berkeley students who’ve contributed code include Achal&#xD;Dave. Kyle Hotchkiss, Ivan Motyashov, and Yuan Yuan. Contributors of translations are too numerous to list&#xD;here, but they’re in the “About…” box in Snap! itself.&#xD;This material is based upon work supported in part by the National Science Foundation under Grants No.&#xD;1138596, 1143566, and 1441075; and in part by MioSoft, Arduino.org, SAP, and YC Research. Any opinions,&#xD;findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not&#xD;necessarily reflect the views of the National Science Foundation or other funders.&#xD;5&#xD;Snap! Reference Manual&#xD;Version 8.0&#xD;Snap! (formerly BYOB) is an extended reimplementation of Scratch (h!ps://scratch.mit.edu) that allows you to&#xD;Build Your Own Blocks. It also features first class lists, first class procedures, first class sprites, first class&#xD;costumes, first class sounds, and first class continuations. These added capabilities make it suitable for a serious&#xD;introduction to computer science for high school or college students.&#xD;In this manual we sometimes make reference to Scratch, e.g., to explain how some Snap! feature extends&#xD;something familiar in Scratch. It’s very helpful to have some experience with Scratch before reading this&#xD;manual, but not essential.&#xD;To run Snap!, open a browser window and connect to h!ps://snap.berkeley.edu/run. The Snap! community&#xD;web site at h!ps://snap.berkeley.edu is not part of this manual’s scope.&#xD;I. Blocks, Scripts, and Sprites&#xD;This chapter describes the Snap! features inherited from Scratch; experienced Scratch users can skip to&#xD;Section B.&#xD;Snap! is a programming language—a notation in which you can tell a computer what you want it to do.&#xD;Unlike most programming languages, though, Snap! is a visual language; instead of writing a program using the&#xD;keyboard, the Snap! programmer uses the same drag-and-drop interface familiar to computer users.&#xD;Start Snap!. You should see the following arrangement of regions in the window:&#xD;(The proportions of these areas may be different, depending on the size and shape of your browser window.)&#xD;A Snap! program consists of one or more scripts, each of which is made of blocks. Here’s a typical script:&#xD;6&#xD;The five blocks that make up this script have three different colors, corresponding to three of the eight palettes in&#xD;which blocks can be found. The palette area at the left edge of the window shows one palette at a time, chosen&#xD;with the eight buttons just above the palette area. In this script, the gold blocks are from the Control palette; the&#xD;green block is from the Pen palette; and the blue blocks are from the Motion palette. A script is assembled by&#xD;dragging blocks from a palette into the scripting area in the middle part of the window. Blocks snap together&#xD;(hence the name Snap! for the language) when you drag a block so that its indentation is near the tab of the one&#xD;above it:&#xD;The white horizontal line is a signal that if you let go of the green block it will snap into the tab of the gold one.&#xD;Hat Blocks and Command Blocks&#xD;At the top of the script is a hat block, which indicates when the script should be carried out. Hat block names&#xD;typically start with the word “when”; in the square-drawing example on page 5, the script should be run when&#xD;the green flag near the right end of the Snap! tool bar is clicked. (The Snap! tool bar is part of the Snap! window,&#xD;not the same as the browser’s or operating system’s menu bar.) A script isn’t required to have a hat block, but if&#xD;not, then the script will be run only if the user clicks on the script itself. A script can’t have more than one hat&#xD;block, and the hat block can be used only at the top of the script; its distinctive shape is meant to remind you of&#xD;that.1&#xD;The other blocks in our example script are command blocks. Each command block corresponds to an action&#xD;that Snap! already knows how to carry out. For example, the block tells the sprite (the&#xD;arrowhead shape on the stage at the right end of the window) to move ten steps (a step is a very small unit of&#xD;distance) in the direction in which the arrowhead is pointing. We’ll see shortly that there can be more than one&#xD;sprite, and that each sprite has its own scripts. Also, a sprite doesn’t have to look like an arrowhead, but can&#xD;have any picture as a costume. The shape of the move block is meant to remind you of a Lego™ brick; a script is&#xD;a stack of blocks. (The word “block” denotes both the graphical shape on the screen and the procedure, the&#xD;action, that the block carries out.)&#xD;The number 10 in the move block above is called an input to the block. By clicking on the white oval, you can&#xD;type any number in place of the 10. The sample script on the previous page uses 100 as the input value. We’ll&#xD;see later that inputs can have non-oval shapes that accept values other than numbers. We’ll also see that you&#xD;can compute input values, instead of typing a particular value into the oval. A block can have more than one&#xD;input slot. For example, the glide block located about halfway down the Motion palette has three inputs.&#xD;1 One of the hat blocks, the generic “when anything” block , is subtly different from the others. When the stop&#xD;sign is clicked, or when a project or sprite is loaded, this block doesn’t test whether the condition in its hexagonal input slot is true, so&#xD;the script beneath it will not run, until some other script in the project runs (because, for example, you click the green flag). When&#xD;generic when blocks are disabled, the stop sign will be square instead of octagonal.&#xD;7&#xD;Most command blocks have that brick shape, but some, like the repeat block in the sample script, are C-shaped.&#xD;Most C-shaped blocks are found in the Control palette. The slot inside the C shape is a special kind of input slot&#xD;that accepts a script as the input.&#xD;In the sample script&#xD;C-shaped blocks can be put in a script in two ways. If you see a white line and let go, the block will be inserted&#xD;into the script like any command block:&#xD;But if you see an orange halo and let go, the block will wrap around the haloed blocks:&#xD;The halo will always extend from the cursor position to the bottom of the script:&#xD;If you want only some of those blocks, after wrapping you can grab the first block you don’t want wrapped, pull&#xD;it down, and snap it under the C-shaped block.&#xD;For “E-shaped” blocks with more than one C-shaped slot, only the first slot will wrap around existing blocks in a&#xD;script, and only if that C-shaped slot is empty before wrapping. (You can fill the other slots by dragging blocks&#xD;into the desired slot.)&#xD;the repeat block has two inputs:&#xD;the number 4 and the script&#xD;8&#xD;A. Sprites and Parallelism&#xD;Just below the stage is the “new sprite” button . Click the button to add a new sprite to the stage. The&#xD;new sprite will appear in a random position on the stage, with a random color, but always facing to the right.&#xD;Each sprite has its own scripts. To see the scripts for a particular sprite in the scripting area, click on the&#xD;picture of that sprite in the sprite corral in the bottom right corner of the window. Try putting one of the&#xD;following scripts in each sprite’s scripting area:&#xD;When you click the green flag, you should see one sprite rotate while the other moves back and forth. This&#xD;experiment illustrates the way different scripts can run in parallel. The turning and the moving happen&#xD;together. Parallelism can be seen with multiple scripts of a single sprite also. Try this example:&#xD;When you press the space key, the sprite should move forever in a circle, because the move and turn blocks are&#xD;run in parallel. (To stop the program, click the red stop sign at the right end of the tool bar.)&#xD;Costumes and Sounds&#xD;To change the appearance of a sprite, paint or import a new costume for it. To paint a costume, click on the&#xD;Costumes tab above the scripting area, and click the paint button . The Paint Editor that appears is&#xD;explained on page 128. There are three ways to import a costume. First select the desired sprite in the sprite&#xD;corral. Then, one way is to click on the file icon in the tool bar , then choose the “Costumes…”menu&#xD;item. You will see a list of costumes from the public media library, and can choose one. The second way, for a&#xD;costume stored on your own computer, is to click on the file icon and choose the “Import…” menu item. You&#xD;can then select a file in any picture format (PNG, JPEG, etc.) supported by your browser. The third way is&#xD;quicker if the file you want is visible on the desktop: Just drag the file onto the Snap! window. In any of these&#xD;cases, the scripting area will be replaced by something like this:&#xD;9&#xD;Just above this part of the window is a set of three tabs: Scripts, Costumes, and Sounds. You’ll see that the&#xD;Costumes tab is now selected. In this view, the sprite’s wardrobe, you can choose whether the sprite should wear&#xD;its Turtle costume or its Alonzo costume. (Alonzo, the Snap! mascot, is named after Alonzo Church, a&#xD;mathematician who invented the idea of procedures as data, the most important way in which Snap! is different&#xD;from Scratch.) You can give a sprite as many costumes as you like, and then choose which it will wear either by&#xD;clicking in its wardrobe or by using the or block in a script. (Every&#xD;costume has a number as well as a name. The next costume block selects the next costume by number; after&#xD;the highest-numbered costume it switches to costume 1. The Turtle, costume 0, is never chosen by next&#xD;costume.) The Turtle costume is the only one that changes color to match a change in the sprite’s pen color.&#xD;Protip: switches to the previous costume, wrapping like next costume.&#xD;In addition to its costumes, a sprite can have sounds; the equivalent for sounds of the sprite’s wardrobe is called&#xD;its jukebox. Sound files can be imported in any format (WAV, OGG, MP3, etc.) supported by your browser.&#xD;Two blocks accomplish the task of playing sounds. If you would like a script to continue running while the&#xD;sound is playing, use the block . In contrast, you can use the&#xD;block to wait for the sound&apos;s completion before continuing the rest of the script.&#xD;Inter-Sprite Communication with Broadcast&#xD;Earlier we saw an example of two sprites moving at the same time. In a more interesting program, though, the&#xD;sprites on stage will interact to tell a story, play a game, etc. Often one sprite will have to tell another sprite to run&#xD;a script. Here’s a simple example:&#xD;In the block, the word “bark” is just an arbitrary name I made up. When you click&#xD;on the downward arrowhead in that input slot, one of the choices (the only choice, the first time) is “new,” which&#xD;then prompts you to enter a name for the new broadcast. When this block is run, the chosen message is sent to&#xD;every sprite, which is why the block is called “broadcast.” (But if you click the right arrow after the message&#xD;name, the block becomes , and you can change it to to&#xD;send the message just to one sprite.) In this program, though, only one sprite has a script to run when that&#xD;broadcast is sent, namely the dog. Because the boy’s script uses broadcast and wait rather than just broadcast,&#xD;the boy doesn’t go on to his next say block until the dog’s script finishes. That’s why the two sprites take turns&#xD;talking, instead of both talking at once. In Chapter VII, “Object-Oriented Programming with Sprites,” you’ll&#xD;see a more flexible way to send a message to a specific sprite using the tell and ask blocks.&#xD;Notice, by the way, that the say block’s first input slot is rectangular rather than oval. This means the input&#xD;can be any text string, not only a number. In text input slots, a space character is shown as a brown dot, so that&#xD;you can count the number of spaces between words, and in particular you can tell the difference between an&#xD;empty slot and one containing spaces. The brown dots are not shown on the stage if the text is displayed.&#xD;10&#xD;The stage has its own scripting area. It can be selected by clicking on the Stage icon at the left of the sprite&#xD;corral. Unlike a sprite, though, the stage can’t move. Instead of costumes, it has backgrounds: pictures that fill the&#xD;entire stage area. The sprites appear in front of the current background. In a complicated project, it’s often&#xD;convenient to use a script in the stage’s scripting area as the overall director of the action.&#xD;B. Nesting Sprites: Anchors and Parts&#xD;Sometimes it’s desirable to make a sort of “super-sprite” composed of pieces that can move together but can also&#xD;be separately articulated. The classic example is a person’s body made up of a torso, limbs, and a head. Snap!&#xD;allows one sprite to be designated as the anchor of the combined shape, with other sprites as its parts. To set up&#xD;sprite nesting, drag the sprite corral icon of a part sprite onto the stage display (not the sprite corral icon!) of the&#xD;desired anchor sprite. The precise place where you let go of the mouse button will be the attachment point of the&#xD;part on the anchor.&#xD;Sprite nesting is shown in the sprite corral icons of both anchors and parts:&#xD;In this illustration, it is desired to animate Alonzo’s arm. (The arm has been colored green in this picture to&#xD;make the relationship of the two sprites clearer, but in a real project they’d be the same color, probably.) Sprite,&#xD;representing Alonzo’s body, is the anchor; Sprite(2) is the arm. The icon for the anchor shows small images of&#xD;up to three attached parts at the bottom. The icon for each part shows a small image of the anchor in its top left&#xD;corner, and a synchronous/dangling rotation flag in the top right corner. In its initial, synchronous setting, as shown&#xD;above, it means that the when the anchor sprite rotates, the part sprite also rotates as well as revolving around&#xD;the anchor. When clicked, it changes from a circular arrow to a straight arrow, and indicates that when the&#xD;anchor sprite rotates, the part sprite revolves around it, but does not rotate, keeping its original orientation.&#xD;(The part can also be rotated separately, using its turn blocks.) Any change in the position or size of the anchor&#xD;is always extended to its parts. Also, cloning the anchor (see Section VII. B) will also clone all its parts.&#xD;Top: turning the part: the green arm. Bottom: turning the anchor, with the arm synchronous (left) and dangling (right).&#xD;C. Reporter Blocks and Expressions&#xD;So far, we’ve used two kinds of blocks: hat blocks and command blocks. Another kind is the reporter block, which&#xD;has an oval shape: . It’s called a “reporter” because when it’s run, instead of carrying out an action,&#xD;it reports a value that can be used as an input to another block. If you drag a reporter into the scripting area by&#xD;itself and click on it, the value it reports will appear in a speech balloon next to the block:&#xD;11&#xD;When you drag a reporter block over another block’s input slot, a white “halo” appears around that input slot,&#xD;analogous to the white line that appears when snapping command blocks together:&#xD;Don’t drop the input over a red halo:&#xD;That’s used for a purpose explained on page 68.&#xD;Here’s a simple script that uses a reporter block:&#xD;Here the x position reporter provides the first input to the say block. (The sprite’s X position is its horizontal&#xD;position, how far left (negative values) or right (positive values) it is compared to the center of the stage.&#xD;Similarly, the Y position is measured vertically, in steps above (positive) or below (negative) the center.)&#xD;You can do arithmetic using reporters in the Operators palette:&#xD;The round block rounds 35.3905… to 35, and the + block adds 100 to that. (By the way, the round block is in&#xD;the Operators palette, just like +, but in this script it’s a lighter color with black lettering because Snap! alternates&#xD;light and dark versions of the palette colors when a block is nested inside another block from the same palette:&#xD;This aid to readability is called zebra coloring.) A reporter block with its inputs, maybe including other reporter&#xD;blocks, such as , is called an expression.&#xD;12&#xD;D. Predicates and Conditional Evaluation&#xD;Most reporters report either a number, like , or a text string, like . A predicate is a&#xD;special kind of reporter that always reports true or false. Predicates have a hexagonal shape:&#xD;The special shape is a reminder that predicates don’t generally make sense in an input slot of blocks that are&#xD;expecting a number or text. You wouldn’t say , although (as you can see from the&#xD;picture) Snap! lets you do it if you really want. Instead, you normally use predicates in special hexagonal input&#xD;slots like this one:&#xD;The C-shaped if block runs its input script if (and only if) the expression in its hexagonal input reports true.&#xD;A really useful block in animations runs its input script repeatedly until a predicate is satisfied:&#xD;If, while working on a project, you want to omit temporarily some commands in a script, but you don’t want to&#xD;forget where they belong, you can say&#xD;Sometimes you want to take the same action whether some condition is true or false, but with a different input&#xD;value. For this purpose you can use the reporter if block:&#xD;The technical term for a true or false value is a “Boolean” value; it has a capital B because it’s named after a&#xD;person, George Boole, who developed the mathematical theory of Boolean values. Don’t get confused; a&#xD;hexagonal block is a predicate, but the value it reports is a Boolean.&#xD;Another quibble about vocabulary: Many programming languages reserve the name “procedure” for&#xD;Commands (that carry out an action) and use the name “function” for Reporters and Predicates. In this&#xD;manual, a procedure is any computational capability, including those that report values and those that don’t.&#xD;Commands, Reporters, and Predicates are all procedures. The words “a Procedure type” are shorthand for&#xD;“Command type, Reporter type, or Predicate type.”&#xD;If you want to put a constant Boolean value in a hexagonal slot instead of a predicate-based expression, hover&#xD;the mouse over the block and click on the control that appears:&#xD;13&#xD;E. Variables&#xD;Try this script:&#xD;The input to the move block is an orange oval. To get it there, drag the orange oval that’s part of the for block:&#xD;The orange oval is a variable: a symbol that represents a value. (I took this screenshot before changing the&#xD;second number input to the for block from the default 10 to 200, and before dragging in a turn block.) For runs&#xD;its script input repeatedly, just like repeat, but before each repetition it sets the variable i to a number starting&#xD;with its first numeric input, adding 1 for each repetition, until it reaches the second numeric input. In this case,&#xD;there will be 200 repetitions, first with i=1, then with i=2, then 3, and so on until i=200 for the final repetition.&#xD;The result is that each move draws a longer and longer line segment, and that’s why the picture you see is a kind&#xD;of spiral. (If you try again with a turn of 90 degrees instead of 92, you’ll see why this picture is called a&#xD;“squiral.”)&#xD;The variable i is created by the for block, and it can only be used in the script inside the block’s C-slot. (By the&#xD;way, if you don’t like the name i, you can change it by clicking on the orange oval without dragging it, which&#xD;will pop up a dialog window in which you can enter a different name:&#xD;“I” isn’t a very descriptive name; you might prefer “length” to indicate its purpose in the script. “I” is traditional&#xD;because mathematicians tend to use letters between i and n to represent integer values, but in programming&#xD;languages we don’t have to restrict ourselves to single-letter variable names.)&#xD;14&#xD;Global Variables&#xD;You can create variables “by hand” that aren’t limited to being used within a single block. At the top of the&#xD;Variables palette, click the “Make a variable” button:&#xD;This will bring up a dialog window in which you can give your variable a name:&#xD;The dialog also gives you a choice to make the variable available to all sprites (which is almost always what you&#xD;want) or to make it visible only in the current sprite. You’d do that if you’re going to give several sprites&#xD;individual variables with the same name, so that you can share a script between sprites (by dragging it from the&#xD;current sprite’s scripting area to the picture of another sprite in the sprite corral), and the different sprites will do&#xD;slightly different things when running that script because each has a different value for that variable name.&#xD;If you give your variable the name “name” then the Variables palette will look like this:&#xD;There’s now a “Delete a variable” button, and there’s an orange oval with the variable name in it, just like the&#xD;orange oval in the for block. You can drag the variable into any script in the scripting area. Next to the oval is&#xD;a checkbox, initially checked. When it’s checked, you’ll also see a variable watcher on the stage:&#xD;15&#xD;When you give the variable a value, the orange box in its watcher will display the value.&#xD;How do you give it a value? You use the set block:&#xD;Note that you don’t drag the variable’s oval into the set block! You click on the downarrow in the first input&#xD;slot, and you get a menu of all the available variable names.&#xD;If you do choose “For this sprite only” when creating a variable, its block in the palette looks like this:&#xD;The location-pin icon is a bit of a pun on a sprite-local variable. It’s shown only in the palette.&#xD;Script Variables&#xD;In the name example above, our project is going to carry on an interaction with the user, and we want to&#xD;remember their name throughout the project. That’s a good example of a situation in which a global variable&#xD;(the kind you make with the “Make a variable” button) is appropriate. Another common example is a variable&#xD;called “score” in a game project. But sometimes you only need a variable temporarily, during the running of a&#xD;particular script. In that case you can use the script variables block to make the variable:&#xD;As in the for block, you can click on an orange oval in the script variables block without dragging to change its&#xD;name. You can also make more than one temporary variable by clicking on the right arrow at the end of the&#xD;block to add another variable oval:&#xD;Renaming variables&#xD;There are several reasons why you might want to change the name of a variable:&#xD;1. It has a default name, such as the “a” in script variables or the “i” in for.&#xD;2. It conflicts with another name, such as a global variable, that you want to use in the same script.&#xD;3. You just decide a different name would be more self-documenting.&#xD;In the first and third case, you probably want to change the name everywhere it appears in that script, or even&#xD;in all scripts. In the second case, if you’ve already used both variables in the script before realizing that they&#xD;have the same name, you’ll want to look at each instance separately to decide which ones to rename. Both of&#xD;these operations are possible by right-clicking or control-clicking on a variable oval.&#xD;16&#xD;If you right-click on an orange oval in a context in which the variable is used, then you are able to rename just&#xD;that one orange oval:&#xD;If you right-click on the place where the variable is defined (a script variables block, the orange oval for a global&#xD;variable in the Variables palette, or an orange oval that’s built into a block such as the “i” in for), then you are&#xD;given two renaming options, “rename” and “rename all.” If you choose “rename,” then the name is changed&#xD;only in that one orange oval, as in the previous case:&#xD;But if you choose “rename all,” then the name will be changed throughout the scope of the variable (the script&#xD;for a script variable, or everywhere for a global variable):&#xD;Transient variables&#xD;So far we’ve talked about variables with numeric values, or with short text strings such as someone’s name. But&#xD;there’s no limit to the amount of information you can put in a variable; in Chapter IV you’ll see how to use lists&#xD;to collect many values in one data structure, and in Chapter VIII you’ll see how to read information from web&#xD;sites. When you use these capabilities, your project may take up a lot of memory in the computer. If you get&#xD;close to the amount of memory available to Snap!, then it may become impossible to save your project. (Extra&#xD;space is needed temporarily to convert from Snap! ’s internal representation to the form in which projects are&#xD;exported or saved.) If your program reads a lot of data from the outside world that will still be available when&#xD;you use it next, you might want to have values containing a lot of data removed from memory before saving the&#xD;project. To do this, right-click or control-click on the orange oval in the Variables palette, to see this menu:&#xD;You already know about the rename options, and help… displays a help screen about variables in general.&#xD;Here we’re interested in the check box next to transient. If you check it, this variable’s value will not be saved&#xD;when you save your project. Of course, you’ll have to ensure that when your project is loaded, it recreates the&#xD;needed value and sets the variable to it.&#xD;17&#xD;F. Debugging&#xD;Snap! provides several tools to help you debug a program. They center around the idea of pausing the running of&#xD;a script partway through, so that you can examine the values of variables.&#xD;The pause button&#xD;The simplest way to pause a program is manually, by clicking the pause button in the top right corner of&#xD;the window. While the program is paused, you can run other scripts by clicking on them, show variables on&#xD;stage with the checkbox next to the variable in the Variables palette or with the show variable block, and do all&#xD;the other things you can generally do, including modifying the paused scripts by adding or removing blocks.&#xD;The button changes shape to and clicking it again resumes the paused scripts.&#xD;Breakpoints: the pause all block&#xD;The pause button is great if your program seems to be in an infinite loop, but more often you’ll want to set a&#xD;breakpoint, a particular point in a script at which you want to pause. The block, near the bottom of&#xD;the Control palette, can be inserted in a script to pause when it is run. So, for example, if your program is&#xD;getting an error message in a particular block, you could use pause all just before that block to look at the values&#xD;of variables just before the error happens.&#xD;The pause all block turns bright cyan while paused. Also, during the pause, you can right-click on a running&#xD;script and the menu that appears will give you the option to show watchers for temporary variables of the script:&#xD;But what if the block with the error is run many times in a loop, and it only errors when a particular condition&#xD;is true—say, the value of some variable is negative, which shouldn’t ever happen. In the iteration library (see&#xD;page 25 for more about how to use libraries) is a breakpoint block that lets you set a conditional breakpoint, and&#xD;automatically display the relevant variables before pausing. Here’s a sample use of it:&#xD;(In this contrived example, variable zot comes from outside the script but is relevant to its behavior.) When you&#xD;continue (with the pause button), the temporary variable watchers are removed by this breakpoint block before&#xD;resuming the script. The breakpoint block isn’t magic; you could alternatively just put a pause all inside an if.1&#xD;1 The hide variable and show variable blocks can also be used to hide and show primitives in the palette. The pulldown menu doesn’t&#xD;include primitive blocks, but there’s a generally useful technique to give a block input values it wasn’t expecting using run or call:&#xD;In order to use a block as an input this way, you must explicitly put a ring around it, by right-clicking on it and choosing ringify. More&#xD;about rings in Chapter VI.&#xD;18&#xD;Visible stepping&#xD;Sometimes you’re not exactly sure where the error is, or you don’t understand how the program got there. To&#xD;understand better, you’d like to watch the program as it runs, at human speed rather than at computer speed.&#xD;You can do this by clicking the visible stepping button ( ), before running a script or while the script is paused.&#xD;The button will light up ( ) and a speed control slider will appear in the toolbar. When you start&#xD;or continue the script, its blocks and input slots will light up cyan one at a time:&#xD;In this simple example, the inputs to the blocks are constant values, but if an input were a more complicated&#xD;expression involving several reporter blocks, each of those would light up as they are called. Note that the input&#xD;to a block is evaluated before the block itself is called, so, for example, the 100 lights up before the move.&#xD;The speed of stepping is controlled by the slider. If you move the slider all the way to the left, the speed is&#xD;zero, the pause button turns into a step button , and the script takes a single step each time you push it.&#xD;The name for this is single stepping.&#xD;If several scripts that are visible in the scripting area are running at the same time, all of them are stepped in&#xD;parallel. However, consider the case of two repeat loops with different numbers of blocks. While not stepping,&#xD;each script goes through a complete cycle of its loop in each display cycle, despite the difference in the length of&#xD;a cycle. In order to ensure that the visible result of a program on the stage is the same when stepped as when&#xD;not stepped, the shorter script will wait at the bottom of its loop for the longer script to catch up.&#xD;When we talk about custom blocks in Chapter III, we’ll have more to say about visible stepping as it affects&#xD;those blocks.&#xD;G. Etcetera&#xD;This manual doesn’t explain every block in detail. There are many more motion blocks, sound blocks, costume&#xD;and graphics effects blocks, and so on. You can learn what they all do by experimentation, and also by reading&#xD;the “help screens” that you can get by right-clicking or control-clicking a block and selecting “help…” from the&#xD;menu that appears. If you forget what palette (color) a block is, but you remember at least part of its name, type&#xD;control-F and enter the name in the text block that appears in the palette area.&#xD;Here are the primitive blocks that don’t exist in Scratch:&#xD;reports a new costume consisting of everything that’s drawn on the stage by any sprite. Rightclicking&#xD;the block in the scripting area gives the option to change it to if vector logging is&#xD;enabled. See page 116.&#xD;Print characters in the given point size on the stage, at the sprite’s position and&#xD;in its direction. The sprite moves to the end of the text. (That’s not always&#xD;what you want, but you can save the sprite’s position before using it, and&#xD;sometimes you need to know how big the text turned out to be, in turtle steps.) If the pen is down, the text will&#xD;be underlined.&#xD;. . .&#xD;19&#xD;Get or set selected&#xD;global flags.&#xD;Blocks only for the Stage:&#xD;Takes a sprite as input. Like stamp except that the costume is stamped onto the selected&#xD;sprite instead of onto the stage. (Does nothing if the current sprite doesn’t overlap the&#xD;chosen sprite.)&#xD;Takes a sprite as input. Erases from that sprite’s costume the area that overlaps with the&#xD;current sprite’s costume. (Does not affect the costume in the chosen sprite’s wardrobe, only&#xD;the copy currently visible.)&#xD;See page 6. See page 17.&#xD;Reporter version of the if/else primitive command block. Only one of the two branches is evaluated,&#xD;depending on the value of the first input.&#xD;Looping block like repeat but with an index variable.&#xD;Declare local variables in a script.&#xD;See page 91.&#xD;Constant true or false value. See page 12.&#xD;Create a primitive using JavaScript. (This block is disabled by default; the user&#xD;must check “Javascript extensions” in the setting menu each time a project is loaded.)&#xD;The at block lets you examine the screen pixel directly behind the rotation center of&#xD;a sprite, the mouse, or an arbitrary (x,y) coordinate pair dropped onto the second&#xD;menu slot. The first five items of the left menu let you examine the color visible at&#xD;the position. (The “RGBA” option reports a list.) The “sprites” option reports a list&#xD;of all sprites, including this one, any point of which overlaps this sprite’s rotation&#xD;center (behind or in front). This is a hyperblock with respect to its second input.&#xD;Checks the data type of a value.&#xD;Runs only this script&#xD;until finished. In the Control&#xD;palette even though it’s gray.&#xD;reports the value of a graphics effect.&#xD;20&#xD;Turn the text into a list, using the second input as the delimiter between&#xD;items. The default delimiter, indicated by the brown dot in the input&#xD;slot, is a single space character. “Le!er” puts each character of the text&#xD;in its own list item. “Word” puts each word in an item. (Words are&#xD;separated by any number of consecutive space, tab, carriage return, or&#xD;newline characters.) “Line” is a newline character (0xa); “tab” is a tab&#xD;character (0x9); “cr” is a carriage return (0xd). “Csv” and “json” split&#xD;formatted text into lists of lists; see page 54. “Blocks” takes a script as&#xD;the first input, reporting a list structure representing the structure of the&#xD;script. See Chapter XI.&#xD;For lists, reports true only if its two input values are the very same list, so changing an&#xD;item in one of them is visible in the other. (For =, lists that look the same are the same.) For text strings, uses&#xD;case-sensitive comparison, unlike =, which is case-independent.&#xD;These hidden blocks can be found with the relabel option of any&#xD;dyadic arithmetic block. They’re hidden partly because writing them in Snap! is a good, pretty easy&#xD;programming exercise. Note: the two inputs to atan2 are Δx and Δy in that order, because we measure angles&#xD;clockwise from north. Max and min are variadic; by clicking the arrowhead, you can provide additional inputs.&#xD;Similarly, these hidden predicates can be found by relabeling the relational&#xD;predicates.&#xD;Metaprogramming (see Chapter XI. , page 101)&#xD;These blocks support metaprogramming, which means manipulating blocks and scripts as data. This is not the&#xD;same as manipulating procedures (see Chapter VI. ), which are what the blocks mean; in metaprogramming the&#xD;actual blocks, what you see on the screen, are the data. This capability is new in version 8.0.&#xD;First class list blocks (see Chapter IV, page 46):&#xD;Numbers from will count up or down.&#xD;The script input to for each can refer to an&#xD;item of the list with the item variable.&#xD;21&#xD;report the sprite or mouse position as a two-item vector (x,y).&#xD;First class procedure blocks (see Chapter VI, page 65):&#xD;First class continuation blocks (see Chapter X, page 93):&#xD;First class sprite, costume, and sound blocks (see Chapter VII, page 73):&#xD;Scenes:&#xD;The major new feature of version 7.0 is scenes: A project can include within&#xD;it sub-projects, called scenes, each with its own stage, sprites, scripts, and&#xD;so on. This block makes another scene active, replacing the current one.&#xD;Nothing is automatically shared between scenes: no sprites, no blocks, no&#xD;variables. But the old scene can send a message to the new one, to start it&#xD;running, with optional payload as in broadcast (page 23).&#xD;In particular, you can say&#xD;if the new scene expects to be started with a green flag signal.&#xD;Object is a hyperblock.&#xD;22&#xD;These aren’t new blocks but they have a new feature:&#xD;These accept two-item (x,y) lists as input, and have extended menus (also including other sprites):&#xD;“Center” means the center of the stage, the point at (0,0). “Direction” is in the point in direction sense, the&#xD;direction that would leave this sprite pointing toward another sprite, the mouse, or the center. “Ray length” is&#xD;the distance from the center of this sprite to the nearest point on the other sprite, in the current direction.&#xD;The stop block has two extra menu choices. Stop this block is used&#xD;inside the definition of a custom block to stop just this invocation of&#xD;this custom block and continue the script that called it. Stop all but&#xD;this script is good at the end of a game to stop all the game pieces&#xD;from moving around, but keep running this script to provide the user’s&#xD;final score. The last two menu choices add a tab at the bottom of the&#xD;block because the current script can continue after it.&#xD;The new “pen trails” option is true if the sprite is touching any drawn or&#xD;stamped ink on the stage. Also, touching will not detect hidden sprites,&#xD;but a hidden sprite can use it to detect visible sprites.&#xD;The video block has a snap option that takes a snapshot and reports it as a&#xD;costume. It is hyperized with respect to its second input.&#xD;The “neg” option is a monadic negation operator, equivalent to .&#xD;“lg” is log2. “id” is the identity function, which reports its input. “sign” reports 1 for&#xD;positive input, 0 for zero input, or -1 for negative input.&#xD;name changed to clarify&#xD;that it’s different from&#xD;+ and × are variadic: they take two or more inputs. If&#xD;you drop a list on the arrowheads, the block name&#xD;changes to sum or product.&#xD;23&#xD;Extended mouse interaction events, sensing clicking, dragging, hovering, etc.&#xD;The “stopped” option triggers when all scripts are stopped, as with the&#xD;stop button; it is useful for robots whose hardware interface must be told to&#xD;turn off motors. A when I am stopped script can run only for a limited time.&#xD;Extended broadcast: Click the right arrowhead to direct the&#xD;message to a single sprite or the stage. Click again to add any value&#xD;as a payload to the message.&#xD;Extended when I receive: Click the right arrowhead to expose a script variable (click&#xD;on it to change its name, like any script variable) that will be set to the data of a&#xD;matching broadcast. If the first input is set to “any message,” then the data&#xD;variable will be set to the message, if no payload is included with the broadcast, or&#xD;to a two-item list containing the message and the payload.&#xD;If the input is set to “any key,” then a right arrowhead appears:&#xD;and if you click it, a script variable key is created whose value is the key that was&#xD;pressed. (If the key is one that’ represented in the input menu by a word or phrase,&#xD;e.g., “enter” or “up arrow,” then the value of key will be that word or phrase, except for&#xD;the space character, which is represented as itself in key.)&#xD;24&#xD;These ask features and more in the Menus library.&#xD;The of block has an extended menu of attributes of a sprite. Position reports an (x,y)&#xD;vector. Size reports the percentage of normal size, as controlled by the set size block in&#xD;the Looks category. Left, right, etc. report the stage coordinates of the corresponding&#xD;edge of the sprite’s bounding box. Variables reports a list of the names of all variables in&#xD;scope (global, sprite-local, and script variables if the right input is a script.&#xD;The RGB(A) option accepts a&#xD;single number, which is a&#xD;grayscale value 0-255; a twonumber&#xD;list, grayscale plus&#xD;opacity 0-255; a three-item&#xD;RGB list, or a four-item&#xD;RGBA list.&#xD;25&#xD;H. Libraries&#xD;There are several collections of useful procedures that aren’t Snap! primitives, but are provided as libraries. To&#xD;include a library in your project, choose the Libraries… option in the file ( ) menu.&#xD;When you click on the one-line description of a library, you are shown the actual blocks in the library and a&#xD;longer explanation of its purpose. You can browse the libraries to find one that will satisfy your needs.&#xD;The libraries and their contents may change, but as of this writing the list library has these blocks:&#xD;(The lightning bolt before the name in several of these blocks means that they use&#xD;compiled HOFs or JavaScript primitives to achieve optimal speed. They are&#xD;officially considered experimental.) Remove duplicates from reports a list in which&#xD;no two items are equal. The sort block takes a list and a two-input comparison&#xD;predicate, such as &lt;, and reports a list with the items sorted according to that&#xD;comparison. The assoc block is for looking up a key in an association list: a list of&#xD;two-item lists. In each two-item list, the first is a key and the second is a value. The&#xD;inputs are a key and an association list; the block reports the first key-value pair&#xD;whose key is equal to the input key.&#xD;For each item is a variant of the primitive version that provides a # variable&#xD;containing the position in the input list of the currently considered item. Multimap&#xD;is a version of map that allows multiple list inputs, in which case the mapping&#xD;function must take as many inputs as there are lists; it will be called with all the&#xD;first items, all the second items, and so on. Zip takes any number of lists as inputs; it reports a list of lists: all the&#xD;first items, all the second items, and so on. The no-name identity function reports its input.&#xD;Sentence and sentence➔list are borrowed from the word and sentence library (page 27) to serve as a variant of&#xD;append that accepts non-lists as inputs. Printable takes a list structure of any depth as input and reports a&#xD;compact representation of the list as a text string.&#xD;The library menu is divided into five broad categories. The first&#xD;is, broadly, utilities: blocks that might well be primitives. They&#xD;might be useful in all kinds of projects.&#xD;The second category is blocks related to media computation:&#xD;ones that help in dealing with costumes and sounds (a/k/a Jens&#xD;libraries). There is some overlap with “big data” libraries, for&#xD;dealing with large lists of lists.&#xD;The third category is, roughly, specific to non-media applications&#xD;(a/k/a Brian libraries). Three of them are imports from other&#xD;programming languages: words and sentences from Logo, array&#xD;functions from APL, and streams from Scheme. Most of the&#xD;others are to meet the needs of the BJC curriculum.&#xD;The fourth category is major packages (extensions) provided by&#xD;users.&#xD;The fifth category provides support for hardware devices such as&#xD;robots, through general interfaces, replacing specific hardware&#xD;libraries in versions before 7.0.&#xD;26&#xD;The iteration, composition library has these blocks:&#xD;Catch and throw provide a nonlocal exit facility. You can drag the tag from a&#xD;catch block to a throw inside its C-slot, and the throw will then jump directly out to&#xD;the matching catch without doing anything in between.&#xD;If do and pause all is for setting a breakpoint while debugging code. The idea is to&#xD;put show variable blocks for local variables in the C-slot; the watchers will be deleted&#xD;when the user continues from the pause.&#xD;Ignore is used when you need to call a reporter but you don’t care about the value it&#xD;reports. (For example, you are writing a script to time how long the reporter takes.)&#xD;The cascade blocks take an initial value and call a function repeatedly on that value,&#xD;f(f(f(f…(x)))).&#xD;The compose block takes two functions and reports the function f(g(x)).&#xD;The first three repeat blocks are variants of the primitive repeat until block, giving&#xD;all four combinations of whether the first test happens before or after the first&#xD;repetition, and whether the condition must be true or false to continue repeating.&#xD;The last repeat block is like the repeat primitive, but makes the number of&#xD;repetitions so far available to the repeated script. The next two blocks are variations&#xD;on for: the first allows an explicit step instead of using ±1, and the second allows any&#xD;values, not just numbers; inside the script you say&#xD;replacing the grey block in the picture with an expression to give the next desired value for the loop index. Pipe&#xD;allows reordering a nested composition with a left-to-right one:&#xD;The stream library has these blocks:&#xD;Streams are a special kind of list whose items are not computed&#xD;until they are needed. This makes certain computations more&#xD;efficient, and also allows the creation of lists with infinitely&#xD;many items, such as a list of all the positive integers. The first&#xD;five blocks are stream versions of the list blocks in front of,&#xD;item 1 of, all but #rst of, map, and keep. Show stream takes&#xD;a stream and a number as inputs, and reports an ordinary list&#xD;of the first n items of the stream. Stream is like the primitive&#xD;list; it makes a finite stream from explicit items. Sieve is an&#xD;example block that takes as input the stream of integers&#xD;starting with 2 and reports the stream of all the prime numbers. Stream with numbers from is like the numbers&#xD;from block for lists, except that there is no endpoint; it reports an infinite stream of numbers.&#xD;27&#xD;The word and sentence library has these blocks:&#xD;This library has the goal of recreating the Logo approach to handling text: A text&#xD;isn’t best viewed as a string of characters, but rather as a sentence, made of words, each&#xD;of which is a string of letters. With a few specialized exceptions, this is why people put&#xD;text into computers: The text is sentences of natural (i.e., human) language, and the&#xD;emphasis is on words as constitutive of sentences. You barely notice the letters of the&#xD;words, and you don’t notice the spaces between them at all, unless you’re proofreading.&#xD;(Even then: Proofreading is diffciult, because you see what you expect to&#xD;see, what will make the snetence make sense, rather than the misspelling in front of&#xD;of your eyes.) Internally, Logo stores a sentence as a list of words, and a word as a&#xD;string of letters.&#xD;Inexplicably, the designers of Scratch chose to abandon that tradition, and to focus&#xD;on the representation of text as a string of characters. The one vestige of the Logo&#xD;tradition from which Scratch developed is the block named le!er (1) of (world),&#xD;rather than character (1) of (world). Snap! inherits its text handling from Scratch.&#xD;In Logo, the visual representation of a sentence (a list of words) looks like a natural&#xD;language sentence: a string of words with spaces between them. In Snap!, the visual&#xD;representation of a list looks nothing at all like natural language. On the other hand, representing a sentence as&#xD;a string means that the program must continually re-parse the text on every operation, looking for spaces,&#xD;treating multiple consecutive spaces as one, and so on. Also, it’s more convenient to treat a sentence as a list of&#xD;words rather than a string of words because in the former case you can use the higher order functions map,&#xD;keep, and combine on them. This library attempts to be agnostic as to the internal representation of sentences.&#xD;The sentence selectors accept any combination of lists and strings; there are two sentence constructors, one to&#xD;make a string (join words) and one to make a list (sentence).&#xD;The selector names come from Logo, and should be self-explanatory. However, because in a block language&#xD;you don’t have to type the block name, instead of the terse but#rst or the cryptic bf we spell out “all but first of”&#xD;and include “word” or “sentence” to indicate the intended domain. There’s no #rst le!er of block because&#xD;le!er 1 of serves that need. Join words (the sentence-as-string constructor) is like the primitive join except that&#xD;it puts a space in the reported value between each of the inputs. Sentence (the List-colored sentence-as-list&#xD;constructor) accepts any number of inputs, which can be words, sentences-as-lists, or sentences-as-strings. (If&#xD;inputs are lists of lists, only one level of flattening is done.) Sentence reports a list of words; there will be no&#xD;empty words or words containing spaces. The four blocks with right-arrows in their names convert back and&#xD;forth between text strings (words or sentences) and lists. (Splitting a word into a list of letters is unusual unless&#xD;you’re a linguist investigating orthography.) Printable takes a list (including a deep list) of words as input and&#xD;reports a text string in which parentheses are used to show the structure, as in Lisp/Scheme.&#xD;The pixels library has one block:&#xD;Costumes are first class data in Snap!. Most of the processing of costume data is done by primitive&#xD;blocks in the Looks category. (See page 79.) This library provides snap, which takes a picture&#xD;using your computer’s camera and reports it as a costume.&#xD;28&#xD;The bar charts library has these blocks:&#xD;Bar chart takes a table (typically from a CSV data set) as&#xD;input and reports a summary of the table grouped by the&#xD;field in the specified column number. The remaining&#xD;three inputs are used only if the field values are numbers,&#xD;in which case they can be grouped into buckets (e.g.,&#xD;decades, centuries, etc.). Those inputs specify the smallest&#xD;and largest values of interest and, most importantly, the&#xD;width of a bucket (10 for decades, 100 for centuries). If&#xD;the field isn&apos;t numeric, leave these three inputs empty or&#xD;set them to zero. Each string value of the field is its own bucket, and they appear sorted alphabetically.&#xD;Bar chart reports a new table with three columns. The first column contains the bucket name or smallest&#xD;number. The second column contains a nonnegative integer that says how many records in the input table fall&#xD;into this bucket. The third column is a subtable containing the actual records from the original table that fall&#xD;into the bucket. Plot bar chart takes the table reported by bar chart and graphs it on the stage, with axes&#xD;labelled appropriately. The remaining blocks are helpers for those.&#xD;If your buckets aren&apos;t of constant width, or you want to group by some function of more than one field, load the&#xD;"Frequency Distribution Analysis" library instead.&#xD;The multi-branched conditional library has these blocks:&#xD;The catch and throw blocks duplicate ones in the iteration library, and are&#xD;included because they are used to implement the others. The cases block sets up&#xD;a multi-branch conditional, similar to cond in Lisp or switch in C-family&#xD;languages. The first branch is built into the cases block; it consists of a Boolean&#xD;test in the first hexagonal slot and an action script, in the C-slot, to be run if the&#xD;test reports true. The remaining branches go in the variadic hexagonal input at&#xD;the end; each branch consists of an else if block, which includes the Boolean test&#xD;and the corresponding action script, except possibly for the last branch, which can&#xD;use the unconditional else block. As in other languages, once a branch succeeds,&#xD;no other branches are tested.&#xD;The variadic library has these blocks:&#xD;These are versions of the associative operators and, and or that take any number of inputs&#xD;instead of exactly two inputs. As with any variadic input, you can also drop a list of values&#xD;onto the arrowheads instead of providing the inputs one at a time As of version 8.0, the&#xD;arithmetic operators sum, product, minimum, and maximum are no longer included, because the primitive&#xD;operators +. ×, min, and max are themselves variadic.&#xD;29&#xD;The colors and crayons library has these blocks:&#xD;It is intended as a more powerful replacement for the primitive set pen block, including first class color support;&#xD;HSL color specification as a better alternative to the HSV that Snap! inherits from JavaScript; a “fair hue” scale&#xD;that compensates for the eye’s grouping a wide range of light frequencies as green while labelling mere slivers as&#xD;orange or yellow; the X11/W3C standard color names; RGB in hexadecimal; a linear color scale (as in the old&#xD;days, but better) based on fair hues and including shades (darker colors) and grayscale. Another linear scale is a&#xD;curated set of 100 “crayons,” explained further on the next page.&#xD;Colors are created by the block (for direct user selection), the color from block to specify a color&#xD;numerically, or by , which reports the color currently in use by the pen. The from color block&#xD;reports names or numbers associated with a color:&#xD;Colors can be created from other colors:&#xD;The three blocks with pen in their names are improved versions of primitive Pen blocks. In principle set pen,&#xD;for example, could be implemented using a (hypothetical) set pen to color composed with the color from block,&#xD;but in fact set pen benefits from knowing how the pen color was set in its previous invocation, so it’s&#xD;implemented separately from color from. Details in Appendix A.&#xD;The recommended way to choose a color is from one of two linear scales: the continuous color numbers and the&#xD;discrete crayons:&#xD;Color numbers are based on fair hues, a modification of the spectrum (rainbow) hue scale that devotes less space&#xD;to green and more to orange and yellow, as well as promoting brown to a real color. Here is the normal hue&#xD;scale, for reference:&#xD;Here is the fair hue scale:&#xD;Here is the color number scale:&#xD;(The picture is wider so that pure spectral colors line up with the fair hue scale.)&#xD;And here are the 100 crayons:&#xD;30&#xD;The color from block, for example, provides different pulldown menus depending on which scale you choose:&#xD;You can also type the crayon name: There are many scales:&#xD;The white slot at the end of some of the blocks has two purposes. It can be used to add a transparency to a&#xD;color (0=opaque, 100=transparent):&#xD;or it can be expanded to enter three or four numbers for a vector directly into the block, so these are equivalent:&#xD;But note that a transparency number in a four-number RGBA vector is on the scale 255=opaque,&#xD;0=transparent, so the following are not equivalent:&#xD;Set pen crayon to provides the equivalent of a box of 100 crayons. They are divided into color groups, so the&#xD;menu in the set pen crayon to input slot has submenus. The colors are chosen so that starting from crayon 0,&#xD;change pen crayon by 10 rotates through an interesting, basic set of ten colors:&#xD;Using change pen crayon by 5 instead gives ten more colors, for a total of 20:&#xD;31&#xD;(Why didn’t we use the colors of the 100-crayon Crayola™ box? A few reasons, one of which is that some&#xD;Crayola colors aren’t representable on RGB screens. Some year when you have nothing else to do, look up&#xD;“color space” on Wikipedia. Also “crayon.” Oh, it’s deliberate that change pen crayon by 5 doesn’t include&#xD;white, since that’s the usual stage background color. White is crayon 14.) Note that crayon 43 is “Variables”;&#xD;all the standard block colors are included.&#xD;See Appendix A (page 139) for more information.&#xD;The crayon library has only the crayon features, without the rest of the colors&#xD;package.&#xD;The catch errors library has these blocks:&#xD;The safely try block allows you to handle errors that happen&#xD;when your program is run within the program, instead of&#xD;stopping the script with a red halo and an obscure error&#xD;message. The block runs the script in its first C-slot. If it&#xD;finishes without an error, nothing else happens. But if an error&#xD;happens, the code in the second C-slot is run. While that&#xD;second script is running, the variable contains the text of&#xD;the error message that would have been displayed if you weren’t catching the error. The error block is sort of&#xD;the opposite: it lets your program generate an error message, which will be displayed with a red halo unless it is&#xD;caught by safely try. Safely try reporting is the reporter version of safely try.&#xD;The text costumes library has only two blocks:&#xD;Costume from text reports a costume that can be used with the switch to&#xD;costume block to make a button:&#xD;Costume with background reports a costume made from another costume by coloring its background, taking a&#xD;color input like the set pen color to RGB(A) block and a number of turtle steps of padding around the original&#xD;costume. These two blocks work together to make even better buttons:&#xD;The text to speech library has these blocks:&#xD;This library interfaces with a capability in up-to-date browsers, so it might&#xD;not work for you. It works best if the accent matches the text!&#xD;The parallelization library contains these blocks:&#xD;The two do in parallel blocks take any number of scripts as inputs. Those scripts will be run&#xD;in parallel, like ordinary independent scripts in the scripting area. The and wait version&#xD;waits until all of those scripts have finished before continuing the script below the block.&#xD;32&#xD;The create variables library has these blocks:&#xD;These blocks allow a program to perform the same operation as the&#xD;button, making global, sprite local, or script variables, but allowing the program to&#xD;compute the variable name(s). It can also set and find the values of these variables, show&#xD;and hide their stage watchers, delete them, and find out if they already exist.&#xD;The getters and setters library has these blocks:&#xD;The purpose of this library is to allow program access to the settings controlled by&#xD;user interface elements, such as the settings menu. The se!ing block reports&#xD;a setting; the set $ag block sets yes-or-no options that have checkboxes in the user&#xD;interface, while the set value block controls settings with numeric or text values,&#xD;such as project name.&#xD;Certain settings are ordinarily remembered on a per-user basis, such as the “zoom blocks” value. But when&#xD;these settings are changed by this library, the change is in effect only while the project using the library is&#xD;loaded. No permanent changes are made. Note: this library has not been converted for version 7.0, so you’ll&#xD;have to enable Javascript extensions to use it.&#xD;The bignums, rationals, complex #s library has these blocks:&#xD;The USE BIGNUMS block takes a Boolean input, to turn the infinite precision&#xD;feature on or off. When on, all of the arithmetic operators are redefined to accept&#xD;and report integers of any number of digits (limited only by the memory of your&#xD;computer) and, in fact, the entire Scheme numeric tower, with exact rationals and&#xD;with complex numbers. The Scheme number block has a list of functions&#xD;applicable to Scheme numbers, including subtype predicates such as rational? and&#xD;in#nite?, and selectors such as numerator and real-part.&#xD;The ! block computes the factorial function, useful to test whether bignums are turned on. Without bignums:&#xD;With bignums:&#xD;The 375-digit value of 200! isn’t readable on this page, but if you right-click on the block and choose “result&#xD;pic,” you can open the resulting picture in a browser window and scroll through it. (These values end with a&#xD;bunch of zero digits. That’s not roundoff error; the prime factors of 100! and 200! include many copies of 2 and&#xD;5.) The block with no name is a way to enter things like 3/4 and 4+7i into numeric input slots by converting&#xD;the slot to Any type.&#xD;33&#xD;The strings, multi-line input library provides these blocks:&#xD;All of these could be written in Snap! itself, but these&#xD;are implemented using the corresponding&#xD;JavaScript library functions directly, so they run&#xD;fast. They can be used, for example, in scraping&#xD;data from a web site. The command use caseindependent&#xD;comparisons applies only to this&#xD;library. The multiline block accepts and reports a&#xD;text input that can include newline characters.&#xD;The animation library has these blocks:&#xD;Despite the name, this isn’t only about graphics;&#xD;you can animate the values of a variable, or&#xD;anything else that’s expressed numerically.&#xD;The central idea of this library is an easing function,&#xD;a reporter whose domain and range are real&#xD;numbers between 0 and 1 inclusive. The function&#xD;represents what fraction of the “distance” (in&#xD;quotes because it might be any numeric value,&#xD;such as temperature in a simulation of weather)&#xD;from here to there should be covered in what&#xD;fraction of the time. A linear easing function&#xD;means steady progression. A quadratic easing function means starting slowly and accelerating. (Note that, since&#xD;it’s a requirement that f(0)=0 and f(1)=1, there is only one linear easing function, f(x)=x, and similarly for other&#xD;categories.) The block reports some of the common easing functions.&#xD;The two Motion blocks in this library animate a sprite. Glide always animates the sprite’s motion. Animate’s&#xD;first pulldown menu input allows you to animate horizontal or vertical motion, but will also animate the sprite’s&#xD;direction or size. The animate block in Control lets you animate any numeric quantity with any easing&#xD;function. The getter and setter inputs are best explained by example:&#xD;is equivalent to&#xD;The other blocks in the library are helpers for these four.&#xD;The serial ports library contains these blocks:&#xD;It is used to allow hardware developers to control devices such as robots that are&#xD;connected to your computer via a serial port.&#xD;34&#xD;The frequency distribution analysis library has these blocks:&#xD;This is a collection of tools for analyzing large&#xD;data sets and plotting histograms of how often&#xD;some value is found in some column of the table&#xD;holding the data.&#xD;For more information go here:&#xD;h!ps://tinyurl.com/jens-data&#xD;The audio comp library includes these blocks:&#xD;This library takes a sound, one that you record or one&#xD;from our collection of sounds, and manipulates it by&#xD;systematically changing the intensity of the samples in&#xD;the sound and by changing the sampling rate at which&#xD;the sound is reproduced. Many of the blocks are helpers&#xD;for the plot sound block, used to plot the waveform of a&#xD;sound. The play sound (primitive) block plays a sound.&#xD;__ Hz for reports a sine wave as a list of samples.&#xD;The web services library has these blocks:&#xD;The first block is a generalization of the primitive url block,&#xD;allowing more control over the various options in web&#xD;requests: GET, POST, PUT, and DELETE, and fine&#xD;control over the content of the message sent to the server.&#xD;Current location reports your latitude and longitude.&#xD;Listify takes some text in JSON format (see page 54) and&#xD;converts it to a structured list. Value at key looks up a key-value pair in a (listified) JSON dictionary. The&#xD;key:value: block is just a constructor for an abstract data type used with the other blocks&#xD;The database library contains these blocks:&#xD;It is used to keep data that persist from one Snap! session to the next, if you&#xD;use the same browser and the same login.&#xD;35&#xD;The world map library has these blocks:&#xD;Using any of the command blocks puts a map on the screen, in a layer in&#xD;front of the stage’s background but behind the pen trails layer (which is in&#xD;turn behind all the sprites). The first block asks your browser for your&#xD;current physical location, for which you may be asked to give permission.&#xD;The next two blocks get and set the map’s zoom amount; the default&#xD;zoom of 10 fits from San Francisco not quite down to Palo Alto on the&#xD;screen. A zoom of 1 fits almost the entire world. A zoom of 3 fits the&#xD;United States; a zoom of 5 fits Germany. The zoom can be changed in&#xD;half steps, i.e., 5.5 is different from 5, but 5.25 isn’t.&#xD;The next five blocks convert between stage coordinates (pixels) and Earth&#xD;coordinates (latitude and longitude). The change by x: y: block shifts the&#xD;map relative to the stage. The distance to block measures the map&#xD;distance (in meters) between two sprites. The three reporters with&#xD;current in their names find your actual location, again supposing that&#xD;geolocation is enabled on your device. Update redraws the map; as&#xD;costume reports the visible section of the map as a costume. Set style allows things like satellite pictures.&#xD;The APL primitives library contains these blocks:&#xD;For more information about APL, see Appendix B (page 148).&#xD;The list comprehension library has one block, zip. Its first input is a function of two&#xD;inputs. The two Any-type inputs are deep lists (lists of lists of…) interpreted as trees, and the&#xD;function is called with every possible combination of a leaf node of the first tree and a leaf&#xD;node of the second tree. But instead of taking atoms (non-lists) as the leaves, zip allows the leaves of each tree to&#xD;be vectors (one-dimensional lists), matrices (two-dimensional lists), etc. The Number-type inputs specify the leaf&#xD;dimension for each tree, so the function input might be called with a vector from the first tree and an atom from&#xD;the second tree.&#xD;36&#xD;The bitwise library provides bitwise logic functions; each bit of the reported value is the result&#xD;of applying the corresponding Boolean function to the corresponding bits of the input(s). The&#xD;Boolean functions are not for ¬, and for ∧, or for ∨, and xor (exclusive or) for ⊻. The&#xD;remaining functions shift their &lt;irst input left or right by the number of bits given by the&#xD;second input. &lt;&lt; is left shift, &gt;&gt; is arithmetic right shift (shifting in one bits from the left),&#xD;and &gt;&gt;&gt; is logical right shift (shifting in zero bits from the left). If you don’t already know&#xD;what these mean, &lt;ind a tutorial online.&#xD;The MQTT library supports the Message Queuing Telemetry Transport protocol, for connecting with IOT&#xD;devices. See https://mqtt.org/ for more information.&#xD;The Signada library allows you to&#xD;control a microBit or similar&#xD;device that works with the&#xD;Signada MicroBlocks project.&#xD;The menus library provides the ability to display&#xD;hierarchical menus on the stage, using the ask block’s&#xD;ability to take lists as inputs. See page 24.&#xD;The SciSnap! library and the TuneScope library are too big to discuss here and are documented&#xD;separately at http://emu-online.de/ProgrammingWithSciSnap.pdf and&#xD;https://maketolearn.org/creating-art-animations-and-music/ respectively.&#xD;37&#xD;II. Saving and Loading Projects and Media&#xD;After you’ve created a project, you’ll want to save it, so that you can have access to it the next time you use Snap!.&#xD;There are two ways to do that. You can save a project on your own computer, or you can save it at the Snap!&#xD;web site. The advantage of saving on the net is that you have access to your project even if you are using a&#xD;different computer, or a mobile device such as a tablet or smartphone. The advantage of saving on your&#xD;computer is that you have access to the saved project while on an airplane or otherwise not on the net. Also,&#xD;cloud projects are limited in size, but you can have all the costumes and sounds you like if you save locally. This&#xD;is why we have multiple ways to save.&#xD;In either case, if you choose “Save as…” from the File menu. You’ll see something like this:&#xD;(If you are not logged in to your Snap! cloud account, Computer will be the only usable option.) The text box at&#xD;the bottom right of the Save dialog allows you to enter project notes that are saved with the project.&#xD;A. Local Storage&#xD;Click on Computer and Snap!’s Save Project dialog window will be replaced by your operating system’s standard&#xD;save window. If your project has a name, that name will be the default filename if you don’t give a different&#xD;name. Another, equivalent way to save to disk is to choose “Export project” from the File menu.&#xD;B. Creating a Cloud Account&#xD;The other possibility is to save your project “in the cloud,” at the Snap! web site. In order to&#xD;do this, you need an account with us. Click on the Cloud button ( ) in the Tool Bar.&#xD;Choose the “Signup…” option. This will show you a window that looks like the picture at&#xD;the right.&#xD;You must choose a user name that will identify you on the web site, such as Jens or bh. If&#xD;you’re a Scratch user, you can use your Scratch name for Snap! too. If you’re a kid, don’t&#xD;pick a user name that includes your family name, but first names or initials are okay. Don’t&#xD;pick something you’d be embarrassed to have other users (or your parents) see! If the name&#xD;you want is already taken, you’ll have to choose another one. You must also supply a password.&#xD;38&#xD;We ask for your month and year of birth; we use this information only to decide whether to ask for your own&#xD;email address or your parent’s email address. (If you’re a kid, you shouldn’t sign up for anything on the net, not&#xD;even Snap!, without your parent’s knowledge.) We do not store your birthdate information on our server; it is&#xD;used on your own computer only during this initial signup. We do not ask for your exact birthdate, even for this&#xD;one-time purpose, because that’s an important piece of personally identifiable information.&#xD;When you click OK, an email will be sent to the email address you gave, asking you to verify (by clicking a&#xD;link) that it’s really your email address. We keep your email address on file so that, if you forget your password,&#xD;we can send you a password-reset link. We will also email you if your account is suspended for violation of the&#xD;Terms of Service. We do not use your address for any other purpose. You will never receive marketing emails&#xD;of any kind through this site, neither from us nor from third parties. If, nevertheless, you are worried about&#xD;providing this information, do a web search for “temporary email.”&#xD;Finally, you must read and agree to the Terms of Service. A quick summary: Don’t interfere with anyone&#xD;else’s use of the web site, and don’t put copyrighted media or personally identifiable information in projects that&#xD;you share with other users. And we’re not responsible if something goes wrong. (Not that we expect anything to&#xD;go wrong; since Snap! runs in JavaScript in your browser, it is strongly isolated from the rest of your computer.&#xD;But the lawyers make us say this.)&#xD;C. Saving to the Cloud&#xD;Once you’ve created your account, you can log into it using the “Login…” option from the Cloud menu:&#xD;Use the user name and password that you set up earlier. If you check the “Stay signed in” box, then you will be&#xD;logged in automatically the next time you run Snap! from the same browser on the same computer. Check the&#xD;box if you’re using your own computer and you don’t share it with siblings. Don’t check the box if you’re using a&#xD;public computer at the library, at school, etc.&#xD;Once logged in, you can choose the “Cloud” option in the “Save Project” dialog shown on page 37. You&#xD;enter a project name, and optionally project notes; your project will be saved online and can be loaded from&#xD;anywhere with net access. The project notes will be visible to other users if you publish your project.&#xD;D. Loading Saved Projects&#xD;Once you’ve saved a project, you want to be able to load it back into Snap!. There are two ways to do this:&#xD;1. If you saved the project in your online Snap! account, choose the “Open…” option from the File menu.&#xD;Choose the “Cloud” button, then select your project from the list in the big text box and click OK, or choose&#xD;the “Computer” button to open an operating system open dialog. (A third button, “Examples,” lets you choose&#xD;39&#xD;n&#xD;from example projects that we provide. You can see what each of these projects is about by clicking on it and&#xD;reading its project notes.)&#xD;2. If you saved the project as an XML file on your computer, choose “Import…” from the File menu. This will&#xD;give you an ordinary browser file-open window, in which you can navigate to the file as you would in other&#xD;software. Alternatively, find the XML file on your desktop, and just drag it onto the Snap! window.&#xD;The second technique above also allows you to import media (costumes and sounds) into a project. Just&#xD;choose “Import…” and then select a picture or sound file instead of an XML file.&#xD;Snap! can also import projects created in BYOB 3.0 or 3.1, or (with some effort; see our web site) in Scratch 1.4,&#xD;2.0 or 3.0. Almost all such projects work correctly in Snap!, apart from a small number of incompatible blocks.&#xD;If you saved projects in an earlier version of Snap! using the “Browser” option, then a Browser button will be shown in the Open&#xD;dialog to allow you to retrieve those projects. But you can save them only with the Computer and Cloud options.&#xD;E. If you lose your project, do this first!&#xD;If you are still in Snap! and realize that you’ve loaded another project without saving the one you were&#xD;working on: Don’t edit the new project. From the File menu choose the Restore unsaved project&#xD;option.&#xD;Restore unsaved project will also work if you log out of Snap! and later log back in, as long as you don’t edit&#xD;another project meanwhile. Snap! remembers only the most recent project that you’ve edited (not just opened,&#xD;but actually changed in the project editor).&#xD;If your project on the cloud is missing, empty, or otherwise broken and isn’t the one you edited&#xD;most recently, or if Restore unsaved project fails: Don’t edit the broken project. In the Open… box, enter&#xD;your project name, then push the Recover button. Do this right away, because we save only the version before the&#xD;most recent, and the latest before today. So don’t keep saving bad versions; Recover right away. The Recover&#xD;feature works only on a project version that you actually saved, so Restore unsaved project is your first choice if&#xD;you switch away from a project without saving it.&#xD;To help you remember to save your projects, when you’ve edited the project and haven’t yet saved it, Snap!&#xD;displays a pencil icon to the left of the project name on the toolbar at the top of the window:&#xD;F. Private and Public Projects&#xD;By default, a project you save in the cloud is private; only you can see it. There are two ways to make a project&#xD;available to others. If you share a project, you can give your friends a project URL (in your browser’s URL bar&#xD;after you open the project) they can use to read it. If you publish a project, it will appear on the Snap! web site,&#xD;and the whole world can see it. In any case, nobody other than you can ever overwrite your project; if others&#xD;ask to save it, they get their own copy in their own account.&#xD;40&#xD;III. Building a Block&#xD;The first version of Snap! was called BYOB, for “Build Your Own Blocks.” This was the first and is still the&#xD;most important capability we added to Scratch. (The name was changed because a few teachers have no sense&#xD;of humor. ☹ You pick your battles.) Scratch 2.0 and later also has a partial custom block capability.&#xD;A. Simple Blocks&#xD;In every palette, at or near the bottom, is a button labeled “Make a block.” Also, floating near the top of the&#xD;palette is a plus sign. Also, the menu you get by right-clicking on the background of the scripting area has a&#xD;“make a block” option.&#xD;Clicking any of these will display a dialog window in which you choose the block’s name, shape, and&#xD;palette/color. You also decide whether the block will be available to all sprites, or only to the current sprite and&#xD;its children.&#xD;In this dialog box, you can choose the block&apos;s palette, shape, and name. With one exception, there is one color&#xD;per palette, e.g., all Motion blocks are blue. But the Variables palette includes the orange variable-related&#xD;blocks and the red list-related blocks. Both colors are available, along with an “Other” option that makes grey&#xD;blocks in the Variables palette for blocks that don’t fit any category.&#xD;There are three block shapes, following a convention that should be familiar to Scratch users: The jigsawpuzzle-&#xD;piece shaped blocks are Commands, and don’t report a value. The oval blocks are Reporters, and the&#xD;41&#xD;hexagonal blocks are Predicates, which is the technical term for reporters that report Boolean (true or false)&#xD;values.&#xD;Suppose you want to make a block named “square” that draws a square. You would choose Motion,&#xD;Command, and type “square” into the name field. When you click OK, you enter the Block Editor. This&#xD;works just like making a script in the sprite’s scripting area, except that the “hat” block at the top, instead of&#xD;saying something like “when I am clicked,” has a picture of the block you’re building. This hat block is called the&#xD;prototype of your custom block.1 You drag blocks under the hat to program your custom block, then click OK:&#xD;Your block appears at the bottom of the Motion palette. Here’s the block and the result of using it:&#xD;1 This use of the word “prototype” is unrelated to the prototyping object oriented programming discussed later.&#xD;42&#xD;Custom Blocks with Inputs&#xD;But suppose you want to be able to draw squares of different sizes. Control-click or right-click on the block,&#xD;choose “edit,” and the Block Editor will open. Notice the plus signs before and after the word square in the&#xD;prototype block. If you hover the mouse over one, it lights up:&#xD;Click on the plus on the right. You will then see the “input name” dialog:&#xD;Type in the name “size” and click OK. There are other options in this dialog; you can choose “title text” if&#xD;you want to add words to the block name, so it can have text after an input slot, like the “move ( ) steps” block.&#xD;Or you can select a more extensive dialog with a lot of options about your input name. But we’ll leave that for&#xD;later. When you click OK, the new input appears in the block prototype:&#xD;You can now drag the orange variable down into the script, then click okay:&#xD;43&#xD;Your block now appears in the Motion palette with an input box: You can draw any size square by&#xD;entering the length of its side in the box and running the block as usual, by clicking it or by putting it in a script.&#xD;Editing Block Properties&#xD;What if you change your mind about a block’s color (palette) or shape (command, reporter, predicate)? If you&#xD;click in the hat block at the top that holds the prototype, but not in the prototype itself, you’ll see a window in&#xD;which you can change the color, and sometimes the shape, namely, if the block is not used in any script, whether&#xD;in a scripting area or in another custom block. (This includes a one-block script consisting of a copy of the new&#xD;block pulled out of the palette into the scripting area, seeing which made you realize it’s the wrong category.&#xD;Just delete that copy (drag it back to the palette) and then change the category.)&#xD;If you right-click/control-click the hat block, you get this menu:&#xD;Script pic exports a picture of the script. (Many of the illustrations in this manual were made that way.)&#xD;Translations opens a window in which you can specify how your block should be translated if the user chooses a&#xD;language other than the one in which you are programming. Block variables lets you create a variant of script&#xD;variables for this block: A script variable is created when a block is called, and it disappears when that call&#xD;finishes. What if you want a variable that’s local to this block, as a script variable is, but doesn’t disappear&#xD;between invocations? That’s a block variable. If the definition of a block includes a block variable, then every&#xD;time that (custom) block is dragged from the palette into a script, the block variable is created. Every time that&#xD;copy of the block is called, it uses the same block variable, which preserves its value between calls. Other copies&#xD;of the block have their own block variables. The in pale!e checkbox determines whether or not this block will&#xD;be visible in the palette. It’s normally checked, but you may want to hide custom blocks if you’re a curriculum&#xD;writer creating a Parsons problem. To unhide blocks, choose “Hide blocks” from the File menu and uncheck&#xD;the checkboxes. Edit does the same thing as regular clicking, as described earlier.&#xD;B. Recursion&#xD;Since the new custom block appears in its palette as soon as you start editing it, you can write recursive blocks&#xD;(blocks that call themselves) by dragging the block into its own definition:&#xD;(If you added inputs to the block since opening the editor, click Apply before finding the block in the palette, or&#xD;drag the block from the top of the block editor rather than from the palette.)&#xD;44&#xD;If recursion is new to you, here are a few brief hints: It’s crucial that the recursion have a base case, that is,&#xD;some small(est) case that the block can handle without using recursion. In this example, it’s the case depth=0,&#xD;for which the block does nothing at all, because of the enclosing if. Without a base case, the recursion would&#xD;run forever, calling itself over and over.&#xD;Don’t try to trace the exact sequence of steps that the computer follows in a recursive program. Instead,&#xD;imagine that inside the computer there are many small people, and if Theresa is drawing a tree of size 100,&#xD;depth 6, she hires Tom to make a tree of size 70, depth 5, and later hires Theo to make another tree of size 70,&#xD;depth 5. Tom in turn hires Tammy and Tallulah, and so on. Each little person has his or her own local&#xD;variables size and depth, each with different values.&#xD;You can also write recursive reporters, like this block to compute the factorial function:&#xD;Note the use of the report block. When a reporter block uses this block, the reporter finishes its work and&#xD;reports the value given; any further blocks in the script are not evaluated. Thus, the if else block in the script&#xD;above could have been just an if, with the second report block below it instead of inside it, and the result would&#xD;be the same, because when the first report is seen in the base case, that finishes the block invocation, and the&#xD;second report is ignored. There is also a stop this block block that has a similar purpose, ending the block&#xD;invocation early, for command blocks. (By contrast, the stop this script block stops not only the current block&#xD;invocation, but also the entire toplevel script that called it.)&#xD;Here’s a slightly more compact way to write the factorial function:&#xD;For more on recursion, see Thinking Recursively by Eric Roberts. (The original edition is ISBN&#xD;978-0471816522; a more recent Thinking Recursively in Java is ISBN 978-0471701460.)&#xD;C. Block Libraries&#xD;When you save a project (see Chapter II above), any custom blocks you’ve made are saved with it. But&#xD;sometimes you’d like to save a collection of blocks that you expect to be useful in more than one project.&#xD;Perhaps your blocks implement a particular data structure (a stack, or a dictionary, etc.), or they’re the&#xD;framework for building a multilevel game. Such a collection of blocks is called a block library.&#xD;45&#xD;To create a block library, choose “Export blocks…” from the File menu. You then see a window like this:&#xD;The window shows all of your global custom blocks. You can uncheck some of the checkboxes to select exactly&#xD;which blocks you want to include in your library. (You can right-click or control-click on the export window for&#xD;a menu that lets you check or uncheck all the boxes at once.) Then press OK. An XML file containing the&#xD;blocks will appear in your Downloads location.&#xD;To import a block library, use the “Import…” command in the File menu, or just drag the XML file into the&#xD;Snap! window.&#xD;Several block libraries are included with Snap!; for details about them, see page 25.&#xD;D. Custom blocks and Visible Stepping&#xD;Visible stepping normally treats a call to a custom block as a single step. If you want to see stepping inside a&#xD;custom block you must take these steps in order:&#xD;1. Turn on Visible Stepping.&#xD;2. Select “Edit” in the context menu(s) of the block(s) you want to examine.&#xD;3. Then start the program.&#xD;The Block Editor windows you open in step 2 do not have full editing capability. You can tell because there is&#xD;only one “OK” button at the bottom, not the usual three buttons. Use the button to close these windows when&#xD;done stepping.&#xD;46&#xD;IV. First class lists&#xD;A data type is first class in a programming language if data of that type can be&#xD;● the value of a variable&#xD;● an input to a procedure&#xD;● the value returned by a procedure&#xD;● a member of a data aggregate&#xD;● anonymous (not named)&#xD;In Scratch, numbers and text strings are first class. You can put a number in a variable, use one as the input to&#xD;a block, call a reporter that reports a number, or put a number into a list.&#xD;But Scratch’s lists are not first class. You create one using the “Make a list” button, which requires that you&#xD;give the list a name. You can’t put the list into a variable, into an input slot of a block, or into a list item—you&#xD;can’t have lists of lists. None of the Scratch reporters reports a list value. (You can use a reduction of the list&#xD;into a text string as input to other blocks, but this loses the list structure; the input is just a text string, not a data&#xD;aggregate.)&#xD;A fundamental design principle in Snap! is that all data should be first class. If it’s in the language, then&#xD;we should be able to use it fully and freely. We believe that this principle avoids the need for many special-case&#xD;tools, which can instead be written by Snap! users themselves.&#xD;Note that it’s a data type that’s first class, not an individual value. Don’t think, for example, that some lists are&#xD;first class, while others aren’t. In Snap!, lists are first class, period.&#xD;A. The list Block&#xD;At the heart of providing first class lists is the ability to make an “anonymous” list—to make a list without&#xD;simultaneously giving it a name. The list reporter block does that.&#xD;At the right end of the block are two left-and-right arrowheads. Clicking on these changes the number of inputs&#xD;to list, i.e., the number of elements in the list you are building. Shift-clicking changes by three at a time.&#xD;47&#xD;You can use this block as input to many other blocks:&#xD;Snap! does not have a “Make a list” button like the one in Scratch. If you want a global “named list,” make a&#xD;global variable and use the set block to put a list into the variable.&#xD;B. Lists of Lists&#xD;Lists can be inserted as elements in larger lists. We can easily create ad hoc structures as needed:&#xD;Notice that this list is presented in a different format from the “She Loves You” list above. A two-dimensional&#xD;list is called a table and is by default shown in table view. We’ll have more to say about this later.&#xD;We can also build any classic computer science data structure out of lists of lists, by defining constructors (blocks&#xD;to make an instance of the structure), selectors (blocks to pull out a piece of the structure), and mutators (blocks to&#xD;change the contents of the structure) as needed. Here we create binary trees with selectors that check for input&#xD;of the correct data type; only one selector is shown but the ones for left and right children are analogous.&#xD;48&#xD;C. Functional and Imperative List Programming&#xD;There are two ways to create a list inside a program. Scratch users will be familiar with the imperative&#xD;programming style, which is based on a set of command blocks that modify a list:&#xD;As an example, here are two blocks that take a list of numbers as input, and report a new list containing only the&#xD;even numbers from the original list:1&#xD;or&#xD;In this script, we first create a temporary variable, then put an empty list in it, then go through the items of the&#xD;input list using the add … to (result) block to modify the result list, adding one item at a time, and finally&#xD;report the result.&#xD;Functional programming is a different approach that is becoming important in “real world” programming&#xD;because of parallelism, i.e., the fact that different processors can be manipulating the same data at the same&#xD;time. This makes the use of mutation (changing the value associated with a variable, or the items of a list)&#xD;problematic because with parallelism it’s impossible to know the exact sequence of events, so the result of&#xD;mutation may not be what the programmer expected. Even without parallelism, though, functional&#xD;programming is sometimes a simpler and more effective technique, especially when dealing with recursively&#xD;defined data structures. It uses reporter blocks, not command blocks, to build up a list value:&#xD;1 Note to users of earlier versions: From the beginning, there has been a tension in our work between the desire to provide tools such&#xD;as for (used in this example) and the higher order functions introduced on the next page as primitives, to be used as easily as other&#xD;primitives, and the desire to show how readily such tools can be implemented in Snap! itself. This is one instance of our general&#xD;pedagogic understanding that learners should both use abstractions and be permitted to see beneath the abstraction barrier. Until&#xD;version 5.0, we used the uneasy compromise of a library of tools written in Snap! and easily, but not easily enough, loaded into a&#xD;project. By not loading the tools, users or teachers could explore how to program them. In 5.0 we made them true primitives, partly&#xD;because that’s what some of us wanted all along and partly because of the increasing importance of fast performance as we explore&#xD;“big data” and media computation. But this is not the end of the story for us. In a later version, after we get the design firmed up, we&#xD;intend to introduce “hybrid” primitives, implemented in high speed Javascript but with an “Edit” option that will open, not the&#xD;primitive implementation, but the version written in Snap!. The trick is to ensure that this can be done without dramatically slowing&#xD;users’ projects.&#xD;49&#xD;In a functional program, we often use recursion to construct a list, one item at a time. The in front of block&#xD;makes a list that has one item added to the front of an existing list, without changing the value of the original list. A&#xD;nonempty list is processed by dividing it into its first item (item 1 of) and all the rest of the items (all but #rst&#xD;of), which are handled through a recursive call:&#xD;Snap! uses two different internal representations of lists, one (dynamic array) for imperative programming and&#xD;the other (linked list) for functional programming. Each representation makes the corresponding built-in list&#xD;blocks (commands or reporters, respectively) most efficient. It’s possible to mix styles in the same program, but&#xD;if the same list is used both ways, the program will run more slowly because it converts from one representation to&#xD;the other repeatedly. (The item ( ) of [ ] block doesn’t change the representation.) You don’t have to know the&#xD;details of the internal representations, but it’s worthwhile to use each list in a consistent way.&#xD;D. Higher Order List Operations and Rings&#xD;There’s an even easier way to select the even numbers from a list:&#xD;The keep block takes a Predicate expression as its first input, and a list as its second input. It reports a list&#xD;containing those elements of the input list for which the predicate returns true. Notice two things about the&#xD;predicate input: First, it has a grey ring around it. Second, the mod block has an empty input. Keep puts each&#xD;item of its input list, one at a time, into that empty input before evaluating the predicate. (The empty input is&#xD;supposed to remind you of the “box” notation for variables in elementary school: ☐+3=7.) The grey ring is&#xD;part of the keep block as it appears in the palette:&#xD;What the ring means is that this input is a block (a predicate block, in this case, because the interior of the ring is&#xD;a hexagon), rather than the value reported by that block. Here’s the difference:&#xD;Evaluating the = block without a ring reports true or false; evaluating the block with a ring reports the block&#xD;itself. This allows keep to evaluate the = predicate repeatedly, once for each list item. A block that takes&#xD;another block as input is called a higher order block (or higher order procedure, or higher order function).&#xD;50&#xD;Snap! provides four higher order function blocks for operating on lists:&#xD;You’ve already seen keep. Find #rst is similar, but it reports just the first item that satisfies the predicate, not a&#xD;list of all the matching items. It’s equivalent to but faster because it&#xD;stops looking as soon as it finds a match. If there are no matching items, it returns an empty string.&#xD;These examples use small lists, to fit the page, but the higher order blocks work for any size list.&#xD;An empty gray ring represents the identity function, which just reports its input. Leaving the ring in map empty is&#xD;the most concise way to make a shallow copy of a list (that is, in the case of a list of lists, the result is a new&#xD;toplevel list whose items are the same (uncopied) lists that are items of the toplevel input list). To make a deep&#xD;copy of a list (that is, one in which all the sublists, sublists of sublists, etc. are copied), use the list as input to the&#xD;block (one of the variants of the sqrt of block). This works because id of is a hyperblock (page 55).&#xD;The third higher order block, combine, computes a single result from all the items of a list, using a two-input&#xD;reporter as its second input. In practice, there are only a few blocks you’ll ever use with combine:&#xD;( )&#xD;( )&#xD;map&#xD;( )&#xD;( )&#xD;keep&#xD;( )&#xD;combine&#xD;Map takes a Reporter block and a list as inputs. It reports a new list in which each&#xD;item is the value reported by the Reporter block as applied to one item from the&#xD;input list. That’s a mouthful, but an example will make its meaning clear:&#xD;By the way, we’ve been using arithmetic examples, but the list items can be of any&#xD;type, and any reporter can be used. We’ll make the plurals of some words:&#xD;51&#xD;These blocks take the sum of the list items, take their product, string them into one word, combine them into a&#xD;sentence (with spaces between items), see if all items of a list of Booleans are true, see if any of the items is true, find&#xD;the smallest, or find the largest.&#xD;Why + but not −? It only makes sense to combine list items using an associative function: one that doesn’t care in&#xD;what order the items are combined (left to right or right to left). (2+3)+4 = 2+(3+4), but (2−3)−4 ≠ 2−(3−4).&#xD;The functions map, keep, and #nd #rst have an advanced mode with rarely-used features: If their function&#xD;input is given explicit input names (by clicking the arrowhead at the right end of the gray ring; see page 69),&#xD;then it will be called for each list item with three inputs: the item’s value (as usual), the item’s position in the input&#xD;list (its index), and the entire input list. No more than three input names can be used in this contex&#xD;E. Table View vs. List View&#xD;We mentioned earlier that there are two ways of representing lists visually. For one-dimensional lists (lists whose&#xD;items are not themselves lists) the visual differences are small:&#xD;For one-dimensional lists, it’s not really the appearance that’s important. What matters is that the list view allows&#xD;very versatile direct manipulation of the list through the picture: you can edit the individual items, you can&#xD;delete items by clicking the tiny buttons next to each item, and you can add new items at the end by clicking the&#xD;tiny plus sign in the lower left corner. (You can just barely see that the item deletion buttons have minus signs in&#xD;them.) Even if you have several watchers for the same list, all of them will be updated when you change&#xD;anything. On the other hand, this versatility comes at an efficiency cost; a list view watcher for a long list would&#xD;52&#xD;be way too slow. As a partial workaround, the list view can only contain 100 items at a time; the downwardpointing&#xD;arrowhead opens a menu in which you can choose which 100 to display.&#xD;By contrast, because it doesn’t allow direct editing, the table view watcher can hold hundreds of thousands of&#xD;items and still scroll through them efficiently. The table view has flatter graphics for the items to remind you&#xD;that they’re not clickable to edit the values.&#xD;Right-clicking on a list watcher (in either form) gives you the option to switch to the other form. The rightclick&#xD;menu also offers an open in dialog… option that opens an offstage table view watcher, because the watchers&#xD;can take up a lot of stage space that may make it hard to see what your program is actually doing. Once the&#xD;offstage dialog box is open, you can close the stage watcher. There’s an OK button on the offstage dialog to&#xD;close it if you want. Or you can right-click it to make another offstage watcher, which is useful if you want to&#xD;watch two parts of the list at once by having each watcher scrolled to a different place.&#xD;Table view is the default if the list has more than 100 items, or if any of the first ten items of the list are lists, in&#xD;which case it makes a very different-looking two-dimensional picture:&#xD;In this format, the column of red items has been replaced by a spreadsheet-looking display. For short, wide&#xD;lists, this display makes the content of the list very clear. A vertical display, with much of the space taken up by&#xD;the “machinery” at the bottom of each sublist, would make it hard to show all the text at once. (The pedagogic&#xD;cost is that the structure is no longer explicit; we can’t tell just by looking that this is a list of row-lists, rather than&#xD;a list of column-lists or a primitive two-dimensional array type. But you can choose list view to see the&#xD;structure.)&#xD;Beyond such simple cases, in which every item of the main list is a list of the same length, it’s important to keep&#xD;in mind that the design of table view has to satisfy two goals, not always in agreement: (1) a visually compelling&#xD;display of two-dimensional arrays, and (2) highly efficient display generation, so that Snap! can handle very large&#xD;lists, since “big data” is an important topic of study. To meet the first goal perfectly in the case of “ragged right”&#xD;arrays in which sublists can have different lengths, Snap! would scan the entire list to find the maximum width&#xD;before displaying anything, but that would violate the second goal.&#xD;Snap! uses the simplest possible compromise between the two goals: It examines only the first ten items of the&#xD;list to decide on the format. If none of those are lists, or they’re all lists of one item, and the overall length is no&#xD;more than 100, list view is used. If the any of first ten items is a list, then table view is used, and the number of&#xD;columns in the table is equal to the largest number of items among the first ten items (sublists) of the main list.&#xD;Table views open with standard values for the width and height of a cell, regardless of the actual data. You&#xD;can change these values by dragging the column letters or row numbers. Each column has its own width, but&#xD;changing the height of a row changes the height for all rows. (This distinction is based not on the semantics of&#xD;53&#xD;rows vs. columns, but on the fact that a constant row height makes scrolling through a large list more efficient.)&#xD;Shift-dragging a column label will change the width of that column.&#xD;If you tried out the adjustments in the previous paragraph, you may have noticed that a column letter turns&#xD;into a number when you hover over it. Labeling rows and columns differently makes cell references such as&#xD;“cell 4B” unambiguous; you don’t have to have a convention about whether to say the row first or the column&#xD;first. (“Cell B4” is the same as “cell 4B.”) On the other hand, to extract a value from column B in your&#xD;program, you have to say item 2 of, not item B of. So it’s useful to be able to find out a column number by&#xD;hovering over its letter.&#xD;Any value that can appear in a program can be displayed in a table cell:&#xD;This display shows that the standard cell dimensions may not be enough for large value images. By expanding&#xD;the entire speech balloon and then the second column and all the rows, we can make the result fit:&#xD;But we make an exception for cases in which the value in a cell is a list (so that the entire table is threedimensional).&#xD;Because lists are visually very big, we don’t try to fit the entire value in a cell:&#xD;Even if you expand the size of the cells, Snap! will not display sublists of sublists in table view. There are two&#xD;ways to see these inner sublists: You can switch to list view, or you can double-click on a list icon in the table to&#xD;open a dialog box showing just that sub-sub-list in table view.&#xD;One last detail: If the first item of a list is a list (so table view is used), but a later item isn’t a list, that later item&#xD;will be displayed on a red background, like an item of a single-column list:&#xD;So, in particular, if only the first item is a list, the display will look almost like a one-column display.&#xD;54&#xD;Comma-Separated Values&#xD;Spreadsheet and database programs generally offer the option to export their data as CSV (comma-separated&#xD;values lists. You can import these files into Snap! and turn them into tables (lists of lists), and you can export&#xD;tables in CSV format. Snap! recognizes a CSV file by the extension .csv in its filename.&#xD;A CSV file has one line per table row, with the fields separated by commas within a row:&#xD;John,Lennon,rhythm guitar&#xD;Paul,McCartney,bass guitar&#xD;George,Harrison,lead guitar&#xD;Ringo,Starr,drums&#xD;Here’s what the corresponding table looks like:&#xD;Here’s how to read a spreadsheet into Snap!:&#xD;1. Make a variable with a watcher on stage:&#xD;2. Right-click on the watcher and choose the “import” option. (If the variable’s value is already a list, be sure to&#xD;click on the outside border of the watcher; there is a different menu if you click on the list itself.) Select the file&#xD;with your csv data.&#xD;3. There is no 3; that’s it! Snap! will notice that the name of the file you’re importing is something.csv and will&#xD;turn the text into a list of lists automatically.&#xD;Or, even easier, just drag and drop the file from your desktop onto the Snap! window, and Snap! will automatically&#xD;create a variable named after the file and import the data into it.&#xD;If you actually want to import the raw CSV data into a variable, either change the file extension to .txt before&#xD;loading it, or choose “raw data” instead of “import” in the watcher menu.&#xD;If you want to export a list, put a variable watcher containing the list on the stage, right-click its border, and&#xD;choose “Export.” (Don’t right-click an item instead of the border; that gives a different menu.)&#xD;Multi-dimensional lists and JSON&#xD;CSV format is easy to read, but works only for one- or two-dimensional lists. If you have a list of lists of lists,&#xD;Snap! will instead export your list as a JSON (JavaScript Object Notation) file. I modified my list:&#xD;and then exported again, getting this file:&#xD;[["John","Lennon","rhythm guitar"],[["James","Paul"],"McCartney","bass&#xD;guitar"],["George","Harrison","lead guitar"],["Ringo","Starr","drums"]]&#xD;You can also import lists, including tables, from a .json file. (And you can import plain text from a .txt file.)&#xD;Drag and drop works for these formats also.&#xD;table view list view&#xD;55&#xD;F. Hyperblocks&#xD;A scalar is anything other than a list. The name comes from mathematics, where it means a magnitude without&#xD;direction, as opposed to a vector, which points toward somewhere. A scalar function is one whose domain and&#xD;range are scalars, so all the arithmetic operations are scalar functions, but so are the text ones such as le!er and&#xD;the Boolean ones such as not.&#xD;The major new feature in Snap! 6.0 is that the domain and range of most scalar function blocks is extended to&#xD;multi-dimensional lists, with the underlying scalar function applied termwise:&#xD;Mathematicians, note in the last example above that the result is just a termwise application of the underlying&#xD;function (7×3, 8×5, etc.), not matrix multiplication. See Appendix B for that. For a dyadic (two-input) function,&#xD;if the lengths don’t agree, the length of the result (in each dimension) is the length of the shorter input:&#xD;However, if the number of dimensions differs in the two inputs, then the number of dimensions in the result agrees&#xD;with the higher-dimensional input; the lower-dimensional one is used repeatedly in the missing dimension(s):&#xD;(7×6. 8×10, 1×20, 40×6, 20×10, etc.). In particular, a scalar input is paired with every scalar in the other input:&#xD;One important motivation for this feature is how it simplifies and speeds up media computation, as in this&#xD;shifting of the Alonzo costume to be bluer:&#xD;56&#xD;Each pixel of the result has ¾ of its original red and green, and three times its original blue (with its&#xD;transparency unchanged). By putting some sliders on the stage, you can play with colors dynamically:&#xD;There are a few naturally scalar functions that have already had specific meanings when applied to lists and&#xD;therefore are not hyperblocks: = and identical to (because they compare entire structures, not just scalars,&#xD;always reporting a single Boolean result), and and or (because they don’t evaluate their second input at all if the&#xD;first input determines the result), join (because it converts non-scalar (and other non-text) inputs to text string&#xD;form), and is a (type) (because it applies to its input as a whole). Blocks whose inputs are “natively” lists, such as&#xD;and , are never hyperblocks.&#xD;The reshape block takes a list (of any depth) as its first input, and then takes&#xD;zero or more sizes along the dimensions of an array. In the example it will report a table (a matrix) of four rows&#xD;and three columns. If no sizes are given, the result is an empty list. Otherwise, the cells of the specified shape&#xD;are filled with the atomic values from the input list. If more values are needed than provided, the block starts&#xD;again at the head of the list, using values more than once. If more values are provided than needed, the extras&#xD;are ignored; this isn’t an error.&#xD;The item of block has a special set of rules, designed to preserve its pre-hyperblock&#xD;meaning and also provide a useful behavior when given a list as its first (index) input:&#xD;1. If the index is a number, then item of reports the indicated top-level item of the list input; that item&#xD;may be a sublist, in which case the entire sublist is reported (the original meaning of item of):&#xD;2. If the index is a list of numbers (no sublists), then item of reports a list of the indicated top-level items&#xD;(rows, in a matrix; a straightforward hyperization):&#xD;The combinations block takes any number of lists&#xD;as input; it reports a list in which each item is a list whose length is the&#xD;number of inputs; item i of a sublist is an item of input i. Every possible&#xD;combination of items of the inputs is included, so the length of the reported&#xD;list is the product of the lengths of the inputs.&#xD;57&#xD;3. If the index is a list of lists of numbers, then item of reports an array of only those scalars whose&#xD;position in the list input matches the index input in all dimensions (changed in Snap! 6.6!):&#xD;4. If a list of list of numbers includes an empty sublist, then all items are chosen along that dimension:&#xD;To get a column or columns of a spreadsheet, use an empty list in the row selector (changed in Snap! 6.6!):&#xD;The length of block is extended to provide various ways of looking at the shape and contents of a list. The&#xD;options other than length are mainly useful for lists of lists, to any depth. These new options work well with&#xD;hyperblocks and the APL library. (Examples are on the next page.)&#xD;length: reports the number of (toplevel) items in the list, as always.&#xD;rank: reports the number of dimensions of the list, i.e., the maximum depth of lists of lists&#xD;of lists of lists. (That example would be rank 4.)&#xD;dimensions: reports a list of numbers, each of which is the maximum length in one&#xD;dimension, so a spreadsheet of 1000 records, each with 4 fields, would report the list&#xD;[1000 4].&#xD;$a!en: reports a flat, one-dimensional list containing the atomic (non-list) items&#xD;anywhere in the input list.&#xD;columns: reports a list in which the rows and columns of the input list are interchanged,&#xD;so the shape of the transpose of a shape [1000 4] list would be [4 1000]. This option works only for lists&#xD;whose rank is at most 2. The name reflects the fact that the toplevel items of the reported table are the columns&#xD;of the original table.&#xD;reverse: reports a list in which the (toplevel) items of the input list are in reverse order.&#xD;The remaining three options report a (generally multi-line) text string. The input list may not include any&#xD;atomic (non-list) data other than text or numbers. The lines option is intended for use with rank-one lists of text&#xD;strings; it reports a string in which each list item becomes a line of text. You can think of it as the opposite of the&#xD;split by line block. The csv option (comma-separated values) is intended for rank-two lists that represent a&#xD;spreadsheet or other tabular data. Each item of the input list should be a list of atoms; the block reports a text&#xD;string in which each item of the big list becomes a line of text in which the items of that sublist are separated by&#xD;commas. The json option is for lists of any rank; it reports a text string in which the list structure is explicitly&#xD;represented using square brackets. These are the opposites of split by csv and split by json.&#xD;58&#xD;The idea of extending the domain and range of scalar functions to include arrays comes from the language&#xD;APL. (All the great programming languages are based on mathematical ideas. Our primary ancestors are&#xD;Smalltalk, based on models, and Lisp, based on lambda calculus. Prolog, a great language not (so far)&#xD;influencing Snap!, is based on logic. And APL, now joining our family, is based on linear algebra, which studies&#xD;vectors and matrices. Those other programming languages are based on the weaknesses of computer hardware.)&#xD;Hyperblocks are not the whole story about APL, which also has mixed-domain functions and higher order&#xD;functions. Some of what’s missing is provided in the APL library. (See Appendix B.)&#xD;input&#xD;59&#xD;V. Typed Inputs&#xD;A. Scratch’s Type Notation&#xD;Prior to version 3, Scratch block inputs came in two types: Text-or-number type and Number type. The former&#xD;is indicated by a rectangular box, the latter by a rounded box: . A third Scratch type,&#xD;Boolean (true/false), can be used in certain Control blocks with hexagonal slots.&#xD;The Snap! types are an expanded collection including Procedure, List, and Object types. Note that, with the&#xD;exception of Procedure types, all of the input type shapes are just reminders to the user of what the block&#xD;expects; they are not enforced by the language.&#xD;B. The Snap! Input Type Dialog&#xD;In the Block Editor input name dialog, there is a right-facing arrowhead after the “Input name” option:&#xD;Clicking that arrowhead opens the “long” input name dialog:&#xD;There are twelve input type shapes, plus three mutually exclusive modifiers, listed in addition to the basic&#xD;choice between title text and an input name. The default type, the one you get if you don’t choose anything&#xD;60&#xD;else, is “Any,” meaning that this input slot is meant to accept any value of any type. If the size input in your&#xD;block should be an oval-shaped numeric slot rather than a generic rectangle, click “Number.”&#xD;The arrangement of the input types is systematic. As the pictures on this and the next page show, each row of&#xD;types is a category, and parts of each column form a category. Understanding the arrangement will make it a&#xD;little easier to find the type you want.&#xD;The second row of input types contains the ones found in Scratch: Number, Any, and Boolean. (The reason&#xD;these are in the second row rather than the first will become clear when we look at the column arrangement.)&#xD;The first row contains the new Snap! types other than procedures: Object, Text, and List. The last two rows are&#xD;the types related to procedures, discussed more fully below.&#xD;The List type is used for first class lists, discussed in Chapter IV above. The red rectangles inside the input slot&#xD;are meant to resemble the appearance of lists as Snap! displays them on the stage: each element in a red&#xD;rectangle.&#xD;The Object type is for sprites, costumes, sounds, and similar data types.&#xD;The Text type is really just a variant form of the Any type, using a shape that suggests a text input.1&#xD;Procedure Types&#xD;Although the procedure types are discussed more fully later, they are the key to understanding the column&#xD;arrangement in the input types. Like Scratch, Snap! has three block shapes: jigsaw-piece for command blocks,&#xD;oval for reporters, and hexagonal for predicates. (A predicate is a reporter that always reports true or false.) In&#xD;Snap! these blocks are first class data; an input to a block can be of Command type, Reporter type, or Predicate&#xD;type. Each of these types is directly below the type of value that that kind of block reports, except for&#xD;Commands, which don’t report a value at all. Thus, oval Reporters are related to the Any type, while&#xD;hexagonal Predicates are related to the Boolean (true or false) type.&#xD;1 In Scratch, every block that takes a Text-type input has a default value that makes the rectangles for text wider than tall. The blocks&#xD;that aren’t specifically about text either are of Number type or have no default value, so those rectangles are taller than wide. At first&#xD;some of us (bh) thought that Text was a separate type that always had a wide input slot; it turns out that this isn’t true in Scratch (delete&#xD;the default text and the rectangle narrows), but we thought it a good idea anyway, so we allow Text-shaped boxes even for empty input&#xD;slots. (This is why Text comes just above Any in the input type selection box.)&#xD;61&#xD;The unevaluated procedure types in the fourth row are explained in Section VI.E below. In one handwavy&#xD;sentence, they combine the meaning of the procedure types with the appearance of the reported value types two&#xD;rows higher. (Of course, this isn’t quite right for the C-shaped command input type, since commands don’t&#xD;report values. But you’ll see later that it’s true in spirit.)&#xD;Pulldown inputs&#xD;Certain primitive blocks have pulldown inputs, either read-only, like the input to the touching block:&#xD;(indicated by the input slot being the same (cyan, in this case) color as the body of the block), or writeable, like the&#xD;input to the point in direction block:&#xD;(indicated by the white input slot), which means that the user can type in an arbitrary input instead of using the&#xD;pulldown menu.&#xD;Custom blocks can also have such inputs. To make a pulldown input, open the long form input dialog, choose&#xD;a text type (Any, Text, or Number) and click the icon in the bottom right corner, or control/right-click in the&#xD;dialog. You will see this menu:&#xD;62&#xD;Click the read-only checkbox if you want a read-only pulldown input. Then from the same menu, choose&#xD;options… to get this dialog box:&#xD;Each line in the text box represents one menu item. If the line does not contain any of the characters =&#126;{}&#xD;then the text is both what’s shown in the menu and the value of the input if that entry is chosen.&#xD;If the line contains an equal sign =, then the text to the left of the equal sign is shown in the menu, and the text&#xD;to the right is what appears in the input slot if that entry is chosen, and is also the value of the input as seen by&#xD;the procedure.&#xD;If the line consists of a tilde &#126;, then it represents a separator (a horizontal line) in the menu, used to divide long&#xD;menus into visible categories. There should be nothing else on the line. This separator is not choosable, so&#xD;there is no input value corresponding to it.&#xD;If the line ends with the two characters equal sign and open brace ={, then it represents a submenu. The text&#xD;before the equal sign is a name for the submenu, and will be displayed in the menu with an arrowhead ► at the&#xD;end of the line. This line is not clickable, but hovering the mouse over it displays the submenu next to the&#xD;original menu. A line containing a close brace } ends the submenu; nothing else should be on that line.&#xD;Submenus may be nested to arbitrary depth.&#xD;Alternatively, instead of giving a menu listing as described above, you can put a JavaScript function that&#xD;returns the desired menu in the textbox. This is an experimental feature and requires that JavaScript be&#xD;enabled in the Settings menu.&#xD;63&#xD;It is also possible to get the special menus used in some primitive blocks, by choosing from the menu submenu:&#xD;broadcast messages, sprites and stage, costumes, sounds, variables that can be set in this scope, the play note&#xD;piano keyboard, or the point in direction 360° dial. Finally, you can make the input box accept more than one&#xD;line of text (that is, text including a newline character) from the special submenu, either “multi-line” for regular&#xD;text or “code” for monospace-font computer code.&#xD;If the input type is something other than text, then clicking the button will instead show this menu:&#xD;As an example, we want to make this block: The second input must be a read-only&#xD;object menu:&#xD;The “Multiple inputs” option: The list block introduced earlier accepts any number of inputs to specify the&#xD;items of the new list. To allow this, Snap! introduces the arrowhead notation (34) that expands and contracts&#xD;the block, adding and removing input slots. (Shift-clicking on an arrowhead adds or removes three input slots at&#xD;once.) Custom blocks made by the Snap! user have that capability, too. If you choose the “Multiple inputs”&#xD;button, then arrowheads will appear after the input slot in the block. More or fewer slots (as few as zero) may be&#xD;used. When the block runs, all of the values in all of the slots for this input name are collected into a list, and the&#xD;value of the input as seen inside the script is that list of values:&#xD;The ellipsis (…) in the orange input slot name box in the prototype indicates a multiple or variadic input.&#xD;The third category, “Upvar - make internal variable visible to caller,” isn’t really an input at all, but rather a&#xD;sort of output from the block to its user. It appears as an orange variable oval in the block, rather than as an&#xD;input slot. Here’s an example; the uparrow (↑) in the prototype indicates this kind of internal variable name:&#xD;Input variants&#xD;We now turn to the three mutually exclusive options that&#xD;come below the type array.&#xD;The “single input” option: In Scratch, all inputs are in this category. There is one input slot in&#xD;the block as it appears in its palette. If a single input is of type Any, Number, Text, or Boolean,&#xD;then you can specify a default value that will be shown in that slot in the palette, like the “10” in&#xD;steps block. In the prototype block at the top of the the move (10) steps block. In the prototype block input at the top of sthcrei psct riinp tt hine Bthleo cBkl oecdkit oErd, iatonr , an input with&#xD;name “size” and default value 10 looks like this:&#xD;64&#xD;The variable i (in the block on the right above) can be dragged from the for block into the blocks used in its Cshaped&#xD;command slot. Also, by clicking on the orange i, the user can change the name of the variable as seen in&#xD;the calling script (although the name hasn’t changed inside the block’s definition). This kind of variable is called&#xD;an upvar for short, because it is passed upward from the custom block to the script that uses it.&#xD;Note about the example: for is a primitive block, but it doesn’t need to be. You’re about to see (next chapter)&#xD;how it can be written in Snap!. Just give it a different name to avoid confusion, such as my for as above.&#xD;Prototype Hints&#xD;We have mentioned three notations that can appear in an input slot in the prototype to remind you of what&#xD;kind of input this is. Here is the complete list of such notations:&#xD;= default value … multiple input ↑ upvar # number&#xD;λ procedure types ⫶ list ? Boolean object ¶ multi-line text&#xD;Title Text and Symbols&#xD;Some primitive blocks have symbols as part of the block name: . Custom blocks&#xD;can use symbols too. In the Block Editor, click the plus sign in the prototype at the point where&#xD;you want to insert the symbol. Then click the title text picture below the text box that’s expecting&#xD;an input slot name. The dialog will then change to look like this:&#xD;The important part to notice is the arrowhead that has appeared at the right end of the text box.&#xD;Click it to see the menu shown here at the left.&#xD;Choose one of the symbols. The result will have the symbol you want: The&#xD;available symbols are, pretty much, the ones that are used in Snap! icons.&#xD;But I’d like the arrow symbol bigger, and yellow, so I edit its name:&#xD;This makes the symbol 1.5 times as big as the letters in the block text, using a color with redgreen-&#xD;blue values of 255-255-150 (each between 0 and 255). Here’s the result:&#xD;The size and color controls can also be used with text: $foo-8-255-120-0&#xD;will make a huge orange “foo.”&#xD;Note the last entry in the symbol menu: “new line.” This can be used in a block with many inputs to control&#xD;where the text continues on another line, instead of letting Snap! choose the line break itself.&#xD;➜&#xD;65&#xD;VI. Procedures as Data&#xD;A. Call and Run&#xD;In the for block example above, the input named action has been declared as type “Command (C-shaped)”;&#xD;that’s why the finished block is C-shaped. But how does the block actually tell Snap! to carry out the commands&#xD;inside the C-slot? Here is a simple version of the block script:&#xD;This is simplified because it assumes, without checking, that the ending value is greater than the starting value; if&#xD;not, the block should (depending on the designer’s purposes) either not run at all, or change the variable by −1&#xD;for each repetition instead of by 1.&#xD;The important part of this script is the run block near the end. This is a Snap! built-in command block that&#xD;takes a Command-type value (a script) as its input, and carries out its instructions. (In this example, the value of&#xD;the input is the script that the user puts in the C-slot of the my for block.) There is a similar call reporter&#xD;block for invoking a Reporter or Predicate block. The call and run blocks are at the heart of Snap!’s first class&#xD;procedure feature; they allow scripts and blocks to be used as data—in this example, as an input to a block—&#xD;and eventually carried out under control of the user’s program.&#xD;Here’s another example, this time using a Reporter-type input in a map block (see page 50):&#xD;Here we are calling the Reporter “multiply by 10” three times, once with each item of the given list as its input,&#xD;and collecting the results as a list. (The reported list will always be the same length as the input list.) Note that&#xD;the multiplication block has two inputs, but here we have specified a particular value for one of them (10), so the&#xD;call block knows to use the input value given to it just to fill the other (empty) input slot in the multiplication&#xD;block. In the my map definition, the input function is declared to be type Reporter, and data is of type List.&#xD;Call/Run with inputs&#xD;The call block (like the run block) has a right arrowhead at the end; clicking on it adds the phrase “with inputs”&#xD;and then a slot into which an input can be inserted:&#xD;66&#xD;If the left arrowhead is used to remove the last input slot, the “with inputs” disappears also. The right&#xD;arrowhead can be clicked as many times as needed for the number of inputs required by the reporter block&#xD;being called.&#xD;If the number of inputs given to call (not counting the Reporter-type input that comes first) is the same as the&#xD;number of empty input slots, then the empty slots are filled from left to right with the given input values. If call&#xD;is given exactly one input, then every empty input slot of the called block is filled with the same value:&#xD;If the number of inputs provided is neither one nor the number of empty slots, then there is no automatic filling&#xD;of empty slots. (Instead you must use explicit parameters in the ring, as discussed in Section C below.)&#xD;An even more important thing to notice about these examples is the ring around the Reporter-type input slots&#xD;in call and map above. This notation indicates that the block itself, not the number or other value that the block&#xD;would report when called, is the input. If you want to use a block itself in a non-Reporter-type (e.g., Any-type)&#xD;input slot, you can enclose it explicitly in a ring, found at the top of the Operators palette.&#xD;As a shortcut, if you right-click or control-click on a block (such as the + block in this example), one of the&#xD;choices in the menu that appears is “ringify” and/or “unringify.” The ring indicating a Reporter-type or&#xD;Predicate-type input slot is essentially the same idea for reporters as the C-shaped input slot with which you’re&#xD;already familiar; with a C-shaped slot, it’s the script you put in the slot that becomes the input to the C-shaped&#xD;block.&#xD;There are three ring shapes. All are oval on the outside, indicating that the ring reports a value, the block or&#xD;script inside it, but the inside shapes are command, reporter, or predicate, indicating what kind of block or script&#xD;is expected. Sometimes you want to put something more complicated than a single reporter inside a reporter&#xD;ring; if so, you can use a script, but the script must report a value, as in a custom reporter definition.&#xD;Variables in Ring Slots&#xD;Note that the run block in the definition of the my for block (page 65) doesn’t have a ring around its input&#xD;variable action. When you drag a variable into a ringed input slot, you generally do want to use the value of the&#xD;variable, which will be the block or script you’re trying to run or call, rather than the orange variable reporter&#xD;itself. So Snap! automatically removes the ring in this case. If you ever do want to use the variable block itself,&#xD;rather than the value of the variable, as a Procedure-type input, you can drag the variable into the input slot,&#xD;then control-click or right-click it and choose “ringify” from the menu that appears. (Similarly, if you ever want&#xD;to call a function that will report a block to use as the input, such as item 1 of applied to a list of blocks, you can&#xD;choose “unringify” from the menu. Almost all the time, though, Snap! does what you mean without help.)&#xD;B. Writing Higher Order Procedures&#xD;A higher order procedure is one that takes another procedure as an input, or that reports a procedure. In this&#xD;document, the word “procedure” encompasses scripts, individual blocks, and nested reporters. (Unless specified&#xD;otherwise, “reporter” includes predicates. When the word is capitalized inside a sentence, it means specifically&#xD;oval-shaped blocks. So, “nested reporters” includes predicates, but “a Reporter-type input” doesn’t.)&#xD;Although an Any-type input slot (what you get if you use the small input-name dialog box) will accept a&#xD;procedure input, it doesn’t automatically ring the input as described above. So the declaration of Proceduretype&#xD;inputs makes the use of your custom higher order block much more convenient.&#xD;67&#xD;Why would you want a block to take a procedure as input? This is actually not an obscure thing to do; the&#xD;primitive conditional and looping blocks (the C-shaped ones in the Control palette) take a script as input. Users&#xD;just don’t usually think about it in those terms! We could write the repeat block as a custom block this way, if&#xD;Snap! didn’t already have one:&#xD;The lambda (λ) next to action in the prototype indicates that this is a C-shaped block, and that the script&#xD;enclosed by the C when the block is used is the input named action in the body of the script. The only way to&#xD;make sense of the variable action is to understand that its value is a script.&#xD;To declare an input to be Procedure-type, open the input name dialog as usual, and click on the arrowhead:&#xD;Then, in the long dialog, choose the appropriate Procedure type. The third row of input types has a ring in the&#xD;shape of each block type (jigsaw for Commands, oval for Reporters, and hexagonal for Predicates). In practice,&#xD;though, in the case of Commands it’s more common to choose the C-shaped slot on the fourth row, because this&#xD;“container” for command scripts is familiar to Scratch users. Technically the C-shaped slot is an unevaluated&#xD;procedure type, something discussed in Section E below. The two Command-related input types (inline and Cshaped)&#xD;are connected by the fact that if a variable, an item (#) of [list] block, or a custom Reporter block is&#xD;dropped onto a C-shaped slot of a custom block, it turns into an inline slot, as in the repeater block’s recursive&#xD;call above. (Other built-in Reporters can’t report scripts, so they aren’t accepted in a C-shaped slot.)&#xD;68&#xD;Why would you ever choose an inline Command slot rather than a C shape? Other than the run block&#xD;discussed below, the only case I can think of is something like the C/C++/Java for loop, which actually has three&#xD;command script inputs (and one predicate input), only one of which is the “featured” loop body:&#xD;Okay, now that we have procedures as inputs to our blocks, how do we use them? We use the blocks run (for&#xD;commands) and call (for reporters). The run block’s script input is an inline ring, not C-shaped, because we&#xD;anticipate that it will be rare to use a specific, literal script as the input. Instead, the input will generally be a&#xD;variable whose value is a script.&#xD;The run and call blocks have arrowheads at the end that can be used to open slots for inputs to the called&#xD;procedures. How does Snap! know where to use those inputs? If the called procedure (block or script) has empty&#xD;input slots, Snap! “does the right thing.” This has several possible meanings:&#xD;1. If the number of empty slots is exactly equal to the number of inputs provided, then Snap! fills the empty slots&#xD;from left to right:&#xD;2. If exactly one input is provided, Snap! will fill any number of empty slots with it:&#xD;3. Otherwise, Snap! won’t fill any slots, because the user’s intention is unclear.&#xD;If the user wants to override these rules, the solution is to use a ring with explicit input names that can be put&#xD;into the given block or script to indicate how inputs are to be used. This will be discussed more fully below.&#xD;Recursive Calls to Multiple-Input Blocks&#xD;A relatively rare situation not yet considered here is the case of a recursive block that has a variable number of&#xD;inputs. Let’s say the user of your project calls your block with five inputs one time, and 87 inputs another time.&#xD;How do you write the recursive call to your block when you don’t know how many inputs to give it? The&#xD;answer is that you collect the inputs in a list (recall that, when you declare an input name to represent a variable&#xD;number of inputs, your block sees those inputs as a list of values in the first place), and then, in the recursive call,&#xD;you drop that input list onto the arrowheads that indicate a variable-input slot, rather than onto the input slot:&#xD;69&#xD;Note that the halo you see while dragging onto the arrowheads is red instead of white, and covers the input slot&#xD;as well as the arrowheads. And when you drop the expression onto the arrowheads, the words “input list:” are&#xD;added to the block text and the arrowheads disappear (in this invocation only) to remind you that the list&#xD;represents all of the multiple inputs, not just a single input. The items in the list are taken individually as inputs to&#xD;the script. Since numbers is a list of numbers, each individual item is a number, just what sizes wants. This&#xD;block will take any number of numbers as inputs, and will make the sprite grow and shrink accordingly:&#xD;The user of this block calls it with any number of individual numbers as inputs. But inside the definition of the&#xD;block, all of those numbers form a list that has a single input name, numbers. This recursive definition first&#xD;checks to make sure there are any inputs at all. If so, it processes the first input (item 1 of the list), then it wants&#xD;to make a recursive call with all but the first number. But sizes doesn’t take a list as input; it takes numbers as&#xD;inputs! So this would be wrong:&#xD;C. Formal Parameters&#xD;The rings around Procedure-type inputs have an arrowhead at the right. Clicking the arrowhead allows you&#xD;to give the inputs to a block or script explicit names, instead of using empty input slots as we’ve done until now.&#xD;The names #1, #2, etc. are provided by default, but you can change a name by clicking on its orange oval in&#xD;the input names list. Be careful not to drag the oval when clicking; that’s how you use the input inside the ring.&#xD;The names of the input variables are called the formal parameters of the encapsulated procedure.&#xD;Here’s a simple but contrived example using explicit names to control which input goes where inside the ring:&#xD;Here we just want to put one of the inputs into two different slots. If we left all three slots empty, Snap! would&#xD;not fill any of them, because the number of inputs provided (2) would not match the number of empty slots (3).&#xD;70&#xD;Here is a more realistic, much more advanced example:&#xD;This is the definition of a block that takes any number of lists, and reports the list of all possible combinations of&#xD;one item from each list. The important part for this discussion is that near the bottom there are two nested calls&#xD;to map, the higher order function that applies an input function to each item of an input list. In the inner block,&#xD;the function being mapped is in front of, and that block takes two inputs. The second, the empty List-type slot,&#xD;will get its value in each call from an item of the inner map’s list input. But there is no way for the outer map to&#xD;communicate values to empty slots of the in front of block. We must give an explicit name, newitem, to the&#xD;value that the outer map is giving to the inner one, then drag that variable into the in front of block.&#xD;By the way, once the called block provides names for its inputs, Snap! will not automatically fill empty slots, on&#xD;the theory that the user has taken control. In fact, that’s another reason you might want to name the inputs&#xD;explicitly: to stop Snap! from filling a slot that should really remain empty.&#xD;D. Procedures as Data&#xD;Here’s an example of a situation in which a procedure must be explicitly marked as data by pulling a ring from&#xD;the Operators palette and putting the procedure (block or script) inside it:&#xD;Here, we are making a list of procedures. But the list block accepts inputs of any type, so its input slots are not&#xD;ringed. We must say explicitly that we want the block itself as the input, rather than whatever value would result&#xD;from evaluating the block.&#xD;71&#xD;Besides the list block in the example above, other blocks into which you may want to put procedures are set&#xD;(to set the value of a variable to a procedure), say and think (to display a procedure to the user), and report (for&#xD;a reporter that reports a procedure):&#xD;E. Special Forms&#xD;The primitive if else block has two C-shaped command slots and chooses one or the other depending on a&#xD;Boolean test. Because Scratch doesn’t emphasize functional programming, it lacks a corresponding reporter&#xD;block to choose between two expressions. Snap! has one, but we could write our own:&#xD;Our block works for these simple examples, but if we try to use it in writing a recursive operator, it’ll fail:&#xD;The problem is that when any block is called, all of its inputs are computed (evaluated) before the block itself&#xD;runs. The block itself knows only the values of its inputs, not what expressions were used to compute them. In&#xD;particular, all of the inputs to our if then else block are evaluated first thing. That means that even in the base&#xD;case, factorial will try to call itself recursively, causing an infinite loop. We need our if then else block to be&#xD;able to select only one of the two alternatives to be evaluated.&#xD;We have a mechanism to allow that: declare the then and else inputs to be of type Reporter rather than type&#xD;Any. Then, when calling the block, those inputs will be enclosed in a ring so that the expressions themselves,&#xD;rather than their values, become the inputs:&#xD;In this version, the program works, with no infinite loop. But we’ve paid a heavy price: this reporter-if is no&#xD;longer as intuitively obvious as the Scratch command-if. You have to know about procedures as data, about&#xD;rings, and about a trick to get a constant value in a ringed slot. (The id block implements the identity function,&#xD;72&#xD;which reports its input.1 We need it because rings take only reporters as input, not numbers.) What we’d like is&#xD;a reporter-if that behaves like this one, delaying the evaluation of its inputs, but looks like our first version, which&#xD;was easy to use except that it didn’t work.&#xD;Such blocks are indeed possible. A block that seems to take a simple expression as input, but delays the&#xD;evaluation of that input by wrapping an “invisible ring” around it (and, if necessary, an id-like transformation of&#xD;constant data into constant functions) is called a special form. To turn our if block into a special form, we edit the&#xD;block’s prototype, declaring the inputs yes and no to be of type “Any (unevaluated)” instead of type Reporter.&#xD;The script for the block is still that of the second version, including the use of call to evaluate either yes or no&#xD;but not both. But the slots appear as white Any-type rectangles, not Reporter-type rings, and the factorial&#xD;block will look like our first attempt.&#xD;In a special form’s prototype, the unevaluated input slot(s) are indicated by a lambda (λ) next to the input&#xD;name, just as if they were declared as Procedure type. They are Procedure type, really; they’re just disguised to&#xD;the user of the block.&#xD;Special forms trade off implementor sophistication for user sophistication. That is, you have to understand all&#xD;about procedures as data to make sense of the special form implementation of my if then else. But any&#xD;experienced Scratch programmer can use my if then else without thinking at all about how it works internally.&#xD;Special Forms in Scratch&#xD;Special forms are actually not a new invention in Snap!. Many of Scratch’s conditional and looping blocks are&#xD;really special forms. The hexagonal input slot in the if block is a straightforward Boolean value, because the&#xD;value can be computed once, before the if block makes its decision about whether or not to run its action input.&#xD;But the forever if, repeat until, and wait until blocks’ inputs can’t be Booleans; they have to be of type “Boolean&#xD;(unevaluated),” so that Scratch can evaluate them over and over again. Since Scratch doesn’t have custom&#xD;C-shaped blocks, it can afford to handwave away the distinction between evaluated and unevaluated Booleans,&#xD;but Snap! can’t. The pedagogic value of special forms is proven by the fact that no Scratcher ever notices that&#xD;there’s anything strange about the way in which the hexagonal inputs in the Control blocks are evaluated.&#xD;Also, the C-shaped slot familiar to Scratch users is an unevaluated procedure type; you don’t have to use a ring&#xD;to keep the commands in the C-slot from being run before the C-shaped block is run. Those commands&#xD;themselves, not the result of running them, are the input to the C-shaped Control block. (This is taken for&#xD;granted by Scratch users, especially because Scratchers don’t think of the contents of a C-slot as an input at all.)&#xD;This is why it makes sense that “C-shaped” is on the fourth row of types in the long form input dialog, with&#xD;other unevaluated types.&#xD;1 There is a primitive id function in the menu of the sqrt of block, but we think seeing its (very simple) implementation will make this&#xD;example easier to understand.&#xD;73VII. Object Oriented Programming with Sprites&#xD;Object oriented programming is a style based around the abstraction object: a collection of data and methods&#xD;(procedures, which from our point of view are just more data) that you interact with by sending it a message (just&#xD;a name, maybe in the form of a text string, and perhaps additional inputs). The object responds to the message&#xD;by carrying out a method, which may or may not report a value back to the asker. Some people emphasize the&#xD;data hiding aspect of OOP (because each object has local variables that other objects can access only by sending&#xD;request messages to the owning object) while others emphasize the simulation aspect (in which each object&#xD;abstractly represents something in the world, and the interactions of objects in the program model real&#xD;interactions of real people or things). Data hiding is important for large multi-programmer industrial projects,&#xD;but for Snap! users it’s the simulation aspect that’s important. Our approach is therefore less restrictive than that&#xD;of some other OOP languages; we give objects easy access to each others’ data and methods.&#xD;Technically, object oriented programming rests on three legs: (1) Message passing: There is a notation by which&#xD;any object can send a message to another object. (2) Local state: Each object can remember the important past&#xD;history of the computation it has performed. (“Important” means that it need not remember every message it&#xD;has handled, but only the lasting effects of those messages that will affect later computation.) (3) Inheritance: It&#xD;would be impractical if each individual object had to contain methods, many of them identical to those of other&#xD;objects, for all of the messages it can accept. Instead, we need a way to say that this new object is just like that&#xD;old object except for a few differences, so that only those differences need be programmed explicitly.&#xD;A. First Class Sprites&#xD;Like Scratch, Snap! comes with things that are natural objects: its sprites. Each sprite can own local variables;&#xD;each sprite has its own scripts (methods). A Scratch animation is plainly a simulation of the interaction of&#xD;characters in a play. There are two ways in which Scratch sprites are less versatile than the objects of an OOP&#xD;language. First, Scratch message passing is weak in three respects: Messages can only be broadcast, not&#xD;addressed to an individual sprite; messages can’t take inputs; and methods can’t return values to their caller.&#xD;Second, and more basic, in the OOP paradigm objects are data; they can be the value of a variable, an element&#xD;of a list, and so on, but that’s not the case for Scratch sprites.&#xD;Snap! sprites are first class data. They can be created and deleted by a script, stored in a variable or list, and&#xD;sent messages individually. The children of a sprite can inherit sprite-local variables, methods (sprite-local&#xD;procedures), and other attributes (e.g., x position).&#xD;The fundamental means by which programs get access to sprites is the my reporter block. It has a dropdownmenu&#xD;input slot that, when clicked, gives access to all the sprites, plus the stage. reports a single sprite,&#xD;the one asking the question. r e p o rts a list of all sprites other than the one asking the question.&#xD;reports a list of all sprites that are near the one asking—the ones that are candidates for having&#xD;collided with this one, for example. The my block has many other options, discussed below. If you know the&#xD;name of a particular sprite, the object reporter will report the sprite itself.&#xD;An object or list of objects reported by my or object can be used as input to any block that accepts any input&#xD;type, such as set’s second input. If you say an object, the resulting speech balloon will contain a smaller image&#xD;of the object’s costume or (for the stage) background.&#xD;74&#xD;B. Permanent and Temporary Clones&#xD;The b l o c k i s u s e d to create and report an instance (a clone) of any sprite. (There is also a&#xD;command version, for historical reasons.) There are two different kinds of situations in which clones are used.&#xD;One is that you’ve made an example sprite and, when you start the project, you want a fairly large number of&#xD;essentially identical sprites that behave like the example. (Hereafter we’ll call the example sprite the “parent”&#xD;and the others the “children.”) Once the game or animation is over, you don’t need the copies any more. (As&#xD;we’ll see, “copies” is the wrong word because the parent and the children share a lot of properties. That’s why&#xD;we use the word “clones” to describe the children rather than “copies.”) These are temporary clones. They&#xD;are automatically deleted when the user presses either the green flag or the red stop sign. In Scratch 2.0 and&#xD;later, all clones are temporary.&#xD;The other kind of situation is what happens when you want specializations of sprites. For example, let’s say&#xD;you have a sprite named Dog. It has certain behaviors, such as running up to a person who comes near it. Now&#xD;you decide that the family in your story really likes dogs, so they adopt a lot of them. Some are cocker spaniels,&#xD;who wag their tails when they see you. Others are rottweilers, who growl at you when they see you. So you&#xD;make a clone of Dog, perhaps rename it Cocker Spaniel, and give it a new costume and a script for what to do&#xD;when someone gets near. You make another clone of Dog, perhaps rename it Rottweiler, and give it a new&#xD;costume, etc. Then you make three clones of Cocker Spaniel (so there are four altogether) and two clones of&#xD;Rottweiler. Maybe you hide the Dog sprite after all this, since it’s no breed in particular. Each dog has its own&#xD;position, special behaviors, and so on. You want to save all of these dogs in the project. These are permanent&#xD;clones. In BYOB 3.1, the predecessor to Snap!, all clones are permanent.&#xD;One advantage of temporary clones is that they don’t slow down Snap! even when you have a lot of them. (If&#xD;you’re curious, one reason is that permanent clones appear in the sprite corral, where their pictures have to be&#xD;updated to reflect the clone’s current costume, direction, and so on.) We have tried to anticipate your needs, as&#xD;follows: When you make a clone in a script, using the b l o c k , i t i s “born” temporary. But&#xD;when you make a clone from the user interface, for example by right-clicking on a sprite and choosing “clone,”&#xD;it is born permanent. The reason this makes sense is that you don’t create 100 kinds of dogs automatically. Each&#xD;kind has many different characteristics, programmed by hand. But when your project is running, it might&#xD;create 100 rottweilers, and those will be identical unless you change them in the program.&#xD;You can change a temporary sprite to permanent by right-clicking it and choosing “edit.” (It’s called “edit”&#xD;rather than, say, “permanent” because it also shifts the scripting area to reflect that sprite, as if you’d pressed its&#xD;button in the sprite corral.) You can change a permanent sprite to temporary by right-clicking it and choosing&#xD;“release.” You can also change the status of a clone in your program with with true or&#xD;false as the second input.&#xD;C. Sending Messages to Sprites&#xD;The messages that a sprite accepts are the blocks in its palettes, including both all-sprites and this-sprite-only&#xD;blocks. (For custom blocks, the corresponding methods are the scripts as seen in the Block Editor.&#xD;The way to send a message to a sprite (or the stage) is with the tell block (for command messages) or the ask&#xD;block (for reporter messages).&#xD;75&#xD;A small point to note in the examples above: all dropdown menus include an empty entry at the top, which&#xD;can be selected for use in higher order procedures like the for each and map examples. Each of the sprites in my&#xD;neighbors or my other sprites is used to fill the blank space in turn.&#xD;By the way, if you want a list of all the sprites, including this sprite, you can use either of these:&#xD;Tell and ask wait until the other sprite has carried out its method before this sprite’s script continues. (That&#xD;has to be the case for ask, since we want to do something with the value it reports.) So tell is analogous to&#xD;broadcast and wait. Sometimes the other sprite’s method may take a long time, or may even be a forever loop,&#xD;so you want the originating script to continue without waiting. For this purpose we have the launch block:&#xD;Launch is analogous to broadcast without the “wait.”&#xD;Snap! 4.1, following BYOB 3.1, used an extension of the of block to provide access to other sprites’ methods.&#xD;That interface was designed back when we were trying hard to avoid adding new primitive blocks; it allowed us&#xD;to write ask and tell as tool procedures in Snap! itself. That technique still works, but is deprecated, because&#xD;nobody understood it, and now we have the more straightforward primitives.&#xD;Polymorphism&#xD;Suppose you have a Dog sprite with two clones CockerSpaniel and PitBull. In the Dog sprite you define this&#xD;method (“For this sprite only” block):&#xD;Note the location (map-pin) symbol before the block’s name. The symbol is not part of the block title; it’s a&#xD;visual reminder that this is a sprite-local block. Sprite-local variables are similarly marked.&#xD;But you don’t define greet as friend or greet as enemy in Dog. Each kind of dog has a different behavior.&#xD;Here’s what a CockerSpaniel does:&#xD;And here’s what a PitBull does:&#xD;76&#xD;Greet is defined in the Dog sprite. If Fido is a particular cocker spaniel, and you ask Fido to greet someone,&#xD;Fido inherits the greet method from Dog, but Dog itself couldn’t actually run that method, because Dog doesn’t&#xD;have greet as friend or greet as enemy. And perhaps only individual dogs such as Fido have friend? methods.&#xD;Even though the greet method is defined in the Dog sprite, when it’s running it remembers what specific dog&#xD;sprite called it, so it knows which greet as friend to use. Dog’s greet block is called a polymorphic method,&#xD;because it means different things to different dogs, even though they all share the same script.&#xD;D. Local State in Sprites: Variables and Attributes&#xD;A sprite’s memory of its own past history takes two main forms. It has variables, created explicitly by the user&#xD;with the “Make a variable” button; it also has attributes, the qualities every sprite has automatically, such as&#xD;position, direction, and pen color. Each variable can be examined using its own orange oval block; there is one&#xD;set block to modify all variables. Attributes, however, have a less uniform programming interface in Scratch:&#xD;● A sprite’s direction can be examined with the direction block, and modified with the point in direction block. It can also be&#xD;modified less directly using the blocks turn, point towards, and if on edge, bounce.&#xD;● There is no way for a script to examine a sprite’s pen color, but there are blocks set pen color to &lt;color&gt;, set pen color to&#xD;&lt;number&gt;, and change pen color to modify it.&#xD;● A sprite’s name can be neither examined nor modified by scripts; it can be modified by typing a new name directly into the&#xD;box that displays the name, above the scripting area.&#xD;The block, if any, that examines a variable or attribute is called its getter; a block (there may be more than one, as&#xD;in the direction example above) that modifies a variable or attribute is called a setter.&#xD;In Snap! we allow virtually all attributes to be examined. But instead of&#xD;adding dozens of reporters, we use a more uniform interface for attributes:&#xD;The my block’s menu (in Sensing; see page 78) includes many of the&#xD;attributes of a sprite. It serves as a general getter for those attributes, e.g.,&#xD;my [anchor] to find the sprite, if any, to which this sprite is attached in a&#xD;nesting arrangement (see page 10). Similarly, the same set block used to&#xD;set variable values allows setting some sprite attributes.&#xD;E. Prototyping: Parents and Children&#xD;Most current OOP languages use a class/instance approach to creating objects. A class is a particular kind of object,&#xD;and an instance is an actual object of that type. For example, there might be a Dog class, and several instances&#xD;Fido, Spot, and Runt. The class typically specifies the methods shared by all dogs (RollOver, SitUpAndBeg,&#xD;Fetch, and so on), and the instances contain data such as species, color, and friendliness. Snap! uses a different&#xD;approach called prototyping, in which there is no distinction between classes and instances. Prototyping is better&#xD;suited to an experimental, tinkering style of work: You make a single dog sprite, with both methods (blocks) and&#xD;data (variables); you can actually watch it and interact with it on the stage; and when you like it, you use it as the&#xD;prototype from which to clone other dogs. If you later discover a bug in the behavior of dogs, you can edit a&#xD;method in the parent, and all of the children will automatically share the new version of the method block.&#xD;Experienced class/instance programmers may find prototyping strange at first, but it is actually a more&#xD;expressive system, because you can easily simulate a class/instance hierarchy by hiding the prototype sprite!&#xD;77&#xD;Prototyping is also a better fit with the Scratch design principle that everything in a project should be concrete&#xD;and visible on the stage; in class/instance OOP the programming process begins with an abstract, invisible&#xD;entity, the class, that must be designed before any concrete objects can be made.1&#xD;There are three ways to make a child sprite. If you control-click or right-click on a sprite in the “sprite corral”&#xD;at the bottom right corner of the window, you get a menu that includes “clone” as one of the choices. There is&#xD;an a new clone of block in the Control palette that creates and reports a child sprite. And sprites have a&#xD;“parent” attribute that can be set, like any attribute, thereby changing the parent of an existing sprite.&#xD;F. Inheritance by Delegation&#xD;A clone inherits properties of its parent. “Properties” include scripts, custom blocks, variables, named lists,&#xD;system attributes, costumes, and sounds. Each individual property can be shared between parent and child, or&#xD;not shared (with a separate one in the child). The getter block for a shared property, in the child’s palette, is&#xD;displayed in a lighter color; separate properties of the child are displayed in the traditional colors.&#xD;When a new clone is created, by default it shares only its methods, wardrobe, and jukebox with its parent. All&#xD;other properties are copied to the clone, but not shared. (One exception is that a new permanent clone is given a&#xD;random position. Another is that temporary clones share the scripts in their parent’s scripting area. A third is that&#xD;sprite-local variables that the parent creates after cloning are shared with its children.) If the value of a shared&#xD;property is changed in the parent, then the children see the new value. If the value of a shared property is&#xD;changed in the child, then the sharing link is broken, and a new private version is created in that child. (This is&#xD;the mechanism by which a child chooses not to share a property with its parent.) “Changed” in this context&#xD;means using the set or change block for a variable, editing a block in the Block Editor, editing a costume or&#xD;sound, or inserting, deleting, or reordering costumes or sounds. To change a property from unshared to shared,&#xD;the child uses the inherit command block. The pulldown menu in the block lists all the things this sprite can&#xD;inherit from its parent (which might be nothing, if this sprite has no parent) and is not already inheriting. But&#xD;that would prevent telling a child to inherit, so if the inherit block is inside a ring, its pulldown menu includes all&#xD;the things a child could inherit from this sprite. Right-clicking on the scripting area of a permanent clone gives&#xD;a menu option to share the entire collection of scripts from its parent, as a temporary clone does.&#xD;1 Some languages popular in the “real world” today, such as JavaScript, claim to use prototyping, but their object system is much more&#xD;complicated than what we are describing (we’re guessing it’s because they were designed by people too familiar with class/instance&#xD;programming); that has, in some circles, given prototyping a bad name. Our prototyping design comes from Object Logo, and before&#xD;that, from Henry Lieberman. [Lieberman, H., Using Prototypical Objects to Implement Shared Behavior in Object-Oriented&#xD;Systems, First Conference on Object-Oriented Programming Languages, Systems, and Applications [OOPSLA-86], ACM SigCHI,&#xD;Portland, OR, September, 1986. Also in Object-Oriented Computing, Gerald Peterson, Ed., IEEE Computer Society Press, 1987.]&#xD;78&#xD;The rules are full of details, but the basic idea is simple: Parents can change their children, but children can’t&#xD;directly change their parents. That’s what you’d expect from the word “inherit”: the influence just goes in one&#xD;direction. When a child changes some property, it’s declaring independence from its parent (with respect to that&#xD;one property). What if you really want the child to be able to make a change in the parent (and therefore in&#xD;itself and all its siblings)? Remember that in this system any object can tell any other object to do something:&#xD;When a sprite gets a message for which it doesn’t have a corresponding block, the message is delegated to that&#xD;sprite’s parent. When a sprite does have the corresponding block, then the message is not delegated. If the&#xD;script that implements a delegated message refers to my (self), it means the child to which the message was&#xD;originally sent, not the parent to which the message was delegated.&#xD;G. List of attributes&#xD;At the right is a picture of the dropdown menu of attributes in the my block.&#xD;Several of these are not real attributes, but things related to attributes:&#xD;● self: this sprite&#xD;● neighbors: a list of nearby sprites1&#xD;● other sprites: a list of all sprites except myself&#xD;● stage: the stage, which is first-class, like a sprite&#xD;● clones: a list of my temporary clones&#xD;● other clones: a list of my temporary siblings&#xD;● parts: a list of sprites whose anchor attribute is this sprite&#xD;● children: a list of all my clones, temporary and permanent&#xD;The others are individual attributes:&#xD;● anchor: the sprite of which I am a (nested) part&#xD;● parent: the sprite of which I am a clone&#xD;● temporary?: am I a temporary clone?&#xD;● name: my name (same as parent’s name if I’m temporary)&#xD;● costumes: a list of the sprite’s costumes&#xD;● sounds: a list of the sprite’s sounds&#xD;● blocks: a list of the blocks visible in this sprite&#xD;● categories: a list of all the block category names&#xD;● dangling?: True if I am a part and not in synchronous orbit&#xD;● draggable?: True if the user can move me with the mouse&#xD;● width, height, left, right, top, bo!om: The width or height of my costume as&#xD;seen right now, or the left, etc., edge of my bounding box, taking rotation into&#xD;account.&#xD;● rotation x, rotation y: when reading with my, the same as x position,&#xD;y position. When set, changes the sprite’s rotation center without moving the&#xD;sprite, like dragging the rotation center in the paint editor.&#xD;● center x, center y: the x and y position of the center of my&#xD;bounding box, rounded off–the geometric center of the costume.&#xD;1 Neighbors are all other sprites whose bounding boxes intersect the doubled dimensions of the requesting sprite&apos;s bounds.&#xD;79&#xD;H. First Class Costumes and Sounds&#xD;Costumes and sounds don’t have methods, as sprites do; you can’t ask them to do things. But they are first class:&#xD;you can make a list of them, put them in variables, use them as input to a procedure, and so on. My [costumes]&#xD;and my [sounds] report lists of them.&#xD;Media Computation with Costumes&#xD;The components of a costume are its name, width, height, and pixels. The block gives&#xD;access to these components using its left menu. From its right menu you can choose the current costume, the&#xD;Turtle costume, or any costume in the sprite’s wardrobe. Since costumes are first class, you can also drop an&#xD;expression whose value is a costume, or a list of costumes, on that second input slot. (Due to a misfeature, even&#xD;though you can select Turtle in the right menu, the block reports 0 for its width and height, and an empty string&#xD;for the other components.) The costume’s width and height are in its standard orientation, regardless of the&#xD;sprite’s current direction. (This is different from the sprite’s width and height, reported by the my block.)&#xD;But the really interesting part of a costume is its bitmap, a list of pixels. (A pixel, short for “picture element,”&#xD;represents one dot on your display.) Each pixel is itself a list of four items, the red, green, and blue components&#xD;of its color (in the range 0-255) and what is standardly called its “transparency” but should be called its opacity,&#xD;also in the range 0-255, in which 0 means that the pixel is invisible and 255 means that it’s fully opaque: you&#xD;can’t see anything from a rearward layer at that point on the stage. (Costume pixels typically have an opacity of&#xD;0 only for points inside the bounding box of the costume but not actually part of the costume; points in the&#xD;interior of a costume typically have an opacity of 255. Intermediate values appear mainly at the edge of a&#xD;costume, or at sharp boundaries between colors inside the costume, where they are used to reduce “jaggies”: the&#xD;stairstep-like shape of a diagonal line displayed on an array of discrete rectangular screen coordinates. Note that&#xD;the opacity of a sprite pixel is determined by combining the costume’s opacity with the sprite’s ghost effect. (The&#xD;latter really is a measure of transparency: 0 means opaque and 100 means invisible.)&#xD;The bitmap is a one-dimensional list of pixels, not an array of height rows of width pixels each. That’s why the&#xD;pixel list has to be combined with the dimensions to produce a costume. This choice partly reflects the way&#xD;bitmaps are stored in the computer’s hardware and operating system, but also makes it easy to produce&#xD;transformations of a costume with map:&#xD;In this simplest possible transformation, the red value of all the pixels have been changed to a constant 150.&#xD;Colors that were red in the original (such as the logo printed on the t-shirt) become closer to black (the other&#xD;color components being near zero); the blue jeans become purple (blue plus red); perhaps counterintuitively, the&#xD;white t-shirt, which has the maximum value for all three color components, loses some of its red and becomes&#xD;cyan, the color opposite red on the color wheel. In reading the code, note that the function that is the first input&#xD;to map is applied to a single pixel, whose first item is its red component. Also note that this process works only&#xD;on bitmap costumes; if you call pixels of on a vector costume (one with “svg” in the corner of its picture), it will&#xD;be converted to pixels first.&#xD;80&#xD;One important point to see here is that a bitmap (list of pixels) is not, by itself, a costume. The new costume&#xD;block creates a costume by combining a bitmap, a width, and a height. But, as in the example above, switch to&#xD;costume will accept a bitmap as input and will automatically use the width and height of the current costume.&#xD;Note that there’s no name input; costumes computed in this way are all named costume. Note also that the use&#xD;of switch to costume does not add the computed costume to the sprite’s wardrobe; to do that, say&#xD;Here’s a more interesting example of color manipulation:&#xD;Each color value is constrained to be 0, 80, 160, or 240. This gives the picture a more cartoonish look.&#xD;Alternatively, you can do the computation taking advantage of hyperblocks:&#xD;Here’s one way to exchange red and green values:&#xD;It’s the list that determines the rearrangement of colors: green➔red, red➔green, and the other&#xD;two unchanged. That list is inside another list because otherwise it would be selecting rows of the pixel array,&#xD;and we want to select columns. We use pixels of costume current rather than costume apple because the latter&#xD;is always a red apple, so this little program would get stuck turning it green, instead of alternating colors.&#xD;The stretch block takes a costume as its first input, either by selecting a costume from the menu or by&#xD;dropping a costume-valued expression such as onto it. The other two inputs are&#xD;percents of the original width and height, as advertised, so you can make fun house mirror versions of costumes:&#xD;The resulting costumes can be used with switch to costume and so on.&#xD;Finally, you can use pictures from your computer’s camera in your projects using these blocks:&#xD;Using the video on block turns on the camera and displays what it sees on the stage, regardless of the inputs&#xD;given. The camera remains on until you click the red stop button, your program runs the stop all block, or you&#xD;turn it off explicitly with the block. The video image on the stage is partly ghosted, to an&#xD;extent determined by the set video transparency block, whose input really is transparency and not opacity.&#xD;81&#xD;(Small numbers make the video more visible.) By default, the video image is mirrored, like the selfie camera on&#xD;your cell phone: When you raise your left hand, your image raises its right hand. You can control this&#xD;mirroring with the block.&#xD;The video snap on block then takes a still picture from the camera, and trims it to fit on the selected sprite.&#xD;(Video snap on stage means to use the entire stage-sized rectangle.) For example, here’s a camera snapshot&#xD;trimmed to fit Alonzo:&#xD;The “Video Capture” project in the Examples collection repeatedly takes such trimmed snapshots and has the&#xD;Alonzo sprite use the current snapshot as its costume, so it looks like this:&#xD;(The picture above was actually taken with transparency set to 50, to make the background more visible for&#xD;printing.) Because the sprite is always still in the place where the snapshot was taken, its costume exactly fits in&#xD;with the rest of the full-stage video. If you were to add a move 100 steps block after the switch to costume,&#xD;you’d see something like this:&#xD;This time, the sprite’s costume was captured at one position, and then the sprite is shown at a different position.&#xD;(You probably wouldn’t want to do this, but perhaps it’s helpful for explanatory purposes.)&#xD;82&#xD;What you would want to do is push the sprite around the stage:&#xD;(Really these should be Jens’s picture; it’s his project. But he’s vacationing. ☺) Video motion compares two&#xD;snapshots a moment apart, looking only at the part within the given trim (here myself, meaning the current&#xD;sprite, not the person looking into the camera), to detect a difference between them. It reports a number,&#xD;measuring the number of pixels through which some part of the picture has moved. Video direction also&#xD;compares two snapshots to detect motion, but what it reports is the direction (in the point in direction sense) of&#xD;the motion. So the script above moves the sprite in the direction in which it’s being pushed, but only if a&#xD;significant amount of motion is found; otherwise the sprite would jiggle around too much. And yes, you can run&#xD;the second script without the first to push a balloon around the stage.&#xD;Media Computation with Sounds&#xD;The starting point for computation with sound is the microphone block. It starts by&#xD;recording a brief burst of sound from your microphone. (How brief? On my computer,&#xD;0.010667 seconds, but you’ll see shortly how to find out or control the sample size on your&#xD;computer.)&#xD;Just as the pixel is the smallest piece of a picture, the sample is the smallest piece of a sound.&#xD;It says here: that on my computer, 48,000 samples are&#xD;recorded per second, so each sample is 1/48,000 of a second. The value of a sample is&#xD;between -1 and 1, and represents the sound pressure on the microphone—how hard the air is pushing—at that&#xD;instant. (You can skip the next page or so if you know about Fourier analysis.) Here’s a picture of 400 samples:&#xD;In this graph, the x axis represents the time at which each sample was measured; the y axis measures the value of&#xD;the sample at that time. The first obvious thing about this graph is that it has a lot of ups and downs. The most&#xD;basic up-and-down function is the sine wave:&#xD;83&#xD;Every periodic function (more or less, any sample that sounds like music rather than sounding like static) is&#xD;composed of a sum of sine waves of different frequencies.&#xD;Look back at the graph of our sampled sound. There is a green dot every seven samples. There’s nothing&#xD;magic about the number seven; I tried different values until I found one that looked right. What “right” means&#xD;is that, for the first few dots at least, they coincide almost perfectly with the high points and low points of the&#xD;graph. Near the middle (horizontally) of the graph, the green dots don’t seem anywhere near the high and low&#xD;points, but if you find the very lowest point of the graph, about 2/3 of the way along, the dots start lining up&#xD;almost perfectly again.&#xD;The red graph above shows two cycles of a sine wave. One cycle goes up, then down, then up again. The&#xD;amount of time taken for one cycle is the period of the sine function. If the green dots match both ups and downs&#xD;in the captured sound, then two dots—14 samples, or 14/48000 of a second—represent the period. The first&#xD;cycle and a half of the graph looks like it could be a pure sine wave, but after that, the tops and bottoms don’t&#xD;line up, and there are peculiar little jiggles, such as the one before the fifth green dot. This happens because sine&#xD;waves of different periods are added together.&#xD;It turns out to be more useful to measure the reciprocal of the period, in our case, 48000/14 or about 3429 cycles&#xD;per second. Another name for “cycles per second” is “Hertz,” abbreviated Hz, so our sound has a component at&#xD;3249 Hz. As a musical note, that’s about an A (a little flat), four octaves above middle C. (Don’t worry too&#xD;much about the note being a little off; remember that the 14-sample period was just eyeballed and is unlikely to&#xD;be exactly right.)&#xD;Four octaves above middle C is really high! That would be a shrill-sounding note. But remember that a&#xD;complex waveform is the sum of multiple sine waves at different frequency. Here’s a different up-and-down&#xD;regularity:&#xD;It’s not obvious, but in the left part of the graph, the signal is more above the x axis than below it. Toward the&#xD;right, it seems to be more below than above the axis. At the very right it looks like it might be climbing again.&#xD;The period of the red sine wave is 340 samples, or 340/48000 second. That’s a frequency of about 141 Hz,&#xD;about D below middle C. Again, this is measuring by eyeball, but likely to be close to the right frequency.&#xD;All this eyeballing doesn’t seem very scientific. Can’t we just get the computer to find all the relevant&#xD;frequencies? Yes, we can, using a mathematical technique called Fourier analysis. (Jean-Baptiste Joseph Fourier,&#xD;1768–1830, made many contributions to mathematics and physics, but is best known for working out the nature&#xD;of periodic functions as a sum of sine waves.) Luckily we don’t have to do the math; the microphone block will&#xD;do it for us, if we ask for microphone spectrum:&#xD;84&#xD;These are frequency spectra from (samples of) three different songs. The most obvious thing about these graphs&#xD;is that their overall slope is downward; the loudest frequency is the lowest frequency. That’s typical of music.&#xD;The next thing to notice is that there’s a regularity in the spacing of spikes in the graph. This is partly just an&#xD;artifact; the frequency (horizontal) axis isn’t continuous. There are a finite number of “buckets” (default: 512),&#xD;and all the frequencies within a bucket contribute to the amplitude (vertical axis) of that bucket. The spectrum&#xD;is a list of that many amplitudes. But the patterns of alternating rising and falling values are real; the frequencies&#xD;that are multiples of the main note being sampled will have higher amplitude than other frequencies.&#xD;Samples and spectrum are the two most detailed representations of a sound. But the microphone block has&#xD;other, simpler options also:&#xD;volume the instantaneous volume when the block is called&#xD;note the MIDI note number (as in play note) of the main note heard&#xD;frequency the frequency in Hz of the main note heard&#xD;sample rate the number of samples being collected per second&#xD;resolution the size of the array in which data are collected (typically 512, must be a power of 2)&#xD;The block for sounds that corresponds to new picture for pictures is&#xD;Its first input is a list of samples, and its second input specifies how many samples occupy one second.&#xD;85&#xD;VIII. OOP with Procedures&#xD;The idea of object oriented programming is often taught in a way that makes it seem as if a special object&#xD;oriented programming language is necessary. In fact, any language with first class procedures and lexical scope&#xD;allows objects to be implemented explicitly; this is a useful exercise to help demystify objects.&#xD;The central idea of this implementation is that an object is represented as a dispatch procedure that takes a&#xD;message as input and reports the corresponding method. In this section we start with a stripped-down example&#xD;to show how local state works, and build up to full implementations of class/instance and prototyping OOP.&#xD;A. Local State with Script Variables&#xD;This script implements an object class, a type of object, namely the counter class. In this first simplified version&#xD;there is only one method, so no explicit message passing is necessary. When the make a counter block is called,&#xD;it reports a procedure, the ringed script inside its body. That procedure implements a specific counter object, an&#xD;instance of the counter class. When invoked, a counter instance increases and reports its count variable. Each&#xD;counter has its own local count:&#xD;This example will repay careful study, because it isn’t obvious why each instance has a separate count. From&#xD;the point of view of the make a counter procedure, each invocation causes a new count variable to be created.&#xD;Usually such script variables are temporary, going out of existence when the script ends. But this one is special,&#xD;because make a counter returns another script that makes reference to the count variable, so it remains active.&#xD;86&#xD;(The script variables block makes variables local to a script. It can be used in a sprite’s script area or in the&#xD;Block Editor. Script variables can be “exported” by being used in a reported procedure, as here.)&#xD;In this approach to OOP, we are representing both classes and instances as procedures. The make a counter&#xD;block represents the class, while each instance is represented by a nameless script created each time make a&#xD;counter is called. The script variables created inside the make a counter block but outside the ring are instance&#xD;variables, belonging to a particular counter.&#xD;B. Messages and Dispatch Procedures&#xD;In the simplified class above, there is only one method, and so there are no messages; you just call the instance&#xD;to carry out its one method. Here is a more refined version that uses message passing:&#xD;Again, the make a counter block represents the counter class, and again the script creates a local variable count&#xD;each time it is invoked. The large outer ring represents an instance. It is a dispatch procedure: it takes a message&#xD;(just a text word) as input, and it reports a method. The two smaller rings are the methods. The top one is the&#xD;next method; the bottom one is the reset method. The latter requires an input, named value.&#xD;In the earlier version, calling the instance did the entire job. In this version, calling the instance gives access to&#xD;a method, which must then be called to finish the job. We can provide a block to do both procedure calls in one:&#xD;The ask block has two required inputs: an object and a message. It also accepts optional additional inputs,&#xD;which Snap! puts in a list; that list is named args inside the block. Ask has two nested call blocks. The inner one&#xD;calls the object, i.e., the dispatch procedure. The dispatch procedure always takes exactly one input, namely the&#xD;message. It reports a method, which may take any number of inputs; note that this is the situation in which we&#xD;drop a list of values onto the arrowheads of a multiple input (in the outer call block). Note also that this is one&#xD;of the rare cases in which we must unringify the inner call block, whose value when called gives the method.&#xD;87&#xD;C. Inheritance via Delegation&#xD;So, our objects now have local state variables and message passing. What about inheritance? We can provide&#xD;that capability using the technique of delegation. Each instance of the child class contains an instance of the&#xD;parent class, and simply passes on the messages it doesn’t want to specialize:&#xD;This script implements the buzzer class, which is a child of counter. Instead of having a count (a number) as a&#xD;local state variable, each buzzer has a counter (an object) as a local state variable. The class specializes the next&#xD;method, reporting what the counter reports unless that result is divisible by 7, in which case it reports “buzz.”&#xD;(Yeah, it should also check for a digit 7 in the number, but this code is complicated enough already.) If the&#xD;message is anything other than next, though, such as reset, then the buzzer simply invokes its counter’s&#xD;dispatch procedure. So the counter handles any message that the buzzer doesn’t handle explicitly. (Note that in&#xD;the non-next case we call the counter, not ask it something, because we want to report a method, not the value&#xD;that the message reports.) So, if we ask a buzzer to reset to a value divisible by 7, it will end up reporting that&#xD;number, not “buzz.”&#xD;88&#xD;D. An Implementation of Prototyping OOP&#xD;In the class/instance system above, it is necessary to design the complete behavior of a class before you can&#xD;make any instances of the class. This is okay for top-down design, but not great for experimentation. Here we&#xD;sketch the implementation of a prototyping OOP system: You make an object, tinker with it, make clones of it,&#xD;and keep tinkering. Any changes you make in the parent are inherited by its children. In effect, that first object&#xD;is both the class and an instance of the class. In the implementation below, children share properties (methods&#xD;and local variables) of their parent unless and until a child changes a property, at which point that child gets a&#xD;private copy. (If a child wants to change something for its entire family, it must ask the parent to do it.)&#xD;Because we want to be able to create and delete properties dynamically, we won’t use Snap! variables to hold&#xD;an object’s variables or methods. Instead, each object has two tables, called methods and data, each of which is&#xD;an association list: a list of two-item lists, in which each of the latter contains a key and a corresponding value. We&#xD;provide a lookup procedure to locate the key-value pair corresponding to a given key in a given table.&#xD;There are also commands to insert and delete entries:&#xD;As in the class/instance version, an object is represented as a dispatch procedure that takes a message as its&#xD;input and reports the corresponding method. When an object gets a message, it will first look for that keyword&#xD;in its methods table. If it’s found, the corresponding value is the method we want. If not, the object looks in its&#xD;data table. If a value is found there, what the object returns is not that value, but rather a reporter method that,&#xD;when called, will report the value. This means that what an object returns is always a method.&#xD;89&#xD;If the object has neither a method nor a datum with the desired name, but it does have a parent, then the&#xD;parent (that is, the parent’s dispatch procedure) is invoked with the message as its input. Eventually, either a&#xD;match is found, or an object with no parent is found; the latter case is an error, meaning that the user has sent&#xD;the object a message not in its repertoire.&#xD;Messages can take any number of inputs, as in the class/instance system, but in the prototyping version, every&#xD;method automatically gets the object to which the message was originally sent as an extra first input. We must&#xD;do this so that if a method is found in the parent (or grandparent, etc.) of the original recipient, and that method&#xD;refers to a variable or method, it will use the child’s variable or method if the child has its own version.&#xD;The clone of block below takes an object as its input and makes a child object. It should be considered as an&#xD;internal part of the implementation; the preferred way to make a child of an object is to send that object a clone&#xD;message.&#xD;90&#xD;Every object is created with predefined methods for set, method, delete-var, delete-method, and clone. It has&#xD;one predefined variable, parent. Objects without a parent are created by calling new object:&#xD;As before, we provide procedures to call an object’s dispatch procedure and then call the method. But in this&#xD;version, we provide the desired object as the first method input. We provide one procedure for Command&#xD;methods and one for Reporter methods:&#xD;(Remember that the “Input list:” variant of the run and call blocks is made by dragging the input expression&#xD;over the arrowheads rather than over the input slot.)&#xD;The script below demonstrates how this prototyping system can be used to make counters. We start with one&#xD;prototype counter, called counter1. We count this counter up a few times, then create a child counter2 and&#xD;give it its own count variable, but not its own total variable. The next method always sets counter1’s total&#xD;variable, which therefore keeps count of the total number of times that any counter is incremented. Running&#xD;this script should [say] and (think) the following lists:&#xD;[1 1] [2 2] [3 3] [4 4] (1 5) (2 6) (3 7) [5 8] [6 9] [7 10] [8 11]&#xD;91&#xD;IX. The Outside World&#xD;The facilities discussed so far are fine for projects that take place entirely on your computer’s screen. But you&#xD;may want to write programs that interact with physical devices (sensors or robots) or with the World Wide Web.&#xD;For these purposes Snap! provides a single primitive block:&#xD;This might not seem like enough, but in fact it can be used to build the desired capabilities.&#xD;A. The World Wide Web&#xD;The input to the url block is the URL (Uniform Resource Locator) of a web page. The block reports the body&#xD;of the Web server’s response (minus HTTP header), without interpretation. This means that in most cases the&#xD;response is a description of the page in HTML (HyperText Markup Language) notation. Often, especially for&#xD;commercial web sites, the actual information you’re trying to find on the page is actually at another URL&#xD;included in the reported HTML. The Web page is typically a very long text string, and so the primitive split&#xD;block is useful to get the text in a manageable form, namely, as a list of lines:&#xD;The second input to split is the character to be used to separate the text string into a list of lines, or one of a set&#xD;of common cases (such as line, which separates on carriage return and/or newline characters.&#xD;This might be a good place for a reminder that list-view watchers scroll through only 100 items at a time. The&#xD;downarrow near the bottom right corner of the speech balloon in the picture presents a menu of hundred-item&#xD;ranges. (This may seem unnecessary, since the scroll bar should allow for any number of items, but doing it this&#xD;way makes Snap! much faster.) In table view, the entire list is included.&#xD;92&#xD;If you include a protocol name in the input to the url block (such as h!p:// or h!ps://), that protocol will be&#xD;used. If not, the block first tries HTTPS and then, if that fails, HTTP.&#xD;A security restriction in JavaScript limits the ability of one web site to initiate communication with another site.&#xD;There is an official workaround for this limitation called the CORS protocol (Cross-Origin Resource Sharing),&#xD;but the target site has to allow snap.berkeley.edu explicitly, and of course most don’t. To get around this&#xD;problem, you can use third-party sites (“cors proxies”) that are not limited by JavaScript and that forward your&#xD;requests.&#xD;B. Hardware Devices&#xD;Another JavaScript security restriction prevents Snap! from having direct access to devices connected to your&#xD;computer, such as sensors and robots. (Mobile devices such as smartphones may also have useful devices built&#xD;in, such as accelerometers and GPS receivers.) The url block is also used to interface Snap! with these external&#xD;capabilities.&#xD;The idea is that you run a separate program that both interfaces with the device and provides a local HTTP&#xD;server that Snap! can use to make requests to the device. Unlike Snap! itself, these programs have access to anything on&#xD;your computer, so you have to trust the author of the software! Our web site, snap.berkeley.edu, provides links to&#xD;drivers for several devices, including, at this writing, the Lego NXT, Finch, Hummingbird, and Parallax S2&#xD;robots; the Nintendo Wiimote and Leap Motion sensors, the Arduino microcomputer, and Super-Awesome&#xD;Sylvia’s Water Color Bot. The same server technique can be used for access to third party software libraries,&#xD;such as the speech synthesis package linked on our web site.&#xD;Most of these packages require some expertise to install; the links are to source code repositories. This&#xD;situation will improve with time.&#xD;C. Date and Time&#xD;The current block in the Sensing palette can be used to find out the current date or time. Each call to this block&#xD;reports one component of the date or time, so you will probably combine several calls, like this:&#xD;for Americans, or like this:&#xD;for Europeans.&#xD;93&#xD;X. Continuations&#xD;Blocks are usually used within a script. The continuation of a block within a particular script is the part of the&#xD;computation that remains to be completed after the block does its job. A continuation can be represented as a&#xD;ringed script. Continuations are always part of the interpretation of any program in any language, but usually&#xD;these continuations are implicit in the data structures of the language interpreter or compiler. Making&#xD;continuations explicit is an advanced but versatile programming technique that allows users to create control&#xD;structures such as nonlocal exit and multithreading.&#xD;In the simplest case, the continuation of a command block may just be the part of the script after the block.&#xD;For example, in the script&#xD;the continuation of the move 100 steps block is&#xD;But some situations are more complicated. For example, what is the continuation of move 100 steps in the&#xD;following script?&#xD;That’s a trick question; the move block is run four times, and it has a different continuation each time. The first&#xD;time, its continuation is&#xD;Note that there is no repeat 3 block in the actual script, but the continuation has to represent the fact that there&#xD;are three more times through the loop to go. The fourth time, the continuation is just&#xD;What counts is not what’s physically below the block in the script, but what computational work remains to be&#xD;done.&#xD;(This is a situation in which visible code may be a little misleading. We have to put a repeat 3 block in the picture of the&#xD;continuation, but the actual continuation is made from the evaluator’s internal bookkeeping of where it’s up to in a script. So it’s really&#xD;the original script plus some extra information. But the pictures here do correctly represent what work the process still has left to do.)&#xD;94&#xD;When a block is used inside a custom block, its continuation may include parts of more than one script. For&#xD;example, if we make a custom square block&#xD;and then use that block in a script:&#xD;then the continuation of the first use of move 100 steps is&#xD;in which part comes from inside the square block and part comes from the call to square. Nevertheless,&#xD;ordinarily when we display a continuation we show only the part within the current script.&#xD;The continuation of a command block, as we’ve seen, is a simple script with no input slots. But the&#xD;continuation of a reporter block has to do something with the value reported by the block, so it takes that value as&#xD;input. For example, in the script&#xD;the continuation of the 3+4 block is&#xD;Of course the name result in that picture is arbitrary; any name could be used, or no name at all by using the&#xD;empty-slot notation for input substitution.&#xD;A. Continuation Passing Style&#xD;Like all programming languages, Snap! evaluates compositions of nested reporters from the inside out. For&#xD;example, in the expression Snap! first adds 4 and 5, then multiplies 3 by that sum. This often&#xD;means that the order in which the operations are done is backwards from the order in which they appear in the&#xD;expression: When reading the above expression you say “times” before you say “plus.” In English, instead of&#xD;saying “three times four plus five,” which actually makes the order of operations ambiguous, you could say,&#xD;“take the sum of four and five, and then take the product of three and that sum.” This sounds more awkward,&#xD;but it has the virtue of putting the operations in the order in which they’re actually performed.&#xD;95&#xD;That may seem like overkill in a simple expression, but suppose you’re trying to convey the expression&#xD;to a friend over the phone. If you say “factorial of three times factorial of two plus two plus five” you might&#xD;mean any of these:&#xD;Wouldn’t it be better to say, “Add two and two, take the factorial of that, add five to that, multiply three by that,&#xD;and take the factorial of the result”? We can do a similar reordering of an expression if we first define versions&#xD;of all the reporters that take their continuation as an explicit input. In the following picture, notice that the new&#xD;blocks are commands, not reporters.&#xD;We can check that these blocks give the results we want:&#xD;96&#xD;The original expression can now be represented as&#xD;If you read this top to bottom, don’t you get “Add two and two, take the factorial of that, add five to that,&#xD;multiply three by that, and take the factorial of the result”? Just what we wanted! This way of working, in&#xD;which every block is a command that takes a continuation as one of its inputs, is called continuation-passing style&#xD;(CPS). Okay, it looks horrible, but it has subtle virtues. One of them is that each script is just one block long&#xD;(with the rest of the work buried in the continuation given to that one block), so each block doesn’t have to&#xD;remember what else to do—in the vocabulary of this section, the (implicit) continuation of each block is empty.&#xD;Instead of the usual picture of recursion, with a bunch of little people all waiting for each other, with CPS what&#xD;happens is that each little person hands off the problem to the next one and goes to the beach, so there’s only&#xD;one active little person at a time. In this example, we start with Alfred, an add specialist, who computes the&#xD;value 4 and then hands off the rest of the problem to Francine, a factorial specialist. She computes the value&#xD;24, then hands the problem off to Anne, another add specialist, who computes 29. And so on, until finally Sam,&#xD;a say specialist, says the value 2.107757298379527×10132, which is a very large number!&#xD;Go back to the definitions of these blocks. The ones, such as add, that correspond to primitive reporters are&#xD;simple; they just call the reporter and then call their continuation with its result. But the definition of factorial&#xD;is more interesting. It doesn’t just call our original factorial reporter and send the result to its continuation.&#xD;CPS is used inside factorial too! It says, “See if my input is zero. Send the (true or false) result to if. If the&#xD;result is true, then call my continuation with the value 1. Otherwise, subtract 1 from my input. Send the result&#xD;of that to factorial, with a continuation that multiplies the smaller number’s factorial by my original input.&#xD;Finally, call my continuation with the product.” You can use CPS to unwind even the most complicated&#xD;branched recursions.&#xD;By the way, I cheated a bit above. The if/else block should also use CPS; it should take one true/false input&#xD;and two continuations. It will go to one or the other continuation depending on the value of its input. But in fact&#xD;the C-shaped blocks (or E-shaped, like if/else) are really using CPS in the first place, because they implicitly&#xD;wrap rings around the sub-scripts within their branches. See if you can make an explicitly CPS if/else block.&#xD;97&#xD;B. Call/Run w/Continuation&#xD;To use explicit continuation passing style, we had to define special versions of all the reporters, add and so on.&#xD;Snap! provides a primitive mechanism for capturing continuations when we need to, without using continuation&#xD;passing throughout a project.&#xD;Here’s the classic example. We want to write a recursive block that takes a list of numbers as input, and&#xD;reports the product of all the numbers:&#xD;But we can improve the efficiency of this block, in the case of a list that includes a zero; as soon as we see the&#xD;zero, we know that the entire product is zero.&#xD;But this is not as efficient as it might seem. Consider, as an example, the list 1,2,3,0,4,5. We find the zero on&#xD;the third recursive call (the fourth call altogether), as the first item of the sublist 0,4,5. What is the continuation&#xD;of the report 0 block? It’s&#xD;Even though we already know that result is zero, we’re going to do three unnecessary multiplications while&#xD;unwinding the recursive calls.&#xD;We can improve upon this by capturing the continuation of the top-level call to product:&#xD;98&#xD;The block takes as its input a one-input script, as shown in the product example. It&#xD;calls that script with the continuation of the call-with-continuation block itself as its input. In this case, that&#xD;continuation is&#xD;reporting to whichever script called product. If the input list doesn’t include a zero, then nothing is ever done&#xD;with that continuation, and this version works just like the original product. But if the input list is 1,2,3,0,4,5,&#xD;then three recursive calls are made, the zero is seen, and product-helper runs the continuation, with an input of 0.&#xD;The continuation immediately reports that 0 to the caller of product, without unwinding all the recursive calls&#xD;and without the unnecessary multiplications.&#xD;I could have written product a little more simply using a Reporter ring instead of a Command ring:&#xD;but it’s customary to use a script to represent the input to call w/continuation because very often that input takes&#xD;the form&#xD;so that the continuation is saved permanently and can be called from anywhere in the project. That’s why the&#xD;input slot in call w/continuation has a Command ring rather than a Reporter ring.&#xD;First class continuations are an experimental feature in Snap! and there are many known limitations in it. One&#xD;is that the display of reporter continuations shows only the single block in which the call w/continuation is an&#xD;input.&#xD;99&#xD;Nonlocal exit&#xD;Many programming languages have a break command that can be used inside a looping construct such as&#xD;repeat to end the repetition early. Using first class continuations, we can generalize this mechanism to allow&#xD;nonlocal exit even within a block called from inside a loop, or through several levels of nested loops:&#xD;The upvar break has as its value a continuation that can be called from anywhere in the program to jump&#xD;immediately to whatever comes after the catch block in its script. Here’s an example with two nested&#xD;invocations of catch, with the upvar renamed in the outer one:&#xD;As shown, this will say 1, then 2, then 3, then exit both nested catches and think “Hmm.” If in the run block&#xD;the variable break is used instead of outer, then the script will say 1, 2, 3, and “Hello!” before thinking “Hmm.”&#xD;There are corresponding catch and throw blocks for reporters. The catch block is a reporter that takes an&#xD;expression as input instead of a C-shaped slot. But the throw block is a command; it doesn’t report a value to its&#xD;own continuation, but instead reports a value (which it takes as an additional input, in addition to the catch tag)&#xD;to the corresponding catch block’s continuation:&#xD;Without the throw, the inner call reports 5, the + block reports 8, so the catch block reports 8, and the × block&#xD;reports 80. With the throw, the inner call doesn’t report at all, and neither does the + block. The throw block’s&#xD;input of 20 becomes the value reported by the catch block, and the × block multiplies 10 and 20.&#xD;100&#xD;Creating a Thread System&#xD;Snap! can be running several scripts at once, within a single sprite and across many sprites. If you only have&#xD;one computer, how can it do many things at once? The answer is that only one is actually running at any&#xD;moment, but Snap! switches its attention from one script to another frequently. At the bottom of every looping&#xD;block (repeat, repeat until, forever), there is an implicit “yield” command, which remembers where the current&#xD;script is up to, and switches to some other script, each in turn. At the end of every script is an implicit “end&#xD;thread” command (a thread is the technical term for the process of running a script), which switches to another&#xD;script without remembering the old one.&#xD;Since this all happens automatically, there is generally no need for the user to think about threads. But, just to&#xD;show that this, too, is not magic, here is an implementation of a simple thread system. It uses a global variable&#xD;named tasks that initially contains an empty list. Each use of the C-shaped thread block adds a continuation&#xD;(the ringed script) to the list. The yield block uses run w/continuation to create a continuation for a partly done&#xD;thread, adds it to the task list, and then runs the first waiting task. The end thread block (which is automatically&#xD;added at the end of every thread’s script by the thread block) just runs the next waiting task.&#xD;Here is a sample script using the thread system. One thread&#xD;says numbers; the other says letters. The number thread yields&#xD;after every prime number, while the letter thread yields after&#xD;every vowel. So the sequence of speech balloons is&#xD;1,2,a,3,b,c,d,e,4,5,f,g,h,i,6,7,j,k,l,m,n,o,8,9,10,11,&#xD;p,q,r,s,t,u,12,13,v,w,x,y,z,14,15,16,17,18,…30.&#xD;If we wanted this to behave exactly like Snap!’s own threads,&#xD;we’d define new versions of repeat and so on that run yield after&#xD;each repetition.&#xD;101&#xD;XI. Metaprogramming&#xD;The scripts and custom blocks that make up a program can be examined or created by the program itself.&#xD;A. Reading a block&#xD;The de#nition of block takes a custom block (in a ring, since it’s the block itself that’s the input, not the result&#xD;of calling the block) as input and reports the block’s definition, i.e., its inputs and body, in the form of a ring with&#xD;named inputs corresponding to the block’s input names, so that those input names are bound in the body.&#xD;The split by blocks block takes any expression or script as input (ringed) and reports a list representing a syntax&#xD;tree for the script or expression, in which the first item is a block with no inputs and the remaining items are the&#xD;input values, which may themselves be syntax trees.&#xD;Using split by blocks to select custom blocks whose definitions contain another block gives us this debugging&#xD;aid:&#xD;102&#xD;Note in passing the my blocks block, which reports a list of all visible blocks, primitive and custom. (There’s also&#xD;a my categories block, which reports a list of the names of the palette categories.) Also note custom? of block,&#xD;which reports True if its input is a custom block.&#xD;B. Writing a block&#xD;The inverse function to split by blocks is provided by the join block, which when given a syntax tree as input&#xD;reports the corresponding expression or script.&#xD;Here we are taking the definition of square, modifying the repetition count (to 6), modifying the turning angle&#xD;(to 60), using join to turn the result back into a ringed definition, and using the define block to create a new&#xD;hexagon block.&#xD;The de#ne block has three “input” slots. The quotation marks are there because the first slot is an upvar, i.e.,&#xD;a way for de#ne to provide information to its caller, rather than the other way around. In this case, the value of&#xD;block is the new block itself (the hexagon block, in this example). The second slot is where you give the label for&#xD;the new block. In this example, the label is “hexagon _” in which the underscore represents an input slot. So,&#xD;here are a few examples of block labels:&#xD;set pen _ to _&#xD;for _ = _ to _ _&#xD;ask _ and wait&#xD;_ of _&#xD;Note that the underscores are separated from the block text by spaces. Note in the case of the for block’s label&#xD;that the upvar (the i) and the C-slot both count as inputs. Note also that the label is not meant to be a unique&#xD;symbol that represents only this block. For example, and both have the label&#xD;_ of _. The label does not give the input slots names (that’s done in the body, coming next) or types (that’s done&#xD;in the set _ of block _ to _ block, coming in two paragraphs).&#xD;The third slot is for the definition of the new block. This is a (ringed) script whose input names (formal&#xD;parameters) will become the formal parameters of the new block. And the script is its script.&#xD;So far we know the block’s label, parameters, and script. There are other things to specify about the block,&#xD;and one purpose of the block upvar is to allow that. In the example on the previous page, there are four&#xD;set _ of block _ to _ blocks, reproduced below for your convenience:&#xD;103&#xD;The category of the block can be set to any primitive or custom category. The default is other. The type is&#xD;command, reporter, or predicate. Command is the default, so this setting is redundant, but we want to show all&#xD;the choices in the set block. The scope is either global or sprite, with global as the default. The last input to&#xD;set slots is a list of length less than or equal to the number of underscores in the label. Each item of the list is a&#xD;type name, like the ones in the is (5) a (number)? block. If there is only one input, you can use just the name&#xD;instead of putting it in a list. An empty or missing list item means type Any.&#xD;It&apos;s very important that these set blocks appear in the same script as the define that creates the block, because&#xD;the block upvar is local to that script. You can’t later say, for example,&#xD;because the copy of the hexagon block in this instruction counts as “using” it.&#xD;The of block reporter is useful to copy attributes from one block to another, as we copied the definition of&#xD;square, modified it, and used it to define hexagon. Some of the values this block reports are a little unfriendly:&#xD;“1”? Yes, this block reports numbers instead of names for category, type, and scope. The reason is that maybe&#xD;someday we’ll have translations to other languages for custom category names, as we already do for the built-in&#xD;categories, types, and scopes; if you translate a program using this block to another language, the numeric&#xD;outputs won’t change, simplifying comparisons in your code. The set block accepts these numbers as an&#xD;alternative to the names.&#xD;There are a few more attributes of a block, less commonly used.&#xD;The list input is just like the one for set slots except for default values instead of types. Now for a block with a&#xD;menu input:&#xD;Prefer a read-only menu?&#xD;104&#xD;We passed too quickly over how the script turned the square block into a hexagon block:&#xD;Those replace item blocks aren’t very elegant. I had to look at foo by hand to figure out where the numbers I&#xD;wanted to change are. This situation can be improved with a little programming:&#xD;Exercise for the reader: Implement this:&#xD;Returning to the define block, there’s another reason for the block upvar: It’s helpful in defining a recursive&#xD;procedure using define. For a procedure to call itself, it needs a name for itself. But in the definition input to&#xD;the define block, define itself hasn’t been called yet, so the new block isn’t in the palette yet. So you do this:&#xD;Yes, you put block in the define, but it gets changed into this script in the resulting definition. You could use&#xD;this script directly in a simple case like this, but in a complicated case with a recursive call inside a ring inside&#xD;105&#xD;the one giving the block definition, this script always means the innermost ring. But the upvar means the outer&#xD;ring:&#xD;It’s analogous to using explicit formal parameters when you nest calls to higher order functions.&#xD;C. Macros&#xD;Users of languages in the C family have learned to think of macros as entirely about text strings, with no&#xD;relation to the syntax of the language. So you can do things like&#xD;#define foo baz)&#xD;with the result that you can only use the foo macro after an open parenthesis.&#xD;In the Lisp family of languages we have a different tradition, in which macros are syntactically just like&#xD;procedure calls, except that the “procedure” is a macro, with different evaluation rules from ordinary&#xD;procedures. Two things make a macro different: its input expressions are not evaluated, so a macro can&#xD;establish its own syntax (but still delimited by parentheses, in Lisp, or still one block, in Snap! ); and the result of a&#xD;macro call is a new expression that is evaluated as if it appeared in the caller of the macro, with access to the caller’s&#xD;variables and, implicitly, its continuation.&#xD;106&#xD;Snap! has long had the first part of this, the ability to make inputs unevaluated. In version 8.0 we add the&#xD;ability to run code in the context of another procedure, just as we can run code in the context of another sprite,&#xD;using the same mechanism: the of block. In the example on the previous page, the if _ report _ caller block runs&#xD;a report block, but not in its own context; it causes the fizzbuzz block to report “fizz” or “buzz” as appropriate.&#xD;(Yes, we know that the rules implemented here are simplified compared to the real game.) It doesn’t just report&#xD;out of the entire toplevel script; you can see that map is able to prepend “The answer is” to each reported value.&#xD;This macro capability isn’t fully implemented. First, we shouldn’t have to use the calling script as an explicit&#xD;input to the macro. In a later release, this will be fixed; when defining a block you’ll be able to say that it’s a&#xD;macro, and it will automatically get its caller’s context as an invisible input. Second, there is a possibility of&#xD;confusion between the variables of the macro and the variables of its caller. (What if the macro wanted to refer&#xD;to a variable value in its caller?) The one substantial feature of Scheme that we don’t yet implement is hygienic&#xD;macros, which make it possible to keep the two namespaces separate.&#xD;107&#xD;XII. User Interface Elements&#xD;In this chapter we describe in detail the various buttons, menus, and other clickable elements of the Snap! user&#xD;interface. Here again is the map of the Snap! window:&#xD;A. Tool Bar Features&#xD;Holding down the Shift key while clicking on any of the menu buttons gives access to an extended menu with&#xD;options, shown in red, that are experimental or for use by the developers. We’re not listing those extra options&#xD;here because they change frequently and you shouldn’t rely on them. But they’re not secrets.&#xD;The Snap! Logo Menu&#xD;The Snap! logo at the left end of the tool bar is clickable. It shows a menu of options about Snap! itself:&#xD;The About option displays information about Snap! itself, including version numbers for the source modules,&#xD;the implementors, and the license (AGPL: you can do anything with it except create proprietary versions,&#xD;basically).&#xD;108&#xD;The Reference manual option downloads a copy of the latest revision of this manual in PDF format.&#xD;The Snap! website option opens a browser window pointing to snap.berkeley.edu, the web site for Snap!.&#xD;The Download source option opens a browser window displaying the Github repository of the source files for&#xD;Snap!. At the bottom of the page are links to download the latest official release. Or you can navigate around&#xD;the site to find the current development version. You can read the code to learn how Snap! is implemented, host&#xD;a copy on your own computer (this is one way to keep working while on an airplane), or make a modified&#xD;version with customized features. (However, access to cloud accounts is limited to the official version hosted at&#xD;Berkeley.)&#xD;The File Menu&#xD;The file icon shows a menu mostly about saving and loading projects. You may not see all these options, if&#xD;you don’t have multiple sprites, scenes, custom blocks, and custom categories.&#xD;The Notes option opens a window in which you can type notes about the project: How to use it, what it does,&#xD;whose project you modified to create it, if any, what other sources of ideas you used, or any other information&#xD;about the project. This text is saved with the project, and is useful if you share it with other users.&#xD;The New option starts a new, empty project. Any project you were working on before disappears, so you are&#xD;asked to confirm that this is really what you want. (It disappears only from the current working Snap! window;&#xD;you should save the current project, if you want to keep it, before using New.)&#xD;Note the ^N at the end of the line. This indicates that you can type control-N as a shortcut for this menu item.&#xD;Alas, this is not the case in every browser. Some Mac browsers require command-N (⌘N) instead, while others&#xD;open a new browser window instead of a new project. You’ll have to experiment. In general, the keyboard&#xD;shortcuts in Snap! are the standard ones you expect in other software.&#xD;The Open… option shows a project open dialog box in which you can choose a project to open:&#xD;In this dialog, the three large buttons at the left select a source of projects: Cloud means your Snap! account’s&#xD;cloud storage. Examples means a collection of sample projects we provide. Computer is for projects saved on&#xD;your own computer; when you click it, this dialog is replaced with your computer’s system dialog for opening&#xD;files. The text box to the right of those buttons is an alphabetical listing of projects from that source; selecting a&#xD;project by clicking shows its thumbnail (a picture of the stage when it was saved) and its project notes at the&#xD;right.&#xD;109&#xD;The search bar at the top can be used to find a project by name or text in the project notes. So in this example:&#xD;I was looking for my ice cream projects and typed “crea” in the search bar, then wondered why “ferris”&#xD;matched. But then when I clicked on ferris I saw this:&#xD;My search matched the word “recreate” in the project notes.&#xD;The six buttons at the bottom select an action to perform on the selected project. In the top row, Recover looks&#xD;in your cloud account for older versions of the chosen project. If your project is damaged, don’t keep&#xD;saving broken versions! Use Recover first thing. You will see a list of saved versions; choose one to open&#xD;it. Typically, you’ll see the most recent version before the last save, and the newest version saved before today.&#xD;Then come buttons Share/Unshare and Publish/Unpublish. The labelling of the buttons depends on your&#xD;project’s publication status. If a project is neither shared nor published (the ones in lightface type in the project&#xD;list), it is private and nobody can see it except you, its owner. If it is shared (boldface in the project list), then&#xD;when you open it you’ll see a URL like this one:&#xD;h!ps://snap.berkeley.edu/snapsource/snap.html#present:Username=bh&amp;ProjectName=count%20change&#xD;but with your username and project name. (“%20” in the project name represents a space, which can’t be part&#xD;of a URL.) Anyone who knows this URL can see your project. Finally, if your project is published (bold italic&#xD;in the list), then your project is shown on the Snap! web site for all the world to see. (In all of these cases, you are&#xD;the only one who can write to (save) your project. If another user saves it, a separate copy will be saved in that&#xD;user’s account. Projects remember the history of who created the original version and any other “remix”&#xD;versions along the way.&#xD;In the second row, the first button, Open, loads the project into Snap! and closes the dialog box. The next&#xD;button (if Cloud is the source) is Delete, and if clicked it deletes the selected project. Finally, the Cancel button&#xD;closes the dialog box without opening a project. (It does not undo any sharing, unsharing, or deletion you’ve&#xD;done.)&#xD;110&#xD;Back to the File menu, the Save menu option saves the project to the same source and same name that was&#xD;used when opening the project. (If you opened another user’s shared project or an example project, the project&#xD;will be saved to your own cloud account. You must be logged in to save to the cloud.)&#xD;The Save as… menu option opens a dialog box in which you can specify where to save the project:&#xD;This is much like the Open dialog, except for the horizontal text box at the top, into which you type a name for&#xD;the project. You can also publish, unpublish, share, unshare, and delete projects from here. There is no&#xD;Recover button.&#xD;The Import… menu option is for bringing some external resource into the current project, or it can load an&#xD;entirely separate project, from your local disk. You can import costumes (any picture format that your browser&#xD;supports), sounds (again, any format supported by your browser), and block libraries or sprites (XML format,&#xD;previously exported from Snap! itself). Imported costumes and sounds will belong to the currently selected sprite;&#xD;imported blocks are global (for all sprites). Using the Import option is equivalent to dragging the file from your&#xD;desktop onto the Snap! window.&#xD;Depending on your browser, the Export project… option either directly saves to your disk or opens a new&#xD;browser tab containing your complete project in XML notation (a plain text format). You can then use the&#xD;browser’s Save feature to save the project as an XML file, which should be named something.xml so that&#xD;Snap! will recognize it as a project when you later drag it onto a Snap! window. This is an alternative to saving the&#xD;project to your cloud account: keeping it on your own computer. It is equivalent to choosing Computer from&#xD;the Save dialog described earlier.&#xD;The Export summary… option creates a web page, in HTML, with all of the information about your project:&#xD;its name, its project notes, a picture of what’s on its stage, definitions of global blocks, and then per-sprite&#xD;information: name, wardrobe (list of costumes), and local variables and block definitions. The page can be&#xD;converted to PDF by the browser; it’s intended to meet the documentation requirements of the Advanced&#xD;Placement Computer Science Principles create task.&#xD;The Export blocks… option is used to create a block library. It presents a list of all the global (for all sprites)&#xD;blocks in your project, and lets you select which to export. It then opens a browser tab with those blocks in&#xD;XML format, or stores directly to your local disk, as with the Export project option. Block libraries can be&#xD;imported with the Import option or by dragging the file onto the Snap! window. This option is shown only if you&#xD;have defined custom blocks.&#xD;111&#xD;The Unused blocks… option presents a listing of all the global custom blocks in your project that aren’t used&#xD;anywhere, and offers to delete them. As with Export blocks, you can choose a subset to delete with checkboxes.&#xD;This option is shown only if you have defined custom blocks.&#xD;The Hide blocks… option shows all blocks, including primitives, with checkboxes. This option does not&#xD;remove any blocks from your project, but it does hide selected block in your palette. The purpose of the option&#xD;is to allow teachers to present students with a simplified Snap! with some features effectively removed. The&#xD;hiddenness of primitives is saved with each project, so students can load a shared project and see just the desired&#xD;blocks. But users can always unhide blocks by choosing this option and unclicking all the checkboxes. (Rightclick&#xD;in the background of the dialog box to get a menu from which you can check all boxes or uncheck all&#xD;boxes.)&#xD;The New category… option allows you to add your own categories to the palette. It opens a dialog box in&#xD;which you specify a name and a color for the category. (A lighter version of the same color will be used for the&#xD;zebra coloring feature.)&#xD;The Remove a category… option appears only if you’ve created custom categories. It opens a very small,&#xD;easy-to-miss menu of category names just under the file icon in the menu bar. If you remove a category that has&#xD;blocks in it, all those blocks are also removed.&#xD;The next group of options concern the scenes feature, new in Snap! 7.0. A scene is a complete project, with its&#xD;own stage, sprites, and code, but several can be merged into one project, using the block to&#xD;bring another scene onscreen. The Scenes… option presents a menu of all the scenes in your project, where&#xD;the File menu was before you clicked it. The New scene option creates a new, empty scene, which you can&#xD;rename as you like from its context menu. Add scene… is like Import… but for scenes. (A complete project&#xD;can be imported as a scene into another project, so you have to specify that you’re importing the project as a&#xD;scene rather than replacing the current project.)&#xD;The Libraries… option presents a menu of useful, optional block libraries:&#xD;The library menu is divided into five broad categories. The first&#xD;is, broadly, utilities: blocks that might well be primitives. They&#xD;might be useful in all kinds of projects.&#xD;The second category is blocks related to media computation:&#xD;ones that help in dealing with costumes and sounds (a/k/a Jens&#xD;libraries). There is some overlap with “big data” libraries, for&#xD;dealing with large lists of lists.&#xD;The third category is, roughly, specific to non-media applications&#xD;(a/k/a Brian libraries). Three of them are imports from other&#xD;programming languages: words and sentences from Logo, array&#xD;functions from APL, and streams from Scheme. Most of the&#xD;others are to meet the needs of the BJC curriculum.&#xD;The fourth category is major packages provided by users.&#xD;The fifth category provides support for hardware devices such as&#xD;robots, through general interfaces, replacing specific hardware&#xD;libraries in versions before 7.0.&#xD;112&#xD;When you click on the one-line description of a library, you are shown the actual blocks in the library and a&#xD;longer explanation of its purpose. You can browse the libraries to find one that will satisfy your needs. The&#xD;libraries are described in detail in Section I.H, page 25.&#xD;The Costumes… option opens a browser into the costume library:&#xD;You can import a single costume by clicking it and then clicking the Import button. Alternatively, you can&#xD;import more than one costume by double-clicking each one, and then clicking Cancel when done. Notice that&#xD;some costumes are tagged with “svg” in this picture; those are vector-format costumes that are not (yet) editable&#xD;within Snap!.&#xD;If you have the stage selected in the sprite corral, rather than a sprite, the Costumes… option changes to a&#xD;Backgrounds… option, with different choices in the browser:&#xD;The costume and background libraries include both bitmap (go jagged if enlarged) and vector (enlarge&#xD;smoothly) images. Thanks to Scratch 2.0/3.0 for most of these images! Some older browsers refuse to import a&#xD;vector image, but instead convert it to bitmap.&#xD;113&#xD;The Sounds… option opens the third kind of media browser:&#xD;The Play buttons can be used to preview the sounds.&#xD;Finally, the Undelete sprites… option appears only if you have deleted a sprite; it allows you to recover a&#xD;sprite that was deleted by accident (perhaps intending to delete only a costume).&#xD;The Cloud Menu&#xD;shows a menu of options relating to your Snap! The cloud icon cloud account. If you are not logged&#xD;in, you see the outline icon and get this menu:&#xD;Choose Login… if you have a Snap! account and remember your password. Choose Signup… if you don’t have&#xD;an account. Choose Reset Password… if you’ve forgotten your password or just want to change it. You will&#xD;then get an email, at the address you gave when you created your account, with a new temporary password.&#xD;Use that password to log in, then you can choose your own password, as shown below. Choose Resend&#xD;Veri#cation Email… if you have just created a Snap! account but can’t find the email we sent you with the link to&#xD;verify that it’s really your email. (If you still can’t find it, check your spam folder. If you are using a school email&#xD;address, your school may block incoming email from outside the school.) The Open in Community Site option&#xD;appears only if you have a project open; it takes you to the community site page about that project.&#xD;If you are already logged in, you’ll see the solid icon and get this menu:&#xD;Logout is obvious, but has the additional benefit of showing you who’s logged in. Change password… will ask&#xD;for your old password (the temporary one if you’re resetting your password) and the new password you want,&#xD;entered twice because it doesn’t echo. Open in Community Site is the same as above.&#xD;114&#xD;The Settings Menu&#xD;shows a menu of Snap! options, either for the current The settings icon project or for you permanently,&#xD;depending on the option:&#xD;The Language… option lets you see the Snap! user interface (blocks and messages) in a language other than&#xD;English. (Note: Translations have been provided by Snap! users. If your native language is missing, send us an&#xD;email!)&#xD;The Zoom blocks... option lets you change the size of blocks, both in the palettes and in scripts. The standard&#xD;size is 1.0 units. The main purpose of this option is to let you take very high-resolution pictures of scripts for use&#xD;on posters. It can also be used to improve readability when projecting onto a screen while lecturing, but bear in&#xD;mind that it doesn’t make the palette or script areas any wider, so your computer’s command-option-+ feature&#xD;may be more practical. Note that a zoom of 2 is gigantic! Don’t even try 10.&#xD;The Fade blocks… option opens a dialog in which you can change the appearance of blocks:&#xD;Mostly this is a propaganda aid to use on people who think that text languages are somehow better or more&#xD;grown up than block languages, but some people do prefer less saturated block colors. You can use the&#xD;pulldown menu for preselected fadings, use the slider to see the result as you change the fading amount, or type&#xD;a number into the text box once you’ve determined your favorite value.&#xD;The Stage size… option lets you set the size of the full-size stage in pixels. If the stage is in half-size or doublesize&#xD;(presentation mode), the stage size values don’t change; they always reflect the full-size stage.&#xD;115&#xD;The Microphone resolution… option sets the buffer size used by the microphone block in Settings.&#xD;“Resolution” is an accurate name if you are getting frequency domain samples; the more samples, the narrower&#xD;the range of frequencies in each sample. In the time domain, the buffer size determines the length of time over&#xD;which samples are collected.&#xD;The remaining options let you turn various features on and off. There are three groups of checkboxes. The&#xD;first is for temporary settings not saved in your project nor in your user preferences.&#xD;The JavaScript extensions option enables the use of the JavaScript function block. Because malicious&#xD;projects could use JavaScript to collect private information about you, or to delete or modify your saved&#xD;projects, you must enable JavaScript each time you load a project that uses it.&#xD;The Extension blocks option adds two blocks to the palette:&#xD;These blocks provide assorted capabilities to official libraries that were formerly implemented with the&#xD;JavaScript function block. This allows these libraries to run without requiring the JavaScript extensions&#xD;option. Details are subject to change.&#xD;Input sliders provides an alternate way to put values in numeric input slots; if you click in such a slot, a slider&#xD;appears that you can control with the mouse:&#xD;The range of the slider will be from 25 less than the input’s current value to 25 more than the&#xD;current value. If you want to make a bigger change than that, you can slide the slider all the&#xD;way to either end, then click on the input slot again, getting a new slider with a new center&#xD;point. But you won’t want to use this technique to change the input value from 10 to 1000,&#xD;and it doesn’t work at all for non-integer input ranges. This feature was implemented&#xD;because software keyboard input on phones and tablets didn’t work at all in the beginning,&#xD;and still doesn’t work perfectly on Android devices, so sliders provide a workaround. It has&#xD;since found another use in providing “lively” response to input changes; if Input sliders is&#xD;checked, reopening the settings menu will show an additional option called Execute on slider change. If this&#xD;option is also checked, then changing a slider in the scripting area automatically runs the script in which that&#xD;input appears. The project live-tree in the Examples collection shows how this can be used; it features a fractal&#xD;tree custom block with several inputs, and you can see how each input affects the picture by moving a slider.&#xD;Turbo mode makes many projects run much faster, at the cost of not keeping the stage display up to date.&#xD;(Snap! ordinarily spends most of its time drawing sprites and updating variable watchers, rather than actually&#xD;carrying out the instructions in your scripts.) So turbo mode isn’t a good idea for a project with glide blocks or&#xD;one in which the user interacts with animated characters, but it’s great for drawing a complicated fractal, or&#xD;computing the first million digits of !, so that you don’t need to see anything until the final result. While in&#xD;turbo mode, the button that normally shows a green flag instead shows a green lightning bolt. (But when "&#xD;clicked hat blocks still activate when the button is clicked.)&#xD;Visible stepping enables the slowed-down script evaluation described in Chapter I. Checking this option is&#xD;equivalent to clicking the footprint button above the scripting area. You don’t want this on except when you’re&#xD;actively debugging, because even the fastest setting of the slider is still slowed a lot.&#xD;116&#xD;Log pen vectors tells Snap! to remember lines drawn by sprites as exact vectors, rather than remember only the&#xD;pixels that the drawing leaves on the stage. This remembered vector picture can be used in two ways: First,&#xD;right-clicking on a pen trails block gives an option to relabel it into a pen vectors block which, when run,&#xD;reports the logged lines as a vector (svg) costume. Second, right-clicking on the stage when there are logged&#xD;vectors shows an extra option, svg…, that exports a picture of the stage in vector format. Only lines are logged,&#xD;not color regions made with the #ll block.&#xD;The next group of four are user preference options, preserved when you load a new project. Long form input&#xD;dialog, if checked, means that whenever a custom block input name is created or edited, you immediately see&#xD;the version of the input name dialog that includes the type options, default value setting, etc., instead of the short&#xD;form with just the name and the choice between input name and title text. The default (unchecked) setting is&#xD;definitely best for beginners, but more experienced Snap! programmers may find it more convenient always to&#xD;see the long form.&#xD;Plain prototype labels eliminates the plus signs between words in the Block Editor prototype block. This&#xD;makes it harder to add an input to a custom block; you have to hover the mouse where the plus sign would have&#xD;been, until a single plus sign appears temporarily for you to click on. It’s intended for people making pictures of&#xD;scripts in the block editor for use in documentation, such as this manual. You probably won’t need it otherwise.&#xD;Clicking sound causes a really annoying sound effect whenever one block snaps next to another in a script.&#xD;Certain very young children, and our colleague Dan Garcia, like this, but if you are such a child you should&#xD;bear in mind that driving your parents or teachers crazy will result in you not being allowed to use Snap!. It&#xD;might, however, be useful for visually impaired users.&#xD;Flat design changes the “skin” of the Snap! window to a really hideous design with white and pale-grey&#xD;background, rectangular rather than rounded buttons, and monochrome blocks (rather than the shaded,&#xD;somewhat 3D-looking normal blocks). The monochrome blocks are the reason for the “flat” in the name of this&#xD;option. The only thing to be said for this option is that, because of the white background, it may blend in better&#xD;with the rest of a web page when a Snap! project is run in a frame in a larger page. (I confess I used it to make&#xD;the picture of blocks faded all the way to just text two pages ago, though.)&#xD;The final group of settings change the way Snap! interprets your program; they are saved with the project, so&#xD;anyone who runs your project will experience the same behavior. Thread safe scripts changes the way Snap!&#xD;responds when an event (clicking the green flag, say) starts a script, and then, while the script is still running, the&#xD;same event happens again. Ordinarily, the running process stops where it is, ignoring the remaining commands&#xD;in the script, and the entire script starts again from the top. This behavior is inherited from Scratch, and some&#xD;converted Scratch projects depend on it; that’s why it’s the default. It’s also sometimes the right thing, especially&#xD;in projects that play music in response to mouse clicks or keystrokes. If a note is still playing but you ask for&#xD;another one, you want the new one to start right then, not later after the old process finishes. But if your script&#xD;makes several changes to a database and is interrupted in the middle, the result may be that the database is&#xD;inconsistent. When you select Thread safe scripts, the same event happening again in the middle of running a&#xD;script is simply ignored. (This is arguably still not the right thing; the event should be remembered and the&#xD;script run again as soon as it finishes. We’ll probably get around to adding that choice eventually.) Keyboard&#xD;events (when __ key pressed) are always thread-safe.&#xD;117&#xD;Flat line ends affects the drawing of thick lines (large pen width). Usually the ends are rounded, which looks&#xD;best when turning corners. With this option selected, the ends are flat. It’s useful for drawing a brick wall or a&#xD;filled rectangle.&#xD;Codi#cation support enables a feature that can translate a Snap! project to a text-based (rather than blockbased)&#xD;programming language. The feature doesn’t know about any particular other language; instead, you can&#xD;provide a translation for each primitive block using these special blocks:&#xD;Using these primitive blocks, you can build a block library to translate into any programming language. Watch&#xD;for such libraries to be added to our library collection (or contribute one). To see some examples, open the&#xD;project “Codi#cation” in the Examples project list. Edit the blocks map to Smalltalk, map to JavaScript, etc.,&#xD;to see examples of how to provide translations for blocks.&#xD;The Single pale!e option puts all blocks, regardless&#xD;of category, into a single palette. It’s intended mainly&#xD;for use by curriculum developers building Parsons&#xD;problems: projects in which only a small set of blocks are&#xD;provided, and the task is to arrange those blocks to&#xD;achieve a set goal. In that application, this option is&#xD;combined with the hiding of almost all primitive&#xD;blocks. (See page 119.) When Single pale!e is turned&#xD;on, two additional options (initially on) appear in the&#xD;settings menu; the Show categories option controls&#xD;the appearance of the palette category names such as&#xD;and , while the Show bu!ons option&#xD;controls the appearance of the and&#xD;buttons in the palette.&#xD;The HSL pen color model option changes the set&#xD;pen, change pen, and pen blocks to provide menu&#xD;options hue, saturation, and lightness instead of hue,&#xD;saturation, and brightness (a/k/a value). Note: the&#xD;name “saturation” means something different in HSL&#xD;from in HSV! See Appendix A for all the information&#xD;you need about colors.&#xD;The Disable click-to-run option tells Snap! to ignore user mouse clicks on blocks and scripts if it would&#xD;ordinarily run the block or script. (Right-clicking and dragging still work, and so does clicking in an input slot to&#xD;edit it.) This is another Parsons problem feature; the idea is that there will be buttons displayed that run code&#xD;only in teacher-approved ways. But kids can uncheck the checkbox. ☺&#xD;Visible Stepping Controls&#xD;After the menu buttons you’ll see the project name. After that comes the footprint button used to turn on&#xD;visible stepping and, when it’s on, the slider to control the speed of stepping.&#xD;118&#xD;Stage Resizing Buttons&#xD;Still in the tool bar, but above the left edge of the stage, are two buttons that change the size of the stage. The&#xD;first is the shrink/grow button. Normally it looks like this: Clicking the button displays the stage at halfnormal&#xD;size horizontally and vertically (so it takes up ¼ of its usual area). When the stage is half size the button&#xD;looks like this: and clicking it returns the stage to normal size. The main reason you’d want a half size&#xD;stage is during the development process, when you’re assembling scripts with wide input expressions and the&#xD;normal scripting area isn’t wide enough to show the complete script. You’d typically then switch back to&#xD;normal size to try out the project. The next presentation mode button normally looks like this: Clicking&#xD;the button makes the stage double size in both dimensions and eliminates most of the other user interface&#xD;elements (the palette, the scripting area, the sprite corral, and most of the tool bar). When you open a shared&#xD;project using a link someone has sent you, the project starts in presentation mode. While in presentation mode,&#xD;the button looks like this: Clicking it returns to normal (project development) mode.&#xD;Project Control Buttons&#xD;Above the right edge of the stage are three buttons that control the running of the project.&#xD;Technically, the green $ag is no more a project control than anything else that can trigger a hat block:&#xD;typing on the keyboard or clicking on a sprite. But it’s a convention that clicking the flag should start the action&#xD;of the project from the beginning. It’s only a convention; some projects have no flag-controlled scripts at all, but&#xD;respond to keyboard controls instead. Clicking the green flag also deletes temporary clones.&#xD;Whenever any script is running (not necessarily in the current sprite), the green flag is lit: .&#xD;Shift-clicking the button enters Turbo mode, and the button then looks like a lightning bolt: . Shiftclicking&#xD;again turns Turbo mode off.&#xD;Scripts can simulate clicking the green flag by broadcasting the special message .&#xD;The pause button suspends running all scripts. If clicked while scripts are running, the button&#xD;changes shape to become a play button: Clicking it while in this form resumes the suspended scripts.&#xD;There is also a pause all block in the Control palette that can be inserted in a script to suspend all scripts; this&#xD;provides the essence of a breakpoint debugging capability. The use of the pause button is slightly different in&#xD;visible stepping mode, described in Chapter I.&#xD;The stop button stops all scripts, like the stop all block. It does not prevent a script from starting again&#xD;in response to a click or keystroke; the user interface is always active. There is one exception: generic when&#xD;blocks will not fire after a stop until some non-generic event starts a script. The stop button also&#xD;deletes all temporary clones.&#xD;119&#xD;B. The Palette Area&#xD;At the top of the palette area are the eight buttons that select which palette (which block category) is shown:&#xD;Motion, Looks, Sound, Pen, Control, Sensing, Operators, and Variables (which also includes the List and Other&#xD;blocks). There are no menus behind these buttons.&#xD;Buttons in the Palette&#xD;Under the eight palette selector buttons, at the top of the actual palette, are two semi-transparent buttons. The&#xD;first is the search button, which is equivalent to typing control-F: It replaces the palette with a search bar&#xD;into which you can type part of the title text of the block you’re trying to find. To leave this search mode, click&#xD;one of the eight palette selectors, or type the Escape key.&#xD;The other button is equivalent to the “Make a block” button, except that the dialog window that it opens&#xD;has the current palette (color) preselected.&#xD;Context Menus for Palette Blocks&#xD;Most elements of the Snap! display can be control-clicked/right-clicked to show a context menu, with items relevant&#xD;to that element. If you control-click/right-click a primitive block in the palette, you see this menu:&#xD;The help… option displays a box with documentation about the block. Here’s an example:&#xD;If you control-click/right-click a custom (user-defined) block in the palette, you see this menu:&#xD;The help… option for a custom block displays the comment, if any, attached to the custom block’s hat block in&#xD;the Block Editor. Here is an example of a block with a comment and its help display:&#xD;120&#xD;If the help text includes a URL, it is clickable and will open the page in a new tab.&#xD;The delete block de#nition… option asks for confirmation, then deletes the custom block and removes it from&#xD;any scripts in which it appears. (The result of this removal may not leave a sensible script; it’s best to find and&#xD;correct such scripts before deleting a block.) Note that there is no option to hide a custom block; this can be done&#xD;in the Block Editor by right-clicking on the hat block.&#xD;The duplicate block de#nition… option makes a copy of the block and opens that copy in the Block Editor.&#xD;Since you can’t have two custom blocks with the same title text and input types, the copy is created with “(2)”&#xD;(or a higher number if necessary) at the end of the block prototype.&#xD;The export block de#nition… option writes a file in your browser’s downloads directory containing the&#xD;definition of this block and any other custom blocks that this block invokes, directly or indirectly. So the&#xD;resulting file can be loaded later without the risk of red Unde#ned! blocks because of missing dependencies.&#xD;The edit… option opens a Block Editor with the definition of the custom block.&#xD;Context Menu for the Palette Background&#xD;Right-click/control-click on the grey background of the palette area shows this menu:&#xD;The #nd blocks… option does the same thing as the magnifying-glass button. The&#xD;hide blocks… option opens a dialog box in which you can choose which blocks&#xD;(custom as well as primitive) should be hidden. (Within that dialog box, the context&#xD;menu of the background allows you to check or uncheck all the boxes at once.)&#xD;121&#xD;The make a category… option, which is intended mainly for authors of snap extensions, lets you add custom&#xD;categories to the palette. It opens a small dialog window in which you specify a name and a color for the new&#xD;category:&#xD;Pick a dark color, because it will be lightened for zebra coloring when users nest blocks of the same category.&#xD;Custom categories are shown below the built-in categories in the category selector:&#xD;This example comes from Eckart Modrow’s SciSnap! library. Note that the custom category list has its own&#xD;scroll bar, which appears if you have more than six custom categories. Note also that the buttons to select a&#xD;custom category occupy the full width of the palette area, unlike the built-in categories, which occupy only half&#xD;of the width. Custom categories are listed in alphabetical order; this is why Prof. Modrow chose to start each&#xD;category name with a number, so that he could control their order.&#xD;If there are no blocks visible in a category, the category name is dimmed in the category selector:&#xD;Here we see that category foo has blocks in it, but categories bar and garply are empty. The built-in categories&#xD;are also subject to dimming, if all of the blocks of a category are hidden.&#xD;122&#xD;Palette Resizing&#xD;At the right end of the palette area, just to the left of the scripting area, is a resizing&#xD;handle that can be dragged rightward to increase the width of the palette area. This is&#xD;useful if you write custom blocks with very long names. You can’t reduce the width of&#xD;the palette below its standard value.&#xD;C. The Scripting Area&#xD;The scripting area is the middle vertical region of the Snap! window, containing scripts and also some controls for&#xD;the appearance and behavior of a sprite. There is always a current sprite, whose scripts are shown in the scripting&#xD;area. A dark grey rounded rectangle in the sprite corral shows which sprite (or the stage) is current. Note that&#xD;it’s only the visible display of the scripting area that is “current” for a sprite; all scripts of all sprites may be&#xD;running at the same time. Clicking on a sprite thumbnail in the sprite corral makes it current. The stage itself&#xD;can be selected as current, in which case the appearance is different, with some primitives not shown.&#xD;Sprite Appearance and Behavior Controls&#xD;At the top of the scripting area are a picture of the sprite and some controls for it:&#xD;Note that the sprite picture reflects its rotation, if any. There are three things that can be controlled here:&#xD;1. The three circular buttons in a column at the left control the sprite’s rotation behavior. Sprite costumes are&#xD;designed to be right-side-up when the sprite is facing toward the right (direction = 90). If the topmost button is&#xD;lit, the default as shown in the picture above, then the sprite’s costume rotates as the sprite changes direction. If&#xD;the middle button is selected, then the costume is reversed left-right when the sprite’s direction is roughly&#xD;leftward (direction between 180 and 359, or equivalently, between -180 and -1). If the bottom button is&#xD;selected, the costume’s orientation does not change regardless of the sprite’s direction.&#xD;2. The sprite’s name can be changed in the text box that, in this picture, says “Sprite.”&#xD;3. Finally, if the draggable checkbox is checked, then the user can move the sprite on the stage by clicking and&#xD;dragging it. The common use of this feature is in game projects, in which some sprites are meant to be under&#xD;the player’s control but others are not.&#xD;Scripting Area Tabs&#xD;Just below the sprite controls are three tabs that determine what is shown in the scripting area:&#xD;Scripts and Blocks Within Scripts&#xD;Most of what’s described in this section also applies to blocks and scripts in a Block Editor.&#xD;Clicking on a script (which includes a single unattached block) runs it. If the script starts with a hat block,&#xD;clicking on the script runs it even if the event in the hat block doesn’t happen. (This is a useful debugging&#xD;123&#xD;technique when you have a dozen sprites and they each have five scripts with green-flag hat blocks, and you&#xD;want to know what a single one of those scripts does.) The script will have a green “halo” around it while it’s&#xD;running. If the script is shared with clones, then while it has the green halo it will also have a count of how&#xD;many instances of the script are running. Clicking a script with such a halo stops the script. (If the script includes&#xD;a warp block, which might be inside a custom block used in the script, then Snap! may not respond immediately&#xD;to clicks.)&#xD;If a script is shown with a red halo, that means that an error was caught in that script, such as using a list where&#xD;a number was needed, or vice versa. Clicking the script will turn off the halo.&#xD;If any blocks have been dragged into the scripting area, then in its top right corner you’ll see an undo&#xD;and/or redo button that can be used to undo or redo block and script drops. When you undo a drop into&#xD;an input slot, whatever used to be in the slot is restored. The redo button appears once you’ve used undo.&#xD;The third button starts keyboard editing mode (Section D, page 130).&#xD;Control-click/right-clicking a primitive block within a script shows a menu like this one:&#xD;command block: r eporter block:&#xD;The help… option shows the help screen for the block, just as in the palette. The other options appear only&#xD;when a block is right-clicked/control-clicked in the scripting area.&#xD;Not every primitive block has a relabel… option. When present, it allows the block to be replaced by another,&#xD;similar block, keeping the input expressions in place. For example, here’s what happens when you choose&#xD;relabel… for an arithmetic operator:&#xD;Note that the inputs to the existing – block are displayed in the menu of alternatives also. Click a block in the&#xD;menu to choose it, or click outside the menu to keep the original block. Note that the last three choices are not&#xD;available in the palette; you must use the relabel feature to access them.&#xD;Not every reporter has a compile option; it exists only for the higher order functions. When selected, a&#xD;lightning bolt appears before the block name: and Snap! tries to compile the function inside&#xD;the ring to JavaScript, so it runs at primitive speed. This works only for simple functions (but the higher order&#xD;function still works even if the compilation doesn’t). The function to be compiled must be quick, because it will&#xD;be uninterruptable; in particular, if it’s an infinite loop, you may have to quit your browser to recover.&#xD;124&#xD;Therefore, save your project before you experiment with the compilation feature. The right-click menu for&#xD;a compiled higher order function will have an uncompile option. This is an experimental feature.&#xD;The duplicate option for a command block makes a copy of the entire script starting from the selected block.&#xD;For a reporter, it copies only that reporter and its inputs. The copy is attached to the mouse, and you can drag&#xD;it to another script (or even to another Block Editor window), even though you are no longer holding down the&#xD;mouse button. Click the mouse to drop the script copy.&#xD;The block picture underneath the word duplicate for a command block is another duplication option, but it&#xD;duplicates only the selected block, not everything under it in the script. Note that if the selected block is a Cshaped&#xD;control block, the script inside its C-shaped slot is included. If the block is at the end of its script, this&#xD;option does not appear. (Use duplicate instead.)&#xD;The extract option removes the selected block from the script and leaves you holding it with the mouse. In&#xD;other words, it’s like the block picture option, but it doesn’t leave a copy of the block in the original script. If the&#xD;block is at the end of its script, this option does not appear. (Just grab the block with the mouse.) A shorthand&#xD;for this operation is to shift-click and drag out the block.&#xD;The delete option deletes the selected block from the script.&#xD;The add comment option creates a comment, like the same option in the background of the scripting area, but&#xD;attaches it to the block you clicked.&#xD;The script pic… option saves a picture of the entire script, not just from the selected block to the end, into&#xD;your download folder; or, in some browsers, opens a new browser tab containing the picture. In the latter case,&#xD;you can use the browser’s Save feature to put the picture in a file. This is a super useful feature if you happen to&#xD;be writing a Snap! manual! (If you have a Retina display, consider turning off Retina support before making&#xD;script pictures; if not, they end up huge.) For reporters not inside a script, there is an additional result pic…&#xD;option that calls the reporter and includes a speech balloon with the result in the picture. Note: The&#xD;downloaded file is a “smart picture”: It also contains the code of the script, as if you’d exported the project. If&#xD;you later drag the file into the costumes tab, it will be loaded as a costume. But if you drag it into the scripts tab,&#xD;it will be loaded as a script, which you can drop wherever you want it in the scripting area.&#xD;If the script does not start with a hat block, or you clicked on a reporter, then there’s one more option: ringify&#xD;(and, if there is already a grey ring around the block or script, unringify). Ringify surrounds the block (reporter)&#xD;or the entire script (command) with a grey ring, meaning that the block(s) inside the ring are themselves data, as&#xD;an input to a higher order procedure, rather than something to be evaluated within the script. See Chapter VI,&#xD;Procedures as Data.&#xD;Clicking a custom block in a script gives a similar but different menu:&#xD;The relabel… option for custom blocks shows a menu of other same-shape custom blocks with the same inputs.&#xD;At present you can’t relabel a custom block to a primitive block or vice versa. The two options at the bottom,&#xD;125&#xD;for custom blocks only, are the same as in the palette. The other options are the same as for primitive&#xD;commands.&#xD;If a reporter block is in the scripting area, possibly with inputs included, but not itself serving as input to another&#xD;block, then the menu is a little different again:&#xD;What’s new here is the result pic… option. It’s like script pic… but it includes in the picture a speech balloon&#xD;with the result of calling the block.&#xD;Broadcast and broadcast and wait blocks in the scripting area have an additional option: receivers…. When&#xD;clicked, it causes a momentary (be looking for it when you click!) halo around the picture in the sprite corral of&#xD;those sprites that have a when I receive hat block for the same message. Similarly, when I receive blocks have a&#xD;senders… option that light up the sprite corral icons of sprites that broadcast the same message.&#xD;Scripting Area Background Context Menu&#xD;Control-click/right-click on the grey striped background of the scripting area gives this menu:&#xD;The undrop option is a sort of “undo” feature for the common case of dropping a block somewhere other than&#xD;where you meant it to go. It remembers all the dragging and dropping you’ve done in this sprite’s scripting area&#xD;(that is, other sprites have their own separate drop memory), and undoes the most recent, returning the block to&#xD;its former position, and restoring the previous value in the relevant input slot, if any. Once you’ve undropped&#xD;something, the redrop option appears, and allows you to repeat the operation you just undid. These menu&#xD;options are equivalent to the and buttons described earlier.&#xD;The clean up option rearranges the position of scripts so that they are in a single column, with the same left&#xD;margin, and with uniform spacing between scripts. This is a good idea if you can’t read your own project!&#xD;The add comment option puts a comment box, like the picture to the right, in the&#xD;scripting area. It’s attached to the mouse, as with duplicating scripts, so you position the&#xD;mouse where you want the comment and click to release it. You can then edit the text&#xD;in the comment as desired.&#xD;You can drag the bottom right corner of the comment box to resize it. Clicking the arrowhead at the top left&#xD;changes the box to a single-line compact form, , so that you can have a number of&#xD;collapsed comments in the scripting area and just expand one of them when you want to read it in full.&#xD;If you drag a comment over a block in a script, the comment will be attached to the block with a yellow line:&#xD;126&#xD;Comments have their own context menu, with obvious meanings:&#xD;Back to the options in the menu for the background of the scripting area (picture on the previous page):&#xD;The scripts pic… option saves, or opens a new browser tab with, a picture of all scripts in the scripting area,&#xD;just as they appear, but without the grey striped background. Note that “all scripts in the scripting area” means&#xD;just the top-level scripts of the current sprite, not other sprites’ scripts or custom block definitions. This is also a&#xD;“smart picture”; if you drag it into the scripting area, it will create a new sprite with those scripts in its scripting&#xD;area.&#xD;Finally, the make a block… option does the same thing as the “Make a block” button in the palettes. It’s a&#xD;shortcut so that you don’t have to keep scrolling down the palette if you make a lot of blocks.&#xD;Controls in the Costumes Tab&#xD;If you click on the word “Costumes” under the sprite controls, you’ll see something like this:&#xD;The Turtle costume is always present in every sprite; it is costume number 0. Other costumes can be painted&#xD;within Snap! or imported from files or other browser tabs if your browser supports that. Clicking on a costume&#xD;selects it; that is, the sprite will look like the selected costume. Clicking on the paint brush icon opens the&#xD;Paint Editor, in which you can create a new costume. Clicking on the camera icon opens a window in&#xD;which you see what your computer’s camera is seeing, and you can take a picture (which will be the full size of&#xD;the stage unless you shrink it in the Paint Editor). This works only if you give Snap! permission to use the&#xD;camera, and maybe only if you opened Snap! in secure (HTTPS) mode, and then only if your browser loves you.&#xD;127&#xD;Brian’s bedroom when he’s staying at Paul’s house.&#xD;Control-clicking/right-clicking on the turtle picture gives this menu:&#xD;In this menu, you choose the turtle’s rotation point, which is also the point from which the turtle draws lines. The&#xD;two pictures below show what the stage looks like after drawing a square in each mode; tip (otherwise known as&#xD;“Jens mode”) is on the left in the pictures below, middle (“Brian mode”) on the right:&#xD;As you see, “tip” means the front tip of the arrowhead; “middle” is not the middle of the shaded region, but&#xD;actually the middle of the four vertices, the concave one. (If the shape were a simple isosceles triangle instead of&#xD;a fancier arrowhead, it would mean the midpoint of the back edge.) The advantage of tip mode is that the&#xD;sprite is less likely to obscure the drawing. The advantage of middle mode is that the rotation point of a sprite is&#xD;rarely at a tip, and students are perhaps less likely to be confused about just what will happen if you ask the&#xD;turtle to turn 90 degrees from the position shown. (It’s also the traditional rotation point of the Logo turtle,&#xD;which originated this style of drawing.)&#xD;Costumes other than the turtle have a different context menu:&#xD;128&#xD;The edit option opens the Paint Editor on this costume. The rename option opens a dialog box in which you&#xD;can rename the costume. (A costume’s initial name comes from the file from which it was imported, if any, or is&#xD;something like costume5.) Duplicate makes a copy of the costume, in the same sprite. (Presumably you’d do&#xD;that because you intend to edit one of the copies.) Delete is obvious. The get blocks option appears only for a&#xD;smart costume, and brings its script to the scripting area. The export option saves the costume as a file on your&#xD;computer, in your usual downloads folder.&#xD;You can drag costumes up and down in the Costumes tab in order to renumber them, so that next costume&#xD;will behave as you prefer.&#xD;If you drag a smart picture of a script into the Costumes tab, its icon will display the text “&lt;/&gt;” in the corner to&#xD;remind you that it includes code:&#xD;Its right-click menu will have an extra get blocks option that switches to the Scripts tab with the script ready to&#xD;be dropped there.&#xD;The Paint Editor&#xD;Here is a picture of a Paint Editor window:&#xD;If you’ve used any painting program, most of this will be familiar to you. Currently, costumes you import can&#xD;be edited only if they are in a bitmap format (png, jpeg, gif, etc.). There is a vector editor, but it works only for&#xD;creating a costume, not editing an imported vector (svg) picture. Unlike the case of the Block Editor, only one&#xD;Paint Editor window can be open at a time.&#xD;The ten square buttons in two rows of five near the top left of the window are the tools. The top row, from left&#xD;to right, are the paintbrush tool, the outlined rectangle tool, the outlined ellipse tool, the eraser tool, and the&#xD;rotation point tool. The bottom row tools are the line drawing tool, the solid rectangle tool, the solid ellipse&#xD;tool, the floodfill tool, and the eyedropper tool. Below the tools is a row of four buttons that immediately change&#xD;the picture. The first two change its overall size; the next two flip the picture around horizontally or vertically.&#xD;Below these are a color palette, a greyscale tape, and larger buttons for black, white, and transparent paint.&#xD;Below these is a solid bar displaying the currently selected color. Below that is a picture of a line showing the&#xD;brush width for painting and drawing, and below that, you can set the width either with a slider or by typing a&#xD;129&#xD;number (in pixels) into the text box. Finally, the checkbox constrains the line tool to draw horizontally or&#xD;vertically, the rectangle tools to draw squares, and the ellipse tools to draw circles. You can get the same effect&#xD;temporarily by holding down the shift key, which makes a check appear in the box as long as you hold it down.&#xD;(But the Caps Lock key doesn’t affect it.)&#xD;You can correct errors with the undo button, which removes the last thing you drew, or the clear button,&#xD;which erases the entire picture. (Note, it does not revert to what the costume looked like before you started&#xD;editing it! If that’s what you want, click the Cancel button at the bottom of the editor.) When you’re finished&#xD;editing, to keep your changes, click OK.&#xD;Note that the ellipse tools work more intuitively than ones in other software you may have used. Instead of&#xD;dragging between opposite corners of the rectangle circumscribing the ellipse you want, so that the endpoints of&#xD;your dragging have no obvious connection to the actual shape, in Snap! you start at the center of the ellipse you&#xD;want and drag out to the edge. When you let go of the button, the mouse cursor will be on the curve. If you&#xD;drag out from the center at 45 degrees to the axes, the resulting curve will be a circle; if you drag more&#xD;horizontally or vertically, the ellipse will be more eccentric. (Of course if you want an exact circle you can hold&#xD;down the shift key or check the checkbox.) The rectangle tools, though, work the way you expect: You start at&#xD;one corner of the desired rectangle and drag to the opposite corner.&#xD;Using the eyedropper tool, you can click anywhere in the Snap! window, even outside the Paint Editor, and the&#xD;tool will select the color at the mouse cursor for use in the Paint Editor. You can only do this once, because the&#xD;Paint Editor automatically selects the paintbrush when you choose a color. (Of course you can click on the&#xD;eyedropper tool button again.)&#xD;The only other non-obvious tool is the rotation point tool. It shows in the Paint Editor where the sprite’s&#xD;current rotation center is (the point around which it turns when you use a turn block); if you click or drag in the&#xD;picture, the rotation point will move where you click. (You’d want to do this, for example, if you want a&#xD;character to be able to wave its arm, so you use two sprites connected together. You want the rotation point of&#xD;the arm sprite to be at the end where it joins the body, so it remains attached to the shoulder while waving.)&#xD;The vector editor’s controls are much like those in the bitmap editor. One point of difference is that the&#xD;bitmap editor has two buttons for solid and outline rectangles, and similarly for ellipses, but in the vector&#xD;editor there is always an edge color and a fill color, even if the latter is “transparent paint,” and so only one&#xD;button per shape is needed. Since each shape that you draw is a separate layer (like sprites on the stage), there&#xD;are controls to move the selected shape up (frontward) or down (rearward) relative to other shapes. There is a&#xD;selection tool to drag out a rectangular area and select all the shapes within that area.&#xD;130&#xD;Controls in the Sounds Tab&#xD;There is no Sound Editor in Snap!, and also no current sound the way there’s a current costume for each sprite.&#xD;(The sprite always has an appearance unless hidden, but it doesn’t sing unless explicitly asked.) So the context&#xD;menu for sounds has only rename, delete, and export options, and it has a clickable button labeled Play or&#xD;Stop as appropriate. There is a sound recorder, which appears if you click the red record button ( ):&#xD;The first, round button starts recording. The second, square button stops recording. The third, triangular&#xD;button plays back a recorded sound. If you don’t like the result, click the round button again to re-record.&#xD;When you’re satisfied, push the Save button. If you need a sound editor, consider the free (both senses)&#xD;https://audacity.sourceforge.net.&#xD;D. Keyboard Editing&#xD;An ongoing area of research is how to make visual programming languages usable by people with visual or&#xD;motoric disabilities. As a first step in this direction, we provide a keyboard editor, so that you can create and&#xD;edit scripts without tracking the mouse. So far, not every user interface element is controllable by keyboard, and&#xD;we haven’t even begun providing output support, such as interfacing with a speech synthesizer. This is an area in&#xD;which we know we have a long way to go! But it’s a start. The keyboard editor may also be useful to anyone&#xD;who can type faster than they can drag blocks.&#xD;Starting and stopping the keyboard editor&#xD;There are three ways to start the keyboard editor. Shift-clicking anywhere in the scripting area will start the&#xD;editor at that point: either editing an existing script or, if you shift-click on the background of the scripting area,&#xD;editing a new script at the mouse position. Alternatively, typing shift-enter will start the editor on an existing&#xD;script, and you can use the tab key to switch to another script. Or you can click the keyboard button at the top&#xD;of the scripting area.&#xD;When the script editor is running, its position is represented by a blinking white bar:&#xD;To leave the keyboard editor, type the escape key, or just click on the background of the scripting area.&#xD;Navigating in the keyboard editor&#xD;To move to a different script, type the tab key. Shift-tab to move through the scripts in reverse order.&#xD;131&#xD;A script is a vertical stack of command blocks. A command block may have input slots, and each input slot&#xD;may have a reporter block in it; the reporter may itself have input slots that may have other reporters. You can&#xD;navigate through a script quickly by using the up arrow and down arrow keys to move between command&#xD;blocks. Once you find the command block that you want to edit, the left and right arrow keys move between&#xD;editable items within that command. (Left and right arrow when there are no more editable items within the&#xD;current command block will move up or down to another command block, respectively.) Here is a sequence of&#xD;pictures showing the results of repeated right arrow keys starting from the position shown above:&#xD;You can rearrange scripts within the scripting area from the keyboard. Typing shift-arrow keys (left, right,&#xD;up, or down) will move the current script. If you move it onto another script, the two won’t snap together; the&#xD;one you’re moving will overlap the one already there. This means that you can move across another script to&#xD;get to a free space.&#xD;Editing a script&#xD;Note that the keyboard editor focus, the point shown as a white bar or halo, is either between two command blocks&#xD;or on an input slot. The editing keys do somewhat different things in each of those two cases.&#xD;The backspace key deletes a block. If the focus is between two commands, the one before (above) the blinking&#xD;bar is deleted. If the focus is on an input slot, the reporter in that slot is deleted. (If that input slot has a default&#xD;value, it will appear in the slot.) If the focus is on a variadic input (one that can change the number of inputs by&#xD;clicking on arrowheads), then one input slot is deleted. (When you right-arrow into a variadic input, the focus&#xD;first covers the entire thing, including the arrowheads; another right-arrow focuses on the first slot within that&#xD;input group. The focus is “on the variadic input” when it covers the entire thing.)&#xD;The enter key does nothing if the focus is between commands, or on a reporter. If the focus is on a variadic&#xD;input, the enter key adds one more input slot. If the focus is on a white input slot (one that doesn’t have a&#xD;reporter in it), then the enter key selects that input slot for editing; that is, you can type into it, just as if you’d&#xD;clicked on the input slot. (Of course, if the focus is on an input slot containing a reporter, you can use the&#xD;backspace key to delete that reporter, and then use the enter key to type a value into it.) When you finish typing&#xD;the value, type the enter key again to accept it and return to navigation, or the escape key if you decide not to&#xD;change the value already in the slot.&#xD;The space key is used to see a menu of possibilities for the input slot in focus. It does nothing unless the focus&#xD;is on a single input slot. If the focus is on a slot with a pulldown menu of options, then the space key shows that&#xD;menu. (If it’s a block-colored slot, meaning that only the choices in the menu can be used, the enter key will do&#xD;the same thing. But if it’s a white slot with a menu, such as in the turn blocks, then enter lets you type a value,&#xD;while space shows the menu.) Otherwise, the space key shows a menu of variables available at this point in the&#xD;script. In either case, use the up and down arrow keys to navigate the menu, use the enter key to accept the&#xD;highlighted entry, or use the escape key to leave the menu without choosing an option.&#xD;132&#xD;Typing any other character key (not special keys on fancy keyboards that do something other than&#xD;generating a character) activates the block search palette. This palette, which is also&#xD;accessible by typing control-F or command-F outside the keyboard editor, or by&#xD;clicking the search button floating at the top of the palette, has a text entry field at the&#xD;top, followed by blocks whose title text includes what you type. The character key you&#xD;typed to start the block search palette is entered into the text field, so you start with a&#xD;palette of blocks containing that character. Within the palette, blocks whose titles start&#xD;with the text you type come first, then blocks in which a word of the title starts with the&#xD;text you type, and finally blocks in which the text appears inside a word of the title.&#xD;Once you have typed enough text to see the block you want, use the arrow keys to navigate to that block in the&#xD;palette, then enter to insert that block, or escape to leave the block search palette without inserting the block.&#xD;(When not in the keyboard editor, instead of navigating with the arrow keys, you drag the block you want into&#xD;the script, as you would from any other palette.)&#xD;If you type an arithmetic operator (+-*/) or comparison operator (&lt;=&gt;) into the block search text box,&#xD;you can type an arbitrarily complicated expression, and a collection of arithmetic operator blocks will be&#xD;constructed to match:&#xD;As the example shows, you can also use parentheses for grouping, and non-numeric operands are treated as&#xD;variables or primitive functions. (A variable name entered in this way may or may not already exist in the script.&#xD;Only round and the ones in the pulldown menu of the sqrt block can be used as function names.)&#xD;Running the selected script&#xD;Type control-shift-enter to run the script with the editor focus, like clicking the script.&#xD;E. Controls on the Stage&#xD;The stage is the area in the top right of the Snap! window in which sprites move.&#xD;Sprites&#xD;Most sprites can be moved by clicking and dragging them. (If you have unchecked the draggable checkbox for&#xD;a sprite, then dragging it has no effect.) Control-clicking/right-clicking a sprite shows this context menu:&#xD;The duplicate option makes another sprite with copies of the same scripts, same costumes, etc., as this sprite.&#xD;The new sprite starts at a randomly chosen position different from the original, so you can see quickly which is&#xD;which. The new sprite is selected: It becomes the current sprite, the one shown in the scripting area. The clone&#xD;option makes a permanent clone of this sprite, with some shared attributes, and selects it.&#xD;133&#xD;The delete option deletes the sprite. It’s not just hidden; it’s gone for good. (But you can undelete it by&#xD;clicking the wastebasket just below the right edge of the stage.) The edit option selects the sprite. It doesn’t&#xD;actually change anything about the sprite, despite the name; it’s just that making changes in the scripting area&#xD;will change this sprite.&#xD;The move option shows a “move handle” inside the sprite (the diagonal striped square in the middle):&#xD;You can ordinarily just grab and move the sprite without this option, but there are two reasons you might need&#xD;it: First, it works even if the “draggable” checkbox above the scripting area is unchecked. Second, it works for&#xD;part sprites relative to their anchor; ordinarily, dragging a part moves the entire nested sprite.&#xD;The rotate option displays a rotation menu:&#xD;You can choose one of the four compass directions in the lower part (the same as in the point in direction block)&#xD;or use the mouse to rotate the handle on the dial in 15° increments.&#xD;The pivot option shows a crosshair inside the sprite:&#xD;You can click and drag the crosshair anywhere onstage to set the costume’s pivot point. (If you move it outside&#xD;the sprite, then turning the sprite will revolve as well as rotate it around the pivot.) When done, click on the&#xD;stage not on the crosshair. Note that, unlike moving the pivot point in the Paint Editor, this technique does not&#xD;visibly move the sprite on the stage. Instead, the values of x position and y position will change.&#xD;The edit option makes this the selected sprite, highlighting it in the sprite corral and showing its scripting area.&#xD;If the sprite was a temporary clone, it becomes permanent.&#xD;The export… option saves, or opens a new browser tab containing, the XML text representation of the sprite.&#xD;(Not just its costume, but all of its costumes, scripts, local variables and blocks, and other properties.) You can&#xD;save this tab into a file on your computer, and later import the sprite into another project. (In some browsers,&#xD;the sprite is directly saved into a file.)&#xD;134&#xD;Variable watchers&#xD;Right-clicking on a variable watcher shows this menu:&#xD;The first section of the menu lets you choose one of three visualizations of the watcher:&#xD;The first (normal) visualization is for debugging. The second (large) is for displaying information to the user of&#xD;a project, often the score in a game. And the third (slider) is for allowing the user to control the program&#xD;behavior interactively. When the watcher is displayed as a slider, the middle section of the menu allows you to&#xD;control the range of values possible in the slider. It will take the minimum value when the slider is all the way to&#xD;the left, the maximum value when all the way to the right.&#xD;The third section of the menu allows data to be passed between your computer and the variable. The&#xD;import… option will read a computer text file. Its name must end with .txt, in which case the text is read into&#xD;the variable as is, or .csv or .json, in which case the text is converted into a list structure, which will always&#xD;be a two-dimensional array for csv (comma-separated values) data, but can be any shape for json data. The raw&#xD;data… option prevents that conversion to list form. The export… option does the opposite conversion, passing&#xD;a text-valued variable value into a .txt file unchanged, but converting a list value into csv format if the list is&#xD;one- or two-dimensional, or into json format if the list is more complicated. (The scalar values within the list&#xD;must be numbers and/or text; lists of blocks, sprites, costumes, etc. cannot be exported.)&#xD;An alternative to using the import… option is simply to drag the file onto the Snap! window, in which case a&#xD;variable will be created if necessary with the same name as the file (but without the extension).&#xD;If the value of the variable is a list, then the menu will include an additional blockify option; clicking it will&#xD;generate an expression with nested list blocks that, if evaluated, will reconstruct the list. It’s useful if you&#xD;imported a list and then want to write code that will construct the same list later.&#xD;135&#xD;The stage itself&#xD;Control-clicking/right-clicking on the stage background (that is, anywhere on the stage except on a sprite or&#xD;watcher) shows the stage’s own context menu:&#xD;The stage’s edit option selects the stage, so the stage’s scripts and backgrounds are seen in the scripting area.&#xD;Note that when the stage is selected, some blocks, especially the Motion ones, are not in the palette area because&#xD;the stage can’t move.&#xD;The show all option makes all sprites visible, both in the sense of the show block and by bringing the sprite&#xD;onstage if it has moved past the edge of the stage.&#xD;The pic… option saves, or opens a browser tab with, a picture of everything on the stage: its background, lines&#xD;drawn with the pen, and any visible sprites. What you see is what you get. (If you want a picture of just the&#xD;background, select the stage, open its costumes tab, control-click/right-click on a background, and export it.)&#xD;The pen trails option creates a new costume for the currently selected sprite consisting of all lines drawn on&#xD;the stage by the pen of any sprite. The costume’s rotation center will be the current position of the sprite.&#xD;If you previously turned on the log pen vectors option, and there are logged vectors, the menu includes an&#xD;extra option, svg…, that exports a picture of the stage in vector format. Only lines are logged, not color regions&#xD;made with the #ll block.&#xD;F. The Sprite Corral and Sprite Creation Buttons&#xD;Between the stage and the sprite corral at the bottom right of the Snap! window is a dark grey bar containing&#xD;three buttons at the left and one at the right. The first three are used to create a new sprite. The first button&#xD;makes a sprite with just the turtle costume, with a randomly chosen position and pen color. (If you hold&#xD;down the Shift key while clicking, the new sprite’s direction will also be random.) The second button&#xD;makes a sprite and opens the Paint Editor so that you can make your own costume for it. (Of course you could&#xD;click the first button and then click the paint button in its costumes tab; this paint button is a shortcut for all&#xD;that.) Similarly, the third button uses your camera, if possible, to make a costume for the new sprite.&#xD;The trash can button at the right has two uses. You can drag a sprite thumbnail onto it from the sprite&#xD;corral to delete that sprite, or you can click it to undelete a sprite you deleted by accident.&#xD;In the sprite corral, you click on a sprite’s “thumbnail” picture to select that sprite (to make it the one whose&#xD;scripts, costumes, etc. are shown in the scripting area). You can drag sprite thumbnails (but not the stage one) to&#xD;reorder them; this has no special effect on your project, but lets you put related ones next to each other, for&#xD;example. Double-clicking a thumbnail flashes a halo around the actual sprite on the stage.&#xD;136&#xD;You can right-click/control-click a sprite’s thumbnail to get this context menu:&#xD;The show option makes the sprite visible, if it was hidden, and also brings it onto the stage, if it had moved past&#xD;the stage boundary. The next three options are the same as in the context menu of the actual sprite on the&#xD;stage, discussed above.&#xD;The parent… option displays a menu of all other sprites, showing which if any is this sprite’s parent, and&#xD;allowing you to choose another sprite (replacing any existing parent). The release option is shown only if this&#xD;sprite is a (permanent, or it wouldn’t be in the sprite corral) clone; it changes the sprite to a temporary clone.&#xD;(The name is supposed to mean that the sprite is released from the corral.) The export… option exports the&#xD;sprite, like the same option on the stage.&#xD;The context menu for the stage thumbnail has only one option, pic…, which takes a picture of everything on&#xD;the stage, just like the same option in the context menu of the stage background. If pen trails are being logged,&#xD;there will also be an svg… option.&#xD;If your project includes scenes, then under the stage icon in the sprite corral will be the scene corral:&#xD;Clicking on a scene will select it; right-clicking will present a menu in which you can rename, delete, or export&#xD;the scene.&#xD;G. Preloading a Project when Starting Snap!&#xD;There are several ways to include a pointer to a project in the URL when starting Snap! in order to load a&#xD;project automatically. You can think of such a URL as just running the project rather than as running Snap!,&#xD;especially if the URL says to start in presentation mode and click the green flag. The general form is&#xD;https://snap.berkeley.edu/run#verb:project&amp;flag&amp;flag…&#xD;The “verb” above can be any of open, run, cloud, present, or dl. The last three are for shared projects&#xD;in the Snap! cloud; the first two are for projects that have been exported and made available anywhere on the&#xD;Internet.&#xD;Here’s an example that loads a project stored at the Snap! web site (not the Snap! cloud!):&#xD;https://snap.berkeley.edu/run#open:https://snap.berkeley.edu/snapsource/Examples/vee.xml&#xD;137&#xD;The project file will be opened, and Snap! will start in edit mode (with the program visible). Using #run:&#xD;instead of #open: will start in presentation mode (with only the stage visible) and will “start” the project by&#xD;clicking the green flag. (“Start” is in quotation marks because there is no guarantee that the project includes any&#xD;scripts triggered by the green flag. Some projects are started by typing on the keyboard or by clicking a sprite.)&#xD;If the verb is run, then you can also use any subset of the following flags:&#xD;&amp;editMode Start in edit mode, not presentation mode.&#xD;&amp;noRun Don’t click the green flag.&#xD;&amp;hideControls Don’t show the row of buttons above the stage (edit mode, green flag, pause, stop).&#xD;&amp;lang=fr Set language to (in this example) French.&#xD;&amp;noCloud Don’t allow cloud operations from this project (for running projects from unknown&#xD;sources that include JavaScript code)&#xD;&amp;noExitWarning When closing the window or loading a different URL, don’t show the browser&#xD;“are you sure you want to leave this page” message.&#xD;&amp;blocksZoom=n Like the Zoom blocks option in the Settings menu.&#xD;The last of these flags is intended for use on a web page in which a Snap! window is embedded.&#xD;Here’s an example that loads a shared (public) project from the Snap! cloud:&#xD;https://snap.berkeley.edu/run#present:Username=jens&amp;ProjectName=tree%20animation&#xD;(Note that “Username” and “ProjectName” are TitleCased, even though the flags such as “noRun” are&#xD;camelCased. Note also that a space in the project name must be represented in Unicode as %20.) The verb&#xD;present behaves like run: it ordinarily starts the project in presentation mode, but its behavior can be&#xD;modified with the same four flags as for run. The verb cloud (yes, we know it’s not a verb in its ordinary use)&#xD;behaves like open except that it loads from the Snap! cloud rather than from the Internet in general. The verb&#xD;dl (short for “download”) does not start Snap! but just downloads a cloud-saved project to your computer as an&#xD;.xml file. This is useful for debugging; sometimes a defective project that Snap! won’t run can be downloaded,&#xD;edited, and then re-saved to the cloud.&#xD;H. Mirror Sites&#xD;If the site snap.berkeley.edu is ever unavailable, you can load Snap! at the following mirror sites:&#xD;● https://bjc.edc.org/snapsource/snap.html&#xD;● https://cs10.org/snap&#xD;138&#xD;Appendix A. Snap! color library&#xD;The Colors and Crayons library provides several tools for manipulating color. Although its main purpose is&#xD;controlling a sprite’s pen color, it also establishes colors as a first class data type:&#xD;For people who just want colors in their projects without having to be color experts, we provide two simple&#xD;mechanisms: a color number scale with a broad range of continuous color variation and a set of 100 crayons&#xD;organized by color family (ten reds, ten oranges, etc.) The crayons include the block colors:&#xD;For experts, we provide color selection by RGB, HSL, HSV, X11/W3C names, and variants on those scales.&#xD;Introduction to Color&#xD;Your computer monitor can display millions of colors, but you probably can’t distinguish that many. For&#xD;example, here’s red 57, green 180, blue 200: And here’s red 57, green 182, blue 200: You might be&#xD;able to tell them apart if you see them side by side: … but maybe not even then.&#xD;Color space—the collection of all possible colors—is three-dimensional, but there are many ways to choose the&#xD;dimensions. RGB (red-green-blue), the one most commonly used in computers, matches the way TVs and&#xD;displays produce color. Behind every dot on the screen are three tiny lights: a red one, a green one, and a blue&#xD;one. But if you want to print colors on paper, your printer probably uses a different set of three colors: CMY&#xD;(cyan-magenta-yellow). You may have seen the abbreviation CMYK, which represents the common technique&#xD;of adding black ink to the collection. (Mixing cyan, magenta, and yellow in equal amounts is supposed to result&#xD;in black ink, but typically it comes out a muddy brown instead, because chemistry.) Other systems that try to&#xD;mimic human perception are HSL (hue-saturation-lightness) and HSV (hue-saturation-value). There are many,&#xD;many more, each designed for a particular purpose.&#xD;If you are a color professional—a printer, a web designer, a graphic designer, an artist—then you need to&#xD;understand all this. It can also be interesting to learn about. For example, there are colors that you can see but&#xD;your computer display can’t generate. If that intrigues you, look up color theory in Wikipedia.&#xD;139&#xD;Crayons and Color Numbers&#xD;But if you just want some colors in your project, we provide a simple, one-dimensional subset of the available&#xD;colors. Two subsets, actually: crayons and color numbers. Here’s the difference:&#xD;The first row shows 100 distinct colors. They have names; this is pumpkin, and this is denim. You’re&#xD;supposed to think of them as a big box of 100 crayons. They’re arranged in families: grays, pinks, reds, browns,&#xD;oranges, etc. But they’re not consistently ordered within a family; you’d be unlikely to say “next crayon” in a&#xD;project. (But look at the crayon spiral on page 145.) Instead, you’d think “I want this to look like a really old-fashioned&#xD;photo” and so you’d find sepia as crayon number 33. You don’t have to memorize the numbers! You can&#xD;find them in a menu with a submenu for each family.&#xD;Or, if you know the crayon name, just .&#xD;The crayon numbers are chosen so that skipping by 10 gives a sensible box of ten crayons:&#xD;Alternatively, skipping by 5 gives a still-sensible set of twenty crayons:&#xD;The set of color numbers is arranged so that each color number is visually near each of its neighbors. Bright and&#xD;dark colors alternate for each family. Color numbers range from 0 to 99, like crayon numbers, but you can use&#xD;fractional numbers to get as tiny a step as you like:&#xD;(“As tiny as you like” isn’t quite true because in the end, your color has to be rounded to integer RGB values for display.)&#xD;Both of these scales include the range of shades of gray, from black to white. Since black is the initial pen color, and black isn’t a hue, Scratch and&#xD;Snap! users would traditionally try to use set color to escape from black, and it wouldn’t work. By including black in the same scale as other colors, we&#xD;eliminate the Black Hole problem if people use only the recommended color scales.&#xD;We are making a point of saying “color number” for what was sometimes called just “color” in earlier versions&#xD;of the library, because we now reserve the name “color” for an actual color, an instance of the color data type.&#xD;140&#xD;How to Use the Library&#xD;There are three library blocks specifically about controlling the pen. They have the same names as three of the&#xD;primitive Pen blocks:&#xD;The first (Pen block-colored) input slot is used to select which color scale you want to use. (These blocks also&#xD;allow reading or setting two block properties that are not colors: the pen size and its transparency.) The pen&#xD;reporter requires no other inputs; it reports the state of the pen in whatever dimension you choose.&#xD;As the last example shows, you can’t ask for the pen color in a scale incompatible with how you set it, unless the&#xD;block can deduce what you want from what it knows about the current pen color.&#xD;The change pen block applies only to numeric scales (including vectors of three or four numbers). It adds its&#xD;numeric or list input to the current pen value(s), doing vector (item-by-item) addition for vector scales.&#xD;The set pen block changes the pen color to the value(s) you specify. The meaning of the white input slots&#xD;depends on which attribute of the pen you’re setting:&#xD;In the last example, the number 37 sets the transparency, on the scale 0=opaque, 100=invisible. (All color&#xD;attributes are on a 0–100 scale except for RGB components, which are 0–255.) A transparency value can be&#xD;combined with any of these attribute scales.&#xD;The library also includes two constructors and a selector for colors as a data type:&#xD;The latter two are inverses of each other, translating between colors and their attributes. The color from block’s&#xD;attribute menu has fewer choices than the similar set pen block because you can, for example, set the Red value&#xD;of the existing pen color leaving the rest unchanged, but when creating a color out of nothing you have to&#xD;provide its entire specification, e.g., all of Red, Green, and Blue, or the equivalent in other scales. (As you’ll see&#xD;on the next page, we provide two linear (one-dimensional) color scales that allow you to specify a color with a&#xD;single number, at the cost of including only a small subset of the millions of colors your computer can generate.)&#xD;If you have a color and want another color that’s the same except for one number, as in the Red example, you&#xD;can use this block:&#xD;Finally, the library includes the mix block and a helper:&#xD;We’ll have more to say about these after a detour through color theory.&#xD;That’s all you have to know about colors! Crayons for specific interesting ones, color numbers for gradual&#xD;transformation from one color to the next. But there’s a bit more to say, if you’re interested. If not, stop here.&#xD;(But look at the samples of the different scales on page 145.)&#xD;141&#xD;More about Colors: Fair Hues and Shades&#xD;Several of the three-dimensional arrangements of colors use the concept of “hue,” which more or less means&#xD;where a color would appear in a rainbow (magenta, near the right, is a long story):&#xD;These are called “spectral” colors, after the spectrum of rainbow colors. But these colors aren’t equally&#xD;distributed. There’s an awful lot of green, hardly any yellow, and just a sliver of orange. And no brown at all.&#xD;And this is already a handwave, because the range of colors that can be generated by RGB monitors doesn’t include some of the true&#xD;spectral colors. See Spectral color in Wikipedia for all the gory details.&#xD;This isn’t a problem with the physics of rainbows. It’s in the human eye and the human brain that certain&#xD;ranges of wavelength of light waves are lumped together as named colors. The eye is just “tuned” to recognize a&#xD;wide range of colors as green. (See Rods and Cones.) And different human cultures give names to different color&#xD;ranges. Nevertheless, in old Scratch projects, you’d say change pen color by 1 and it’d take forever to reach a&#xD;color that wasn’t green.&#xD;For color professionals, there are good reasons to want to work with the physical rainbow hue layout. But for&#xD;amateurs using a simplified, one-dimensional color model, there’s no reason not to use a more programmerfriendly&#xD;hue scale:&#xD;In this scale, each of the seven rainbow colors and brown get an equal share. (Red’s&#xD;looks too small, but that’s because it’s split between the two ends: hue 0 is pure red,&#xD;brownish reds are to its right, and purplish reds are wrapped around to the right end.)&#xD;We call this scale “fair hue” because each color family gets a fair share of the total hue&#xD;range. (By the way, you were probably taught “… green, blue, indigo, violet” in school, but it turns out that color&#xD;names were different in Isaac Newton’s day, and the color he called “blue” is more like modern cyan, while his&#xD;“indigo” is more like modern blue. See Wikipedia Indigo.)&#xD;Our color number scale is based on fair hues, adding a range of grays from black (color number 0) to white (color&#xD;number14) and also adding shades of the spectral colors. (In color terminology, a shade is a darker version of a&#xD;color; a lighter version is called a tint.) Why do we add shades but not tints? Partly because I find shades more&#xD;exciting. A shade of red can be dark candy apple red or maroon , but a tint is just some kind of&#xD;pink . This admitted prejudice is supported by an objective fact: Most projects are made on a white&#xD;background, so dark colors stand out better than light ones.&#xD;So, in our color number scale, color numbers 0 to 14 are kinds of gray; the remaining color numbers go through&#xD;the fair hues, but alternating full-strength colors with shades.&#xD;This chart shows how the color scales discussed so far are related. Note that all scales range from 0 to 100; the&#xD;fair hues scale has been compressed in the chart so that similar colors line up vertically. (Its dimensions are&#xD;crayons by 10&#xD;crayons by 5&#xD;crayons&#xD;fair hues&#xD;color numbers&#xD;color numbers by 5&#xD;color numbers by 10&#xD;142&#xD;different because it doesn’t include the grays at the left. Since there are eight color families, the pure, named&#xD;fair hues are at multiples of 100/8=12.5, starting with red=0.)&#xD;White is crayon 14 and color number 14. This value was deliberately chosen not to be a multiple of 5 so that the&#xD;every-fifth-crayon and every-tenth-crayon selections don’t include it, so that all of the crayons in those smaller&#xD;boxes are visible against a white stage background.&#xD;Among purples, the official spectral violet (crayon 90) is the end of the spectrum.&#xD;Magenta, brighter than violet, isn’t a spectral color at all. (In the picture at the left, the&#xD;top part is the spectrum of white light spread out through a prism; the middle part is a photograph of&#xD;a rainbow, and the bottom part is a digital simulation of a rainbow.) Magenta is a mixture of&#xD;red and blue. (attribution: Wikipedia user Andys. CC BY-SA.)&#xD;The light gray at color number 10 is slightly different from crayon 10 just because of roundoff in computing&#xD;crayon values. Color number 90 is different from crayon 90 because the official RGB violet (equal parts red and&#xD;blue) is actually lighter than spectral violet. The purple family is also unusual because magenta, crayon and&#xD;color number 95, is lighter than the violet at 90. In other families, the color numbers, crayons, and (scaled) fair&#xD;hues all agree at multiples of ten. These multiple-of-ten positions are the standard RGB primary and secondary&#xD;colors, e.g., the yellow at color number 50 is (255, 255, 0) in RGB. (Gray, brown, and orange don’t have such&#xD;simple RGB settings.)&#xD;The color numbers at odd multiples of five are generally darker shades than the corresponding crayons. The&#xD;latter are often official named shades, e.g., teal, crayon 65, is a half-intensity shade of cyan. The odd-five color&#xD;numbers, though, are often darker, since they are chosen to be the darkest color in a given family that’s visibly&#xD;different from black. The pink at color number 15, though, is quite different from crayon 15, because the&#xD;former is a pure tint of red, whereas the crayon, to get a more interesting pink, has a little magenta mixed in.&#xD;Color numbers at multiples of five are looked up in a table; other color values are determined by linear&#xD;interpolation in RGB space. (Crayons are of course all found by table lookup.)&#xD;The from color block behaves specially when you ask for the color number of a color. Most colors don’t exactly match a color number,&#xD;and for other attributes of a color (crayon number, X11 name) you don’t get an answer unless the color exactly matches one of the&#xD;names or numbers in that attribute. But for color number, the block tries to find the nearest color number to the color you specify. The&#xD;result will be only approximate; you can’t use the number you get to recreate the input color. But you can start choosing nearby color&#xD;numbers as you animate the sprite.&#xD;Perceptual Spaces: HSV and HSL&#xD;RGB is the right way to think about colors if you’re building or programming a display monitor; CMYK is the&#xD;right way if you’re building or programming a color printer. But neither of those coordinate&#xD;systems is very intuitive if you’re trying to understand what color you see if, for example, you mix&#xD;37% red light, 52% green, and 11% blue. The hue scale is one dimension of most attempts at a&#xD;perceptual scale. The square at the right has pale blues along the top edge, dark blues along the&#xD;right edge, various shades of gray toward the left, black at the bottom, and pure spectral blue in the&#xD;top right corner. Although no other point in the square is pure blue, you can tell at a glance that no other&#xD;spectral color is mixed with the blue.&#xD;Aside from hue, the other two dimensions of a color space have to&#xD;represent how much white and/or black is mixed with the spectral&#xD;color. (Bear in mind that “mixing black” is a metaphor when it&#xD;comes to monitors. There really is black paint, but there’s no such&#xD;thing as black light.) One such space, HSV, has one dimension for&#xD;the amount of color (vs. white), c attribution: Wikipedia user SharkD, CC BY-SA 3.0 alled saturation, and one for the&#xD;143&#xD;amount of black, imaginatively called value. HSV stands for Hue-Saturation-Value. (Value is also called&#xD;brightness.) The value is actually measured backward from the above description; that is, if value is 0, the color is&#xD;pure black; if value is 100, then a saturation of 0 means all white, no spectral color; a saturation of 100 means no&#xD;white at all. In the square in the previous paragraph, the x axis is the saturation and the y axis is the value. The&#xD;entire bottom edge is black, but only the top left corner is white. HSV is the traditional color space used in&#xD;Scratch and Snap!. Set pen color set the hue; set pen shade set the value. There was originally no Pen block to&#xD;set the saturation, but there’s a set brightness e&amp;ect Looks block to control the saturation of the sprite’s&#xD;costume. (I speculate that the Scratch designers, like me, thought tints were less vivid than shades against a&#xD;white background, so they made it harder to control tinting.)&#xD;But if you’re looking at colors on a computer display, HSV isn’t really a good match for human perception.&#xD;Intuitively, black and white should be treated symmetrically. This is the HSL (hue-saturation-lightness) color&#xD;space. Saturation, in HSL, is a measure of the grayness or dullness of a color (how close it comes to&#xD;being on a black-and-white scale) and lightness measures spectralness with pure white at one end,&#xD;pure black at the other end, and spectral color in the middle. The saturation number is actually the&#xD;opposite of grayness: 0 means pure gray, and 100 means pure spectral color, provided that the&#xD;lightness is 50, midway between black and white. Colors with lightness other than 50 have some black or white&#xD;mixed in, but saturation 100 means that the color is as fully saturated as it can be, given the amount of white or&#xD;black needed to achieve that lightness. Saturation less than 100 means that both white and black are mixed with&#xD;the spectral color. (Such mixtures are called tones of the spectral color. Perceptually, colors with saturation&#xD;100% don’t look gray: but colors with saturation 75% do:&#xD;Note that HSV and HSL both have a dimension called “saturation,” but they’re not the same thing! In HSV,&#xD;“saturation” means non-whiteness, whereas in HSL it means non-grayness (vividness).&#xD;More fine print: It’s misleading to talk about the spectrum of light wavelengths as if it were the same as perceived hue. If your&#xD;computer display is showing you a yellow area, for example, it’s doing it by turning on its red and green LEDs over that area, and&#xD;what hits your retina is still two wavelengths of light, red and green, superimposed. You could make what’s perceptually the same yellow by&#xD;using a single intermediate wavelength. Your eye and brain don’t distinguish between those two kinds of yellow. Also, your brain&#xD;automatically adjusts perceived hue to correct for differences in illumination. When you place a monochrome object so that it’s half in&#xD;sunlight and half in the shade, you see it as one even though what’s reaching your eyes from the two regions differs a lot. And, sadly,&#xD;it’s HSL whose use of “saturation” disagrees with the official international color vocabulary standardization committee. I learned all&#xD;this from this tutorial, which you might find more coherent than jumping around Wikipedia if you’re interested.&#xD;Although traditional Scratch and Snap! use HSV in programs, they use HSL in the&#xD;color picker. The horizontal axis is hue (fair hue, in this version) and the vertical axis&#xD;is lightness, the scale with black at one end and white at the other end. It would make&#xD;no sense to have only the bottom half of this selector (HSV Value) or only the top half&#xD;(HSV Saturation). And, given that you can only fit two dimensions on a flat screen, it&#xD;makes sense to pick HSL saturation (vividness) as the one to keep at 100%. (In this fair-hue picker, some colors appear&#xD;twice: “spectral” (50% lightness) browns as shades (≈33% lightness) of red or orange, and shades of those browns.)&#xD;Software that isn’t primarily about colors (so, not including Photoshop, for example) typically use HSV or HSL,&#xD;with web-based software more likely to use HSV because that’s what’s built into the JavaScript programming&#xD;language provided by browsers. But if the goal is to model human color perception, neither of these color&#xD;spaces is satisfactory, because they assume that all full-intensity spectral colors are equally bright. But if you’re&#xD;like most people, you see spectral yellow as much brighter than spectral blue . There are better perceptual&#xD;color spaces with names like L*u*v* and L*a*b* that are based on research with human subjects to determine&#xD;true perceived brightness. Wikipedia explains all this and more at HSL and HSV, where they recommend&#xD;ditching both of these simplistic color spaces. J&#xD;144&#xD;Mixing Colors&#xD;Given first class colors, the next question is, what operations apply to them, the way arithmetic operators apply&#xD;to numbers and higher order functions apply to lists? The equivalent to adding numbers is mixing colors, but&#xD;unfortunately there isn’t a simple answer to what that means.&#xD;The easiest kind of color mixing to understand is additive mixing, which is what happens when you shine two&#xD;colored lights onto a (white) wall. It’s also what happens in your computer screen, where each dot (pixel) of an&#xD;image is created by a tiny red light, a tiny green light, and a tiny blue light that can be combined at different&#xD;strengths to make different colors. Essentially, additive mixing of two colors is computed by adding the two red&#xD;components, the two green components, and the two blue components. It’s not quite that simple only because&#xD;each component of the result must be in the range 0 to 255. So, red (255, 0, 0) mixed with green (0, 255, 0)&#xD;gives (255, 255, 0), which is yellow. But red (255, 0, 0) plus yellow (255, 255, 0) can’t give (510, 255, 0). Just&#xD;limiting the red in the result to 255 would mean that red plus yellow is yellow, which doesn’t make sense.&#xD;Instead, if the red value has to be reduced by half (from 510 to 255), then all three values must be reduced by&#xD;half, so the result is (255, 128, 0), which is orange. (Half of 255 is 127.5, but each RGB value must be an&#xD;integer.)&#xD;A different kind of color mixing based on light is done when different colored transparent plastic sheets are&#xD;held in front of a white light, as is done in theatrical lighting. In that situation, the light that gets through both&#xD;filters is what remains after some light is filtered out by the first one and some of what’s left is filtered out by the&#xD;second one. In red-green-blue terms, a red filter filters out green and blue; a yellow filter allows red and green&#xD;through, filtering out blue. But there isn’t any green light for the yellow filter to pass; it was filtered out by the&#xD;red filter. Each filter can only remove light, not add light, so this is called subtractive mixing:&#xD;Perhaps confusingly, the numerical computation of subtractive mixing is done by multiplying the RGB values,&#xD;taken as fractions of the maximum 255, so red (1, 0, 0) times yellow (1, 1, 0) is red again.&#xD;Those are both straightforward to compute. Much, much more complicated is trying to simulate the result of&#xD;mixing paints. It’s not just that we’d have to compute a more complicated function of the red, green, and blue&#xD;values; it’s that RGB values (or any other three-dimensional color space) are inadequate to describe the behavior&#xD;of paints. Two paints can look identical, and have the same RGB values, but may still behave very differently&#xD;when mixed with other colors. The differences are mostly due to the chemistry of the paints, but are also&#xD;affected by exactly how the colors are mixed. The mixing is mostly subtractive; red paint absorbs most of the&#xD;colors other than red, so what’s reflected off the surface is whatever isn’t absorbed by the colors being mixed.&#xD;But there can be an additive component also.&#xD;The proper mathematical abstraction to describe a paint is a reflectance graph, like this:&#xD;(These aren’t paints, but minerals, and one software-generated spectrum, from the US Geological Survey’s&#xD;Spectral Library. The details don’t matter, just the fact that a graph like these gives much more information&#xD;than three RGB numbers.) To mix two paints properly, you multiply the y values (as fractions) at each&#xD;matching x coordinate of the two graphs.&#xD;145&#xD;Having said all that, the mix block takes the colors it is given as inputs and converts them into what we hope&#xD;are typical paint reflectance spectra that would look like those colors, and then mixes those spectra and converts&#xD;back to RGB.&#xD;But unlike the other two kinds of mixing, in this case we can’t say that these colors are “the right answer”; what&#xD;would happen with real paints depends on their chemical composition and how they’re mixed. There are three&#xD;more mixing options, but these three are the ones that correspond to real-world color mixing.&#xD;The mix block will accept any number of colors, and will mix them in equal proportion. If (for any kind of&#xD;mixing) you want more of one color than another, use the color at weight block to make a “weighted color”:&#xD;This mixes four parts red paint to one part green paint. All colors in a mixture can be weighted:&#xD;(Thanks to Scott Burns for his help in understanding paint mixing, along with David Briggs’s tutorial. Remaining mistakes are bh’s.)&#xD;tl;dr&#xD;For normal people, Snap! provides three simple, one-dimensional scales: crayons for specific interesting colors,&#xD;color numbers for a continuum of high-contrast colors with a range of hues and shading, and fair hues for a&#xD;continuum without shading. For color nerds, it provides three-dimensional color spaces RGB, HSL, HSV, and&#xD;fair-hue variants of the latter two. We recommend “fair HSL” for zeroing in on a desired color.&#xD;Color All color numbers. numbers, no grays. Just grays.&#xD;Fair hues. Crayons, no grays.&#xD;146&#xD;Subappendix: Geeky details on fair hue&#xD;The left graph shows that, unsurprisingly, all of the brown fair hues make essentially no progress in real hue, with the orange-brown&#xD;section actually a little retrograde, since browns are really shades of orange and so the real hues overlap between fair browns and fair&#xD;oranges. Green makes up some of the distance, because there are too many green real hues and part of the goal of the fair hue scale is&#xD;to squeeze that part of the hue spectrum. But much of the catching up happens very quickly, between pure magenta at fair hue 93.75&#xD;and the start of the purple-red section at fair hue 97. This abrupt change is unfortunate, but the alternatives involve either stealing&#xD;space from red or stealing space from purple (which already has to include both spectral violet and RGB magenta). The graph has&#xD;discontinuous derivative at the table-lookup points, of which there are two in each color family, one at the pure-named-RGB colors at&#xD;multiples of 12.5, and the other roughly halfway to the next color family, except for the purple family, which has lookup points at 87.5&#xD;(approximate spectral violet), 93.75 (RGB magenta), and 97 (turning point toward the red family). (In the color picker, blue captures cyan&#xD;and purple space in dark shades. This, too, is an artifact of human vision.)&#xD;The right graph shows the HSV saturation and value for all the fair hues. Saturation is at 100%, as it should be in a hue scale, except&#xD;for a very slight drop in part of the browns. (Browns are shades of orange, not tints, so one would expect full saturation, except that&#xD;some of the browns are actually mixtures with related hues.) But value, also as expected, falls substantially in the browns, to a low of&#xD;about 56% (halfway to black) for the “pure” brown at 45° (fair hue 12.5). But the curve is smooth, without inflection points other than&#xD;that minimum-value pure brown.&#xD;“Fair saturation” and “fair value” are by definition 100% for the entire range of fair hues. This means that in the browns, the real&#xD;saturation and value are the product (in percent) of the innate shading of the specific brown fair hue and the user’s fair&#xD;saturation/value setting. When the user’s previous color setting was in a real scale and the new setting is in a fair scale, the program&#xD;assumes that the previous saturation and value were entirely user-determined; when the previous color setting was in a brown fair hue&#xD;and the new setting is also in a fair scale, the program remembers the user’s intention from the previous setting. (Internal calculations&#xD;are based on HSV, even though we recommend HSL to users, because HSV comes to us directly from the JavaScript color&#xD;management implementation.) This is why the set pen block includes options for “fair saturation” and so on.&#xD;For the extra-geeky, here are the exact table lookup points (fair hue, [0,100]):&#xD;and here are the RGB settings at those points:&#xD;147&#xD;Subappendix: Geeky details on color numbers&#xD;Here is a picture of integer color numbers, but remember that color numbers are continuous.&#xD;(As usual, “continuous” values are ultimately converted to integer RGB values, so there’s really some&#xD;granularity.) Color numbers 0-14 are continuously varying grayscale, from 0=black to&#xD;14=white. Color numbers 14+ε to 20 are linearly varying shades of pink, with RGB Red at&#xD;color number 20.&#xD;Beyond that point, in each color family, the multiple of ten color number in the middle is the&#xD;RGB standard color of that family, in which each component is either 255 or 0. (Exceptions&#xD;are brown, which is of course darker than any of those colors; orange, with its green&#xD;component half-strength: [255, 127, 0]; and violet, discussed below.) The following multiple of&#xD;five is the number of the darkest color in that family, although not necessarily the same hue as&#xD;the multiple of ten color number. Color numbers between the multiple of ten and the&#xD;following multiple of five are shades of colors entirely within the family. Color numbers in the&#xD;four before the multiple of ten are mixtures of this family and the one before it. So, for&#xD;example, in the green family, we have&#xD;55 Darkest yellow.&#xD;(55, 60) shades of yellow-green mixtures. As the color number increases, both the hue and the lightness (or value, depending on your&#xD;religion) increase, so we get brighter and greener colors.&#xD;60 Canonical green, [0, 255, 0], whose W3C color name is “lime,” not “green.”&#xD;(60, 65) Shades of green. No cyan mixed in.&#xD;65 Darkest green.&#xD;(65,70) Shades of green-cyan mixtures.&#xD;In the color number chart, all the dark color numbers look a lot like black, but they’re quite different. Here are the darkest colors in&#xD;each color number family.&#xD;Darkest yellow doesn’t look entirely yellow. You might see it as greenish or brownish. As it turns out, the&#xD;darkest color that really looks yellow is hardly dark at all. This color was hand-tweaked to look neither&#xD;green nor brown to me, but ymmv.&#xD;In some families, the center+5 crayon is an important named darker version of the center color: In the red&#xD;family, [128, 0, 0] is “maroon.” In the cyan family, [0, 128, 128] is “teal.” An early version of the color&#xD;number scale used these named shades as the center+5 color number also. But on this page we use the&#xD;word “darkest” advisedly: You can’t find a darker shade of this family anywhere in the color number scale,&#xD;but you can find lighter shades. Teal is color number 73.1, (70 + 5 ∙ !""#$!%&#xD;!""#"&amp; ), because darkest cyan, color 75,&#xD;is [0, 50, 50]. The color number for maroon is left as an exercise for the reader.&#xD;The purple family is different from the others, because it has to include both spectral violet and extraspectral RGB magenta. Violet is&#xD;usually given as RGB [128, 0, 255], but that’s much brighter than the violet in an actual spectrum (see page 142). We use [80, 0, 90],&#xD;a value hand-tweaked to look as much as possible like the violet in rainbow photos, as color number 90. (Crayon 90 is [128, 0, 255].)&#xD;Magenta, [255, 0, 255], is color number 95. This means that the colors get brighter, not darker, between 90 and 95. The darkest violet&#xD;is actually color number 87.5, so it’s bluer than standard violet, but still plainly a purple and not a blue. It’s [39,0,76]. It’s not handtweaked;&#xD;it’s a linear interpolation between darkest blue, [0, 0, 64], and the violet at color number 90. I determined by experiment&#xD;that color number 87.5 is the darkest one that’s still unambiguously purple. (According to Wikipedia, “violet” names only the spectral&#xD;color, while “purple” is the name of the whole color family.)&#xD;Here are the reference points for color numbers that are multiples of five, except for item 4, which is used for color 14, not color 15:&#xD;The very pale three-input list blocks are&#xD;for color numbers that are odd multiples&#xD;of five, generally the “darkest” members&#xD;of each color family. (The block colors&#xD;were adjusted in Photoshop; don’t ask&#xD;how to get blocks this color in Snap!&#xD;Appendix B. APL features&#xD;The book A Programming Language was published by mathematician Kenneth E. Iverson in 1962. He wanted a&#xD;formal language that would look like what mathematicians write on chalkboards. The then-unnamed language&#xD;would later take its name from the first letters of the words in the book’s title. It was little-known until 1964,&#xD;when a formal description of the just-announced IBM System/360 in the IBM Systems Journal used APL&#xD;notation. (Around the same time, Iverson’s associate Adin Falkoff gave a talk on APL to a New York Association for Computing&#xD;Machinery chapter, with an excited 14-year-old Brian Harvey in the audience.) But it wasn’t until 1966 that the first public&#xD;implementation of the language for the System/360 was published by IBM. (It was called “APL\360” because&#xD;the normal slash character / represents the “reduce” operator in APL, while backslash is “expand.”)&#xD;The crucial idea behind APL is that mathematicians think about collections of numbers, one-dimensional&#xD;vectors and two-dimensional matrices, as valid objects in themselves, what computer scientists later learned to call&#xD;“first class data.” A mathematician who wants to add two vectors writes v1 + v2, not “for i = 1 to length(v1),&#xD;result[i]=v1[i]+v2[i].” Same for a programmer using APL.&#xD;There are three kinds of function in APL: scalar functions, mixed functions, and operators. A scalar function is&#xD;one whose natural domain is individual numbers or text characters. A mixed function is one whose domain&#xD;includes arrays (vectors, matrices, or higher-dimensional collections). In Snap!, scalar functions are generally&#xD;found in the green Operators palette, while mixed functions are in the red Lists palette. The third category,&#xD;confusingly for Snap! users, is called operators in APL, but corresponds to what we call higher order functions:&#xD;functions whose domain includes functions.&#xD;Snap! hyperblocks are scalar functions that behave like APL scalar functions: they can be called with arrays as&#xD;inputs, and the underlying function is applied to each number in the arrays. (If the function is monadic, meaning&#xD;that it takes one input, then there’s no complexity to this idea. Take the square root of an array, and you are&#xD;taking the square root of each number in the array. If the function is dyadic, taking two inputs, then the two&#xD;arrays must have the same shape. Snap! is more forgiving than APL; if the arrays don’t agree in number of&#xD;dimensions, called the rank of the array, the lower-rank array is matched repeatedly with subsets of the higherrank&#xD;one; if they don’t agree in length along one dimension, the result has the shorter length and some of the&#xD;numbers in the longer-length array are ignored. An exception in both languages is that if one of the two inputs&#xD;is a scalar, then it is matched with every number in the other array input.)&#xD;As explained in Section IV.F, this termwise extension of scalar functions is the main APL-like feature built into&#xD;Snap! itself. We also include an extension of the item block to address multiple dimensions, an extension to the&#xD;length block with five list functions from APL, and a new primitive reshape block. The APL library extends the&#xD;implementation of APL features to include a few missing scalar functions and several missing mixed functions&#xD;and operators.&#xD;Programming in APL really is very different in style from programming in other languages, even Snap!. This&#xD;appendix can’t hope to be a complete reference for APL, let alone a tutorial. If you’re interested, find one of&#xD;those in a library or a (probably used) bookstore, read it, and do the exercises. Sorry to sound like a teacher, but&#xD;the notation is sufficiently weird as to take a lot of practice before you start to think in APL.&#xD;A note on versions: There is a widely standardized APL2, several idiosyncratic extensions, and a successor&#xD;language named J. The latter uses plain ASCII characters, unlike the ones with APL in their names, which use&#xD;the mathematician’s character set, with Greek letters, typestyles (boldface and/or italics in books; underlined,&#xD;149&#xD;upper case, or lower case in APL) as loose type declarations, and symbols not part of anyone’s alphabet, such as&#xD;# for floor and $ for ceiling. To use the original APL, you needed expensive special computer terminals. (This&#xD;was before you could download fonts in software. Today the more unusual APL characters are in Unicode at&#xD;U+2336 to U+2395.) The character set was probably the main reason APL didn’t take over the world. APL2&#xD;has a lot to recommend it for Snap! users, mainly because it moves from the original APL idea that all arrays&#xD;must be uniform in dimension, and the elements of arrays must be numbers or single text characters, to our idea&#xD;that a list can be an element of another list, and that such elements don’t all have to have the same dimensions.&#xD;Nevertheless, its mechanism for allowing both old-style APL arrays and more general “nested arrays” is&#xD;complicated and hard for an APL beginner (probably all but two or three Snap! users) to understand. So we are&#xD;starting with plain APL. If it turns out to be wildly popular, we may decide later to include APL2 features.&#xD;Here are some of the guiding ideas in the design of the APL library:&#xD;Goal: Enable interested Snap! users to learn the feel and style of APL programming. It’s really&#xD;worth the effort. For example, we didn’t hyperize the = block because Snap! users expect it to give a single yesor-&#xD;no answer about the equality of two complete structures, whatever their types and shapes. In APL, = is a&#xD;scalar function; it compares two numbers or two characters. How could APL users live without the ability to ask&#xD;if two structures are equal? Because in APL you can say !/,a=b to get that answer. Reading from right to left,&#xD;a=b reports an array of Booleans (represented in APL as 0 for False, 1 for True); the comma operator turns the&#xD;shape of the array into a simple vector; and !/ means “reduce with and”; “reduce” is our combine function.&#xD;That six-character program is much less effort than the equivalent&#xD;in Snap!. Note in passing that if you wanted to know how many corresponding elements of the two arrays are&#xD;equal, you’d just use +/ instead of !/. Note also that our APLish blocks are a little verbose, because they include&#xD;up to three notations for the function: the usual Snap! name (e.g., $a!en), the name APL programmers use when&#xD;talking about it (ravel), and, in yellow type, the symbol used in actual APL code (,). We’re not consistent about&#xD;it; seems self-documenting. And LCM (and) is different even though it has two names; it turns&#xD;out that if you represent Boolean values as 0 and 1, then the algorithm to compute the least common multiple of&#xD;two integers computes the and function if the two inputs happen to be Boolean. Including the APL symbols&#xD;serves two purposes: the two or three Snap! users who’ve actually programmed in APL will be sure what function&#xD;they’re using, but more importantly, the ones who are reading an APL tutorial while building programs in Snap!&#xD;will find the block that matches the APL they’re reading.&#xD;Goal: Bring the best and most general APL ideas into “mainstream” Snap! programming style.&#xD;Media computation, in particular, becomes much simpler when scalar functions can be applied to an entire&#xD;picture or sound. Yes, map provides essentially the same capability, but the notation gets complicated if you&#xD;want to map over columns rather than rows. Also, Snap! lists are fundamentally one-dimensional, but real data&#xD;often have more dimensions. A Snap! programmer has to be thinking all the time about the convention that we&#xD;represent a matrix as a list of rows, each of which is a list of individual cells. That is, row 23 of a spreadsheet is&#xD;item 23 of spreadsheet, but column 23 is map (item 23 of _) over spreadsheet. APL treats rows and columns&#xD;more symmetrically.&#xD;Non-goal: Allow programs written originally in APL to run in Snap! essentially unchanged. For&#xD;example, in APL the atomic text unit is a single character, and strings of characters are lists. We treat a text&#xD;150&#xD;string as scalar, and that isn’t going to change. Because APL programmers rarely use conditionals, instead&#xD;computing functions involving arrays of Boolean values to achieve the same effect, the notation they do have for&#xD;conditionals is primitive (in the sense of Paleolithic, not in the sense of built in). We’re not changing ours.&#xD;Non-goal: Emulate the terse APL syntax. It’s too bad, in a way; as noted above, the terseness of&#xD;expressing a computation affects APL programmers’ sense of what’s difficult and what isn’t. But you can’t say&#xD;“terse” and “block language” in the same sentence. Our whole raison d’être is to make it possible to build a&#xD;program without having to memorize the syntax or the names of functions, and to allow those names to be long&#xD;enough to be self-documenting. And APL’s syntax has its own issues, of which the biggest is that it’s hard to use&#xD;functions with more than two inputs; because most mathematical dyadic functions use infix notation (the&#xD;function symbol between the two inputs), the notion of “left argument” and “right argument” is universal in&#xD;APL documentation. The thing people most complain about, that there is no operator precedence (like the&#xD;multiplication-before-addition rule in normal arithmetic notation), really doesn’t turn out to be a problem.&#xD;Function grouping is strictly right to left, so 2×3+4 means two times seven, not six plus four. That takes some&#xD;getting used to, but it really doesn’t take long if you immerse yourself in APL. The reason is that there are too&#xD;many infix operators for people to memorize a precedence table. But in any case, block notation eliminates the&#xD;problem, especially with Snap!’s zebra coloring. You can see and control the grouping by which block is inside&#xD;which other block’s input slot. Another problem with APL’s syntax is that it bends over backward not to have&#xD;reserved words, as opposed to Fortran, its main competition back then. So the dyadic ! “circular functions”&#xD;function uses the left argument to select a trig function. 1!x is sin(x), 2!x is cos(x), and so on. "1!x is arcsin(x).&#xD;What’s 0!x? Glad you asked; it’s √1 − W!.&#xD;Boolean values&#xD;Snap! uses distinct Boolean values true and false that are different from other data types. APL uses 1 and 0,&#xD;respectively. The APL style of programming depends heavily on doing arithmetic on Booleans, although their&#xD;conditionals insist on only 0 or 1 in a Boolean input slot, not other numbers. Snap! arithmetic functions treat false&#xD;as 0 and true as 1, so our APL library tries to report Snap! Boolean values from predicate functions.&#xD;Scalar functions&#xD;These are the scalar functions in the APL library. Most of them are straightforward to figure out. The scalar =&#xD;block provides an APL-style version of = (and other exceptions) as a hyperblock that extends termwise to arrays.&#xD;Join, the only non-predicate non-hyper scalar primitive, has its own scalar join block. 7 deal 52 reports a&#xD;random vector of seven numbers from 1 to 52 with no repetitions, as in dealing a hand of cards. Signum of a&#xD;number reports 1 if the number is positive, 0 if it’s zero, or -1 if it’s negative. Roll 6 reports a random roll of a&#xD;six-sided die. To roll 8 dice, use , which would look much more pleasant&#xD;as ?8⍴6. But perhaps our version is more instantly readable by someone who didn’t grow up with APL. All the&#xD;library functions have help messages available.&#xD;151&#xD;Mixed functions&#xD;Mixed functions include lists in their natural domain or range. That is, one or both of its inputs must be a list, or&#xD;it always reports a list. Sometimes both inputs are naturally lists; sometimes one input of a dyadic mixed&#xD;function is naturally a scalar, and the function treats a list in that input slot as an implicit map, as for scalar&#xD;functions. This means you have to learn the rule for each mixed function individually.&#xD;The shape of function takes any input and reports a vector of the maximum size of the structure along each&#xD;dimension. For a vector, it returns a list of length 1 containing the length of the input. For a matrix, it returns a&#xD;two-item list of the number of rows and number of columns of the input. And so on for higher dimensions. If&#xD;the input isn’t a list at all, then it has zero dimensions, and shape of reports an empty vector.&#xD;Equivalent to the dimensions of primitive, as of 6.6.&#xD;Rank of isn’t an actual APL primitive, but the composition ⍴⍴ (shape of shape of a structure), which reports the&#xD;number of dimensions of the structure (the length of its shape vector), is too useful to omit. (It’s very easy to type&#xD;the same character twice on the APL keyboard, but less easy to drag blocks together.) Equivalent to the rank of&#xD;primitive, as of 6.6.&#xD;Reshape takes a shape vector (such as shape might report) on the left and any structure on the right. It ignores&#xD;the shape of the right input, stringing the atomic elements into a vector in row-major order (that is, all of the first&#xD;row left to right, then all of the second row, etc.). (The primitive reshape takes the inputs in the other order.) It&#xD;then reports an array with the shape specified by the first input containing the items of the second:&#xD;If the right input has more atomic elements than are required by the left-input shape vector, the excess are&#xD;ignored without reporting an error. If the right input has too few atomic elements, the process of filling the&#xD;reported array starts again from the first element. This is most useful in the specific case of an atomic right&#xD;input, which produces an array of any desired shape all of whose atomic elements are equal. But other cases are&#xD;sometimes useful too:&#xD;ID ← {(⍵,⍵)⍴1,⍵⍴0}&#xD;152&#xD;Fla!en takes an arbitrary structure as input and reports a vector of its atomic elements in row-major order.&#xD;Lispians call this flattening the structure, but APLers call it “ravel” because of the metaphor of pulling on a ball&#xD;of yarn, so what they really mean is “unravel.” (But the snarky sound of that is uncalled-for, because a more&#xD;advanced version that we might implement someday is more like raveling.) One APL idiom is to apply this to a&#xD;scalar in order to turn it into a one-element vector, but we can’t use it that way because you can’t type a scalar&#xD;value into the List-type input slot. Equivalent to the primitive $a!en of block.&#xD;Catenate is like our primitive append, with two differences: First, if either input is a scalar, it is treated like a&#xD;one-item vector. Second, if the two inputs are of different rank, the catenate function is recursively mapped&#xD;over the higher-rank input:&#xD;Catenate vertically is similar, but it adds new rows instead of adding new columns.&#xD;Integers (I think that’s what it stands for, although APLers just say “iota”) takes a positive integer input and&#xD;reports a vector of the integers from 1 to the input. This is an example of a function classed as “mixed” not&#xD;because of its domain but because of its range. The difference between this block and the primitive numbers&#xD;from block is in its treatment of lists as inputs. Numbers from is a hyperblock, applying itself to each item of its&#xD;input list:&#xD;Iota has a special meaning for list inputs: The input must be a shape vector; the result is an array with that&#xD;shape in which each item is a list of the indices of the cell along each dimension. A picture is worth 103 words,&#xD;but Snap! isn’t so good at displaying arrays with more than two dimensions, so here we reduce each cell’s index&#xD;list to a string:&#xD;Dyadic iota is like the index of primitive except for its handling of multi-dimensional arrays.&#xD;It looks only for atomic elements, so a vector in the second input doesn’t mean to search for&#xD;that vector as a row of a matrix, which is what it means to index of, but rather to look&#xD;separately for each item of the vector, and report a list of the locations of each item. If the&#xD;first input is a multi-dimensional array, then the location of an item is a vector with the&#xD;indices along each row.&#xD;153&#xD;In this example, the 4 is in the second row, second column. (This is actually an extension of APL iota, which is&#xD;more like a hyperized index of.) Generalizing, if the rank of the second input is less than the rank of the first&#xD;input by two or more, then iota looks for the entire second input in the first input. The reported position is a&#xD;vector whose length is equal to the difference between the two ranks. If the rank of the second input is one less&#xD;than the rank of the first, the reported value is a scalar, the index of the entire second input in the first.&#xD;Why the strange design decision to report length+1 when something isn’t found, instead of a more obvious flag&#xD;value such as 0 or false? Here’s why:&#xD;Note that code has 27 items, not 26. The asterisk at the end is the ciphertext is the translation of all nonalphabet&#xD;characters (spaces and the apostrophe in “doesn’t”). This is a silly example, because it makes up a&#xD;random cipher every time it’s called, and it doesn’t report the cipher, so the recipient can’t decipher the&#xD;message. And you wouldn’t want to make the spaces in the message so obvious. But despite being silly, the&#xD;example shows the benefit of reporting length+1 as the position of items not found.&#xD;The contained in block is like a hyperized contains with the input order reversed. It reports an array of&#xD;Booleans the same shape as the left input. The shape of the right input doesn’t matter; the block looks only for&#xD;atomic elements.&#xD;However, if the two ranks are equal, then the block is hyperized; each item of the second&#xD;input is located in the first input. As the next example shows, only the first instance of each&#xD;item is found (e.g., the 1 in position 2, not the 1 in position 4); if an item does not occur in&#xD;the left input, what is reported is one more than the length of the left input (here, 8).&#xD;154&#xD;The blocks grade up and grade down are used for sorting data. Given an array as input, it reports a vector of&#xD;the indices in which the items (the rows, if a matrix) should be rearranged in order to be sorted. This will be&#xD;clearer with an example:&#xD;The result from grade up tells us that item 3 of foo comes first in sorted order, then item 4, then 2, then 1.&#xD;When we actually select items of foo based on this ordering, we get the desired sorted version. The result&#xD;reported by grade down is almost the reverse of that from grade up, but not quite, if there are equal items in the&#xD;list. (The sort is stable, so if there are equal items, then whichever comes first in the input list will also be first in&#xD;the sorted list.)&#xD;Why this two-step process? Why not just have a sort primitive in APL? One answer is that in a database&#xD;application you might want to sort one array based on the order of another array:&#xD;This is the list of employees of a small company. (Taken from Structure and Interpretation of Computer Programs by Abelson and Sussman. Creative&#xD;Commons licensed.) Each of the smaller lists contains a person&apos;s name, job title, and yearly salary. We would like to sort&#xD;the employees’ names in big-to-small order of salary. First we extract column 3 of the database, the salaries:&#xD;155&#xD;Then we use grade down to get the reordering indices:&#xD;At this point we could use the index vector to sort the salaries:&#xD;But what we actually want is a list of names, sorted by salary:&#xD;By taking the index vector from grade down of column 3 and telling item to apply it to column 1, we get what&#xD;we set out to find. As usual the code is more elegant in APL: database[⍒database[;3];1].&#xD;In case you’ve forgotten, or&#xD;would select the third row of the database; we need the list 3 in the second input slot of the outer list to select by&#xD;columns rather than by rows.&#xD;Select (if take) or select all but (if drop) the first (if n&gt;0) or last (if n&lt;0) |n| items from a vector, or rows from a&#xD;matrix. Alternatively, if the left input is a two-item vector, select rows with the first item and columns with the&#xD;second.&#xD;156&#xD;The compress block selects a subset of its right input based on the Boolean values in its left input, which must&#xD;be a vector of Booleans whose length equals the length of the array (the number of rows, for a matrix) in the&#xD;right input. The block reports an array of the same rank as the right input, but containing only those rows&#xD;whose corresponding Boolean value is true. The columns version ! is the same but selecting columns rather&#xD;than selecting rows.&#xD;A word about the possibly confusing names of these blocks: There are two ways to think about what they do.&#xD;Take the standard / version, to avoid talking about both at once. One way to think about it is that it selects&#xD;some of the rows. The other way is that it shortens the columns. For Lispians, which includes you since you’ve&#xD;learned about keep, the natural way to think about / is that it keeps some of the rows. Since we represent a&#xD;matrix as a list of rows, that also fits with how this function is implemented. (Read the code; you’ll find a keep&#xD;inside.) But APL people think about it the other way, so when you read APL documentation, / is described as&#xD;operating on the last dimension (the columns), while ! is described as operating on rows. We were more than a&#xD;month into this project before I understood all this. You get long block names so it won’t take you a month!&#xD;Don’t confuse this block with the reduce block, whose APL symbol is also a slash. In that block, what comes to&#xD;the left of the slash is a dyadic combining function; it’s the APL equivalent of combine. This block is more&#xD;nearly equivalent to keep. But keep takes a predicate function as input, and calls the function for each item of&#xD;the second input. With compress, the predicate function, if any, has already been called on all the items of the&#xD;right input in parallel, resulting in a vector of Boolean values. This is a typical APL move; since hyperblocks are&#xD;equivalent to an implicit map, it’s easy to make the vector of Booleans, because any scalar function, including&#xD;predicates, can be applied to a list instead of to a scalar. The reason both blocks use the / character is that both&#xD;of them reduce the size of the input array, although in different ways.&#xD;The reverse row order, reverse column order, and transpose blocks form a group: the group of reflections of a&#xD;matrix. The APL symbols are all a circle with a line through it; the lines are the different axes of reflection. So&#xD;the reverse row order block reverses which row is where; the reverse column order block reverses which column&#xD;is where; and the transpose block turns rows into columns and vice versa:&#xD;157&#xD;Except for reverse row order, these work only on full arrays, not ragged-right lists of lists, because the result of&#xD;the other two would be an array in which some rows had “holes”: items 1 and 3 exist, but not item 2. We don’t&#xD;have a representation for that. (In APL, all arrays are full, so it’s even more restrictive.)&#xD;Higher order functions&#xD;The final category of function is operators—APL higher order functions. APL has no explicit map function,&#xD;because the hyperblock capability serves much the same need. But APL2 did add an explicit map, which we&#xD;might get around to adding to the library next time around. Its symbol is ¨ (diaeresis or umlaut).&#xD;The APL equivalent of keep is compress, but it’s not a higher order function. You create a vector of Booleans&#xD;(0s and 1s, in APL) before applying the function to the array you want to compress.&#xD;But APL does have a higher order version of combine:&#xD;The reduce block works just like combine, taking a dyadic function and a list. The / version translates each row&#xD;to a single value; the ! version translates each column to a single value. That’s the only way to think about it&#xD;from the perspective of combining individual elements: you are adding up, or whatever the function is, the&#xD;numbers in a single row (/) or in a single column (!). But APLers think of a matrix as made up of vectors, either&#xD;row vectors or column vectors. And if you think of what these blocks do as adding vectors, rather than adding&#xD;individual numbers, it’s clear that in&#xD;the vector (10, 26, 42) is the sum of column vectors (1, 5, 9)+(2, 6, 10)+(3, 7, 11)+(4, 8, 12). In pre-6.0 Snap!, we’d get&#xD;the same result this way:&#xD;mapping over the rows of the matrix, applying combine to each row. Combining rows, reducing column vectors.&#xD;158&#xD;The outer product block takes two arrays (vectors, typically) and a dyadic scalar function as inputs. It reports&#xD;an array whose rank is the sum of the ranks of the inputs (so, typically a matrix), in which each item is the result&#xD;of applying the function to an atomic element of each array. The third element of the second row of the result is&#xD;the value reported by the function with the second element of the left input and the third element of the right&#xD;input. (The APL symbol ◦. is pronounced “jot dot.”) The way to think about this block is “multiplication table”&#xD;from elementary school:&#xD;The inner product block takes two matrices and two operations as input. The number of columns in the left&#xD;matrix must equal the number of rows in the right matrix. When the two operations are + and ×, this is the&#xD;matrix multiplication familiar to mathematicians:&#xD;But other operations can be used. One common inner product is ∨.∧ (“or dot and”) applied to Boolean matrices,&#xD;to find rows and columns that have corresponding items in common.&#xD;The printable block isn’t an APL function; it’s an aid to exploring APL-in-Snap!. It transforms arrays to a&#xD;compact representation that still makes the structure clear:&#xD;Experts will recognize this as the Lisp representation of list structure,&#xD;&#xD;C&#xD;C&#xD;</l></variable><variable name="Export"><l>THESERIES_OLLO_SHONORHARRINGTONMILITARYHEROINEAN_LATERIN_L_ENTIALPOLITI_IAN__RINGATIMEO_E_TREMEINTERSTELLAR_HANGEAN_TENSIONMOSTO_THEMORETHANNO_ELSAN_ANTHOLOGY_OLLE_TIONS_O_ERE_ENTS_ET_EENAN_A__ITHP_POST_IASPORA_ATING_EGINNING_ITHA_ISPERSALTOTHESTARS_ROMO_RS_NSOLINA_THEMAINSERIESNO_ELSARESETPRIMARILYINATIMELINE_EGINNINGYEARSA_TERHARRINGTONS_IRTHONO_TO_ERA_P_AN_SOMESHORTSTORIES_LESHO_THEREARLIER_AREERA__ITIONALNO_ELSAN_SHORTER_I_TIONTA_EPLA_E_PTOYEARSEARLIERAN_STILLEARLIER_ANONHISTORYIS_ILLE_IN_ET_EENNARRATI_ESAN_INAPPEN_I_ESATTA_HE_TOTHEMAINNO_ELSAN_ANTHOLOGIESTHEPOLITI_ALMA_E_PAN_HISTORYO_THESERIES_RE__ENTLYE_HOESA_T_ALHISTORYPARTI__LARLYTHATO_E_ROPEINTHELASTHAL_O_THESE_ON_MILLENNI_MTHESERIESIS_ONS_IO_SLYMO_ELE_ONTHEHORATIOHORN_LO_ERSERIES_Y_S_ORESTERAN_ITSMAIN_HARA_TERLI_EHORATIOHORN_LO_ERONAMI_O_THOMAS_O_HRANEAN_A_MIRALLOR_NELSON_E_ERORIGINALLYPLANNE__ORHARRINGTONTO_IEINTHE_I_TH_OO_THIS_ASLATER_HANGE_TOPARALLELNELSON_YHA_INGHER_IEATTHEPEA_O_HER_AREERINTHE_LIMA_TI__ATTLEO_MANTI_OREINP_A_THEN_ONTIN_ETHESERIES_ITHHER_HIL_RENASTHEMAINPROTAGONISTSHO_E_ER_OLLA_ORATINGA_THORERI__LINTINTER_ENE_AS_ING_ORTHEIN_ENTIONO_AM_T_ALENEMY_OR_OTHTHESTAR_ING_OMO_MANTI_OREAN_THEREP__LI_O_HA_ENTOOPPOSEINASPYAN__O_NTERSPYSPINO__S__SERIESTHET_O_ONTRA_T_ALLYAGREE_TO_O_RITE__STASTHEYHA_E_ONTRA_TSTO_RITEIN_LINTS_NI_ERSETHISRETHIN_AN_RE_ESIGN_A_SE__E_ERTOMO_ETHESERIESINTERNAL_HRONOLOGY_P_YA_O_TYEARSAN__EGATTHE_RO_NO_SLA_ESNO_EL_IRSTINTHE_RO_NO_SLA_ESS__SERIES_ASE_ONAN_M_ERO_THESHORTSTORIESO_THE_IRST_O_R_OLLE_TIONSINTHISS_ENARIOPRO_IES_ORMANTI_OREAN_HA_ENOPPOSETHESAMEHI__ENENEMYTHEGENETI_SLA_ERSAN_PO_ERS_EHIN_THEGO_ERNMENTAN__ORPORATIONSO_THEPLANETO_MESAMESAISLATERRE_EALE_INMISSIONO_HONORTO_EPARTO_ASE_RET_A_ALO_A_O_TA_O_ENHIGHLY_APA_LEPLANETSTHATARE__SILY__IL_INGASE_RETNA_Y_SINGA__AN_E_TE_HNOLOGIESATASE_RETPLANETAN__NO_NTOITSEL_ASTHEMESANALIGNMENTTHEMESANALIGNMENTSNA_YHASNE_TE_HNOLOGYAN__ON___TSASNEA_ATTA__ONMANTI_OREINP___RINGTHET_EL_THMAINLINENO_ELMISSIONO_HONORTHEMESANSHA_EAYEAROL_SE_RETPROGRAMTOREINSTIT_TEP_RPOSE__LGENETI_ENGINEERINGO_H_MANSAN__REA__PTHESOLARIANLEAG_E_HILETA_ING_O_NALLOPPONENTSOPPOSINGS__HGENETI_ENGINEERINGTHISMA_ESTHESTA_N_HLYANTIGENETI_SLA_ERYSTARNATIONSO_HA_ENMANTI_OREAN__ARIO_SASSO_IATESO_THEPLANET_EO__L_PRIMARYTARGETSO_THEMESANALIGNMENTTHE_RO_NO_SLA_ESS__SERIES_OO_SAN_LASTT_OMAINLINEHONOR_ERSENO_ELS_ETAILTHERISINGE_TENTO_THISTHREATASTHET_OS__SERIESPROGRESSAL_EIT_ITHSOME_HATSEPARATE_ASTSO__HARA_TERSEA_HISE_PE_TE__Y_E_ERTO_ARRYTHE_ETAILE_STORYLINEE_ENTSPARTI__LARTOTHEIRASTROGRAPHI_ALREGION_OR_AR_AN_TIETOGETHERINTOANONGOINGPLOTLINE_ON_ERNINGTHEMASSI_EAN_MONOLITHI_SOLARIANLEAG_E_HI_H_ORESHA_O_INGINTHEMOSTRE_ENTNO_ELSS_GGESTSISA_O_TTO_N_ERGOSE_ERE_ISR_PTIONTHETHIRTEENTHMAINLINENO_ELARISINGTH_N_ERTIESTOGETHERE_ENTSIN_OTHS__SERIESAN_SYN_HRONI_ESTHETIMELINEO_EA_HS__SERIES_ITHHONORHARRINGTONSMAINLINENO_ELSTHIS_OO__ON_IRMSTHESOLARIANLEAG_EISO__I_IALLYNO_THENE_MESAN_ATSPA_E__E_TI_ELYAT_AR_ITH_OTHTHESTAREMPIREO_MANTI_OREAN_THEREP__LI_O_HA_ENASITHAS_EENMANIP_LATE_INTOERRORA_TERERROR_YTHEOPERATI_ESO_THEMESANALIGNMENT</l></variable><variable name="Dauer"><list struct="atomic" id="2616">SnapManual Length 339224 Zeichen</list></variable><variable name="Time"><l>1689437179317</l></variable><variable name="alphabetEN"><list struct="atomic" id="2617">E,T,A,O,N,R,I,S,H,D,L,F,C,M,U,G,Y,P,W,B,V,K,J,X,Z,Q</list></variable><variable name="SnapManual"><l>ACKNOWLEDGEMENTSWEHAVEBEENEXTREMELYLUCKYINOURMENTORSJENSCUTHISTEETHINTHECOMPANYOFTHESMALLTALKPIONEERSALANKAYDANINGALLSANDTHERESTOFTHEGANGWHOINVENTEDPERSONALCOMPUTINGANDOBJECTORIENTEDPROGRAMMINGINTHEGREATDAYSOFXEROXPARCHEWORKEDWITHJOHNMALONEYOFTHEMITSCRATCHTEAMWHODEVELOPEDTHEMORPHICGRAPHICSFRAMEWORKTHATSSTILLATTHEHEARTOFSNAPTHEBRILLIANTDESIGNOFSCRATCHFROMTHELIFELONGKINDERGARTENGROUPATTHEMITMEDIALABISCRUCIALTOSNAPOUREARLIERVERSIONBYOBWASADIRECTMODIFICATIONOFTHESCRATCHSOURCECODESNAPISACOMPLETEREWRITEBUTITSCODESTRUCTUREANDITSUSERINTERFACEREMAINDEEPLYINDEBTEDTOSCRATCHANDTHESCRATCHTEAMWHOCOULDHAVESEENUSASRIVALSHAVEBEENENTIRELYSUPPORTIVEANDWELCOMINGTOUSBRIANGREWUPATTHEMITANDSTANFORDARTIFICIALINTELLIGENCELABSLEARNINGFROMLISPINVENTORJOHNMCCARTHYSCHEMEINVENTORSGERALDJSUSSMANANDGUYSTEELEANDTHEAUTHORSOFTHEWORLDSBESTCOMPUTERSCIENCEBOOKSTRUCTUREANDINTERPRETATIONOFCOMPUTERPROGRAMSHALABELSONANDGERALDJSUSSMANWITHJULIESUSSMANAMONGMANYOTHERHEROESOFCOMPUTERSCIENCEBRIANWASALSOLUCKYENOUGHWHILEINHIGHSCHOOLTOMEETKENNETHIVERSONTHEINVENTOROFAPLINTHEGLORYDAYSOFTHEMITLOGOLABWEUSEDTOSAYLOGOISLISPDISGUISEDASBASICNOWWITHITSFIRSTCLASSPROCEDURESLEXICALSCOPEANDFIRSTCLASSCONTINUATIONSSNAPISSCHEMEDISGUISEDASSCRATCHFOURPEOPLEHAVEMADESUCHMASSIVECONTRIBUTIONSTOTHEIMPLEMENTATIONOFSNAPTHATWEHAVEOFFICIALLYDECLAREDTHEMMEMBERSOFTHETEAMMICHAELBALLANDBERNATROMAGOSAINADDITIONTOCONTRIBUTIONSTHROUGHOUTTHEPROJECTHAVEPRIMARYRESPONSIBILITYFORTHEWEBSITEANDCLOUDSTORAGEJOANGUILLNIPELEGAYHASCONTRIBUTEDVERYCAREFULANDWISEANALYSISOFOUTSTANDINGISSUESINCLUDINGHELPINTAMINGTHEMANAGEMENTOFTRANSLATIONSTONONENGLISHLANGUAGESJADGAHUEGLEHASENERGETICALLYCONTRIBUTEDTOONLINEMINICOURSESABOUTSNAPANDLEADINGWORKSHOPSFORKIDSANDFORADULTSJENSJADGAANDBERNATAREPAIDTOWORKONSNAPBYSAPWHICHALSOSUPPORTSOURCOMPUTINGNEEDSWEHAVEBEENFORTUNATETOGETTOKNOWANAMAZINGGROUPOFBRILLIANTMIDDLESCHOOLANDHIGHSCHOOLSTUDENTSTHROUGHTHESCRATCHADVANCEDTOPICSFORUMSEVERALOFWHOMSINCEGROWNUPHAVECONTRIBUTEDCODETOSNAPKARTIKCHANDRANATHANDINSMORECONNORHUDSONIANREYNOLDSANDDEBORAHSERVILLAMANYMOREHAVECONTRIBUTEDIDEASANDALPHATESTINGBUGREPORTSUCBERKELEYSTUDENTSWHOVECONTRIBUTEDCODEINCLUDEACHALDAVEKYLEHOTCHKISSIVANMOTYASHOVANDYUANYUANCONTRIBUTORSOFTRANSLATIONSARETOONUMEROUSTOLISTHEREBUTTHEYREINTHEABOUTBOXINSNAPITSELFTHISMATERIALISBASEDUPONWORKSUPPORTEDINPARTBYTHENATIONALSCIENCEFOUNDATIONUNDERGRANTSNOANDANDINPARTBYMIOSOFTARDUINOORGSAPANDYCRESEARCHANYOPINIONSFINDINGSANDCONCLUSIONSORRECOMMENDATIONSEXPRESSEDINTHISMATERIALARETHOSEOFTHEAUTHORSANDDONOTNECESSARILYREFLECTTHEVIEWSOFTHENATIONALSCIENCEFOUNDATIONOROTHERFUNDERSSNAPREFERENCEMANUALVERSIONSNAPFORMERLYBYOBISANEXTENDEDREIMPLEMENTATIONOFSCRATCHHPSSCRATCHMITEDUTHATALLOWSYOUTOBUILDYOUROWNBLOCKSITALSOFEATURESFIRSTCLASSLISTSFIRSTCLASSPROCEDURESFIRSTCLASSSPRITESFIRSTCLASSCOSTUMESFIRSTCLASSSOUNDSANDFIRSTCLASSCONTINUATIONSTHESEADDEDCAPABILITIESMAKEITSUITABLEFORASERIOUSINTRODUCTIONTOCOMPUTERSCIENCEFORHIGHSCHOOLORCOLLEGESTUDENTSINTHISMANUALWESOMETIMESMAKEREFERENCETOSCRATCHEGTOEXPLAINHOWSOMESNAPFEATUREEXTENDSSOMETHINGFAMILIARINSCRATCHITSVERYHELPFULTOHAVESOMEEXPERIENCEWITHSCRATCHBEFOREREADINGTHISMANUALBUTNOTESSENTIALTORUNSNAPOPENABROWSERWINDOWANDCONNECTTOHPSSNAPBERKELEYEDURUNTHESNAPCOMMUNITYWEBSITEATHPSSNAPBERKELEYEDUISNOTPARTOFTHISMANUALSSCOPEIBLOCKSSCRIPTSANDSPRITESTHISCHAPTERDESCRIBESTHESNAPFEATURESINHERITEDFROMSCRATCHEXPERIENCEDSCRATCHUSERSCANSKIPTOSECTIONBSNAPISAPROGRAMMINGLANGUAGEANOTATIONINWHICHYOUCANTELLACOMPUTERWHATYOUWANTITTODOUNLIKEMOSTPROGRAMMINGLANGUAGESTHOUGHSNAPISAVISUALLANGUAGEINSTEADOFWRITINGAPROGRAMUSINGTHEKEYBOARDTHESNAPPROGRAMMERUSESTHESAMEDRAGANDDROPINTERFACEFAMILIARTOCOMPUTERUSERSSTARTSNAPYOUSHOULDSEETHEFOLLOWINGARRANGEMENTOFREGIONSINTHEWINDOWTHEPROPORTIONSOFTHESEAREASMAYBEDIFFERENTDEPENDINGONTHESIZEANDSHAPEOFYOURBROWSERWINDOWASNAPPROGRAMCONSISTSOFONEORMORESCRIPTSEACHOFWHICHISMADEOFBLOCKSHERESATYPICALSCRIPTTHEFIVEBLOCKSTHATMAKEUPTHISSCRIPTHAVETHREEDIFFERENTCOLORSCORRESPONDINGTOTHREEOFTHEEIGHTPALETTESINWHICHBLOCKSCANBEFOUNDTHEPALETTEAREAATTHELEFTEDGEOFTHEWINDOWSHOWSONEPALETTEATATIMECHOSENWITHTHEEIGHTBUTTONSJUSTABOVETHEPALETTEAREAINTHISSCRIPTTHEGOLDBLOCKSAREFROMTHECONTROLPALETTETHEGREENBLOCKISFROMTHEPENPALETTEANDTHEBLUEBLOCKSAREFROMTHEMOTIONPALETTEASCRIPTISASSEMBLEDBYDRAGGINGBLOCKSFROMAPALETTEINTOTHESCRIPTINGAREAINTHEMIDDLEPARTOFTHEWINDOWBLOCKSSNAPTOGETHERHENCETHENAMESNAPFORTHELANGUAGEWHENYOUDRAGABLOCKSOTHATITSINDENTATIONISNEARTHETABOFTHEONEABOVEITTHEWHITEHORIZONTALLINEISASIGNALTHATIFYOULETGOOFTHEGREENBLOCKITWILLSNAPINTOTHETABOFTHEGOLDONEHATBLOCKSANDCOMMANDBLOCKSATTHETOPOFTHESCRIPTISAHATBLOCKWHICHINDICATESWHENTHESCRIPTSHOULDBECARRIEDOUTHATBLOCKNAMESTYPICALLYSTARTWITHTHEWORDWHENINTHESQUAREDRAWINGEXAMPLEONPAGETHESCRIPTSHOULDBERUNWHENTHEGREENFLAGNEARTHERIGHTENDOFTHESNAPTOOLBARISCLICKEDTHESNAPTOOLBARISPARTOFTHESNAPWINDOWNOTTHESAMEASTHEBROWSERSOROPERATINGSYSTEMSMENUBARASCRIPTISNTREQUIREDTOHAVEAHATBLOCKBUTIFNOTTHENTHESCRIPTWILLBERUNONLYIFTHEUSERCLICKSONTHESCRIPTITSELFASCRIPTCANTHAVEMORETHANONEHATBLOCKANDTHEHATBLOCKCANBEUSEDONLYATTHETOPOFTHESCRIPTITSDISTINCTIVESHAPEISMEANTTOREMINDYOUOFTHATTHEOTHERBLOCKSINOUREXAMPLESCRIPTARECOMMANDBLOCKSEACHCOMMANDBLOCKCORRESPONDSTOANACTIONTHATSNAPALREADYKNOWSHOWTOCARRYOUTFOREXAMPLETHEBLOCKTELLSTHESPRITETHEARROWHEADSHAPEONTHESTAGEATTHERIGHTENDOFTHEWINDOWTOMOVETENSTEPSASTEPISAVERYSMALLUNITOFDISTANCEINTHEDIRECTIONINWHICHTHEARROWHEADISPOINTINGWELLSEESHORTLYTHATTHERECANBEMORETHANONESPRITEANDTHATEACHSPRITEHASITSOWNSCRIPTSALSOASPRITEDOESNTHAVETOLOOKLIKEANARROWHEADBUTCANHAVEANYPICTUREASACOSTUMETHESHAPEOFTHEMOVEBLOCKISMEANTTOREMINDYOUOFALEGOBRICKASCRIPTISASTACKOFBLOCKSTHEWORDBLOCKDENOTESBOTHTHEGRAPHICALSHAPEONTHESCREENANDTHEPROCEDURETHEACTIONTHATTHEBLOCKCARRIESOUTTHENUMBERINTHEMOVEBLOCKABOVEISCALLEDANINPUTTOTHEBLOCKBYCLICKINGONTHEWHITEOVALYOUCANTYPEANYNUMBERINPLACEOFTHETHESAMPLESCRIPTONTHEPREVIOUSPAGEUSESASTHEINPUTVALUEWELLSEELATERTHATINPUTSCANHAVENONOVALSHAPESTHATACCEPTVALUESOTHERTHANNUMBERSWELLALSOSEETHATYOUCANCOMPUTEINPUTVALUESINSTEADOFTYPINGAPARTICULARVALUEINTOTHEOVALABLOCKCANHAVEMORETHANONEINPUTSLOTFOREXAMPLETHEGLIDEBLOCKLOCATEDABOUTHALFWAYDOWNTHEMOTIONPALETTEHASTHREEINPUTSONEOFTHEHATBLOCKSTHEGENERICWHENANYTHINGBLOCKISSUBTLYDIFFERENTFROMTHEOTHERSWHENTHESTOPSIGNISCLICKEDORWHENAPROJECTORSPRITEISLOADEDTHISBLOCKDOESNTTESTWHETHERTHECONDITIONINITSHEXAGONALINPUTSLOTISTRUESOTHESCRIPTBENEATHITWILLNOTRUNUNTILSOMEOTHERSCRIPTINTHEPROJECTRUNSBECAUSEFOREXAMPLEYOUCLICKTHEGREENFLAGWHENGENERICWHENBLOCKSAREDISABLEDTHESTOPSIGNWILLBESQUAREINSTEADOFOCTAGONALMOSTCOMMANDBLOCKSHAVETHATBRICKSHAPEBUTSOMELIKETHEREPEATBLOCKINTHESAMPLESCRIPTARECSHAPEDMOSTCSHAPEDBLOCKSAREFOUNDINTHECONTROLPALETTETHESLOTINSIDETHECSHAPEISASPECIALKINDOFINPUTSLOTTHATACCEPTSASCRIPTASTHEINPUTINTHESAMPLESCRIPTCSHAPEDBLOCKSCANBEPUTINASCRIPTINTWOWAYSIFYOUSEEAWHITELINEANDLETGOTHEBLOCKWILLBEINSERTEDINTOTHESCRIPTLIKEANYCOMMANDBLOCKBUTIFYOUSEEANORANGEHALOANDLETGOTHEBLOCKWILLWRAPAROUNDTHEHALOEDBLOCKSTHEHALOWILLALWAYSEXTENDFROMTHECURSORPOSITIONTOTHEBOTTOMOFTHESCRIPTIFYOUWANTONLYSOMEOFTHOSEBLOCKSAFTERWRAPPINGYOUCANGRABTHEFIRSTBLOCKYOUDONTWANTWRAPPEDPULLITDOWNANDSNAPITUNDERTHECSHAPEDBLOCKFORESHAPEDBLOCKSWITHMORETHANONECSHAPEDSLOTONLYTHEFIRSTSLOTWILLWRAPAROUNDEXISTINGBLOCKSINASCRIPTANDONLYIFTHATCSHAPEDSLOTISEMPTYBEFOREWRAPPINGYOUCANFILLTHEOTHERSLOTSBYDRAGGINGBLOCKSINTOTHEDESIREDSLOTTHEREPEATBLOCKHASTWOINPUTSTHENUMBERANDTHESCRIPTASPRITESANDPARALLELISMJUSTBELOWTHESTAGEISTHENEWSPRITEBUTTONCLICKTHEBUTTONTOADDANEWSPRITETOTHESTAGETHENEWSPRITEWILLAPPEARINARANDOMPOSITIONONTHESTAGEWITHARANDOMCOLORBUTALWAYSFACINGTOTHERIGHTEACHSPRITEHASITSOWNSCRIPTSTOSEETHESCRIPTSFORAPARTICULARSPRITEINTHESCRIPTINGAREACLICKONTHEPICTUREOFTHATSPRITEINTHESPRITECORRALINTHEBOTTOMRIGHTCORNEROFTHEWINDOWTRYPUTTINGONEOFTHEFOLLOWINGSCRIPTSINEACHSPRITESSCRIPTINGAREAWHENYOUCLICKTHEGREENFLAGYOUSHOULDSEEONESPRITEROTATEWHILETHEOTHERMOVESBACKANDFORTHTHISEXPERIMENTILLUSTRATESTHEWAYDIFFERENTSCRIPTSCANRUNINPARALLELTHETURNINGANDTHEMOVINGHAPPENTOGETHERPARALLELISMCANBESEENWITHMULTIPLESCRIPTSOFASINGLESPRITEALSOTRYTHISEXAMPLEWHENYOUPRESSTHESPACEKEYTHESPRITESHOULDMOVEFOREVERINACIRCLEBECAUSETHEMOVEANDTURNBLOCKSARERUNINPARALLELTOSTOPTHEPROGRAMCLICKTHEREDSTOPSIGNATTHERIGHTENDOFTHETOOLBARCOSTUMESANDSOUNDSTOCHANGETHEAPPEARANCEOFASPRITEPAINTORIMPORTANEWCOSTUMEFORITTOPAINTACOSTUMECLICKONTHECOSTUMESTABABOVETHESCRIPTINGAREAANDCLICKTHEPAINTBUTTONTHEPAINTEDITORTHATAPPEARSISEXPLAINEDONPAGETHEREARETHREEWAYSTOIMPORTACOSTUMEFIRSTSELECTTHEDESIREDSPRITEINTHESPRITECORRALTHENONEWAYISTOCLICKONTHEFILEICONINTHETOOLBARTHENCHOOSETHECOSTUMESMENUITEMYOUWILLSEEALISTOFCOSTUMESFROMTHEPUBLICMEDIALIBRARYANDCANCHOOSEONETHESECONDWAYFORACOSTUMESTOREDONYOUROWNCOMPUTERISTOCLICKONTHEFILEICONANDCHOOSETHEIMPORTMENUITEMYOUCANTHENSELECTAFILEINANYPICTUREFORMATPNGJPEGETCSUPPORTEDBYYOURBROWSERTHETHIRDWAYISQUICKERIFTHEFILEYOUWANTISVISIBLEONTHEDESKTOPJUSTDRAGTHEFILEONTOTHESNAPWINDOWINANYOFTHESECASESTHESCRIPTINGAREAWILLBEREPLACEDBYSOMETHINGLIKETHISJUSTABOVETHISPARTOFTHEWINDOWISASETOFTHREETABSSCRIPTSCOSTUMESANDSOUNDSYOULLSEETHATTHECOSTUMESTABISNOWSELECTEDINTHISVIEWTHESPRITESWARDROBEYOUCANCHOOSEWHETHERTHESPRITESHOULDWEARITSTURTLECOSTUMEORITSALONZOCOSTUMEALONZOTHESNAPMASCOTISNAMEDAFTERALONZOCHURCHAMATHEMATICIANWHOINVENTEDTHEIDEAOFPROCEDURESASDATATHEMOSTIMPORTANTWAYINWHICHSNAPISDIFFERENTFROMSCRATCHYOUCANGIVEASPRITEASMANYCOSTUMESASYOULIKEANDTHENCHOOSEWHICHITWILLWEAREITHERBYCLICKINGINITSWARDROBEORBYUSINGTHEORBLOCKINASCRIPTEVERYCOSTUMEHASANUMBERASWELLASANAMETHENEXTCOSTUMEBLOCKSELECTSTHENEXTCOSTUMEBYNUMBERAFTERTHEHIGHESTNUMBEREDCOSTUMEITSWITCHESTOCOSTUMETHETURTLECOSTUMEISNEVERCHOSENBYNEXTCOSTUMETHETURTLECOSTUMEISTHEONLYONETHATCHANGESCOLORTOMATCHACHANGEINTHESPRITESPENCOLORPROTIPSWITCHESTOTHEPREVIOUSCOSTUMEWRAPPINGLIKENEXTCOSTUMEINADDITIONTOITSCOSTUMESASPRITECANHAVESOUNDSTHEEQUIVALENTFORSOUNDSOFTHESPRITESWARDROBEISCALLEDITSJUKEBOXSOUNDFILESCANBEIMPORTEDINANYFORMATWAVOGGMPETCSUPPORTEDBYYOURBROWSERTWOBLOCKSACCOMPLISHTHETASKOFPLAYINGSOUNDSIFYOUWOULDLIKEASCRIPTTOCONTINUERUNNINGWHILETHESOUNDISPLAYINGUSETHEBLOCKINCONTRASTYOUCANUSETHEBLOCKTOWAITFORTHESOUNDSCOMPLETIONBEFORECONTINUINGTHERESTOFTHESCRIPTINTERSPRITECOMMUNICATIONWITHBROADCASTEARLIERWESAWANEXAMPLEOFTWOSPRITESMOVINGATTHESAMETIMEINAMOREINTERESTINGPROGRAMTHOUGHTHESPRITESONSTAGEWILLINTERACTTOTELLASTORYPLAYAGAMEETCOFTENONESPRITEWILLHAVETOTELLANOTHERSPRITETORUNASCRIPTHERESASIMPLEEXAMPLEINTHEBLOCKTHEWORDBARKISJUSTANARBITRARYNAMEIMADEUPWHENYOUCLICKONTHEDOWNWARDARROWHEADINTHATINPUTSLOTONEOFTHECHOICESTHEONLYCHOICETHEFIRSTTIMEISNEWWHICHTHENPROMPTSYOUTOENTERANAMEFORTHENEWBROADCASTWHENTHISBLOCKISRUNTHECHOSENMESSAGEISSENTTOEVERYSPRITEWHICHISWHYTHEBLOCKISCALLEDBROADCASTBUTIFYOUCLICKTHERIGHTARROWAFTERTHEMESSAGENAMETHEBLOCKBECOMESANDYOUCANCHANGEITTOTOSENDTHEMESSAGEJUSTTOONESPRITEINTHISPROGRAMTHOUGHONLYONESPRITEHASASCRIPTTORUNWHENTHATBROADCASTISSENTNAMELYTHEDOGBECAUSETHEBOYSSCRIPTUSESBROADCASTANDWAITRATHERTHANJUSTBROADCASTTHEBOYDOESNTGOONTOHISNEXTSAYBLOCKUNTILTHEDOGSSCRIPTFINISHESTHATSWHYTHETWOSPRITESTAKETURNSTALKINGINSTEADOFBOTHTALKINGATONCEINCHAPTERVIIOBJECTORIENTEDPROGRAMMINGWITHSPRITESYOULLSEEAMOREFLEXIBLEWAYTOSENDAMESSAGETOASPECIFICSPRITEUSINGTHETELLANDASKBLOCKSNOTICEBYTHEWAYTHATTHESAYBLOCKSFIRSTINPUTSLOTISRECTANGULARRATHERTHANOVALTHISMEANSTHEINPUTCANBEANYTEXTSTRINGNOTONLYANUMBERINTEXTINPUTSLOTSASPACECHARACTERISSHOWNASABROWNDOTSOTHATYOUCANCOUNTTHENUMBEROFSPACESBETWEENWORDSANDINPARTICULARYOUCANTELLTHEDIFFERENCEBETWEENANEMPTYSLOTANDONECONTAININGSPACESTHEBROWNDOTSARENOTSHOWNONTHESTAGEIFTHETEXTISDISPLAYEDTHESTAGEHASITSOWNSCRIPTINGAREAITCANBESELECTEDBYCLICKINGONTHESTAGEICONATTHELEFTOFTHESPRITECORRALUNLIKEASPRITETHOUGHTHESTAGECANTMOVEINSTEADOFCOSTUMESITHASBACKGROUNDSPICTURESTHATFILLTHEENTIRESTAGEAREATHESPRITESAPPEARINFRONTOFTHECURRENTBACKGROUNDINACOMPLICATEDPROJECTITSOFTENCONVENIENTTOUSEASCRIPTINTHESTAGESSCRIPTINGAREAASTHEOVERALLDIRECTOROFTHEACTIONBNESTINGSPRITESANCHORSANDPARTSSOMETIMESITSDESIRABLETOMAKEASORTOFSUPERSPRITECOMPOSEDOFPIECESTHATCANMOVETOGETHERBUTCANALSOBESEPARATELYARTICULATEDTHECLASSICEXAMPLEISAPERSONSBODYMADEUPOFATORSOLIMBSANDAHEADSNAPALLOWSONESPRITETOBEDESIGNATEDASTHEANCHOROFTHECOMBINEDSHAPEWITHOTHERSPRITESASITSPARTSTOSETUPSPRITENESTINGDRAGTHESPRITECORRALICONOFAPARTSPRITEONTOTHESTAGEDISPLAYNOTTHESPRITECORRALICONOFTHEDESIREDANCHORSPRITETHEPRECISEPLACEWHEREYOULETGOOFTHEMOUSEBUTTONWILLBETHEATTACHMENTPOINTOFTHEPARTONTHEANCHORSPRITENESTINGISSHOWNINTHESPRITECORRALICONSOFBOTHANCHORSANDPARTSINTHISILLUSTRATIONITISDESIREDTOANIMATEALONZOSARMTHEARMHASBEENCOLOREDGREENINTHISPICTURETOMAKETHERELATIONSHIPOFTHETWOSPRITESCLEARERBUTINAREALPROJECTTHEYDBETHESAMECOLORPROBABLYSPRITEREPRESENTINGALONZOSBODYISTHEANCHORSPRITEISTHEARMTHEICONFORTHEANCHORSHOWSSMALLIMAGESOFUPTOTHREEATTACHEDPARTSATTHEBOTTOMTHEICONFOREACHPARTSHOWSASMALLIMAGEOFTHEANCHORINITSTOPLEFTCORNERANDASYNCHRONOUSDANGLINGROTATIONFLAGINTHETOPRIGHTCORNERINITSINITIALSYNCHRONOUSSETTINGASSHOWNABOVEITMEANSTHATTHEWHENTHEANCHORSPRITEROTATESTHEPARTSPRITEALSOROTATESASWELLASREVOLVINGAROUNDTHEANCHORWHENCLICKEDITCHANGESFROMACIRCULARARROWTOASTRAIGHTARROWANDINDICATESTHATWHENTHEANCHORSPRITEROTATESTHEPARTSPRITEREVOLVESAROUNDITBUTDOESNOTROTATEKEEPINGITSORIGINALORIENTATIONTHEPARTCANALSOBEROTATEDSEPARATELYUSINGITSTURNBLOCKSANYCHANGEINTHEPOSITIONORSIZEOFTHEANCHORISALWAYSEXTENDEDTOITSPARTSALSOCLONINGTHEANCHORSEESECTIONVIIBWILLALSOCLONEALLITSPARTSTOPTURNINGTHEPARTTHEGREENARMBOTTOMTURNINGTHEANCHORWITHTHEARMSYNCHRONOUSLEFTANDDANGLINGRIGHTCREPORTERBLOCKSANDEXPRESSIONSSOFARWEVEUSEDTWOKINDSOFBLOCKSHATBLOCKSANDCOMMANDBLOCKSANOTHERKINDISTHEREPORTERBLOCKWHICHHASANOVALSHAPEITSCALLEDAREPORTERBECAUSEWHENITSRUNINSTEADOFCARRYINGOUTANACTIONITREPORTSAVALUETHATCANBEUSEDASANINPUTTOANOTHERBLOCKIFYOUDRAGAREPORTERINTOTHESCRIPTINGAREABYITSELFANDCLICKONITTHEVALUEITREPORTSWILLAPPEARINASPEECHBALLOONNEXTTOTHEBLOCKWHENYOUDRAGAREPORTERBLOCKOVERANOTHERBLOCKSINPUTSLOTAWHITEHALOAPPEARSAROUNDTHATINPUTSLOTANALOGOUSTOTHEWHITELINETHATAPPEARSWHENSNAPPINGCOMMANDBLOCKSTOGETHERDONTDROPTHEINPUTOVERAREDHALOTHATSUSEDFORAPURPOSEEXPLAINEDONPAGEHERESASIMPLESCRIPTTHATUSESAREPORTERBLOCKHERETHEXPOSITIONREPORTERPROVIDESTHEFIRSTINPUTTOTHESAYBLOCKTHESPRITESXPOSITIONISITSHORIZONTALPOSITIONHOWFARLEFTNEGATIVEVALUESORRIGHTPOSITIVEVALUESITISCOMPAREDTOTHECENTEROFTHESTAGESIMILARLYTHEYPOSITIONISMEASUREDVERTICALLYINSTEPSABOVEPOSITIVEORBELOWNEGATIVETHECENTERYOUCANDOARITHMETICUSINGREPORTERSINTHEOPERATORSPALETTETHEROUNDBLOCKROUNDSTOANDTHEBLOCKADDSTOTHATBYTHEWAYTHEROUNDBLOCKISINTHEOPERATORSPALETTEJUSTLIKEBUTINTHISSCRIPTITSALIGHTERCOLORWITHBLACKLETTERINGBECAUSESNAPALTERNATESLIGHTANDDARKVERSIONSOFTHEPALETTECOLORSWHENABLOCKISNESTEDINSIDEANOTHERBLOCKFROMTHESAMEPALETTETHISAIDTOREADABILITYISCALLEDZEBRACOLORINGAREPORTERBLOCKWITHITSINPUTSMAYBEINCLUDINGOTHERREPORTERBLOCKSSUCHASISCALLEDANEXPRESSIONDPREDICATESANDCONDITIONALEVALUATIONMOSTREPORTERSREPORTEITHERANUMBERLIKEORATEXTSTRINGLIKEAPREDICATEISASPECIALKINDOFREPORTERTHATALWAYSREPORTSTRUEORFALSEPREDICATESHAVEAHEXAGONALSHAPETHESPECIALSHAPEISAREMINDERTHATPREDICATESDONTGENERALLYMAKESENSEINANINPUTSLOTOFBLOCKSTHATAREEXPECTINGANUMBERORTEXTYOUWOULDNTSAYALTHOUGHASYOUCANSEEFROMTHEPICTURESNAPLETSYOUDOITIFYOUREALLYWANTINSTEADYOUNORMALLYUSEPREDICATESINSPECIALHEXAGONALINPUTSLOTSLIKETHISONETHECSHAPEDIFBLOCKRUNSITSINPUTSCRIPTIFANDONLYIFTHEEXPRESSIONINITSHEXAGONALINPUTREPORTSTRUEAREALLYUSEFULBLOCKINANIMATIONSRUNSITSINPUTSCRIPTREPEATEDLYUNTILAPREDICATEISSATISFIEDIFWHILEWORKINGONAPROJECTYOUWANTTOOMITTEMPORARILYSOMECOMMANDSINASCRIPTBUTYOUDONTWANTTOFORGETWHERETHEYBELONGYOUCANSAYSOMETIMESYOUWANTTOTAKETHESAMEACTIONWHETHERSOMECONDITIONISTRUEORFALSEBUTWITHADIFFERENTINPUTVALUEFORTHISPURPOSEYOUCANUSETHEREPORTERIFBLOCKTHETECHNICALTERMFORATRUEORFALSEVALUEISABOOLEANVALUEITHASACAPITALBBECAUSEITSNAMEDAFTERAPERSONGEORGEBOOLEWHODEVELOPEDTHEMATHEMATICALTHEORYOFBOOLEANVALUESDONTGETCONFUSEDAHEXAGONALBLOCKISAPREDICATEBUTTHEVALUEITREPORTSISABOOLEANANOTHERQUIBBLEABOUTVOCABULARYMANYPROGRAMMINGLANGUAGESRESERVETHENAMEPROCEDUREFORCOMMANDSTHATCARRYOUTANACTIONANDUSETHENAMEFUNCTIONFORREPORTERSANDPREDICATESINTHISMANUALAPROCEDUREISANYCOMPUTATIONALCAPABILITYINCLUDINGTHOSETHATREPORTVALUESANDTHOSETHATDONTCOMMANDSREPORTERSANDPREDICATESAREALLPROCEDURESTHEWORDSAPROCEDURETYPEARESHORTHANDFORCOMMANDTYPEREPORTERTYPEORPREDICATETYPEIFYOUWANTTOPUTACONSTANTBOOLEANVALUEINAHEXAGONALSLOTINSTEADOFAPREDICATEBASEDEXPRESSIONHOVERTHEMOUSEOVERTHEBLOCKANDCLICKONTHECONTROLTHATAPPEARSEVARIABLESTRYTHISSCRIPTTHEINPUTTOTHEMOVEBLOCKISANORANGEOVALTOGETITTHEREDRAGTHEORANGEOVALTHATSPARTOFTHEFORBLOCKTHEORANGEOVALISAVARIABLEASYMBOLTHATREPRESENTSAVALUEITOOKTHISSCREENSHOTBEFORECHANGINGTHESECONDNUMBERINPUTTOTHEFORBLOCKFROMTHEDEFAULTTOANDBEFOREDRAGGINGINATURNBLOCKFORRUNSITSSCRIPTINPUTREPEATEDLYJUSTLIKEREPEATBUTBEFOREEACHREPETITIONITSETSTHEVARIABLEITOANUMBERSTARTINGWITHITSFIRSTNUMERICINPUTADDINGFOREACHREPETITIONUNTILITREACHESTHESECONDNUMERICINPUTINTHISCASETHEREWILLBEREPETITIONSFIRSTWITHITHENWITHITHENANDSOONUNTILIFORTHEFINALREPETITIONTHERESULTISTHATEACHMOVEDRAWSALONGERANDLONGERLINESEGMENTANDTHATSWHYTHEPICTUREYOUSEEISAKINDOFSPIRALIFYOUTRYAGAINWITHATURNOFDEGREESINSTEADOFYOULLSEEWHYTHISPICTUREISCALLEDASQUIRALTHEVARIABLEIISCREATEDBYTHEFORBLOCKANDITCANONLYBEUSEDINTHESCRIPTINSIDETHEBLOCKSCSLOTBYTHEWAYIFYOUDONTLIKETHENAMEIYOUCANCHANGEITBYCLICKINGONTHEORANGEOVALWITHOUTDRAGGINGITWHICHWILLPOPUPADIALOGWINDOWINWHICHYOUCANENTERADIFFERENTNAMEIISNTAVERYDESCRIPTIVENAMEYOUMIGHTPREFERLENGTHTOINDICATEITSPURPOSEINTHESCRIPTIISTRADITIONALBECAUSEMATHEMATICIANSTENDTOUSELETTERSBETWEENIANDNTOREPRESENTINTEGERVALUESBUTINPROGRAMMINGLANGUAGESWEDONTHAVETORESTRICTOURSELVESTOSINGLELETTERVARIABLENAMESGLOBALVARIABLESYOUCANCREATEVARIABLESBYHANDTHATARENTLIMITEDTOBEINGUSEDWITHINASINGLEBLOCKATTHETOPOFTHEVARIABLESPALETTECLICKTHEMAKEAVARIABLEBUTTONTHISWILLBRINGUPADIALOGWINDOWINWHICHYOUCANGIVEYOURVARIABLEANAMETHEDIALOGALSOGIVESYOUACHOICETOMAKETHEVARIABLEAVAILABLETOALLSPRITESWHICHISALMOSTALWAYSWHATYOUWANTORTOMAKEITVISIBLEONLYINTHECURRENTSPRITEYOUDDOTHATIFYOUREGOINGTOGIVESEVERALSPRITESINDIVIDUALVARIABLESWITHTHESAMENAMESOTHATYOUCANSHAREASCRIPTBETWEENSPRITESBYDRAGGINGITFROMTHECURRENTSPRITESSCRIPTINGAREATOTHEPICTUREOFANOTHERSPRITEINTHESPRITECORRALANDTHEDIFFERENTSPRITESWILLDOSLIGHTLYDIFFERENTTHINGSWHENRUNNINGTHATSCRIPTBECAUSEEACHHASADIFFERENTVALUEFORTHATVARIABLENAMEIFYOUGIVEYOURVARIABLETHENAMENAMETHENTHEVARIABLESPALETTEWILLLOOKLIKETHISTHERESNOWADELETEAVARIABLEBUTTONANDTHERESANORANGEOVALWITHTHEVARIABLENAMEINITJUSTLIKETHEORANGEOVALINTHEFORBLOCKYOUCANDRAGTHEVARIABLEINTOANYSCRIPTINTHESCRIPTINGAREANEXTTOTHEOVALISACHECKBOXINITIALLYCHECKEDWHENITSCHECKEDYOULLALSOSEEAVARIABLEWATCHERONTHESTAGEWHENYOUGIVETHEVARIABLEAVALUETHEORANGEBOXINITSWATCHERWILLDISPLAYTHEVALUEHOWDOYOUGIVEITAVALUEYOUUSETHESETBLOCKNOTETHATYOUDONTDRAGTHEVARIABLESOVALINTOTHESETBLOCKYOUCLICKONTHEDOWNARROWINTHEFIRSTINPUTSLOTANDYOUGETAMENUOFALLTHEAVAILABLEVARIABLENAMESIFYOUDOCHOOSEFORTHISSPRITEONLYWHENCREATINGAVARIABLEITSBLOCKINTHEPALETTELOOKSLIKETHISTHELOCATIONPINICONISABITOFAPUNONASPRITELOCALVARIABLEITSSHOWNONLYINTHEPALETTESCRIPTVARIABLESINTHENAMEEXAMPLEABOVEOURPROJECTISGOINGTOCARRYONANINTERACTIONWITHTHEUSERANDWEWANTTOREMEMBERTHEIRNAMETHROUGHOUTTHEPROJECTTHATSAGOODEXAMPLEOFASITUATIONINWHICHAGLOBALVARIABLETHEKINDYOUMAKEWITHTHEMAKEAVARIABLEBUTTONISAPPROPRIATEANOTHERCOMMONEXAMPLEISAVARIABLECALLEDSCOREINAGAMEPROJECTBUTSOMETIMESYOUONLYNEEDAVARIABLETEMPORARILYDURINGTHERUNNINGOFAPARTICULARSCRIPTINTHATCASEYOUCANUSETHESCRIPTVARIABLESBLOCKTOMAKETHEVARIABLEASINTHEFORBLOCKYOUCANCLICKONANORANGEOVALINTHESCRIPTVARIABLESBLOCKWITHOUTDRAGGINGTOCHANGEITSNAMEYOUCANALSOMAKEMORETHANONETEMPORARYVARIABLEBYCLICKINGONTHERIGHTARROWATTHEENDOFTHEBLOCKTOADDANOTHERVARIABLEOVALRENAMINGVARIABLESTHEREARESEVERALREASONSWHYYOUMIGHTWANTTOCHANGETHENAMEOFAVARIABLEITHASADEFAULTNAMESUCHASTHEAINSCRIPTVARIABLESORTHEIINFORITCONFLICTSWITHANOTHERNAMESUCHASAGLOBALVARIABLETHATYOUWANTTOUSEINTHESAMESCRIPTYOUJUSTDECIDEADIFFERENTNAMEWOULDBEMORESELFDOCUMENTINGINTHEFIRSTANDTHIRDCASEYOUPROBABLYWANTTOCHANGETHENAMEEVERYWHEREITAPPEARSINTHATSCRIPTOREVENINALLSCRIPTSINTHESECONDCASEIFYOUVEALREADYUSEDBOTHVARIABLESINTHESCRIPTBEFOREREALIZINGTHATTHEYHAVETHESAMENAMEYOULLWANTTOLOOKATEACHINSTANCESEPARATELYTODECIDEWHICHONESTORENAMEBOTHOFTHESEOPERATIONSAREPOSSIBLEBYRIGHTCLICKINGORCONTROLCLICKINGONAVARIABLEOVALIFYOURIGHTCLICKONANORANGEOVALINACONTEXTINWHICHTHEVARIABLEISUSEDTHENYOUAREABLETORENAMEJUSTTHATONEORANGEOVALIFYOURIGHTCLICKONTHEPLACEWHERETHEVARIABLEISDEFINEDASCRIPTVARIABLESBLOCKTHEORANGEOVALFORAGLOBALVARIABLEINTHEVARIABLESPALETTEORANORANGEOVALTHATSBUILTINTOABLOCKSUCHASTHEIINFORTHENYOUAREGIVENTWORENAMINGOPTIONSRENAMEANDRENAMEALLIFYOUCHOOSERENAMETHENTHENAMEISCHANGEDONLYINTHATONEORANGEOVALASINTHEPREVIOUSCASEBUTIFYOUCHOOSERENAMEALLTHENTHENAMEWILLBECHANGEDTHROUGHOUTTHESCOPEOFTHEVARIABLETHESCRIPTFORASCRIPTVARIABLEOREVERYWHEREFORAGLOBALVARIABLETRANSIENTVARIABLESSOFARWEVETALKEDABOUTVARIABLESWITHNUMERICVALUESORWITHSHORTTEXTSTRINGSSUCHASSOMEONESNAMEBUTTHERESNOLIMITTOTHEAMOUNTOFINFORMATIONYOUCANPUTINAVARIABLEINCHAPTERIVYOULLSEEHOWTOUSELISTSTOCOLLECTMANYVALUESINONEDATASTRUCTUREANDINCHAPTERVIIIYOULLSEEHOWTOREADINFORMATIONFROMWEBSITESWHENYOUUSETHESECAPABILITIESYOURPROJECTMAYTAKEUPALOTOFMEMORYINTHECOMPUTERIFYOUGETCLOSETOTHEAMOUNTOFMEMORYAVAILABLETOSNAPTHENITMAYBECOMEIMPOSSIBLETOSAVEYOURPROJECTEXTRASPACEISNEEDEDTEMPORARILYTOCONVERTFROMSNAPSINTERNALREPRESENTATIONTOTHEFORMINWHICHPROJECTSAREEXPORTEDORSAVEDIFYOURPROGRAMREADSALOTOFDATAFROMTHEOUTSIDEWORLDTHATWILLSTILLBEAVAILABLEWHENYOUUSEITNEXTYOUMIGHTWANTTOHAVEVALUESCONTAININGALOTOFDATAREMOVEDFROMMEMORYBEFORESAVINGTHEPROJECTTODOTHISRIGHTCLICKORCONTROLCLICKONTHEORANGEOVALINTHEVARIABLESPALETTETOSEETHISMENUYOUALREADYKNOWABOUTTHERENAMEOPTIONSANDHELPDISPLAYSAHELPSCREENABOUTVARIABLESINGENERALHEREWEREINTERESTEDINTHECHECKBOXNEXTTOTRANSIENTIFYOUCHECKITTHISVARIABLESVALUEWILLNOTBESAVEDWHENYOUSAVEYOURPROJECTOFCOURSEYOULLHAVETOENSURETHATWHENYOURPROJECTISLOADEDITRECREATESTHENEEDEDVALUEANDSETSTHEVARIABLETOITFDEBUGGINGSNAPPROVIDESSEVERALTOOLSTOHELPYOUDEBUGAPROGRAMTHEYCENTERAROUNDTHEIDEAOFPAUSINGTHERUNNINGOFASCRIPTPARTWAYTHROUGHSOTHATYOUCANEXAMINETHEVALUESOFVARIABLESTHEPAUSEBUTTONTHESIMPLESTWAYTOPAUSEAPROGRAMISMANUALLYBYCLICKINGTHEPAUSEBUTTONINTHETOPRIGHTCORNEROFTHEWINDOWWHILETHEPROGRAMISPAUSEDYOUCANRUNOTHERSCRIPTSBYCLICKINGONTHEMSHOWVARIABLESONSTAGEWITHTHECHECKBOXNEXTTOTHEVARIABLEINTHEVARIABLESPALETTEORWITHTHESHOWVARIABLEBLOCKANDDOALLTHEOTHERTHINGSYOUCANGENERALLYDOINCLUDINGMODIFYINGTHEPAUSEDSCRIPTSBYADDINGORREMOVINGBLOCKSTHEBUTTONCHANGESSHAPETOANDCLICKINGITAGAINRESUMESTHEPAUSEDSCRIPTSBREAKPOINTSTHEPAUSEALLBLOCKTHEPAUSEBUTTONISGREATIFYOURPROGRAMSEEMSTOBEINANINFINITELOOPBUTMOREOFTENYOULLWANTTOSETABREAKPOINTAPARTICULARPOINTINASCRIPTATWHICHYOUWANTTOPAUSETHEBLOCKNEARTHEBOTTOMOFTHECONTROLPALETTECANBEINSERTEDINASCRIPTTOPAUSEWHENITISRUNSOFOREXAMPLEIFYOURPROGRAMISGETTINGANERRORMESSAGEINAPARTICULARBLOCKYOUCOULDUSEPAUSEALLJUSTBEFORETHATBLOCKTOLOOKATTHEVALUESOFVARIABLESJUSTBEFORETHEERRORHAPPENSTHEPAUSEALLBLOCKTURNSBRIGHTCYANWHILEPAUSEDALSODURINGTHEPAUSEYOUCANRIGHTCLICKONARUNNINGSCRIPTANDTHEMENUTHATAPPEARSWILLGIVEYOUTHEOPTIONTOSHOWWATCHERSFORTEMPORARYVARIABLESOFTHESCRIPTBUTWHATIFTHEBLOCKWITHTHEERRORISRUNMANYTIMESINALOOPANDITONLYERRORSWHENAPARTICULARCONDITIONISTRUESAYTHEVALUEOFSOMEVARIABLEISNEGATIVEWHICHSHOULDNTEVERHAPPENINTHEITERATIONLIBRARYSEEPAGEFORMOREABOUTHOWTOUSELIBRARIESISABREAKPOINTBLOCKTHATLETSYOUSETACONDITIONALBREAKPOINTANDAUTOMATICALLYDISPLAYTHERELEVANTVARIABLESBEFOREPAUSINGHERESASAMPLEUSEOFITINTHISCONTRIVEDEXAMPLEVARIABLEZOTCOMESFROMOUTSIDETHESCRIPTBUTISRELEVANTTOITSBEHAVIORWHENYOUCONTINUEWITHTHEPAUSEBUTTONTHETEMPORARYVARIABLEWATCHERSAREREMOVEDBYTHISBREAKPOINTBLOCKBEFORERESUMINGTHESCRIPTTHEBREAKPOINTBLOCKISNTMAGICYOUCOULDALTERNATIVELYJUSTPUTAPAUSEALLINSIDEANIFTHEHIDEVARIABLEANDSHOWVARIABLEBLOCKSCANALSOBEUSEDTOHIDEANDSHOWPRIMITIVESINTHEPALETTETHEPULLDOWNMENUDOESNTINCLUDEPRIMITIVEBLOCKSBUTTHERESAGENERALLYUSEFULTECHNIQUETOGIVEABLOCKINPUTVALUESITWASNTEXPECTINGUSINGRUNORCALLINORDERTOUSEABLOCKASANINPUTTHISWAYYOUMUSTEXPLICITLYPUTARINGAROUNDITBYRIGHTCLICKINGONITANDCHOOSINGRINGIFYMOREABOUTRINGSINCHAPTERVIVISIBLESTEPPINGSOMETIMESYOURENOTEXACTLYSUREWHERETHEERRORISORYOUDONTUNDERSTANDHOWTHEPROGRAMGOTTHERETOUNDERSTANDBETTERYOUDLIKETOWATCHTHEPROGRAMASITRUNSATHUMANSPEEDRATHERTHANATCOMPUTERSPEEDYOUCANDOTHISBYCLICKINGTHEVISIBLESTEPPINGBUTTONBEFORERUNNINGASCRIPTORWHILETHESCRIPTISPAUSEDTHEBUTTONWILLLIGHTUPANDASPEEDCONTROLSLIDERWILLAPPEARINTHETOOLBARWHENYOUSTARTORCONTINUETHESCRIPTITSBLOCKSANDINPUTSLOTSWILLLIGHTUPCYANONEATATIMEINTHISSIMPLEEXAMPLETHEINPUTSTOTHEBLOCKSARECONSTANTVALUESBUTIFANINPUTWEREAMORECOMPLICATEDEXPRESSIONINVOLVINGSEVERALREPORTERBLOCKSEACHOFTHOSEWOULDLIGHTUPASTHEYARECALLEDNOTETHATTHEINPUTTOABLOCKISEVALUATEDBEFORETHEBLOCKITSELFISCALLEDSOFOREXAMPLETHELIGHTSUPBEFORETHEMOVETHESPEEDOFSTEPPINGISCONTROLLEDBYTHESLIDERIFYOUMOVETHESLIDERALLTHEWAYTOTHELEFTTHESPEEDISZEROTHEPAUSEBUTTONTURNSINTOASTEPBUTTONANDTHESCRIPTTAKESASINGLESTEPEACHTIMEYOUPUSHITTHENAMEFORTHISISSINGLESTEPPINGIFSEVERALSCRIPTSTHATAREVISIBLEINTHESCRIPTINGAREAARERUNNINGATTHESAMETIMEALLOFTHEMARESTEPPEDINPARALLELHOWEVERCONSIDERTHECASEOFTWOREPEATLOOPSWITHDIFFERENTNUMBERSOFBLOCKSWHILENOTSTEPPINGEACHSCRIPTGOESTHROUGHACOMPLETECYCLEOFITSLOOPINEACHDISPLAYCYCLEDESPITETHEDIFFERENCEINTHELENGTHOFACYCLEINORDERTOENSURETHATTHEVISIBLERESULTOFAPROGRAMONTHESTAGEISTHESAMEWHENSTEPPEDASWHENNOTSTEPPEDTHESHORTERSCRIPTWILLWAITATTHEBOTTOMOFITSLOOPFORTHELONGERSCRIPTTOCATCHUPWHENWETALKABOUTCUSTOMBLOCKSINCHAPTERIIIWELLHAVEMORETOSAYABOUTVISIBLESTEPPINGASITAFFECTSTHOSEBLOCKSGETCETERATHISMANUALDOESNTEXPLAINEVERYBLOCKINDETAILTHEREAREMANYMOREMOTIONBLOCKSSOUNDBLOCKSCOSTUMEANDGRAPHICSEFFECTSBLOCKSANDSOONYOUCANLEARNWHATTHEYALLDOBYEXPERIMENTATIONANDALSOBYREADINGTHEHELPSCREENSTHATYOUCANGETBYRIGHTCLICKINGORCONTROLCLICKINGABLOCKANDSELECTINGHELPFROMTHEMENUTHATAPPEARSIFYOUFORGETWHATPALETTECOLORABLOCKISBUTYOUREMEMBERATLEASTPARTOFITSNAMETYPECONTROLFANDENTERTHENAMEINTHETEXTBLOCKTHATAPPEARSINTHEPALETTEAREAHEREARETHEPRIMITIVEBLOCKSTHATDONTEXISTINSCRATCHREPORTSANEWCOSTUMECONSISTINGOFEVERYTHINGTHATSDRAWNONTHESTAGEBYANYSPRITERIGHTCLICKINGTHEBLOCKINTHESCRIPTINGAREAGIVESTHEOPTIONTOCHANGEITTOIFVECTORLOGGINGISENABLEDSEEPAGEPRINTCHARACTERSINTHEGIVENPOINTSIZEONTHESTAGEATTHESPRITESPOSITIONANDINITSDIRECTIONTHESPRITEMOVESTOTHEENDOFTHETEXTTHATSNOTALWAYSWHATYOUWANTBUTYOUCANSAVETHESPRITESPOSITIONBEFOREUSINGITANDSOMETIMESYOUNEEDTOKNOWHOWBIGTHETEXTTURNEDOUTTOBEINTURTLESTEPSIFTHEPENISDOWNTHETEXTWILLBEUNDERLINEDGETORSETSELECTEDGLOBALFLAGSBLOCKSONLYFORTHESTAGETAKESASPRITEASINPUTLIKESTAMPEXCEPTTHATTHECOSTUMEISSTAMPEDONTOTHESELECTEDSPRITEINSTEADOFONTOTHESTAGEDOESNOTHINGIFTHECURRENTSPRITEDOESNTOVERLAPTHECHOSENSPRITETAKESASPRITEASINPUTERASESFROMTHATSPRITESCOSTUMETHEAREATHATOVERLAPSWITHTHECURRENTSPRITESCOSTUMEDOESNOTAFFECTTHECOSTUMEINTHECHOSENSPRITESWARDROBEONLYTHECOPYCURRENTLYVISIBLESEEPAGESEEPAGEREPORTERVERSIONOFTHEIFELSEPRIMITIVECOMMANDBLOCKONLYONEOFTHETWOBRANCHESISEVALUATEDDEPENDINGONTHEVALUEOFTHEFIRSTINPUTLOOPINGBLOCKLIKEREPEATBUTWITHANINDEXVARIABLEDECLARELOCALVARIABLESINASCRIPTSEEPAGECONSTANTTRUEORFALSEVALUESEEPAGECREATEAPRIMITIVEUSINGJAVASCRIPTTHISBLOCKISDISABLEDBYDEFAULTTHEUSERMUSTCHECKJAVASCRIPTEXTENSIONSINTHESETTINGMENUEACHTIMEAPROJECTISLOADEDTHEATBLOCKLETSYOUEXAMINETHESCREENPIXELDIRECTLYBEHINDTHEROTATIONCENTEROFASPRITETHEMOUSEORANARBITRARYXYCOORDINATEPAIRDROPPEDONTOTHESECONDMENUSLOTTHEFIRSTFIVEITEMSOFTHELEFTMENULETYOUEXAMINETHECOLORVISIBLEATTHEPOSITIONTHERGBAOPTIONREPORTSALISTTHESPRITESOPTIONREPORTSALISTOFALLSPRITESINCLUDINGTHISONEANYPOINTOFWHICHOVERLAPSTHISSPRITESROTATIONCENTERBEHINDORINFRONTTHISISAHYPERBLOCKWITHRESPECTTOITSSECONDINPUTCHECKSTHEDATATYPEOFAVALUERUNSONLYTHISSCRIPTUNTILFINISHEDINTHECONTROLPALETTEEVENTHOUGHITSGRAYREPORTSTHEVALUEOFAGRAPHICSEFFECTTURNTHETEXTINTOALISTUSINGTHESECONDINPUTASTHEDELIMITERBETWEENITEMSTHEDEFAULTDELIMITERINDICATEDBYTHEBROWNDOTINTHEINPUTSLOTISASINGLESPACECHARACTERLEERPUTSEACHCHARACTEROFTHETEXTINITSOWNLISTITEMWORDPUTSEACHWORDINANITEMWORDSARESEPARATEDBYANYNUMBEROFCONSECUTIVESPACETABCARRIAGERETURNORNEWLINECHARACTERSLINEISANEWLINECHARACTERXATABISATABCHARACTERXCRISACARRIAGERETURNXDCSVANDJSONSPLITFORMATTEDTEXTINTOLISTSOFLISTSSEEPAGEBLOCKSTAKESASCRIPTASTHEFIRSTINPUTREPORTINGALISTSTRUCTUREREPRESENTINGTHESTRUCTUREOFTHESCRIPTSEECHAPTERXIFORLISTSREPORTSTRUEONLYIFITSTWOINPUTVALUESARETHEVERYSAMELISTSOCHANGINGANITEMINONEOFTHEMISVISIBLEINTHEOTHERFORLISTSTHATLOOKTHESAMEARETHESAMEFORTEXTSTRINGSUSESCASESENSITIVECOMPARISONUNLIKEWHICHISCASEINDEPENDENTTHESEHIDDENBLOCKSCANBEFOUNDWITHTHERELABELOPTIONOFANYDYADICARITHMETICBLOCKTHEYREHIDDENPARTLYBECAUSEWRITINGTHEMINSNAPISAGOODPRETTYEASYPROGRAMMINGEXERCISENOTETHETWOINPUTSTOATANAREXANDYINTHATORDERBECAUSEWEMEASUREANGLESCLOCKWISEFROMNORTHMAXANDMINAREVARIADICBYCLICKINGTHEARROWHEADYOUCANPROVIDEADDITIONALINPUTSSIMILARLYTHESEHIDDENPREDICATESCANBEFOUNDBYRELABELINGTHERELATIONALPREDICATESMETAPROGRAMMINGSEECHAPTERXIPAGETHESEBLOCKSSUPPORTMETAPROGRAMMINGWHICHMEANSMANIPULATINGBLOCKSANDSCRIPTSASDATATHISISNOTTHESAMEASMANIPULATINGPROCEDURESSEECHAPTERVIWHICHAREWHATTHEBLOCKSMEANINMETAPROGRAMMINGTHEACTUALBLOCKSWHATYOUSEEONTHESCREENARETHEDATATHISCAPABILITYISNEWINVERSIONFIRSTCLASSLISTBLOCKSSEECHAPTERIVPAGENUMBERSFROMWILLCOUNTUPORDOWNTHESCRIPTINPUTTOFOREACHCANREFERTOANITEMOFTHELISTWITHTHEITEMVARIABLEREPORTTHESPRITEORMOUSEPOSITIONASATWOITEMVECTORXYFIRSTCLASSPROCEDUREBLOCKSSEECHAPTERVIPAGEFIRSTCLASSCONTINUATIONBLOCKSSEECHAPTERXPAGEFIRSTCLASSSPRITECOSTUMEANDSOUNDBLOCKSSEECHAPTERVIIPAGESCENESTHEMAJORNEWFEATUREOFVERSIONISSCENESAPROJECTCANINCLUDEWITHINITSUBPROJECTSCALLEDSCENESEACHWITHITSOWNSTAGESPRITESSCRIPTSANDSOONTHISBLOCKMAKESANOTHERSCENEACTIVEREPLACINGTHECURRENTONENOTHINGISAUTOMATICALLYSHAREDBETWEENSCENESNOSPRITESNOBLOCKSNOVARIABLESBUTTHEOLDSCENECANSENDAMESSAGETOTHENEWONETOSTARTITRUNNINGWITHOPTIONALPAYLOADASINBROADCASTPAGEINPARTICULARYOUCANSAYIFTHENEWSCENEEXPECTSTOBESTARTEDWITHAGREENFLAGSIGNALOBJECTISAHYPERBLOCKTHESEARENTNEWBLOCKSBUTTHEYHAVEANEWFEATURETHESEACCEPTTWOITEMXYLISTSASINPUTANDHAVEEXTENDEDMENUSALSOINCLUDINGOTHERSPRITESCENTERMEANSTHECENTEROFTHESTAGETHEPOINTATDIRECTIONISINTHEPOINTINDIRECTIONSENSETHEDIRECTIONTHATWOULDLEAVETHISSPRITEPOINTINGTOWARDANOTHERSPRITETHEMOUSEORTHECENTERRAYLENGTHISTHEDISTANCEFROMTHECENTEROFTHISSPRITETOTHENEARESTPOINTONTHEOTHERSPRITEINTHECURRENTDIRECTIONTHESTOPBLOCKHASTWOEXTRAMENUCHOICESSTOPTHISBLOCKISUSEDINSIDETHEDEFINITIONOFACUSTOMBLOCKTOSTOPJUSTTHISINVOCATIONOFTHISCUSTOMBLOCKANDCONTINUETHESCRIPTTHATCALLEDITSTOPALLBUTTHISSCRIPTISGOODATTHEENDOFAGAMETOSTOPALLTHEGAMEPIECESFROMMOVINGAROUNDBUTKEEPRUNNINGTHISSCRIPTTOPROVIDETHEUSERSFINALSCORETHELASTTWOMENUCHOICESADDATABATTHEBOTTOMOFTHEBLOCKBECAUSETHECURRENTSCRIPTCANCONTINUEAFTERITTHENEWPENTRAILSOPTIONISTRUEIFTHESPRITEISTOUCHINGANYDRAWNORSTAMPEDINKONTHESTAGEALSOTOUCHINGWILLNOTDETECTHIDDENSPRITESBUTAHIDDENSPRITECANUSEITTODETECTVISIBLESPRITESTHEVIDEOBLOCKHASASNAPOPTIONTHATTAKESASNAPSHOTANDREPORTSITASACOSTUMEITISHYPERIZEDWITHRESPECTTOITSSECONDINPUTTHENEGOPTIONISAMONADICNEGATIONOPERATOREQUIVALENTTOLGISLOGIDISTHEIDENTITYFUNCTIONWHICHREPORTSITSINPUTSIGNREPORTSFORPOSITIVEINPUTFORZEROINPUTORFORNEGATIVEINPUTNAMECHANGEDTOCLARIFYTHATITSDIFFERENTFROMANDAREVARIADICTHEYTAKETWOORMOREINPUTSIFYOUDROPALISTONTHEARROWHEADSTHEBLOCKNAMECHANGESTOSUMORPRODUCTEXTENDEDMOUSEINTERACTIONEVENTSSENSINGCLICKINGDRAGGINGHOVERINGETCTHESTOPPEDOPTIONTRIGGERSWHENALLSCRIPTSARESTOPPEDASWITHTHESTOPBUTTONITISUSEFULFORROBOTSWHOSEHARDWAREINTERFACEMUSTBETOLDTOTURNOFFMOTORSAWHENIAMSTOPPEDSCRIPTCANRUNONLYFORALIMITEDTIMEEXTENDEDBROADCASTCLICKTHERIGHTARROWHEADTODIRECTTHEMESSAGETOASINGLESPRITEORTHESTAGECLICKAGAINTOADDANYVALUEASAPAYLOADTOTHEMESSAGEEXTENDEDWHENIRECEIVECLICKTHERIGHTARROWHEADTOEXPOSEASCRIPTVARIABLECLICKONITTOCHANGEITSNAMELIKEANYSCRIPTVARIABLETHATWILLBESETTOTHEDATAOFAMATCHINGBROADCASTIFTHEFIRSTINPUTISSETTOANYMESSAGETHENTHEDATAVARIABLEWILLBESETTOTHEMESSAGEIFNOPAYLOADISINCLUDEDWITHTHEBROADCASTORTOATWOITEMLISTCONTAININGTHEMESSAGEANDTHEPAYLOADIFTHEINPUTISSETTOANYKEYTHENARIGHTARROWHEADAPPEARSANDIFYOUCLICKITASCRIPTVARIABLEKEYISCREATEDWHOSEVALUEISTHEKEYTHATWASPRESSEDIFTHEKEYISONETHATREPRESENTEDINTHEINPUTMENUBYAWORDORPHRASEEGENTERORUPARROWTHENTHEVALUEOFKEYWILLBETHATWORDORPHRASEEXCEPTFORTHESPACECHARACTERWHICHISREPRESENTEDASITSELFINKEYTHESEASKFEATURESANDMOREINTHEMENUSLIBRARYTHEOFBLOCKHASANEXTENDEDMENUOFATTRIBUTESOFASPRITEPOSITIONREPORTSANXYVECTORSIZEREPORTSTHEPERCENTAGEOFNORMALSIZEASCONTROLLEDBYTHESETSIZEBLOCKINTHELOOKSCATEGORYLEFTRIGHTETCREPORTTHESTAGECOORDINATESOFTHECORRESPONDINGEDGEOFTHESPRITESBOUNDINGBOXVARIABLESREPORTSALISTOFTHENAMESOFALLVARIABLESINSCOPEGLOBALSPRITELOCALANDSCRIPTVARIABLESIFTHERIGHTINPUTISASCRIPTTHERGBAOPTIONACCEPTSASINGLENUMBERWHICHISAGRAYSCALEVALUEATWONUMBERLISTGRAYSCALEPLUSOPACITYATHREEITEMRGBLISTORAFOURITEMRGBALISTHLIBRARIESTHEREARESEVERALCOLLECTIONSOFUSEFULPROCEDURESTHATARENTSNAPPRIMITIVESBUTAREPROVIDEDASLIBRARIESTOINCLUDEALIBRARYINYOURPROJECTCHOOSETHELIBRARIESOPTIONINTHEFILEMENUWHENYOUCLICKONTHEONELINEDESCRIPTIONOFALIBRARYYOUARESHOWNTHEACTUALBLOCKSINTHELIBRARYANDALONGEREXPLANATIONOFITSPURPOSEYOUCANBROWSETHELIBRARIESTOFINDONETHATWILLSATISFYYOURNEEDSTHELIBRARIESANDTHEIRCONTENTSMAYCHANGEBUTASOFTHISWRITINGTHELISTLIBRARYHASTHESEBLOCKSTHELIGHTNINGBOLTBEFORETHENAMEINSEVERALOFTHESEBLOCKSMEANSTHATTHEYUSECOMPILEDHOFSORJAVASCRIPTPRIMITIVESTOACHIEVEOPTIMALSPEEDTHEYAREOFFICIALLYCONSIDEREDEXPERIMENTALREMOVEDUPLICATESFROMREPORTSALISTINWHICHNOTWOITEMSAREEQUALTHESORTBLOCKTAKESALISTANDATWOINPUTCOMPARISONPREDICATESUCHASANDREPORTSALISTWITHTHEITEMSSORTEDACCORDINGTOTHATCOMPARISONTHEASSOCBLOCKISFORLOOKINGUPAKEYINANASSOCIATIONLISTALISTOFTWOITEMLISTSINEACHTWOITEMLISTTHEFIRSTISAKEYANDTHESECONDISAVALUETHEINPUTSAREAKEYANDANASSOCIATIONLISTTHEBLOCKREPORTSTHEFIRSTKEYVALUEPAIRWHOSEKEYISEQUALTOTHEINPUTKEYFOREACHITEMISAVARIANTOFTHEPRIMITIVEVERSIONTHATPROVIDESAVARIABLECONTAININGTHEPOSITIONINTHEINPUTLISTOFTHECURRENTLYCONSIDEREDITEMMULTIMAPISAVERSIONOFMAPTHATALLOWSMULTIPLELISTINPUTSINWHICHCASETHEMAPPINGFUNCTIONMUSTTAKEASMANYINPUTSASTHEREARELISTSITWILLBECALLEDWITHALLTHEFIRSTITEMSALLTHESECONDITEMSANDSOONZIPTAKESANYNUMBEROFLISTSASINPUTSITREPORTSALISTOFLISTSALLTHEFIRSTITEMSALLTHESECONDITEMSANDSOONTHENONAMEIDENTITYFUNCTIONREPORTSITSINPUTSENTENCEANDSENTENCELISTAREBORROWEDFROMTHEWORDANDSENTENCELIBRARYPAGETOSERVEASAVARIANTOFAPPENDTHATACCEPTSNONLISTSASINPUTSPRINTABLETAKESALISTSTRUCTUREOFANYDEPTHASINPUTANDREPORTSACOMPACTREPRESENTATIONOFTHELISTASATEXTSTRINGTHELIBRARYMENUISDIVIDEDINTOFIVEBROADCATEGORIESTHEFIRSTISBROADLYUTILITIESBLOCKSTHATMIGHTWELLBEPRIMITIVESTHEYMIGHTBEUSEFULINALLKINDSOFPROJECTSTHESECONDCATEGORYISBLOCKSRELATEDTOMEDIACOMPUTATIONONESTHATHELPINDEALINGWITHCOSTUMESANDSOUNDSAKAJENSLIBRARIESTHEREISSOMEOVERLAPWITHBIGDATALIBRARIESFORDEALINGWITHLARGELISTSOFLISTSTHETHIRDCATEGORYISROUGHLYSPECIFICTONONMEDIAAPPLICATIONSAKABRIANLIBRARIESTHREEOFTHEMAREIMPORTSFROMOTHERPROGRAMMINGLANGUAGESWORDSANDSENTENCESFROMLOGOARRAYFUNCTIONSFROMAPLANDSTREAMSFROMSCHEMEMOSTOFTHEOTHERSARETOMEETTHENEEDSOFTHEBJCCURRICULUMTHEFOURTHCATEGORYISMAJORPACKAGESEXTENSIONSPROVIDEDBYUSERSTHEFIFTHCATEGORYPROVIDESSUPPORTFORHARDWAREDEVICESSUCHASROBOTSTHROUGHGENERALINTERFACESREPLACINGSPECIFICHARDWARELIBRARIESINVERSIONSBEFORETHEITERATIONCOMPOSITIONLIBRARYHASTHESEBLOCKSCATCHANDTHROWPROVIDEANONLOCALEXITFACILITYYOUCANDRAGTHETAGFROMACATCHBLOCKTOATHROWINSIDEITSCSLOTANDTHETHROWWILLTHENJUMPDIRECTLYOUTTOTHEMATCHINGCATCHWITHOUTDOINGANYTHINGINBETWEENIFDOANDPAUSEALLISFORSETTINGABREAKPOINTWHILEDEBUGGINGCODETHEIDEAISTOPUTSHOWVARIABLEBLOCKSFORLOCALVARIABLESINTHECSLOTTHEWATCHERSWILLBEDELETEDWHENTHEUSERCONTINUESFROMTHEPAUSEIGNOREISUSEDWHENYOUNEEDTOCALLAREPORTERBUTYOUDONTCAREABOUTTHEVALUEITREPORTSFOREXAMPLEYOUAREWRITINGASCRIPTTOTIMEHOWLONGTHEREPORTERTAKESTHECASCADEBLOCKSTAKEANINITIALVALUEANDCALLAFUNCTIONREPEATEDLYONTHATVALUEFFFFXTHECOMPOSEBLOCKTAKESTWOFUNCTIONSANDREPORTSTHEFUNCTIONFGXTHEFIRSTTHREEREPEATBLOCKSAREVARIANTSOFTHEPRIMITIVEREPEATUNTILBLOCKGIVINGALLFOURCOMBINATIONSOFWHETHERTHEFIRSTTESTHAPPENSBEFOREORAFTERTHEFIRSTREPETITIONANDWHETHERTHECONDITIONMUSTBETRUEORFALSETOCONTINUEREPEATINGTHELASTREPEATBLOCKISLIKETHEREPEATPRIMITIVEBUTMAKESTHENUMBEROFREPETITIONSSOFARAVAILABLETOTHEREPEATEDSCRIPTTHENEXTTWOBLOCKSAREVARIATIONSONFORTHEFIRSTALLOWSANEXPLICITSTEPINSTEADOFUSINGANDTHESECONDALLOWSANYVALUESNOTJUSTNUMBERSINSIDETHESCRIPTYOUSAYREPLACINGTHEGREYBLOCKINTHEPICTUREWITHANEXPRESSIONTOGIVETHENEXTDESIREDVALUEFORTHELOOPINDEXPIPEALLOWSREORDERINGANESTEDCOMPOSITIONWITHALEFTTORIGHTONETHESTREAMLIBRARYHASTHESEBLOCKSSTREAMSAREASPECIALKINDOFLISTWHOSEITEMSARENOTCOMPUTEDUNTILTHEYARENEEDEDTHISMAKESCERTAINCOMPUTATIONSMOREEFFICIENTANDALSOALLOWSTHECREATIONOFLISTSWITHINFINITELYMANYITEMSSUCHASALISTOFALLTHEPOSITIVEINTEGERSTHEFIRSTFIVEBLOCKSARESTREAMVERSIONSOFTHELISTBLOCKSINFRONTOFITEMOFALLBUTRSTOFMAPANDKEEPSHOWSTREAMTAKESASTREAMANDANUMBERASINPUTSANDREPORTSANORDINARYLISTOFTHEFIRSTNITEMSOFTHESTREAMSTREAMISLIKETHEPRIMITIVELISTITMAKESAFINITESTREAMFROMEXPLICITITEMSSIEVEISANEXAMPLEBLOCKTHATTAKESASINPUTTHESTREAMOFINTEGERSSTARTINGWITHANDREPORTSTHESTREAMOFALLTHEPRIMENUMBERSSTREAMWITHNUMBERSFROMISLIKETHENUMBERSFROMBLOCKFORLISTSEXCEPTTHATTHEREISNOENDPOINTITREPORTSANINFINITESTREAMOFNUMBERSTHEWORDANDSENTENCELIBRARYHASTHESEBLOCKSTHISLIBRARYHASTHEGOALOFRECREATINGTHELOGOAPPROACHTOHANDLINGTEXTATEXTISNTBESTVIEWEDASASTRINGOFCHARACTERSBUTRATHERASASENTENCEMADEOFWORDSEACHOFWHICHISASTRINGOFLETTERSWITHAFEWSPECIALIZEDEXCEPTIONSTHISISWHYPEOPLEPUTTEXTINTOCOMPUTERSTHETEXTISSENTENCESOFNATURALIEHUMANLANGUAGEANDTHEEMPHASISISONWORDSASCONSTITUTIVEOFSENTENCESYOUBARELYNOTICETHELETTERSOFTHEWORDSANDYOUDONTNOTICETHESPACESBETWEENTHEMATALLUNLESSYOUREPROOFREADINGEVENTHENPROOFREADINGISDIFFCIULTBECAUSEYOUSEEWHATYOUEXPECTTOSEEWHATWILLMAKETHESNETENCEMAKESENSERATHERTHANTHEMISSPELLINGINFRONTOFOFYOUREYESINTERNALLYLOGOSTORESASENTENCEASALISTOFWORDSANDAWORDASASTRINGOFLETTERSINEXPLICABLYTHEDESIGNERSOFSCRATCHCHOSETOABANDONTHATTRADITIONANDTOFOCUSONTHEREPRESENTATIONOFTEXTASASTRINGOFCHARACTERSTHEONEVESTIGEOFTHELOGOTRADITIONFROMWHICHSCRATCHDEVELOPEDISTHEBLOCKNAMEDLEEROFWORLDRATHERTHANCHARACTEROFWORLDSNAPINHERITSITSTEXTHANDLINGFROMSCRATCHINLOGOTHEVISUALREPRESENTATIONOFASENTENCEALISTOFWORDSLOOKSLIKEANATURALLANGUAGESENTENCEASTRINGOFWORDSWITHSPACESBETWEENTHEMINSNAPTHEVISUALREPRESENTATIONOFALISTLOOKSNOTHINGATALLLIKENATURALLANGUAGEONTHEOTHERHANDREPRESENTINGASENTENCEASASTRINGMEANSTHATTHEPROGRAMMUSTCONTINUALLYREPARSETHETEXTONEVERYOPERATIONLOOKINGFORSPACESTREATINGMULTIPLECONSECUTIVESPACESASONEANDSOONALSOITSMORECONVENIENTTOTREATASENTENCEASALISTOFWORDSRATHERTHANASTRINGOFWORDSBECAUSEINTHEFORMERCASEYOUCANUSETHEHIGHERORDERFUNCTIONSMAPKEEPANDCOMBINEONTHEMTHISLIBRARYATTEMPTSTOBEAGNOSTICASTOTHEINTERNALREPRESENTATIONOFSENTENCESTHESENTENCESELECTORSACCEPTANYCOMBINATIONOFLISTSANDSTRINGSTHEREARETWOSENTENCECONSTRUCTORSONETOMAKEASTRINGJOINWORDSANDONETOMAKEALISTSENTENCETHESELECTORNAMESCOMEFROMLOGOANDSHOULDBESELFEXPLANATORYHOWEVERBECAUSEINABLOCKLANGUAGEYOUDONTHAVETOTYPETHEBLOCKNAMEINSTEADOFTHETERSEBUTRSTORTHECRYPTICBFWESPELLOUTALLBUTFIRSTOFANDINCLUDEWORDORSENTENCETOINDICATETHEINTENDEDDOMAINTHERESNORSTLEEROFBLOCKBECAUSELEEROFSERVESTHATNEEDJOINWORDSTHESENTENCEASSTRINGCONSTRUCTORISLIKETHEPRIMITIVEJOINEXCEPTTHATITPUTSASPACEINTHEREPORTEDVALUEBETWEENEACHOFTHEINPUTSSENTENCETHELISTCOLOREDSENTENCEASLISTCONSTRUCTORACCEPTSANYNUMBEROFINPUTSWHICHCANBEWORDSSENTENCESASLISTSORSENTENCESASSTRINGSIFINPUTSARELISTSOFLISTSONLYONELEVELOFFLATTENINGISDONESENTENCEREPORTSALISTOFWORDSTHEREWILLBENOEMPTYWORDSORWORDSCONTAININGSPACESTHEFOURBLOCKSWITHRIGHTARROWSINTHEIRNAMESCONVERTBACKANDFORTHBETWEENTEXTSTRINGSWORDSORSENTENCESANDLISTSSPLITTINGAWORDINTOALISTOFLETTERSISUNUSUALUNLESSYOUREALINGUISTINVESTIGATINGORTHOGRAPHYPRINTABLETAKESALISTINCLUDINGADEEPLISTOFWORDSASINPUTANDREPORTSATEXTSTRINGINWHICHPARENTHESESAREUSEDTOSHOWTHESTRUCTUREASINLISPSCHEMETHEPIXELSLIBRARYHASONEBLOCKCOSTUMESAREFIRSTCLASSDATAINSNAPMOSTOFTHEPROCESSINGOFCOSTUMEDATAISDONEBYPRIMITIVEBLOCKSINTHELOOKSCATEGORYSEEPAGETHISLIBRARYPROVIDESSNAPWHICHTAKESAPICTUREUSINGYOURCOMPUTERSCAMERAANDREPORTSITASACOSTUMETHEBARCHARTSLIBRARYHASTHESEBLOCKSBARCHARTTAKESATABLETYPICALLYFROMACSVDATASETASINPUTANDREPORTSASUMMARYOFTHETABLEGROUPEDBYTHEFIELDINTHESPECIFIEDCOLUMNNUMBERTHEREMAININGTHREEINPUTSAREUSEDONLYIFTHEFIELDVALUESARENUMBERSINWHICHCASETHEYCANBEGROUPEDINTOBUCKETSEGDECADESCENTURIESETCTHOSEINPUTSSPECIFYTHESMALLESTANDLARGESTVALUESOFINTERESTANDMOSTIMPORTANTLYTHEWIDTHOFABUCKETFORDECADESFORCENTURIESIFTHEFIELDISNTNUMERICLEAVETHESETHREEINPUTSEMPTYORSETTHEMTOZEROEACHSTRINGVALUEOFTHEFIELDISITSOWNBUCKETANDTHEYAPPEARSORTEDALPHABETICALLYBARCHARTREPORTSANEWTABLEWITHTHREECOLUMNSTHEFIRSTCOLUMNCONTAINSTHEBUCKETNAMEORSMALLESTNUMBERTHESECONDCOLUMNCONTAINSANONNEGATIVEINTEGERTHATSAYSHOWMANYRECORDSINTHEINPUTTABLEFALLINTOTHISBUCKETTHETHIRDCOLUMNISASUBTABLECONTAININGTHEACTUALRECORDSFROMTHEORIGINALTABLETHATFALLINTOTHEBUCKETPLOTBARCHARTTAKESTHETABLEREPORTEDBYBARCHARTANDGRAPHSITONTHESTAGEWITHAXESLABELLEDAPPROPRIATELYTHEREMAININGBLOCKSAREHELPERSFORTHOSEIFYOURBUCKETSARENTOFCONSTANTWIDTHORYOUWANTTOGROUPBYSOMEFUNCTIONOFMORETHANONEFIELDLOADTHEFREQUENCYDISTRIBUTIONANALYSISLIBRARYINSTEADTHEMULTIBRANCHEDCONDITIONALLIBRARYHASTHESEBLOCKSTHECATCHANDTHROWBLOCKSDUPLICATEONESINTHEITERATIONLIBRARYANDAREINCLUDEDBECAUSETHEYAREUSEDTOIMPLEMENTTHEOTHERSTHECASESBLOCKSETSUPAMULTIBRANCHCONDITIONALSIMILARTOCONDINLISPORSWITCHINCFAMILYLANGUAGESTHEFIRSTBRANCHISBUILTINTOTHECASESBLOCKITCONSISTSOFABOOLEANTESTINTHEFIRSTHEXAGONALSLOTANDANACTIONSCRIPTINTHECSLOTTOBERUNIFTHETESTREPORTSTRUETHEREMAININGBRANCHESGOINTHEVARIADICHEXAGONALINPUTATTHEENDEACHBRANCHCONSISTSOFANELSEIFBLOCKWHICHINCLUDESTHEBOOLEANTESTANDTHECORRESPONDINGACTIONSCRIPTEXCEPTPOSSIBLYFORTHELASTBRANCHWHICHCANUSETHEUNCONDITIONALELSEBLOCKASINOTHERLANGUAGESONCEABRANCHSUCCEEDSNOOTHERBRANCHESARETESTEDTHEVARIADICLIBRARYHASTHESEBLOCKSTHESEAREVERSIONSOFTHEASSOCIATIVEOPERATORSANDANDORTHATTAKEANYNUMBEROFINPUTSINSTEADOFEXACTLYTWOINPUTSASWITHANYVARIADICINPUTYOUCANALSODROPALISTOFVALUESONTOTHEARROWHEADSINSTEADOFPROVIDINGTHEINPUTSONEATATIMEASOFVERSIONTHEARITHMETICOPERATORSSUMPRODUCTMINIMUMANDMAXIMUMARENOLONGERINCLUDEDBECAUSETHEPRIMITIVEOPERATORSMINANDMAXARETHEMSELVESVARIADICTHECOLORSANDCRAYONSLIBRARYHASTHESEBLOCKSITISINTENDEDASAMOREPOWERFULREPLACEMENTFORTHEPRIMITIVESETPENBLOCKINCLUDINGFIRSTCLASSCOLORSUPPORTHSLCOLORSPECIFICATIONASABETTERALTERNATIVETOTHEHSVTHATSNAPINHERITSFROMJAVASCRIPTAFAIRHUESCALETHATCOMPENSATESFORTHEEYESGROUPINGAWIDERANGEOFLIGHTFREQUENCIESASGREENWHILELABELLINGMERESLIVERSASORANGEORYELLOWTHEXWCSTANDARDCOLORNAMESRGBINHEXADECIMALALINEARCOLORSCALEASINTHEOLDDAYSBUTBETTERBASEDONFAIRHUESANDINCLUDINGSHADESDARKERCOLORSANDGRAYSCALEANOTHERLINEARSCALEISACURATEDSETOFCRAYONSEXPLAINEDFURTHERONTHENEXTPAGECOLORSARECREATEDBYTHEBLOCKFORDIRECTUSERSELECTIONTHECOLORFROMBLOCKTOSPECIFYACOLORNUMERICALLYORBYWHICHREPORTSTHECOLORCURRENTLYINUSEBYTHEPENTHEFROMCOLORBLOCKREPORTSNAMESORNUMBERSASSOCIATEDWITHACOLORCOLORSCANBECREATEDFROMOTHERCOLORSTHETHREEBLOCKSWITHPENINTHEIRNAMESAREIMPROVEDVERSIONSOFPRIMITIVEPENBLOCKSINPRINCIPLESETPENFOREXAMPLECOULDBEIMPLEMENTEDUSINGAHYPOTHETICALSETPENTOCOLORCOMPOSEDWITHTHECOLORFROMBLOCKBUTINFACTSETPENBENEFITSFROMKNOWINGHOWTHEPENCOLORWASSETINITSPREVIOUSINVOCATIONSOITSIMPLEMENTEDSEPARATELYFROMCOLORFROMDETAILSINAPPENDIXATHERECOMMENDEDWAYTOCHOOSEACOLORISFROMONEOFTWOLINEARSCALESTHECONTINUOUSCOLORNUMBERSANDTHEDISCRETECRAYONSCOLORNUMBERSAREBASEDONFAIRHUESAMODIFICATIONOFTHESPECTRUMRAINBOWHUESCALETHATDEVOTESLESSSPACETOGREENANDMORETOORANGEANDYELLOWASWELLASPROMOTINGBROWNTOAREALCOLORHEREISTHENORMALHUESCALEFORREFERENCEHEREISTHEFAIRHUESCALEHEREISTHECOLORNUMBERSCALETHEPICTUREISWIDERSOTHATPURESPECTRALCOLORSLINEUPWITHTHEFAIRHUESCALEANDHEREARETHECRAYONSTHECOLORFROMBLOCKFOREXAMPLEPROVIDESDIFFERENTPULLDOWNMENUSDEPENDINGONWHICHSCALEYOUCHOOSEYOUCANALSOTYPETHECRAYONNAMETHEREAREMANYSCALESTHEWHITESLOTATTHEENDOFSOMEOFTHEBLOCKSHASTWOPURPOSESITCANBEUSEDTOADDATRANSPARENCYTOACOLOROPAQUETRANSPARENTORITCANBEEXPANDEDTOENTERTHREEORFOURNUMBERSFORAVECTORDIRECTLYINTOTHEBLOCKSOTHESEAREEQUIVALENTBUTNOTETHATATRANSPARENCYNUMBERINAFOURNUMBERRGBAVECTORISONTHESCALEOPAQUETRANSPARENTSOTHEFOLLOWINGARENOTEQUIVALENTSETPENCRAYONTOPROVIDESTHEEQUIVALENTOFABOXOFCRAYONSTHEYAREDIVIDEDINTOCOLORGROUPSSOTHEMENUINTHESETPENCRAYONTOINPUTSLOTHASSUBMENUSTHECOLORSARECHOSENSOTHATSTARTINGFROMCRAYONCHANGEPENCRAYONBYROTATESTHROUGHANINTERESTINGBASICSETOFTENCOLORSUSINGCHANGEPENCRAYONBYINSTEADGIVESTENMORECOLORSFORATOTALOFWHYDIDNTWEUSETHECOLORSOFTHECRAYONCRAYOLABOXAFEWREASONSONEOFWHICHISTHATSOMECRAYOLACOLORSARENTREPRESENTABLEONRGBSCREENSSOMEYEARWHENYOUHAVENOTHINGELSETODOLOOKUPCOLORSPACEONWIKIPEDIAALSOCRAYONOHITSDELIBERATETHATCHANGEPENCRAYONBYDOESNTINCLUDEWHITESINCETHATSTHEUSUALSTAGEBACKGROUNDCOLORWHITEISCRAYONNOTETHATCRAYONISVARIABLESALLTHESTANDARDBLOCKCOLORSAREINCLUDEDSEEAPPENDIXAPAGEFORMOREINFORMATIONTHECRAYONLIBRARYHASONLYTHECRAYONFEATURESWITHOUTTHERESTOFTHECOLORSPACKAGETHECATCHERRORSLIBRARYHASTHESEBLOCKSTHESAFELYTRYBLOCKALLOWSYOUTOHANDLEERRORSTHATHAPPENWHENYOURPROGRAMISRUNWITHINTHEPROGRAMINSTEADOFSTOPPINGTHESCRIPTWITHAREDHALOANDANOBSCUREERRORMESSAGETHEBLOCKRUNSTHESCRIPTINITSFIRSTCSLOTIFITFINISHESWITHOUTANERRORNOTHINGELSEHAPPENSBUTIFANERRORHAPPENSTHECODEINTHESECONDCSLOTISRUNWHILETHATSECONDSCRIPTISRUNNINGTHEVARIABLECONTAINSTHETEXTOFTHEERRORMESSAGETHATWOULDHAVEBEENDISPLAYEDIFYOUWERENTCATCHINGTHEERRORTHEERRORBLOCKISSORTOFTHEOPPOSITEITLETSYOURPROGRAMGENERATEANERRORMESSAGEWHICHWILLBEDISPLAYEDWITHAREDHALOUNLESSITISCAUGHTBYSAFELYTRYSAFELYTRYREPORTINGISTHEREPORTERVERSIONOFSAFELYTRYTHETEXTCOSTUMESLIBRARYHASONLYTWOBLOCKSCOSTUMEFROMTEXTREPORTSACOSTUMETHATCANBEUSEDWITHTHESWITCHTOCOSTUMEBLOCKTOMAKEABUTTONCOSTUMEWITHBACKGROUNDREPORTSACOSTUMEMADEFROMANOTHERCOSTUMEBYCOLORINGITSBACKGROUNDTAKINGACOLORINPUTLIKETHESETPENCOLORTORGBABLOCKANDANUMBEROFTURTLESTEPSOFPADDINGAROUNDTHEORIGINALCOSTUMETHESETWOBLOCKSWORKTOGETHERTOMAKEEVENBETTERBUTTONSTHETEXTTOSPEECHLIBRARYHASTHESEBLOCKSTHISLIBRARYINTERFACESWITHACAPABILITYINUPTODATEBROWSERSSOITMIGHTNOTWORKFORYOUITWORKSBESTIFTHEACCENTMATCHESTHETEXTTHEPARALLELIZATIONLIBRARYCONTAINSTHESEBLOCKSTHETWODOINPARALLELBLOCKSTAKEANYNUMBEROFSCRIPTSASINPUTSTHOSESCRIPTSWILLBERUNINPARALLELLIKEORDINARYINDEPENDENTSCRIPTSINTHESCRIPTINGAREATHEANDWAITVERSIONWAITSUNTILALLOFTHOSESCRIPTSHAVEFINISHEDBEFORECONTINUINGTHESCRIPTBELOWTHEBLOCKTHECREATEVARIABLESLIBRARYHASTHESEBLOCKSTHESEBLOCKSALLOWAPROGRAMTOPERFORMTHESAMEOPERATIONASTHEBUTTONMAKINGGLOBALSPRITELOCALORSCRIPTVARIABLESBUTALLOWINGTHEPROGRAMTOCOMPUTETHEVARIABLENAMESITCANALSOSETANDFINDTHEVALUESOFTHESEVARIABLESSHOWANDHIDETHEIRSTAGEWATCHERSDELETETHEMANDFINDOUTIFTHEYALREADYEXISTTHEGETTERSANDSETTERSLIBRARYHASTHESEBLOCKSTHEPURPOSEOFTHISLIBRARYISTOALLOWPROGRAMACCESSTOTHESETTINGSCONTROLLEDBYUSERINTERFACEELEMENTSSUCHASTHESETTINGSMENUTHESEINGBLOCKREPORTSASETTINGTHESETAGBLOCKSETSYESORNOOPTIONSTHATHAVECHECKBOXESINTHEUSERINTERFACEWHILETHESETVALUEBLOCKCONTROLSSETTINGSWITHNUMERICORTEXTVALUESSUCHASPROJECTNAMECERTAINSETTINGSAREORDINARILYREMEMBEREDONAPERUSERBASISSUCHASTHEZOOMBLOCKSVALUEBUTWHENTHESESETTINGSARECHANGEDBYTHISLIBRARYTHECHANGEISINEFFECTONLYWHILETHEPROJECTUSINGTHELIBRARYISLOADEDNOPERMANENTCHANGESAREMADENOTETHISLIBRARYHASNOTBEENCONVERTEDFORVERSIONSOYOULLHAVETOENABLEJAVASCRIPTEXTENSIONSTOUSEITTHEBIGNUMSRATIONALSCOMPLEXSLIBRARYHASTHESEBLOCKSTHEUSEBIGNUMSBLOCKTAKESABOOLEANINPUTTOTURNTHEINFINITEPRECISIONFEATUREONOROFFWHENONALLOFTHEARITHMETICOPERATORSAREREDEFINEDTOACCEPTANDREPORTINTEGERSOFANYNUMBEROFDIGITSLIMITEDONLYBYTHEMEMORYOFYOURCOMPUTERANDINFACTTHEENTIRESCHEMENUMERICTOWERWITHEXACTRATIONALSANDWITHCOMPLEXNUMBERSTHESCHEMENUMBERBLOCKHASALISTOFFUNCTIONSAPPLICABLETOSCHEMENUMBERSINCLUDINGSUBTYPEPREDICATESSUCHASRATIONALANDINNITEANDSELECTORSSUCHASNUMERATORANDREALPARTTHEBLOCKCOMPUTESTHEFACTORIALFUNCTIONUSEFULTOTESTWHETHERBIGNUMSARETURNEDONWITHOUTBIGNUMSWITHBIGNUMSTHEDIGITVALUEOFISNTREADABLEONTHISPAGEBUTIFYOURIGHTCLICKONTHEBLOCKANDCHOOSERESULTPICYOUCANOPENTHERESULTINGPICTUREINABROWSERWINDOWANDSCROLLTHROUGHITTHESEVALUESENDWITHABUNCHOFZERODIGITSTHATSNOTROUNDOFFERRORTHEPRIMEFACTORSOFANDINCLUDEMANYCOPIESOFANDTHEBLOCKWITHNONAMEISAWAYTOENTERTHINGSLIKEANDIINTONUMERICINPUTSLOTSBYCONVERTINGTHESLOTTOANYTYPETHESTRINGSMULTILINEINPUTLIBRARYPROVIDESTHESEBLOCKSALLOFTHESECOULDBEWRITTENINSNAPITSELFBUTTHESEAREIMPLEMENTEDUSINGTHECORRESPONDINGJAVASCRIPTLIBRARYFUNCTIONSDIRECTLYSOTHEYRUNFASTTHEYCANBEUSEDFOREXAMPLEINSCRAPINGDATAFROMAWEBSITETHECOMMANDUSECASEINDEPENDENTCOMPARISONSAPPLIESONLYTOTHISLIBRARYTHEMULTILINEBLOCKACCEPTSANDREPORTSATEXTINPUTTHATCANINCLUDENEWLINECHARACTERSTHEANIMATIONLIBRARYHASTHESEBLOCKSDESPITETHENAMETHISISNTONLYABOUTGRAPHICSYOUCANANIMATETHEVALUESOFAVARIABLEORANYTHINGELSETHATSEXPRESSEDNUMERICALLYTHECENTRALIDEAOFTHISLIBRARYISANEASINGFUNCTIONAREPORTERWHOSEDOMAINANDRANGEAREREALNUMBERSBETWEENANDINCLUSIVETHEFUNCTIONREPRESENTSWHATFRACTIONOFTHEDISTANCEINQUOTESBECAUSEITMIGHTBEANYNUMERICVALUESUCHASTEMPERATUREINASIMULATIONOFWEATHERFROMHERETOTHERESHOULDBECOVEREDINWHATFRACTIONOFTHETIMEALINEAREASINGFUNCTIONMEANSSTEADYPROGRESSIONAQUADRATICEASINGFUNCTIONMEANSSTARTINGSLOWLYANDACCELERATINGNOTETHATSINCEITSAREQUIREMENTTHATFANDFTHEREISONLYONELINEAREASINGFUNCTIONFXXANDSIMILARLYFOROTHERCATEGORIESTHEBLOCKREPORTSSOMEOFTHECOMMONEASINGFUNCTIONSTHETWOMOTIONBLOCKSINTHISLIBRARYANIMATEASPRITEGLIDEALWAYSANIMATESTHESPRITESMOTIONANIMATESFIRSTPULLDOWNMENUINPUTALLOWSYOUTOANIMATEHORIZONTALORVERTICALMOTIONBUTWILLALSOANIMATETHESPRITESDIRECTIONORSIZETHEANIMATEBLOCKINCONTROLLETSYOUANIMATEANYNUMERICQUANTITYWITHANYEASINGFUNCTIONTHEGETTERANDSETTERINPUTSAREBESTEXPLAINEDBYEXAMPLEISEQUIVALENTTOTHEOTHERBLOCKSINTHELIBRARYAREHELPERSFORTHESEFOURTHESERIALPORTSLIBRARYCONTAINSTHESEBLOCKSITISUSEDTOALLOWHARDWAREDEVELOPERSTOCONTROLDEVICESSUCHASROBOTSTHATARECONNECTEDTOYOURCOMPUTERVIAASERIALPORTTHEFREQUENCYDISTRIBUTIONANALYSISLIBRARYHASTHESEBLOCKSTHISISACOLLECTIONOFTOOLSFORANALYZINGLARGEDATASETSANDPLOTTINGHISTOGRAMSOFHOWOFTENSOMEVALUEISFOUNDINSOMECOLUMNOFTHETABLEHOLDINGTHEDATAFORMOREINFORMATIONGOHEREHPSTINYURLCOMJENSDATATHEAUDIOCOMPLIBRARYINCLUDESTHESEBLOCKSTHISLIBRARYTAKESASOUNDONETHATYOURECORDORONEFROMOURCOLLECTIONOFSOUNDSANDMANIPULATESITBYSYSTEMATICALLYCHANGINGTHEINTENSITYOFTHESAMPLESINTHESOUNDANDBYCHANGINGTHESAMPLINGRATEATWHICHTHESOUNDISREPRODUCEDMANYOFTHEBLOCKSAREHELPERSFORTHEPLOTSOUNDBLOCKUSEDTOPLOTTHEWAVEFORMOFASOUNDTHEPLAYSOUNDPRIMITIVEBLOCKPLAYSASOUNDHZFORREPORTSASINEWAVEASALISTOFSAMPLESTHEWEBSERVICESLIBRARYHASTHESEBLOCKSTHEFIRSTBLOCKISAGENERALIZATIONOFTHEPRIMITIVEURLBLOCKALLOWINGMORECONTROLOVERTHEVARIOUSOPTIONSINWEBREQUESTSGETPOSTPUTANDDELETEANDFINECONTROLOVERTHECONTENTOFTHEMESSAGESENTTOTHESERVERCURRENTLOCATIONREPORTSYOURLATITUDEANDLONGITUDELISTIFYTAKESSOMETEXTINJSONFORMATSEEPAGEANDCONVERTSITTOASTRUCTUREDLISTVALUEATKEYLOOKSUPAKEYVALUEPAIRINALISTIFIEDJSONDICTIONARYTHEKEYVALUEBLOCKISJUSTACONSTRUCTORFORANABSTRACTDATATYPEUSEDWITHTHEOTHERBLOCKSTHEDATABASELIBRARYCONTAINSTHESEBLOCKSITISUSEDTOKEEPDATATHATPERSISTFROMONESNAPSESSIONTOTHENEXTIFYOUUSETHESAMEBROWSERANDTHESAMELOGINTHEWORLDMAPLIBRARYHASTHESEBLOCKSUSINGANYOFTHECOMMANDBLOCKSPUTSAMAPONTHESCREENINALAYERINFRONTOFTHESTAGESBACKGROUNDBUTBEHINDTHEPENTRAILSLAYERWHICHISINTURNBEHINDALLTHESPRITESTHEFIRSTBLOCKASKSYOURBROWSERFORYOURCURRENTPHYSICALLOCATIONFORWHICHYOUMAYBEASKEDTOGIVEPERMISSIONTHENEXTTWOBLOCKSGETANDSETTHEMAPSZOOMAMOUNTTHEDEFAULTZOOMOFFITSFROMSANFRANCISCONOTQUITEDOWNTOPALOALTOONTHESCREENAZOOMOFFITSALMOSTTHEENTIREWORLDAZOOMOFFITSTHEUNITEDSTATESAZOOMOFFITSGERMANYTHEZOOMCANBECHANGEDINHALFSTEPSIEISDIFFERENTFROMBUTISNTTHENEXTFIVEBLOCKSCONVERTBETWEENSTAGECOORDINATESPIXELSANDEARTHCOORDINATESLATITUDEANDLONGITUDETHECHANGEBYXYBLOCKSHIFTSTHEMAPRELATIVETOTHESTAGETHEDISTANCETOBLOCKMEASURESTHEMAPDISTANCEINMETERSBETWEENTWOSPRITESTHETHREEREPORTERSWITHCURRENTINTHEIRNAMESFINDYOURACTUALLOCATIONAGAINSUPPOSINGTHATGEOLOCATIONISENABLEDONYOURDEVICEUPDATEREDRAWSTHEMAPASCOSTUMEREPORTSTHEVISIBLESECTIONOFTHEMAPASACOSTUMESETSTYLEALLOWSTHINGSLIKESATELLITEPICTURESTHEAPLPRIMITIVESLIBRARYCONTAINSTHESEBLOCKSFORMOREINFORMATIONABOUTAPLSEEAPPENDIXBPAGETHELISTCOMPREHENSIONLIBRARYHASONEBLOCKZIPITSFIRSTINPUTISAFUNCTIONOFTWOINPUTSTHETWOANYTYPEINPUTSAREDEEPLISTSLISTSOFLISTSOFINTERPRETEDASTREESANDTHEFUNCTIONISCALLEDWITHEVERYPOSSIBLECOMBINATIONOFALEAFNODEOFTHEFIRSTTREEANDALEAFNODEOFTHESECONDTREEBUTINSTEADOFTAKINGATOMSNONLISTSASTHELEAVESZIPALLOWSTHELEAVESOFEACHTREETOBEVECTORSONEDIMENSIONALLISTSMATRICESTWODIMENSIONALLISTSETCTHENUMBERTYPEINPUTSSPECIFYTHELEAFDIMENSIONFOREACHTREESOTHEFUNCTIONINPUTMIGHTBECALLEDWITHAVECTORFROMTHEFIRSTTREEANDANATOMFROMTHESECONDTREETHEBITWISELIBRARYPROVIDESBITWISELOGICFUNCTIONSEACHBITOFTHEREPORTEDVALUEISTHERESULTOFAPPLYINGTHECORRESPONDINGBOOLEANFUNCTIONTOTHECORRESPONDINGBITSOFTHEINPUTSTHEBOOLEANFUNCTIONSARENOTFORANDFORORFORANDXOREXCLUSIVEORFORTHEREMAININGFUNCTIONSSHIFTTHEIRIRSTINPUTLEFTORRIGHTBYTHENUMBEROFBITSGIVENBYTHESECONDINPUTISLEFTSHIFTISARITHMETICRIGHTSHIFTSHIFTINGINONEBITSFROMTHELEFTANDISLOGICALRIGHTSHIFTSHIFTINGINZEROBITSFROMTHELEFTIFYOUDONTALREADYKNOWWHATTHESEMEANINDATUTORIALONLINETHEMQTTLIBRARYSUPPORTSTHEMESSAGEQUEUINGTELEMETRYTRANSPORTPROTOCOLFORCONNECTINGWITHIOTDEVICESSEEHTTPSMQTTORGFORMOREINFORMATIONTHESIGNADALIBRARYALLOWSYOUTOCONTROLAMICROBITORSIMILARDEVICETHATWORKSWITHTHESIGNADAMICROBLOCKSPROJECTTHEMENUSLIBRARYPROVIDESTHEABILITYTODISPLAYHIERARCHICALMENUSONTHESTAGEUSINGTHEASKBLOCKSABILITYTOTAKELISTSASINPUTSSEEPAGETHESCISNAPLIBRARYANDTHETUNESCOPELIBRARYARETOOBIGTODISCUSSHEREANDAREDOCUMENTEDSEPARATELYATHTTPEMUONLINEDEPROGRAMMINGWITHSCISNAPPDFANDHTTPSMAKETOLEARNORGCREATINGARTANIMATIONSANDMUSICRESPECTIVELYIISAVINGANDLOADINGPROJECTSANDMEDIAAFTERYOUVECREATEDAPROJECTYOULLWANTTOSAVEITSOTHATYOUCANHAVEACCESSTOITTHENEXTTIMEYOUUSESNAPTHEREARETWOWAYSTODOTHATYOUCANSAVEAPROJECTONYOUROWNCOMPUTERORYOUCANSAVEITATTHESNAPWEBSITETHEADVANTAGEOFSAVINGONTHENETISTHATYOUHAVEACCESSTOYOURPROJECTEVENIFYOUAREUSINGADIFFERENTCOMPUTERORAMOBILEDEVICESUCHASATABLETORSMARTPHONETHEADVANTAGEOFSAVINGONYOURCOMPUTERISTHATYOUHAVEACCESSTOTHESAVEDPROJECTWHILEONANAIRPLANEOROTHERWISENOTONTHENETALSOCLOUDPROJECTSARELIMITEDINSIZEBUTYOUCANHAVEALLTHECOSTUMESANDSOUNDSYOULIKEIFYOUSAVELOCALLYTHISISWHYWEHAVEMULTIPLEWAYSTOSAVEINEITHERCASEIFYOUCHOOSESAVEASFROMTHEFILEMENUYOULLSEESOMETHINGLIKETHISIFYOUARENOTLOGGEDINTOYOURSNAPCLOUDACCOUNTCOMPUTERWILLBETHEONLYUSABLEOPTIONTHETEXTBOXATTHEBOTTOMRIGHTOFTHESAVEDIALOGALLOWSYOUTOENTERPROJECTNOTESTHATARESAVEDWITHTHEPROJECTALOCALSTORAGECLICKONCOMPUTERANDSNAPSSAVEPROJECTDIALOGWINDOWWILLBEREPLACEDBYYOUROPERATINGSYSTEMSSTANDARDSAVEWINDOWIFYOURPROJECTHASANAMETHATNAMEWILLBETHEDEFAULTFILENAMEIFYOUDONTGIVEADIFFERENTNAMEANOTHEREQUIVALENTWAYTOSAVETODISKISTOCHOOSEEXPORTPROJECTFROMTHEFILEMENUBCREATINGACLOUDACCOUNTTHEOTHERPOSSIBILITYISTOSAVEYOURPROJECTINTHECLOUDATTHESNAPWEBSITEINORDERTODOTHISYOUNEEDANACCOUNTWITHUSCLICKONTHECLOUDBUTTONINTHETOOLBARCHOOSETHESIGNUPOPTIONTHISWILLSHOWYOUAWINDOWTHATLOOKSLIKETHEPICTUREATTHERIGHTYOUMUSTCHOOSEAUSERNAMETHATWILLIDENTIFYYOUONTHEWEBSITESUCHASJENSORBHIFYOUREASCRATCHUSERYOUCANUSEYOURSCRATCHNAMEFORSNAPTOOIFYOUREAKIDDONTPICKAUSERNAMETHATINCLUDESYOURFAMILYNAMEBUTFIRSTNAMESORINITIALSAREOKAYDONTPICKSOMETHINGYOUDBEEMBARRASSEDTOHAVEOTHERUSERSORYOURPARENTSSEEIFTHENAMEYOUWANTISALREADYTAKENYOULLHAVETOCHOOSEANOTHERONEYOUMUSTALSOSUPPLYAPASSWORDWEASKFORYOURMONTHANDYEAROFBIRTHWEUSETHISINFORMATIONONLYTODECIDEWHETHERTOASKFORYOUROWNEMAILADDRESSORYOURPARENTSEMAILADDRESSIFYOUREAKIDYOUSHOULDNTSIGNUPFORANYTHINGONTHENETNOTEVENSNAPWITHOUTYOURPARENTSKNOWLEDGEWEDONOTSTOREYOURBIRTHDATEINFORMATIONONOURSERVERITISUSEDONYOUROWNCOMPUTERONLYDURINGTHISINITIALSIGNUPWEDONOTASKFORYOUREXACTBIRTHDATEEVENFORTHISONETIMEPURPOSEBECAUSETHATSANIMPORTANTPIECEOFPERSONALLYIDENTIFIABLEINFORMATIONWHENYOUCLICKOKANEMAILWILLBESENTTOTHEEMAILADDRESSYOUGAVEASKINGYOUTOVERIFYBYCLICKINGALINKTHATITSREALLYYOUREMAILADDRESSWEKEEPYOUREMAILADDRESSONFILESOTHATIFYOUFORGETYOURPASSWORDWECANSENDYOUAPASSWORDRESETLINKWEWILLALSOEMAILYOUIFYOURACCOUNTISSUSPENDEDFORVIOLATIONOFTHETERMSOFSERVICEWEDONOTUSEYOURADDRESSFORANYOTHERPURPOSEYOUWILLNEVERRECEIVEMARKETINGEMAILSOFANYKINDTHROUGHTHISSITENEITHERFROMUSNORFROMTHIRDPARTIESIFNEVERTHELESSYOUAREWORRIEDABOUTPROVIDINGTHISINFORMATIONDOAWEBSEARCHFORTEMPORARYEMAILFINALLYYOUMUSTREADANDAGREETOTHETERMSOFSERVICEAQUICKSUMMARYDONTINTERFEREWITHANYONEELSESUSEOFTHEWEBSITEANDDONTPUTCOPYRIGHTEDMEDIAORPERSONALLYIDENTIFIABLEINFORMATIONINPROJECTSTHATYOUSHAREWITHOTHERUSERSANDWERENOTRESPONSIBLEIFSOMETHINGGOESWRONGNOTTHATWEEXPECTANYTHINGTOGOWRONGSINCESNAPRUNSINJAVASCRIPTINYOURBROWSERITISSTRONGLYISOLATEDFROMTHERESTOFYOURCOMPUTERBUTTHELAWYERSMAKEUSSAYTHISCSAVINGTOTHECLOUDONCEYOUVECREATEDYOURACCOUNTYOUCANLOGINTOITUSINGTHELOGINOPTIONFROMTHECLOUDMENUUSETHEUSERNAMEANDPASSWORDTHATYOUSETUPEARLIERIFYOUCHECKTHESTAYSIGNEDINBOXTHENYOUWILLBELOGGEDINAUTOMATICALLYTHENEXTTIMEYOURUNSNAPFROMTHESAMEBROWSERONTHESAMECOMPUTERCHECKTHEBOXIFYOUREUSINGYOUROWNCOMPUTERANDYOUDONTSHAREITWITHSIBLINGSDONTCHECKTHEBOXIFYOUREUSINGAPUBLICCOMPUTERATTHELIBRARYATSCHOOLETCONCELOGGEDINYOUCANCHOOSETHECLOUDOPTIONINTHESAVEPROJECTDIALOGSHOWNONPAGEYOUENTERAPROJECTNAMEANDOPTIONALLYPROJECTNOTESYOURPROJECTWILLBESAVEDONLINEANDCANBELOADEDFROMANYWHEREWITHNETACCESSTHEPROJECTNOTESWILLBEVISIBLETOOTHERUSERSIFYOUPUBLISHYOURPROJECTDLOADINGSAVEDPROJECTSONCEYOUVESAVEDAPROJECTYOUWANTTOBEABLETOLOADITBACKINTOSNAPTHEREARETWOWAYSTODOTHISIFYOUSAVEDTHEPROJECTINYOURONLINESNAPACCOUNTCHOOSETHEOPENOPTIONFROMTHEFILEMENUCHOOSETHECLOUDBUTTONTHENSELECTYOURPROJECTFROMTHELISTINTHEBIGTEXTBOXANDCLICKOKORCHOOSETHECOMPUTERBUTTONTOOPENANOPERATINGSYSTEMOPENDIALOGATHIRDBUTTONEXAMPLESLETSYOUCHOOSENFROMEXAMPLEPROJECTSTHATWEPROVIDEYOUCANSEEWHATEACHOFTHESEPROJECTSISABOUTBYCLICKINGONITANDREADINGITSPROJECTNOTESIFYOUSAVEDTHEPROJECTASANXMLFILEONYOURCOMPUTERCHOOSEIMPORTFROMTHEFILEMENUTHISWILLGIVEYOUANORDINARYBROWSERFILEOPENWINDOWINWHICHYOUCANNAVIGATETOTHEFILEASYOUWOULDINOTHERSOFTWAREALTERNATIVELYFINDTHEXMLFILEONYOURDESKTOPANDJUSTDRAGITONTOTHESNAPWINDOWTHESECONDTECHNIQUEABOVEALSOALLOWSYOUTOIMPORTMEDIACOSTUMESANDSOUNDSINTOAPROJECTJUSTCHOOSEIMPORTANDTHENSELECTAPICTUREORSOUNDFILEINSTEADOFANXMLFILESNAPCANALSOIMPORTPROJECTSCREATEDINBYOBORORWITHSOMEEFFORTSEEOURWEBSITEINSCRATCHORALMOSTALLSUCHPROJECTSWORKCORRECTLYINSNAPAPARTFROMASMALLNUMBEROFINCOMPATIBLEBLOCKSIFYOUSAVEDPROJECTSINANEARLIERVERSIONOFSNAPUSINGTHEBROWSEROPTIONTHENABROWSERBUTTONWILLBESHOWNINTHEOPENDIALOGTOALLOWYOUTORETRIEVETHOSEPROJECTSBUTYOUCANSAVETHEMONLYWITHTHECOMPUTERANDCLOUDOPTIONSEIFYOULOSEYOURPROJECTDOTHISFIRSTIFYOUARESTILLINSNAPANDREALIZETHATYOUVELOADEDANOTHERPROJECTWITHOUTSAVINGTHEONEYOUWEREWORKINGONDONTEDITTHENEWPROJECTFROMTHEFILEMENUCHOOSETHERESTOREUNSAVEDPROJECTOPTIONRESTOREUNSAVEDPROJECTWILLALSOWORKIFYOULOGOUTOFSNAPANDLATERLOGBACKINASLONGASYOUDONTEDITANOTHERPROJECTMEANWHILESNAPREMEMBERSONLYTHEMOSTRECENTPROJECTTHATYOUVEEDITEDNOTJUSTOPENEDBUTACTUALLYCHANGEDINTHEPROJECTEDITORIFYOURPROJECTONTHECLOUDISMISSINGEMPTYOROTHERWISEBROKENANDISNTTHEONEYOUEDITEDMOSTRECENTLYORIFRESTOREUNSAVEDPROJECTFAILSDONTEDITTHEBROKENPROJECTINTHEOPENBOXENTERYOURPROJECTNAMETHENPUSHTHERECOVERBUTTONDOTHISRIGHTAWAYBECAUSEWESAVEONLYTHEVERSIONBEFORETHEMOSTRECENTANDTHELATESTBEFORETODAYSODONTKEEPSAVINGBADVERSIONSRECOVERRIGHTAWAYTHERECOVERFEATUREWORKSONLYONAPROJECTVERSIONTHATYOUACTUALLYSAVEDSORESTOREUNSAVEDPROJECTISYOURFIRSTCHOICEIFYOUSWITCHAWAYFROMAPROJECTWITHOUTSAVINGITTOHELPYOUREMEMBERTOSAVEYOURPROJECTSWHENYOUVEEDITEDTHEPROJECTANDHAVENTYETSAVEDITSNAPDISPLAYSAPENCILICONTOTHELEFTOFTHEPROJECTNAMEONTHETOOLBARATTHETOPOFTHEWINDOWFPRIVATEANDPUBLICPROJECTSBYDEFAULTAPROJECTYOUSAVEINTHECLOUDISPRIVATEONLYYOUCANSEEITTHEREARETWOWAYSTOMAKEAPROJECTAVAILABLETOOTHERSIFYOUSHAREAPROJECTYOUCANGIVEYOURFRIENDSAPROJECTURLINYOURBROWSERSURLBARAFTERYOUOPENTHEPROJECTTHEYCANUSETOREADITIFYOUPUBLISHAPROJECTITWILLAPPEARONTHESNAPWEBSITEANDTHEWHOLEWORLDCANSEEITINANYCASENOBODYOTHERTHANYOUCANEVEROVERWRITEYOURPROJECTIFOTHERSASKTOSAVEITTHEYGETTHEIROWNCOPYINTHEIROWNACCOUNTIIIBUILDINGABLOCKTHEFIRSTVERSIONOFSNAPWASCALLEDBYOBFORBUILDYOUROWNBLOCKSTHISWASTHEFIRSTANDISSTILLTHEMOSTIMPORTANTCAPABILITYWEADDEDTOSCRATCHTHENAMEWASCHANGEDBECAUSEAFEWTEACHERSHAVENOSENSEOFHUMORYOUPICKYOURBATTLESSCRATCHANDLATERALSOHASAPARTIALCUSTOMBLOCKCAPABILITYASIMPLEBLOCKSINEVERYPALETTEATORNEARTHEBOTTOMISABUTTONLABELEDMAKEABLOCKALSOFLOATINGNEARTHETOPOFTHEPALETTEISAPLUSSIGNALSOTHEMENUYOUGETBYRIGHTCLICKINGONTHEBACKGROUNDOFTHESCRIPTINGAREAHASAMAKEABLOCKOPTIONCLICKINGANYOFTHESEWILLDISPLAYADIALOGWINDOWINWHICHYOUCHOOSETHEBLOCKSNAMESHAPEANDPALETTECOLORYOUALSODECIDEWHETHERTHEBLOCKWILLBEAVAILABLETOALLSPRITESORONLYTOTHECURRENTSPRITEANDITSCHILDRENINTHISDIALOGBOXYOUCANCHOOSETHEBLOCKSPALETTESHAPEANDNAMEWITHONEEXCEPTIONTHEREISONECOLORPERPALETTEEGALLMOTIONBLOCKSAREBLUEBUTTHEVARIABLESPALETTEINCLUDESTHEORANGEVARIABLERELATEDBLOCKSANDTHEREDLISTRELATEDBLOCKSBOTHCOLORSAREAVAILABLEALONGWITHANOTHEROPTIONTHATMAKESGREYBLOCKSINTHEVARIABLESPALETTEFORBLOCKSTHATDONTFITANYCATEGORYTHEREARETHREEBLOCKSHAPESFOLLOWINGACONVENTIONTHATSHOULDBEFAMILIARTOSCRATCHUSERSTHEJIGSAWPUZZLEPIECESHAPEDBLOCKSARECOMMANDSANDDONTREPORTAVALUETHEOVALBLOCKSAREREPORTERSANDTHEHEXAGONALBLOCKSAREPREDICATESWHICHISTHETECHNICALTERMFORREPORTERSTHATREPORTBOOLEANTRUEORFALSEVALUESSUPPOSEYOUWANTTOMAKEABLOCKNAMEDSQUARETHATDRAWSASQUAREYOUWOULDCHOOSEMOTIONCOMMANDANDTYPESQUAREINTOTHENAMEFIELDWHENYOUCLICKOKYOUENTERTHEBLOCKEDITORTHISWORKSJUSTLIKEMAKINGASCRIPTINTHESPRITESSCRIPTINGAREAEXCEPTTHATTHEHATBLOCKATTHETOPINSTEADOFSAYINGSOMETHINGLIKEWHENIAMCLICKEDHASAPICTUREOFTHEBLOCKYOUREBUILDINGTHISHATBLOCKISCALLEDTHEPROTOTYPEOFYOURCUSTOMBLOCKYOUDRAGBLOCKSUNDERTHEHATTOPROGRAMYOURCUSTOMBLOCKTHENCLICKOKYOURBLOCKAPPEARSATTHEBOTTOMOFTHEMOTIONPALETTEHERESTHEBLOCKANDTHERESULTOFUSINGITTHISUSEOFTHEWORDPROTOTYPEISUNRELATEDTOTHEPROTOTYPINGOBJECTORIENTEDPROGRAMMINGDISCUSSEDLATERCUSTOMBLOCKSWITHINPUTSBUTSUPPOSEYOUWANTTOBEABLETODRAWSQUARESOFDIFFERENTSIZESCONTROLCLICKORRIGHTCLICKONTHEBLOCKCHOOSEEDITANDTHEBLOCKEDITORWILLOPENNOTICETHEPLUSSIGNSBEFOREANDAFTERTHEWORDSQUAREINTHEPROTOTYPEBLOCKIFYOUHOVERTHEMOUSEOVERONEITLIGHTSUPCLICKONTHEPLUSONTHERIGHTYOUWILLTHENSEETHEINPUTNAMEDIALOGTYPEINTHENAMESIZEANDCLICKOKTHEREAREOTHEROPTIONSINTHISDIALOGYOUCANCHOOSETITLETEXTIFYOUWANTTOADDWORDSTOTHEBLOCKNAMESOITCANHAVETEXTAFTERANINPUTSLOTLIKETHEMOVESTEPSBLOCKORYOUCANSELECTAMOREEXTENSIVEDIALOGWITHALOTOFOPTIONSABOUTYOURINPUTNAMEBUTWELLLEAVETHATFORLATERWHENYOUCLICKOKTHENEWINPUTAPPEARSINTHEBLOCKPROTOTYPEYOUCANNOWDRAGTHEORANGEVARIABLEDOWNINTOTHESCRIPTTHENCLICKOKAYYOURBLOCKNOWAPPEARSINTHEMOTIONPALETTEWITHANINPUTBOXYOUCANDRAWANYSIZESQUAREBYENTERINGTHELENGTHOFITSSIDEINTHEBOXANDRUNNINGTHEBLOCKASUSUALBYCLICKINGITORBYPUTTINGITINASCRIPTEDITINGBLOCKPROPERTIESWHATIFYOUCHANGEYOURMINDABOUTABLOCKSCOLORPALETTEORSHAPECOMMANDREPORTERPREDICATEIFYOUCLICKINTHEHATBLOCKATTHETOPTHATHOLDSTHEPROTOTYPEBUTNOTINTHEPROTOTYPEITSELFYOULLSEEAWINDOWINWHICHYOUCANCHANGETHECOLORANDSOMETIMESTHESHAPENAMELYIFTHEBLOCKISNOTUSEDINANYSCRIPTWHETHERINASCRIPTINGAREAORINANOTHERCUSTOMBLOCKTHISINCLUDESAONEBLOCKSCRIPTCONSISTINGOFACOPYOFTHENEWBLOCKPULLEDOUTOFTHEPALETTEINTOTHESCRIPTINGAREASEEINGWHICHMADEYOUREALIZEITSTHEWRONGCATEGORYJUSTDELETETHATCOPYDRAGITBACKTOTHEPALETTEANDTHENCHANGETHECATEGORYIFYOURIGHTCLICKCONTROLCLICKTHEHATBLOCKYOUGETTHISMENUSCRIPTPICEXPORTSAPICTUREOFTHESCRIPTMANYOFTHEILLUSTRATIONSINTHISMANUALWEREMADETHATWAYTRANSLATIONSOPENSAWINDOWINWHICHYOUCANSPECIFYHOWYOURBLOCKSHOULDBETRANSLATEDIFTHEUSERCHOOSESALANGUAGEOTHERTHANTHEONEINWHICHYOUAREPROGRAMMINGBLOCKVARIABLESLETSYOUCREATEAVARIANTOFSCRIPTVARIABLESFORTHISBLOCKASCRIPTVARIABLEISCREATEDWHENABLOCKISCALLEDANDITDISAPPEARSWHENTHATCALLFINISHESWHATIFYOUWANTAVARIABLETHATSLOCALTOTHISBLOCKASASCRIPTVARIABLEISBUTDOESNTDISAPPEARBETWEENINVOCATIONSTHATSABLOCKVARIABLEIFTHEDEFINITIONOFABLOCKINCLUDESABLOCKVARIABLETHENEVERYTIMETHATCUSTOMBLOCKISDRAGGEDFROMTHEPALETTEINTOASCRIPTTHEBLOCKVARIABLEISCREATEDEVERYTIMETHATCOPYOFTHEBLOCKISCALLEDITUSESTHESAMEBLOCKVARIABLEWHICHPRESERVESITSVALUEBETWEENCALLSOTHERCOPIESOFTHEBLOCKHAVETHEIROWNBLOCKVARIABLESTHEINPALEECHECKBOXDETERMINESWHETHERORNOTTHISBLOCKWILLBEVISIBLEINTHEPALETTEITSNORMALLYCHECKEDBUTYOUMAYWANTTOHIDECUSTOMBLOCKSIFYOUREACURRICULUMWRITERCREATINGAPARSONSPROBLEMTOUNHIDEBLOCKSCHOOSEHIDEBLOCKSFROMTHEFILEMENUANDUNCHECKTHECHECKBOXESEDITDOESTHESAMETHINGASREGULARCLICKINGASDESCRIBEDEARLIERBRECURSIONSINCETHENEWCUSTOMBLOCKAPPEARSINITSPALETTEASSOONASYOUSTARTEDITINGITYOUCANWRITERECURSIVEBLOCKSBLOCKSTHATCALLTHEMSELVESBYDRAGGINGTHEBLOCKINTOITSOWNDEFINITIONIFYOUADDEDINPUTSTOTHEBLOCKSINCEOPENINGTHEEDITORCLICKAPPLYBEFOREFINDINGTHEBLOCKINTHEPALETTEORDRAGTHEBLOCKFROMTHETOPOFTHEBLOCKEDITORRATHERTHANFROMTHEPALETTEIFRECURSIONISNEWTOYOUHEREAREAFEWBRIEFHINTSITSCRUCIALTHATTHERECURSIONHAVEABASECASETHATISSOMESMALLESTCASETHATTHEBLOCKCANHANDLEWITHOUTUSINGRECURSIONINTHISEXAMPLEITSTHECASEDEPTHFORWHICHTHEBLOCKDOESNOTHINGATALLBECAUSEOFTHEENCLOSINGIFWITHOUTABASECASETHERECURSIONWOULDRUNFOREVERCALLINGITSELFOVERANDOVERDONTTRYTOTRACETHEEXACTSEQUENCEOFSTEPSTHATTHECOMPUTERFOLLOWSINARECURSIVEPROGRAMINSTEADIMAGINETHATINSIDETHECOMPUTERTHEREAREMANYSMALLPEOPLEANDIFTHERESAISDRAWINGATREEOFSIZEDEPTHSHEHIRESTOMTOMAKEATREEOFSIZEDEPTHANDLATERHIRESTHEOTOMAKEANOTHERTREEOFSIZEDEPTHTOMINTURNHIRESTAMMYANDTALLULAHANDSOONEACHLITTLEPERSONHASHISORHEROWNLOCALVARIABLESSIZEANDDEPTHEACHWITHDIFFERENTVALUESYOUCANALSOWRITERECURSIVEREPORTERSLIKETHISBLOCKTOCOMPUTETHEFACTORIALFUNCTIONNOTETHEUSEOFTHEREPORTBLOCKWHENAREPORTERBLOCKUSESTHISBLOCKTHEREPORTERFINISHESITSWORKANDREPORTSTHEVALUEGIVENANYFURTHERBLOCKSINTHESCRIPTARENOTEVALUATEDTHUSTHEIFELSEBLOCKINTHESCRIPTABOVECOULDHAVEBEENJUSTANIFWITHTHESECONDREPORTBLOCKBELOWITINSTEADOFINSIDEITANDTHERESULTWOULDBETHESAMEBECAUSEWHENTHEFIRSTREPORTISSEENINTHEBASECASETHATFINISHESTHEBLOCKINVOCATIONANDTHESECONDREPORTISIGNOREDTHEREISALSOASTOPTHISBLOCKBLOCKTHATHASASIMILARPURPOSEENDINGTHEBLOCKINVOCATIONEARLYFORCOMMANDBLOCKSBYCONTRASTTHESTOPTHISSCRIPTBLOCKSTOPSNOTONLYTHECURRENTBLOCKINVOCATIONBUTALSOTHEENTIRETOPLEVELSCRIPTTHATCALLEDITHERESASLIGHTLYMORECOMPACTWAYTOWRITETHEFACTORIALFUNCTIONFORMOREONRECURSIONSEETHINKINGRECURSIVELYBYERICROBERTSTHEORIGINALEDITIONISISBNAMORERECENTTHINKINGRECURSIVELYINJAVAISISBNCBLOCKLIBRARIESWHENYOUSAVEAPROJECTSEECHAPTERIIABOVEANYCUSTOMBLOCKSYOUVEMADEARESAVEDWITHITBUTSOMETIMESYOUDLIKETOSAVEACOLLECTIONOFBLOCKSTHATYOUEXPECTTOBEUSEFULINMORETHANONEPROJECTPERHAPSYOURBLOCKSIMPLEMENTAPARTICULARDATASTRUCTUREASTACKORADICTIONARYETCORTHEYRETHEFRAMEWORKFORBUILDINGAMULTILEVELGAMESUCHACOLLECTIONOFBLOCKSISCALLEDABLOCKLIBRARYTOCREATEABLOCKLIBRARYCHOOSEEXPORTBLOCKSFROMTHEFILEMENUYOUTHENSEEAWINDOWLIKETHISTHEWINDOWSHOWSALLOFYOURGLOBALCUSTOMBLOCKSYOUCANUNCHECKSOMEOFTHECHECKBOXESTOSELECTEXACTLYWHICHBLOCKSYOUWANTTOINCLUDEINYOURLIBRARYYOUCANRIGHTCLICKORCONTROLCLICKONTHEEXPORTWINDOWFORAMENUTHATLETSYOUCHECKORUNCHECKALLTHEBOXESATONCETHENPRESSOKANXMLFILECONTAININGTHEBLOCKSWILLAPPEARINYOURDOWNLOADSLOCATIONTOIMPORTABLOCKLIBRARYUSETHEIMPORTCOMMANDINTHEFILEMENUORJUSTDRAGTHEXMLFILEINTOTHESNAPWINDOWSEVERALBLOCKLIBRARIESAREINCLUDEDWITHSNAPFORDETAILSABOUTTHEMSEEPAGEDCUSTOMBLOCKSANDVISIBLESTEPPINGVISIBLESTEPPINGNORMALLYTREATSACALLTOACUSTOMBLOCKASASINGLESTEPIFYOUWANTTOSEESTEPPINGINSIDEACUSTOMBLOCKYOUMUSTTAKETHESESTEPSINORDERTURNONVISIBLESTEPPINGSELECTEDITINTHECONTEXTMENUSOFTHEBLOCKSYOUWANTTOEXAMINETHENSTARTTHEPROGRAMTHEBLOCKEDITORWINDOWSYOUOPENINSTEPDONOTHAVEFULLEDITINGCAPABILITYYOUCANTELLBECAUSETHEREISONLYONEOKBUTTONATTHEBOTTOMNOTTHEUSUALTHREEBUTTONSUSETHEBUTTONTOCLOSETHESEWINDOWSWHENDONESTEPPINGIVFIRSTCLASSLISTSADATATYPEISFIRSTCLASSINAPROGRAMMINGLANGUAGEIFDATAOFTHATTYPECANBETHEVALUEOFAVARIABLEANINPUTTOAPROCEDURETHEVALUERETURNEDBYAPROCEDUREAMEMBEROFADATAAGGREGATEANONYMOUSNOTNAMEDINSCRATCHNUMBERSANDTEXTSTRINGSAREFIRSTCLASSYOUCANPUTANUMBERINAVARIABLEUSEONEASTHEINPUTTOABLOCKCALLAREPORTERTHATREPORTSANUMBERORPUTANUMBERINTOALISTBUTSCRATCHSLISTSARENOTFIRSTCLASSYOUCREATEONEUSINGTHEMAKEALISTBUTTONWHICHREQUIRESTHATYOUGIVETHELISTANAMEYOUCANTPUTTHELISTINTOAVARIABLEINTOANINPUTSLOTOFABLOCKORINTOALISTITEMYOUCANTHAVELISTSOFLISTSNONEOFTHESCRATCHREPORTERSREPORTSALISTVALUEYOUCANUSEAREDUCTIONOFTHELISTINTOATEXTSTRINGASINPUTTOOTHERBLOCKSBUTTHISLOSESTHELISTSTRUCTURETHEINPUTISJUSTATEXTSTRINGNOTADATAAGGREGATEAFUNDAMENTALDESIGNPRINCIPLEINSNAPISTHATALLDATASHOULDBEFIRSTCLASSIFITSINTHELANGUAGETHENWESHOULDBEABLETOUSEITFULLYANDFREELYWEBELIEVETHATTHISPRINCIPLEAVOIDSTHENEEDFORMANYSPECIALCASETOOLSWHICHCANINSTEADBEWRITTENBYSNAPUSERSTHEMSELVESNOTETHATITSADATATYPETHATSFIRSTCLASSNOTANINDIVIDUALVALUEDONTTHINKFOREXAMPLETHATSOMELISTSAREFIRSTCLASSWHILEOTHERSARENTINSNAPLISTSAREFIRSTCLASSPERIODATHELISTBLOCKATTHEHEARTOFPROVIDINGFIRSTCLASSLISTSISTHEABILITYTOMAKEANANONYMOUSLISTTOMAKEALISTWITHOUTSIMULTANEOUSLYGIVINGITANAMETHELISTREPORTERBLOCKDOESTHATATTHERIGHTENDOFTHEBLOCKARETWOLEFTANDRIGHTARROWHEADSCLICKINGONTHESECHANGESTHENUMBEROFINPUTSTOLISTIETHENUMBEROFELEMENTSINTHELISTYOUAREBUILDINGSHIFTCLICKINGCHANGESBYTHREEATATIMEYOUCANUSETHISBLOCKASINPUTTOMANYOTHERBLOCKSSNAPDOESNOTHAVEAMAKEALISTBUTTONLIKETHEONEINSCRATCHIFYOUWANTAGLOBALNAMEDLISTMAKEAGLOBALVARIABLEANDUSETHESETBLOCKTOPUTALISTINTOTHEVARIABLEBLISTSOFLISTSLISTSCANBEINSERTEDASELEMENTSINLARGERLISTSWECANEASILYCREATEADHOCSTRUCTURESASNEEDEDNOTICETHATTHISLISTISPRESENTEDINADIFFERENTFORMATFROMTHESHELOVESYOULISTABOVEATWODIMENSIONALLISTISCALLEDATABLEANDISBYDEFAULTSHOWNINTABLEVIEWWELLHAVEMORETOSAYABOUTTHISLATERWECANALSOBUILDANYCLASSICCOMPUTERSCIENCEDATASTRUCTUREOUTOFLISTSOFLISTSBYDEFININGCONSTRUCTORSBLOCKSTOMAKEANINSTANCEOFTHESTRUCTURESELECTORSBLOCKSTOPULLOUTAPIECEOFTHESTRUCTUREANDMUTATORSBLOCKSTOCHANGETHECONTENTSOFTHESTRUCTUREASNEEDEDHEREWECREATEBINARYTREESWITHSELECTORSTHATCHECKFORINPUTOFTHECORRECTDATATYPEONLYONESELECTORISSHOWNBUTTHEONESFORLEFTANDRIGHTCHILDRENAREANALOGOUSCFUNCTIONALANDIMPERATIVELISTPROGRAMMINGTHEREARETWOWAYSTOCREATEALISTINSIDEAPROGRAMSCRATCHUSERSWILLBEFAMILIARWITHTHEIMPERATIVEPROGRAMMINGSTYLEWHICHISBASEDONASETOFCOMMANDBLOCKSTHATMODIFYALISTASANEXAMPLEHEREARETWOBLOCKSTHATTAKEALISTOFNUMBERSASINPUTANDREPORTANEWLISTCONTAININGONLYTHEEVENNUMBERSFROMTHEORIGINALLISTORINTHISSCRIPTWEFIRSTCREATEATEMPORARYVARIABLETHENPUTANEMPTYLISTINITTHENGOTHROUGHTHEITEMSOFTHEINPUTLISTUSINGTHEADDTORESULTBLOCKTOMODIFYTHERESULTLISTADDINGONEITEMATATIMEANDFINALLYREPORTTHERESULTFUNCTIONALPROGRAMMINGISADIFFERENTAPPROACHTHATISBECOMINGIMPORTANTINREALWORLDPROGRAMMINGBECAUSEOFPARALLELISMIETHEFACTTHATDIFFERENTPROCESSORSCANBEMANIPULATINGTHESAMEDATAATTHESAMETIMETHISMAKESTHEUSEOFMUTATIONCHANGINGTHEVALUEASSOCIATEDWITHAVARIABLEORTHEITEMSOFALISTPROBLEMATICBECAUSEWITHPARALLELISMITSIMPOSSIBLETOKNOWTHEEXACTSEQUENCEOFEVENTSSOTHERESULTOFMUTATIONMAYNOTBEWHATTHEPROGRAMMEREXPECTEDEVENWITHOUTPARALLELISMTHOUGHFUNCTIONALPROGRAMMINGISSOMETIMESASIMPLERANDMOREEFFECTIVETECHNIQUEESPECIALLYWHENDEALINGWITHRECURSIVELYDEFINEDDATASTRUCTURESITUSESREPORTERBLOCKSNOTCOMMANDBLOCKSTOBUILDUPALISTVALUENOTETOUSERSOFEARLIERVERSIONSFROMTHEBEGINNINGTHEREHASBEENATENSIONINOURWORKBETWEENTHEDESIRETOPROVIDETOOLSSUCHASFORUSEDINTHISEXAMPLEANDTHEHIGHERORDERFUNCTIONSINTRODUCEDONTHENEXTPAGEASPRIMITIVESTOBEUSEDASEASILYASOTHERPRIMITIVESANDTHEDESIRETOSHOWHOWREADILYSUCHTOOLSCANBEIMPLEMENTEDINSNAPITSELFTHISISONEINSTANCEOFOURGENERALPEDAGOGICUNDERSTANDINGTHATLEARNERSSHOULDBOTHUSEABSTRACTIONSANDBEPERMITTEDTOSEEBENEATHTHEABSTRACTIONBARRIERUNTILVERSIONWEUSEDTHEUNEASYCOMPROMISEOFALIBRARYOFTOOLSWRITTENINSNAPANDEASILYBUTNOTEASILYENOUGHLOADEDINTOAPROJECTBYNOTLOADINGTHETOOLSUSERSORTEACHERSCOULDEXPLOREHOWTOPROGRAMTHEMINWEMADETHEMTRUEPRIMITIVESPARTLYBECAUSETHATSWHATSOMEOFUSWANTEDALLALONGANDPARTLYBECAUSEOFTHEINCREASINGIMPORTANCEOFFASTPERFORMANCEASWEEXPLOREBIGDATAANDMEDIACOMPUTATIONBUTTHISISNOTTHEENDOFTHESTORYFORUSINALATERVERSIONAFTERWEGETTHEDESIGNFIRMEDUPWEINTENDTOINTRODUCEHYBRIDPRIMITIVESIMPLEMENTEDINHIGHSPEEDJAVASCRIPTBUTWITHANEDITOPTIONTHATWILLOPENNOTTHEPRIMITIVEIMPLEMENTATIONBUTTHEVERSIONWRITTENINSNAPTHETRICKISTOENSURETHATTHISCANBEDONEWITHOUTDRAMATICALLYSLOWINGUSERSPROJECTSINAFUNCTIONALPROGRAMWEOFTENUSERECURSIONTOCONSTRUCTALISTONEITEMATATIMETHEINFRONTOFBLOCKMAKESALISTTHATHASONEITEMADDEDTOTHEFRONTOFANEXISTINGLISTWITHOUTCHANGINGTHEVALUEOFTHEORIGINALLISTANONEMPTYLISTISPROCESSEDBYDIVIDINGITINTOITSFIRSTITEMITEMOFANDALLTHERESTOFTHEITEMSALLBUTRSTOFWHICHAREHANDLEDTHROUGHARECURSIVECALLSNAPUSESTWODIFFERENTINTERNALREPRESENTATIONSOFLISTSONEDYNAMICARRAYFORIMPERATIVEPROGRAMMINGANDTHEOTHERLINKEDLISTFORFUNCTIONALPROGRAMMINGEACHREPRESENTATIONMAKESTHECORRESPONDINGBUILTINLISTBLOCKSCOMMANDSORREPORTERSRESPECTIVELYMOSTEFFICIENTITSPOSSIBLETOMIXSTYLESINTHESAMEPROGRAMBUTIFTHESAMELISTISUSEDBOTHWAYSTHEPROGRAMWILLRUNMORESLOWLYBECAUSEITCONVERTSFROMONEREPRESENTATIONTOTHEOTHERREPEATEDLYTHEITEMOFBLOCKDOESNTCHANGETHEREPRESENTATIONYOUDONTHAVETOKNOWTHEDETAILSOFTHEINTERNALREPRESENTATIONSBUTITSWORTHWHILETOUSEEACHLISTINACONSISTENTWAYDHIGHERORDERLISTOPERATIONSANDRINGSTHERESANEVENEASIERWAYTOSELECTTHEEVENNUMBERSFROMALISTTHEKEEPBLOCKTAKESAPREDICATEEXPRESSIONASITSFIRSTINPUTANDALISTASITSSECONDINPUTITREPORTSALISTCONTAININGTHOSEELEMENTSOFTHEINPUTLISTFORWHICHTHEPREDICATERETURNSTRUENOTICETWOTHINGSABOUTTHEPREDICATEINPUTFIRSTITHASAGREYRINGAROUNDITSECONDTHEMODBLOCKHASANEMPTYINPUTKEEPPUTSEACHITEMOFITSINPUTLISTONEATATIMEINTOTHATEMPTYINPUTBEFOREEVALUATINGTHEPREDICATETHEEMPTYINPUTISSUPPOSEDTOREMINDYOUOFTHEBOXNOTATIONFORVARIABLESINELEMENTARYSCHOOLTHEGREYRINGISPARTOFTHEKEEPBLOCKASITAPPEARSINTHEPALETTEWHATTHERINGMEANSISTHATTHISINPUTISABLOCKAPREDICATEBLOCKINTHISCASEBECAUSETHEINTERIOROFTHERINGISAHEXAGONRATHERTHANTHEVALUEREPORTEDBYTHATBLOCKHERESTHEDIFFERENCEEVALUATINGTHEBLOCKWITHOUTARINGREPORTSTRUEORFALSEEVALUATINGTHEBLOCKWITHARINGREPORTSTHEBLOCKITSELFTHISALLOWSKEEPTOEVALUATETHEPREDICATEREPEATEDLYONCEFOREACHLISTITEMABLOCKTHATTAKESANOTHERBLOCKASINPUTISCALLEDAHIGHERORDERBLOCKORHIGHERORDERPROCEDUREORHIGHERORDERFUNCTIONSNAPPROVIDESFOURHIGHERORDERFUNCTIONBLOCKSFOROPERATINGONLISTSYOUVEALREADYSEENKEEPFINDRSTISSIMILARBUTITREPORTSJUSTTHEFIRSTITEMTHATSATISFIESTHEPREDICATENOTALISTOFALLTHEMATCHINGITEMSITSEQUIVALENTTOBUTFASTERBECAUSEITSTOPSLOOKINGASSOONASITFINDSAMATCHIFTHEREARENOMATCHINGITEMSITRETURNSANEMPTYSTRINGTHESEEXAMPLESUSESMALLLISTSTOFITTHEPAGEBUTTHEHIGHERORDERBLOCKSWORKFORANYSIZELISTANEMPTYGRAYRINGREPRESENTSTHEIDENTITYFUNCTIONWHICHJUSTREPORTSITSINPUTLEAVINGTHERINGINMAPEMPTYISTHEMOSTCONCISEWAYTOMAKEASHALLOWCOPYOFALISTTHATISINTHECASEOFALISTOFLISTSTHERESULTISANEWTOPLEVELLISTWHOSEITEMSARETHESAMEUNCOPIEDLISTSTHATAREITEMSOFTHETOPLEVELINPUTLISTTOMAKEADEEPCOPYOFALISTTHATISONEINWHICHALLTHESUBLISTSSUBLISTSOFSUBLISTSETCARECOPIEDUSETHELISTASINPUTTOTHEBLOCKONEOFTHEVARIANTSOFTHESQRTOFBLOCKTHISWORKSBECAUSEIDOFISAHYPERBLOCKPAGETHETHIRDHIGHERORDERBLOCKCOMBINECOMPUTESASINGLERESULTFROMALLTHEITEMSOFALISTUSINGATWOINPUTREPORTERASITSSECONDINPUTINPRACTICETHEREAREONLYAFEWBLOCKSYOULLEVERUSEWITHCOMBINEMAPKEEPCOMBINEMAPTAKESAREPORTERBLOCKANDALISTASINPUTSITREPORTSANEWLISTINWHICHEACHITEMISTHEVALUEREPORTEDBYTHEREPORTERBLOCKASAPPLIEDTOONEITEMFROMTHEINPUTLISTTHATSAMOUTHFULBUTANEXAMPLEWILLMAKEITSMEANINGCLEARBYTHEWAYWEVEBEENUSINGARITHMETICEXAMPLESBUTTHELISTITEMSCANBEOFANYTYPEANDANYREPORTERCANBEUSEDWELLMAKETHEPLURALSOFSOMEWORDSTHESEBLOCKSTAKETHESUMOFTHELISTITEMSTAKETHEIRPRODUCTSTRINGTHEMINTOONEWORDCOMBINETHEMINTOASENTENCEWITHSPACESBETWEENITEMSSEEIFALLITEMSOFALISTOFBOOLEANSARETRUESEEIFANYOFTHEITEMSISTRUEFINDTHESMALLESTORFINDTHELARGESTWHYBUTNOTITONLYMAKESSENSETOCOMBINELISTITEMSUSINGANASSOCIATIVEFUNCTIONONETHATDOESNTCAREINWHATORDERTHEITEMSARECOMBINEDLEFTTORIGHTORRIGHTTOLEFTBUTTHEFUNCTIONSMAPKEEPANDNDRSTHAVEANADVANCEDMODEWITHRARELYUSEDFEATURESIFTHEIRFUNCTIONINPUTISGIVENEXPLICITINPUTNAMESBYCLICKINGTHEARROWHEADATTHERIGHTENDOFTHEGRAYRINGSEEPAGETHENITWILLBECALLEDFOREACHLISTITEMWITHTHREEINPUTSTHEITEMSVALUEASUSUALTHEITEMSPOSITIONINTHEINPUTLISTITSINDEXANDTHEENTIREINPUTLISTNOMORETHANTHREEINPUTNAMESCANBEUSEDINTHISCONTEXETABLEVIEWVSLISTVIEWWEMENTIONEDEARLIERTHATTHEREARETWOWAYSOFREPRESENTINGLISTSVISUALLYFORONEDIMENSIONALLISTSLISTSWHOSEITEMSARENOTTHEMSELVESLISTSTHEVISUALDIFFERENCESARESMALLFORONEDIMENSIONALLISTSITSNOTREALLYTHEAPPEARANCETHATSIMPORTANTWHATMATTERSISTHATTHELISTVIEWALLOWSVERYVERSATILEDIRECTMANIPULATIONOFTHELISTTHROUGHTHEPICTUREYOUCANEDITTHEINDIVIDUALITEMSYOUCANDELETEITEMSBYCLICKINGTHETINYBUTTONSNEXTTOEACHITEMANDYOUCANADDNEWITEMSATTHEENDBYCLICKINGTHETINYPLUSSIGNINTHELOWERLEFTCORNERYOUCANJUSTBARELYSEETHATTHEITEMDELETIONBUTTONSHAVEMINUSSIGNSINTHEMEVENIFYOUHAVESEVERALWATCHERSFORTHESAMELISTALLOFTHEMWILLBEUPDATEDWHENYOUCHANGEANYTHINGONTHEOTHERHANDTHISVERSATILITYCOMESATANEFFICIENCYCOSTALISTVIEWWATCHERFORALONGLISTWOULDBEWAYTOOSLOWASAPARTIALWORKAROUNDTHELISTVIEWCANONLYCONTAINITEMSATATIMETHEDOWNWARDPOINTINGARROWHEADOPENSAMENUINWHICHYOUCANCHOOSEWHICHTODISPLAYBYCONTRASTBECAUSEITDOESNTALLOWDIRECTEDITINGTHETABLEVIEWWATCHERCANHOLDHUNDREDSOFTHOUSANDSOFITEMSANDSTILLSCROLLTHROUGHTHEMEFFICIENTLYTHETABLEVIEWHASFLATTERGRAPHICSFORTHEITEMSTOREMINDYOUTHATTHEYRENOTCLICKABLETOEDITTHEVALUESRIGHTCLICKINGONALISTWATCHERINEITHERFORMGIVESYOUTHEOPTIONTOSWITCHTOTHEOTHERFORMTHERIGHTCLICKMENUALSOOFFERSANOPENINDIALOGOPTIONTHATOPENSANOFFSTAGETABLEVIEWWATCHERBECAUSETHEWATCHERSCANTAKEUPALOTOFSTAGESPACETHATMAYMAKEITHARDTOSEEWHATYOURPROGRAMISACTUALLYDOINGONCETHEOFFSTAGEDIALOGBOXISOPENYOUCANCLOSETHESTAGEWATCHERTHERESANOKBUTTONONTHEOFFSTAGEDIALOGTOCLOSEITIFYOUWANTORYOUCANRIGHTCLICKITTOMAKEANOTHEROFFSTAGEWATCHERWHICHISUSEFULIFYOUWANTTOWATCHTWOPARTSOFTHELISTATONCEBYHAVINGEACHWATCHERSCROLLEDTOADIFFERENTPLACETABLEVIEWISTHEDEFAULTIFTHELISTHASMORETHANITEMSORIFANYOFTHEFIRSTTENITEMSOFTHELISTARELISTSINWHICHCASEITMAKESAVERYDIFFERENTLOOKINGTWODIMENSIONALPICTUREINTHISFORMATTHECOLUMNOFREDITEMSHASBEENREPLACEDBYASPREADSHEETLOOKINGDISPLAYFORSHORTWIDELISTSTHISDISPLAYMAKESTHECONTENTOFTHELISTVERYCLEARAVERTICALDISPLAYWITHMUCHOFTHESPACETAKENUPBYTHEMACHINERYATTHEBOTTOMOFEACHSUBLISTWOULDMAKEITHARDTOSHOWALLTHETEXTATONCETHEPEDAGOGICCOSTISTHATTHESTRUCTUREISNOLONGEREXPLICITWECANTTELLJUSTBYLOOKINGTHATTHISISALISTOFROWLISTSRATHERTHANALISTOFCOLUMNLISTSORAPRIMITIVETWODIMENSIONALARRAYTYPEBUTYOUCANCHOOSELISTVIEWTOSEETHESTRUCTUREBEYONDSUCHSIMPLECASESINWHICHEVERYITEMOFTHEMAINLISTISALISTOFTHESAMELENGTHITSIMPORTANTTOKEEPINMINDTHATTHEDESIGNOFTABLEVIEWHASTOSATISFYTWOGOALSNOTALWAYSINAGREEMENTAVISUALLYCOMPELLINGDISPLAYOFTWODIMENSIONALARRAYSANDHIGHLYEFFICIENTDISPLAYGENERATIONSOTHATSNAPCANHANDLEVERYLARGELISTSSINCEBIGDATAISANIMPORTANTTOPICOFSTUDYTOMEETTHEFIRSTGOALPERFECTLYINTHECASEOFRAGGEDRIGHTARRAYSINWHICHSUBLISTSCANHAVEDIFFERENTLENGTHSSNAPWOULDSCANTHEENTIRELISTTOFINDTHEMAXIMUMWIDTHBEFOREDISPLAYINGANYTHINGBUTTHATWOULDVIOLATETHESECONDGOALSNAPUSESTHESIMPLESTPOSSIBLECOMPROMISEBETWEENTHETWOGOALSITEXAMINESONLYTHEFIRSTTENITEMSOFTHELISTTODECIDEONTHEFORMATIFNONEOFTHOSEARELISTSORTHEYREALLLISTSOFONEITEMANDTHEOVERALLLENGTHISNOMORETHANLISTVIEWISUSEDIFTHEANYOFFIRSTTENITEMSISALISTTHENTABLEVIEWISUSEDANDTHENUMBEROFCOLUMNSINTHETABLEISEQUALTOTHELARGESTNUMBEROFITEMSAMONGTHEFIRSTTENITEMSSUBLISTSOFTHEMAINLISTTABLEVIEWSOPENWITHSTANDARDVALUESFORTHEWIDTHANDHEIGHTOFACELLREGARDLESSOFTHEACTUALDATAYOUCANCHANGETHESEVALUESBYDRAGGINGTHECOLUMNLETTERSORROWNUMBERSEACHCOLUMNHASITSOWNWIDTHBUTCHANGINGTHEHEIGHTOFAROWCHANGESTHEHEIGHTFORALLROWSTHISDISTINCTIONISBASEDNOTONTHESEMANTICSOFROWSVSCOLUMNSBUTONTHEFACTTHATACONSTANTROWHEIGHTMAKESSCROLLINGTHROUGHALARGELISTMOREEFFICIENTSHIFTDRAGGINGACOLUMNLABELWILLCHANGETHEWIDTHOFTHATCOLUMNIFYOUTRIEDOUTTHEADJUSTMENTSINTHEPREVIOUSPARAGRAPHYOUMAYHAVENOTICEDTHATACOLUMNLETTERTURNSINTOANUMBERWHENYOUHOVEROVERITLABELINGROWSANDCOLUMNSDIFFERENTLYMAKESCELLREFERENCESSUCHASCELLBUNAMBIGUOUSYOUDONTHAVETOHAVEACONVENTIONABOUTWHETHERTOSAYTHEROWFIRSTORTHECOLUMNFIRSTCELLBISTHESAMEASCELLBONTHEOTHERHANDTOEXTRACTAVALUEFROMCOLUMNBINYOURPROGRAMYOUHAVETOSAYITEMOFNOTITEMBOFSOITSUSEFULTOBEABLETOFINDOUTACOLUMNNUMBERBYHOVERINGOVERITSLETTERANYVALUETHATCANAPPEARINAPROGRAMCANBEDISPLAYEDINATABLECELLTHISDISPLAYSHOWSTHATTHESTANDARDCELLDIMENSIONSMAYNOTBEENOUGHFORLARGEVALUEIMAGESBYEXPANDINGTHEENTIRESPEECHBALLOONANDTHENTHESECONDCOLUMNANDALLTHEROWSWECANMAKETHERESULTFITBUTWEMAKEANEXCEPTIONFORCASESINWHICHTHEVALUEINACELLISALISTSOTHATTHEENTIRETABLEISTHREEDIMENSIONALBECAUSELISTSAREVISUALLYVERYBIGWEDONTTRYTOFITTHEENTIREVALUEINACELLEVENIFYOUEXPANDTHESIZEOFTHECELLSSNAPWILLNOTDISPLAYSUBLISTSOFSUBLISTSINTABLEVIEWTHEREARETWOWAYSTOSEETHESEINNERSUBLISTSYOUCANSWITCHTOLISTVIEWORYOUCANDOUBLECLICKONALISTICONINTHETABLETOOPENADIALOGBOXSHOWINGJUSTTHATSUBSUBLISTINTABLEVIEWONELASTDETAILIFTHEFIRSTITEMOFALISTISALISTSOTABLEVIEWISUSEDBUTALATERITEMISNTALISTTHATLATERITEMWILLBEDISPLAYEDONAREDBACKGROUNDLIKEANITEMOFASINGLECOLUMNLISTSOINPARTICULARIFONLYTHEFIRSTITEMISALISTTHEDISPLAYWILLLOOKALMOSTLIKEAONECOLUMNDISPLAYCOMMASEPARATEDVALUESSPREADSHEETANDDATABASEPROGRAMSGENERALLYOFFERTHEOPTIONTOEXPORTTHEIRDATAASCSVCOMMASEPARATEDVALUESLISTSYOUCANIMPORTTHESEFILESINTOSNAPANDTURNTHEMINTOTABLESLISTSOFLISTSANDYOUCANEXPORTTABLESINCSVFORMATSNAPRECOGNIZESACSVFILEBYTHEEXTENSIONCSVINITSFILENAMEACSVFILEHASONELINEPERTABLEROWWITHTHEFIELDSSEPARATEDBYCOMMASWITHINAROWJOHNLENNONRHYTHMGUITARPAULMCCARTNEYBASSGUITARGEORGEHARRISONLEADGUITARRINGOSTARRDRUMSHERESWHATTHECORRESPONDINGTABLELOOKSLIKEHERESHOWTOREADASPREADSHEETINTOSNAPMAKEAVARIABLEWITHAWATCHERONSTAGERIGHTCLICKONTHEWATCHERANDCHOOSETHEIMPORTOPTIONIFTHEVARIABLESVALUEISALREADYALISTBESURETOCLICKONTHEOUTSIDEBORDEROFTHEWATCHERTHEREISADIFFERENTMENUIFYOUCLICKONTHELISTITSELFSELECTTHEFILEWITHYOURCSVDATATHEREISNOTHATSITSNAPWILLNOTICETHATTHENAMEOFTHEFILEYOUREIMPORTINGISSOMETHINGCSVANDWILLTURNTHETEXTINTOALISTOFLISTSAUTOMATICALLYOREVENEASIERJUSTDRAGANDDROPTHEFILEFROMYOURDESKTOPONTOTHESNAPWINDOWANDSNAPWILLAUTOMATICALLYCREATEAVARIABLENAMEDAFTERTHEFILEANDIMPORTTHEDATAINTOITIFYOUACTUALLYWANTTOIMPORTTHERAWCSVDATAINTOAVARIABLEEITHERCHANGETHEFILEEXTENSIONTOTXTBEFORELOADINGITORCHOOSERAWDATAINSTEADOFIMPORTINTHEWATCHERMENUIFYOUWANTTOEXPORTALISTPUTAVARIABLEWATCHERCONTAININGTHELISTONTHESTAGERIGHTCLICKITSBORDERANDCHOOSEEXPORTDONTRIGHTCLICKANITEMINSTEADOFTHEBORDERTHATGIVESADIFFERENTMENUMULTIDIMENSIONALLISTSANDJSONCSVFORMATISEASYTOREADBUTWORKSONLYFORONEORTWODIMENSIONALLISTSIFYOUHAVEALISTOFLISTSOFLISTSSNAPWILLINSTEADEXPORTYOURLISTASAJSONJAVASCRIPTOBJECTNOTATIONFILEIMODIFIEDMYLISTANDTHENEXPORTEDAGAINGETTINGTHISFILEJOHNLENNONRHYTHMGUITARJAMESPAULMCCARTNEYBASSGUITARGEORGEHARRISONLEADGUITARRINGOSTARRDRUMSYOUCANALSOIMPORTLISTSINCLUDINGTABLESFROMAJSONFILEANDYOUCANIMPORTPLAINTEXTFROMATXTFILEDRAGANDDROPWORKSFORTHESEFORMATSALSOTABLEVIEWLISTVIEWFHYPERBLOCKSASCALARISANYTHINGOTHERTHANALISTTHENAMECOMESFROMMATHEMATICSWHEREITMEANSAMAGNITUDEWITHOUTDIRECTIONASOPPOSEDTOAVECTORWHICHPOINTSTOWARDSOMEWHEREASCALARFUNCTIONISONEWHOSEDOMAINANDRANGEARESCALARSSOALLTHEARITHMETICOPERATIONSARESCALARFUNCTIONSBUTSOARETHETEXTONESSUCHASLEERANDTHEBOOLEANONESSUCHASNOTTHEMAJORNEWFEATUREINSNAPISTHATTHEDOMAINANDRANGEOFMOSTSCALARFUNCTIONBLOCKSISEXTENDEDTOMULTIDIMENSIONALLISTSWITHTHEUNDERLYINGSCALARFUNCTIONAPPLIEDTERMWISEMATHEMATICIANSNOTEINTHELASTEXAMPLEABOVETHATTHERESULTISJUSTATERMWISEAPPLICATIONOFTHEUNDERLYINGFUNCTIONETCNOTMATRIXMULTIPLICATIONSEEAPPENDIXBFORTHATFORADYADICTWOINPUTFUNCTIONIFTHELENGTHSDONTAGREETHELENGTHOFTHERESULTINEACHDIMENSIONISTHELENGTHOFTHESHORTERINPUTHOWEVERIFTHENUMBEROFDIMENSIONSDIFFERSINTHETWOINPUTSTHENTHENUMBEROFDIMENSIONSINTHERESULTAGREESWITHTHEHIGHERDIMENSIONALINPUTTHELOWERDIMENSIONALONEISUSEDREPEATEDLYINTHEMISSINGDIMENSIONSETCINPARTICULARASCALARINPUTISPAIREDWITHEVERYSCALARINTHEOTHERINPUTONEIMPORTANTMOTIVATIONFORTHISFEATUREISHOWITSIMPLIFIESANDSPEEDSUPMEDIACOMPUTATIONASINTHISSHIFTINGOFTHEALONZOCOSTUMETOBEBLUEREACHPIXELOFTHERESULTHASOFITSORIGINALREDANDGREENANDTHREETIMESITSORIGINALBLUEWITHITSTRANSPARENCYUNCHANGEDBYPUTTINGSOMESLIDERSONTHESTAGEYOUCANPLAYWITHCOLORSDYNAMICALLYTHEREAREAFEWNATURALLYSCALARFUNCTIONSTHATHAVEALREADYHADSPECIFICMEANINGSWHENAPPLIEDTOLISTSANDTHEREFOREARENOTHYPERBLOCKSANDIDENTICALTOBECAUSETHEYCOMPAREENTIRESTRUCTURESNOTJUSTSCALARSALWAYSREPORTINGASINGLEBOOLEANRESULTANDANDORBECAUSETHEYDONTEVALUATETHEIRSECONDINPUTATALLIFTHEFIRSTINPUTDETERMINESTHERESULTJOINBECAUSEITCONVERTSNONSCALARANDOTHERNONTEXTINPUTSTOTEXTSTRINGFORMANDISATYPEBECAUSEITAPPLIESTOITSINPUTASAWHOLEBLOCKSWHOSEINPUTSARENATIVELYLISTSSUCHASANDARENEVERHYPERBLOCKSTHERESHAPEBLOCKTAKESALISTOFANYDEPTHASITSFIRSTINPUTANDTHENTAKESZEROORMORESIZESALONGTHEDIMENSIONSOFANARRAYINTHEEXAMPLEITWILLREPORTATABLEAMATRIXOFFOURROWSANDTHREECOLUMNSIFNOSIZESAREGIVENTHERESULTISANEMPTYLISTOTHERWISETHECELLSOFTHESPECIFIEDSHAPEAREFILLEDWITHTHEATOMICVALUESFROMTHEINPUTLISTIFMOREVALUESARENEEDEDTHANPROVIDEDTHEBLOCKSTARTSAGAINATTHEHEADOFTHELISTUSINGVALUESMORETHANONCEIFMOREVALUESAREPROVIDEDTHANNEEDEDTHEEXTRASAREIGNOREDTHISISNTANERRORTHEITEMOFBLOCKHASASPECIALSETOFRULESDESIGNEDTOPRESERVEITSPREHYPERBLOCKMEANINGANDALSOPROVIDEAUSEFULBEHAVIORWHENGIVENALISTASITSFIRSTINDEXINPUTIFTHEINDEXISANUMBERTHENITEMOFREPORTSTHEINDICATEDTOPLEVELITEMOFTHELISTINPUTTHATITEMMAYBEASUBLISTINWHICHCASETHEENTIRESUBLISTISREPORTEDTHEORIGINALMEANINGOFITEMOFIFTHEINDEXISALISTOFNUMBERSNOSUBLISTSTHENITEMOFREPORTSALISTOFTHEINDICATEDTOPLEVELITEMSROWSINAMATRIXASTRAIGHTFORWARDHYPERIZATIONTHECOMBINATIONSBLOCKTAKESANYNUMBEROFLISTSASINPUTITREPORTSALISTINWHICHEACHITEMISALISTWHOSELENGTHISTHENUMBEROFINPUTSITEMIOFASUBLISTISANITEMOFINPUTIEVERYPOSSIBLECOMBINATIONOFITEMSOFTHEINPUTSISINCLUDEDSOTHELENGTHOFTHEREPORTEDLISTISTHEPRODUCTOFTHELENGTHSOFTHEINPUTSIFTHEINDEXISALISTOFLISTSOFNUMBERSTHENITEMOFREPORTSANARRAYOFONLYTHOSESCALARSWHOSEPOSITIONINTHELISTINPUTMATCHESTHEINDEXINPUTINALLDIMENSIONSCHANGEDINSNAPIFALISTOFLISTOFNUMBERSINCLUDESANEMPTYSUBLISTTHENALLITEMSARECHOSENALONGTHATDIMENSIONTOGETACOLUMNORCOLUMNSOFASPREADSHEETUSEANEMPTYLISTINTHEROWSELECTORCHANGEDINSNAPTHELENGTHOFBLOCKISEXTENDEDTOPROVIDEVARIOUSWAYSOFLOOKINGATTHESHAPEANDCONTENTSOFALISTTHEOPTIONSOTHERTHANLENGTHAREMAINLYUSEFULFORLISTSOFLISTSTOANYDEPTHTHESENEWOPTIONSWORKWELLWITHHYPERBLOCKSANDTHEAPLLIBRARYEXAMPLESAREONTHENEXTPAGELENGTHREPORTSTHENUMBEROFTOPLEVELITEMSINTHELISTASALWAYSRANKREPORTSTHENUMBEROFDIMENSIONSOFTHELISTIETHEMAXIMUMDEPTHOFLISTSOFLISTSOFLISTSOFLISTSTHATEXAMPLEWOULDBERANKDIMENSIONSREPORTSALISTOFNUMBERSEACHOFWHICHISTHEMAXIMUMLENGTHINONEDIMENSIONSOASPREADSHEETOFRECORDSEACHWITHFIELDSWOULDREPORTTHELISTAENREPORTSAFLATONEDIMENSIONALLISTCONTAININGTHEATOMICNONLISTITEMSANYWHEREINTHEINPUTLISTCOLUMNSREPORTSALISTINWHICHTHEROWSANDCOLUMNSOFTHEINPUTLISTAREINTERCHANGEDSOTHESHAPEOFTHETRANSPOSEOFASHAPELISTWOULDBETHISOPTIONWORKSONLYFORLISTSWHOSERANKISATMOSTTHENAMEREFLECTSTHEFACTTHATTHETOPLEVELITEMSOFTHEREPORTEDTABLEARETHECOLUMNSOFTHEORIGINALTABLEREVERSEREPORTSALISTINWHICHTHETOPLEVELITEMSOFTHEINPUTLISTAREINREVERSEORDERTHEREMAININGTHREEOPTIONSREPORTAGENERALLYMULTILINETEXTSTRINGTHEINPUTLISTMAYNOTINCLUDEANYATOMICNONLISTDATAOTHERTHANTEXTORNUMBERSTHELINESOPTIONISINTENDEDFORUSEWITHRANKONELISTSOFTEXTSTRINGSITREPORTSASTRINGINWHICHEACHLISTITEMBECOMESALINEOFTEXTYOUCANTHINKOFITASTHEOPPOSITEOFTHESPLITBYLINEBLOCKTHECSVOPTIONCOMMASEPARATEDVALUESISINTENDEDFORRANKTWOLISTSTHATREPRESENTASPREADSHEETOROTHERTABULARDATAEACHITEMOFTHEINPUTLISTSHOULDBEALISTOFATOMSTHEBLOCKREPORTSATEXTSTRINGINWHICHEACHITEMOFTHEBIGLISTBECOMESALINEOFTEXTINWHICHTHEITEMSOFTHATSUBLISTARESEPARATEDBYCOMMASTHEJSONOPTIONISFORLISTSOFANYRANKITREPORTSATEXTSTRINGINWHICHTHELISTSTRUCTUREISEXPLICITLYREPRESENTEDUSINGSQUAREBRACKETSTHESEARETHEOPPOSITESOFSPLITBYCSVANDSPLITBYJSONTHEIDEAOFEXTENDINGTHEDOMAINANDRANGEOFSCALARFUNCTIONSTOINCLUDEARRAYSCOMESFROMTHELANGUAGEAPLALLTHEGREATPROGRAMMINGLANGUAGESAREBASEDONMATHEMATICALIDEASOURPRIMARYANCESTORSARESMALLTALKBASEDONMODELSANDLISPBASEDONLAMBDACALCULUSPROLOGAGREATLANGUAGENOTSOFARINFLUENCINGSNAPISBASEDONLOGICANDAPLNOWJOININGOURFAMILYISBASEDONLINEARALGEBRAWHICHSTUDIESVECTORSANDMATRICESTHOSEOTHERPROGRAMMINGLANGUAGESAREBASEDONTHEWEAKNESSESOFCOMPUTERHARDWAREHYPERBLOCKSARENOTTHEWHOLESTORYABOUTAPLWHICHALSOHASMIXEDDOMAINFUNCTIONSANDHIGHERORDERFUNCTIONSSOMEOFWHATSMISSINGISPROVIDEDINTHEAPLLIBRARYSEEAPPENDIXBINPUTVTYPEDINPUTSASCRATCHSTYPENOTATIONPRIORTOVERSIONSCRATCHBLOCKINPUTSCAMEINTWOTYPESTEXTORNUMBERTYPEANDNUMBERTYPETHEFORMERISINDICATEDBYARECTANGULARBOXTHELATTERBYAROUNDEDBOXATHIRDSCRATCHTYPEBOOLEANTRUEFALSECANBEUSEDINCERTAINCONTROLBLOCKSWITHHEXAGONALSLOTSTHESNAPTYPESAREANEXPANDEDCOLLECTIONINCLUDINGPROCEDURELISTANDOBJECTTYPESNOTETHATWITHTHEEXCEPTIONOFPROCEDURETYPESALLOFTHEINPUTTYPESHAPESAREJUSTREMINDERSTOTHEUSEROFWHATTHEBLOCKEXPECTSTHEYARENOTENFORCEDBYTHELANGUAGEBTHESNAPINPUTTYPEDIALOGINTHEBLOCKEDITORINPUTNAMEDIALOGTHEREISARIGHTFACINGARROWHEADAFTERTHEINPUTNAMEOPTIONCLICKINGTHATARROWHEADOPENSTHELONGINPUTNAMEDIALOGTHEREARETWELVEINPUTTYPESHAPESPLUSTHREEMUTUALLYEXCLUSIVEMODIFIERSLISTEDINADDITIONTOTHEBASICCHOICEBETWEENTITLETEXTANDANINPUTNAMETHEDEFAULTTYPETHEONEYOUGETIFYOUDONTCHOOSEANYTHINGELSEISANYMEANINGTHATTHISINPUTSLOTISMEANTTOACCEPTANYVALUEOFANYTYPEIFTHESIZEINPUTINYOURBLOCKSHOULDBEANOVALSHAPEDNUMERICSLOTRATHERTHANAGENERICRECTANGLECLICKNUMBERTHEARRANGEMENTOFTHEINPUTTYPESISSYSTEMATICASTHEPICTURESONTHISANDTHENEXTPAGESHOWEACHROWOFTYPESISACATEGORYANDPARTSOFEACHCOLUMNFORMACATEGORYUNDERSTANDINGTHEARRANGEMENTWILLMAKEITALITTLEEASIERTOFINDTHETYPEYOUWANTTHESECONDROWOFINPUTTYPESCONTAINSTHEONESFOUNDINSCRATCHNUMBERANYANDBOOLEANTHEREASONTHESEAREINTHESECONDROWRATHERTHANTHEFIRSTWILLBECOMECLEARWHENWELOOKATTHECOLUMNARRANGEMENTTHEFIRSTROWCONTAINSTHENEWSNAPTYPESOTHERTHANPROCEDURESOBJECTTEXTANDLISTTHELASTTWOROWSARETHETYPESRELATEDTOPROCEDURESDISCUSSEDMOREFULLYBELOWTHELISTTYPEISUSEDFORFIRSTCLASSLISTSDISCUSSEDINCHAPTERIVABOVETHEREDRECTANGLESINSIDETHEINPUTSLOTAREMEANTTORESEMBLETHEAPPEARANCEOFLISTSASSNAPDISPLAYSTHEMONTHESTAGEEACHELEMENTINAREDRECTANGLETHEOBJECTTYPEISFORSPRITESCOSTUMESSOUNDSANDSIMILARDATATYPESTHETEXTTYPEISREALLYJUSTAVARIANTFORMOFTHEANYTYPEUSINGASHAPETHATSUGGESTSATEXTINPUTPROCEDURETYPESALTHOUGHTHEPROCEDURETYPESAREDISCUSSEDMOREFULLYLATERTHEYARETHEKEYTOUNDERSTANDINGTHECOLUMNARRANGEMENTINTHEINPUTTYPESLIKESCRATCHSNAPHASTHREEBLOCKSHAPESJIGSAWPIECEFORCOMMANDBLOCKSOVALFORREPORTERSANDHEXAGONALFORPREDICATESAPREDICATEISAREPORTERTHATALWAYSREPORTSTRUEORFALSEINSNAPTHESEBLOCKSAREFIRSTCLASSDATAANINPUTTOABLOCKCANBEOFCOMMANDTYPEREPORTERTYPEORPREDICATETYPEEACHOFTHESETYPESISDIRECTLYBELOWTHETYPEOFVALUETHATTHATKINDOFBLOCKREPORTSEXCEPTFORCOMMANDSWHICHDONTREPORTAVALUEATALLTHUSOVALREPORTERSARERELATEDTOTHEANYTYPEWHILEHEXAGONALPREDICATESARERELATEDTOTHEBOOLEANTRUEORFALSETYPEINSCRATCHEVERYBLOCKTHATTAKESATEXTTYPEINPUTHASADEFAULTVALUETHATMAKESTHERECTANGLESFORTEXTWIDERTHANTALLTHEBLOCKSTHATARENTSPECIFICALLYABOUTTEXTEITHERAREOFNUMBERTYPEORHAVENODEFAULTVALUESOTHOSERECTANGLESARETALLERTHANWIDEATFIRSTSOMEOFUSBHTHOUGHTTHATTEXTWASASEPARATETYPETHATALWAYSHADAWIDEINPUTSLOTITTURNSOUTTHATTHISISNTTRUEINSCRATCHDELETETHEDEFAULTTEXTANDTHERECTANGLENARROWSBUTWETHOUGHTITAGOODIDEAANYWAYSOWEALLOWTEXTSHAPEDBOXESEVENFOREMPTYINPUTSLOTSTHISISWHYTEXTCOMESJUSTABOVEANYINTHEINPUTTYPESELECTIONBOXTHEUNEVALUATEDPROCEDURETYPESINTHEFOURTHROWAREEXPLAINEDINSECTIONVIEBELOWINONEHANDWAVYSENTENCETHEYCOMBINETHEMEANINGOFTHEPROCEDURETYPESWITHTHEAPPEARANCEOFTHEREPORTEDVALUETYPESTWOROWSHIGHEROFCOURSETHISISNTQUITERIGHTFORTHECSHAPEDCOMMANDINPUTTYPESINCECOMMANDSDONTREPORTVALUESBUTYOULLSEELATERTHATITSTRUEINSPIRITPULLDOWNINPUTSCERTAINPRIMITIVEBLOCKSHAVEPULLDOWNINPUTSEITHERREADONLYLIKETHEINPUTTOTHETOUCHINGBLOCKINDICATEDBYTHEINPUTSLOTBEINGTHESAMECYANINTHISCASECOLORASTHEBODYOFTHEBLOCKORWRITEABLELIKETHEINPUTTOTHEPOINTINDIRECTIONBLOCKINDICATEDBYTHEWHITEINPUTSLOTWHICHMEANSTHATTHEUSERCANTYPEINANARBITRARYINPUTINSTEADOFUSINGTHEPULLDOWNMENUCUSTOMBLOCKSCANALSOHAVESUCHINPUTSTOMAKEAPULLDOWNINPUTOPENTHELONGFORMINPUTDIALOGCHOOSEATEXTTYPEANYTEXTORNUMBERANDCLICKTHEICONINTHEBOTTOMRIGHTCORNERORCONTROLRIGHTCLICKINTHEDIALOGYOUWILLSEETHISMENUCLICKTHEREADONLYCHECKBOXIFYOUWANTAREADONLYPULLDOWNINPUTTHENFROMTHESAMEMENUCHOOSEOPTIONSTOGETTHISDIALOGBOXEACHLINEINTHETEXTBOXREPRESENTSONEMENUITEMIFTHELINEDOESNOTCONTAINANYOFTHECHARACTERSTHENTHETEXTISBOTHWHATSSHOWNINTHEMENUANDTHEVALUEOFTHEINPUTIFTHATENTRYISCHOSENIFTHELINECONTAINSANEQUALSIGNTHENTHETEXTTOTHELEFTOFTHEEQUALSIGNISSHOWNINTHEMENUANDTHETEXTTOTHERIGHTISWHATAPPEARSINTHEINPUTSLOTIFTHATENTRYISCHOSENANDISALSOTHEVALUEOFTHEINPUTASSEENBYTHEPROCEDUREIFTHELINECONSISTSOFATILDETHENITREPRESENTSASEPARATORAHORIZONTALLINEINTHEMENUUSEDTODIVIDELONGMENUSINTOVISIBLECATEGORIESTHERESHOULDBENOTHINGELSEONTHELINETHISSEPARATORISNOTCHOOSABLESOTHEREISNOINPUTVALUECORRESPONDINGTOITIFTHELINEENDSWITHTHETWOCHARACTERSEQUALSIGNANDOPENBRACETHENITREPRESENTSASUBMENUTHETEXTBEFORETHEEQUALSIGNISANAMEFORTHESUBMENUANDWILLBEDISPLAYEDINTHEMENUWITHANARROWHEADATTHEENDOFTHELINETHISLINEISNOTCLICKABLEBUTHOVERINGTHEMOUSEOVERITDISPLAYSTHESUBMENUNEXTTOTHEORIGINALMENUALINECONTAININGACLOSEBRACEENDSTHESUBMENUNOTHINGELSESHOULDBEONTHATLINESUBMENUSMAYBENESTEDTOARBITRARYDEPTHALTERNATIVELYINSTEADOFGIVINGAMENULISTINGASDESCRIBEDABOVEYOUCANPUTAJAVASCRIPTFUNCTIONTHATRETURNSTHEDESIREDMENUINTHETEXTBOXTHISISANEXPERIMENTALFEATUREANDREQUIRESTHATJAVASCRIPTBEENABLEDINTHESETTINGSMENUITISALSOPOSSIBLETOGETTHESPECIALMENUSUSEDINSOMEPRIMITIVEBLOCKSBYCHOOSINGFROMTHEMENUSUBMENUBROADCASTMESSAGESSPRITESANDSTAGECOSTUMESSOUNDSVARIABLESTHATCANBESETINTHISSCOPETHEPLAYNOTEPIANOKEYBOARDORTHEPOINTINDIRECTIONDIALFINALLYYOUCANMAKETHEINPUTBOXACCEPTMORETHANONELINEOFTEXTTHATISTEXTINCLUDINGANEWLINECHARACTERFROMTHESPECIALSUBMENUEITHERMULTILINEFORREGULARTEXTORCODEFORMONOSPACEFONTCOMPUTERCODEIFTHEINPUTTYPEISSOMETHINGOTHERTHANTEXTTHENCLICKINGTHEBUTTONWILLINSTEADSHOWTHISMENUASANEXAMPLEWEWANTTOMAKETHISBLOCKTHESECONDINPUTMUSTBEAREADONLYOBJECTMENUTHEMULTIPLEINPUTSOPTIONTHELISTBLOCKINTRODUCEDEARLIERACCEPTSANYNUMBEROFINPUTSTOSPECIFYTHEITEMSOFTHENEWLISTTOALLOWTHISSNAPINTRODUCESTHEARROWHEADNOTATIONTHATEXPANDSANDCONTRACTSTHEBLOCKADDINGANDREMOVINGINPUTSLOTSSHIFTCLICKINGONANARROWHEADADDSORREMOVESTHREEINPUTSLOTSATONCECUSTOMBLOCKSMADEBYTHESNAPUSERHAVETHATCAPABILITYTOOIFYOUCHOOSETHEMULTIPLEINPUTSBUTTONTHENARROWHEADSWILLAPPEARAFTERTHEINPUTSLOTINTHEBLOCKMOREORFEWERSLOTSASFEWASZEROMAYBEUSEDWHENTHEBLOCKRUNSALLOFTHEVALUESINALLOFTHESLOTSFORTHISINPUTNAMEARECOLLECTEDINTOALISTANDTHEVALUEOFTHEINPUTASSEENINSIDETHESCRIPTISTHATLISTOFVALUESTHEELLIPSISINTHEORANGEINPUTSLOTNAMEBOXINTHEPROTOTYPEINDICATESAMULTIPLEORVARIADICINPUTTHETHIRDCATEGORYUPVARMAKEINTERNALVARIABLEVISIBLETOCALLERISNTREALLYANINPUTATALLBUTRATHERASORTOFOUTPUTFROMTHEBLOCKTOITSUSERITAPPEARSASANORANGEVARIABLEOVALINTHEBLOCKRATHERTHANASANINPUTSLOTHERESANEXAMPLETHEUPARROWINTHEPROTOTYPEINDICATESTHISKINDOFINTERNALVARIABLENAMEINPUTVARIANTSWENOWTURNTOTHETHREEMUTUALLYEXCLUSIVEOPTIONSTHATCOMEBELOWTHETYPEARRAYTHESINGLEINPUTOPTIONINSCRATCHALLINPUTSAREINTHISCATEGORYTHEREISONEINPUTSLOTINTHEBLOCKASITAPPEARSINITSPALETTEIFASINGLEINPUTISOFTYPEANYNUMBERTEXTORBOOLEANTHENYOUCANSPECIFYADEFAULTVALUETHATWILLBESHOWNINTHATSLOTINTHEPALETTELIKETHEINSTEPSBLOCKINTHEPROTOTYPEBLOCKATTHETOPOFTHETHEMOVESTEPSBLOCKINTHEPROTOTYPEBLOCKINPUTATTHETOPOFSTHCREIPSCTRIINPTTHINEBTHLEOCBKLOECDKITOERDIATONRANINPUTWITHNAMESIZEANDDEFAULTVALUELOOKSLIKETHISTHEVARIABLEIINTHEBLOCKONTHERIGHTABOVECANBEDRAGGEDFROMTHEFORBLOCKINTOTHEBLOCKSUSEDINITSCSHAPEDCOMMANDSLOTALSOBYCLICKINGONTHEORANGEITHEUSERCANCHANGETHENAMEOFTHEVARIABLEASSEENINTHECALLINGSCRIPTALTHOUGHTHENAMEHASNTCHANGEDINSIDETHEBLOCKSDEFINITIONTHISKINDOFVARIABLEISCALLEDANUPVARFORSHORTBECAUSEITISPASSEDUPWARDFROMTHECUSTOMBLOCKTOTHESCRIPTTHATUSESITNOTEABOUTTHEEXAMPLEFORISAPRIMITIVEBLOCKBUTITDOESNTNEEDTOBEYOUREABOUTTOSEENEXTCHAPTERHOWITCANBEWRITTENINSNAPJUSTGIVEITADIFFERENTNAMETOAVOIDCONFUSIONSUCHASMYFORASABOVEPROTOTYPEHINTSWEHAVEMENTIONEDTHREENOTATIONSTHATCANAPPEARINANINPUTSLOTINTHEPROTOTYPETOREMINDYOUOFWHATKINDOFINPUTTHISISHEREISTHECOMPLETELISTOFSUCHNOTATIONSDEFAULTVALUEMULTIPLEINPUTUPVARNUMBERPROCEDURETYPESLISTBOOLEANOBJECTMULTILINETEXTTITLETEXTANDSYMBOLSSOMEPRIMITIVEBLOCKSHAVESYMBOLSASPARTOFTHEBLOCKNAMECUSTOMBLOCKSCANUSESYMBOLSTOOINTHEBLOCKEDITORCLICKTHEPLUSSIGNINTHEPROTOTYPEATTHEPOINTWHEREYOUWANTTOINSERTTHESYMBOLTHENCLICKTHETITLETEXTPICTUREBELOWTHETEXTBOXTHATSEXPECTINGANINPUTSLOTNAMETHEDIALOGWILLTHENCHANGETOLOOKLIKETHISTHEIMPORTANTPARTTONOTICEISTHEARROWHEADTHATHASAPPEAREDATTHERIGHTENDOFTHETEXTBOXCLICKITTOSEETHEMENUSHOWNHEREATTHELEFTCHOOSEONEOFTHESYMBOLSTHERESULTWILLHAVETHESYMBOLYOUWANTTHEAVAILABLESYMBOLSAREPRETTYMUCHTHEONESTHATAREUSEDINSNAPICONSBUTIDLIKETHEARROWSYMBOLBIGGERANDYELLOWSOIEDITITSNAMETHISMAKESTHESYMBOLTIMESASBIGASTHELETTERSINTHEBLOCKTEXTUSINGACOLORWITHREDGREENBLUEVALUESOFEACHBETWEENANDHERESTHERESULTTHESIZEANDCOLORCONTROLSCANALSOBEUSEDWITHTEXTFOOWILLMAKEAHUGEORANGEFOONOTETHELASTENTRYINTHESYMBOLMENUNEWLINETHISCANBEUSEDINABLOCKWITHMANYINPUTSTOCONTROLWHERETHETEXTCONTINUESONANOTHERLINEINSTEADOFLETTINGSNAPCHOOSETHELINEBREAKITSELFVIPROCEDURESASDATAACALLANDRUNINTHEFORBLOCKEXAMPLEABOVETHEINPUTNAMEDACTIONHASBEENDECLAREDASTYPECOMMANDCSHAPEDTHATSWHYTHEFINISHEDBLOCKISCSHAPEDBUTHOWDOESTHEBLOCKACTUALLYTELLSNAPTOCARRYOUTTHECOMMANDSINSIDETHECSLOTHEREISASIMPLEVERSIONOFTHEBLOCKSCRIPTTHISISSIMPLIFIEDBECAUSEITASSUMESWITHOUTCHECKINGTHATTHEENDINGVALUEISGREATERTHANTHESTARTINGVALUEIFNOTTHEBLOCKSHOULDDEPENDINGONTHEDESIGNERSPURPOSESEITHERNOTRUNATALLORCHANGETHEVARIABLEBYFOREACHREPETITIONINSTEADOFBYTHEIMPORTANTPARTOFTHISSCRIPTISTHERUNBLOCKNEARTHEENDTHISISASNAPBUILTINCOMMANDBLOCKTHATTAKESACOMMANDTYPEVALUEASCRIPTASITSINPUTANDCARRIESOUTITSINSTRUCTIONSINTHISEXAMPLETHEVALUEOFTHEINPUTISTHESCRIPTTHATTHEUSERPUTSINTHECSLOTOFTHEMYFORBLOCKTHEREISASIMILARCALLREPORTERBLOCKFORINVOKINGAREPORTERORPREDICATEBLOCKTHECALLANDRUNBLOCKSAREATTHEHEARTOFSNAPSFIRSTCLASSPROCEDUREFEATURETHEYALLOWSCRIPTSANDBLOCKSTOBEUSEDASDATAINTHISEXAMPLEASANINPUTTOABLOCKANDEVENTUALLYCARRIEDOUTUNDERCONTROLOFTHEUSERSPROGRAMHERESANOTHEREXAMPLETHISTIMEUSINGAREPORTERTYPEINPUTINAMAPBLOCKSEEPAGEHEREWEARECALLINGTHEREPORTERMULTIPLYBYTHREETIMESONCEWITHEACHITEMOFTHEGIVENLISTASITSINPUTANDCOLLECTINGTHERESULTSASALISTTHEREPORTEDLISTWILLALWAYSBETHESAMELENGTHASTHEINPUTLISTNOTETHATTHEMULTIPLICATIONBLOCKHASTWOINPUTSBUTHEREWEHAVESPECIFIEDAPARTICULARVALUEFORONEOFTHEMSOTHECALLBLOCKKNOWSTOUSETHEINPUTVALUEGIVENTOITJUSTTOFILLTHEOTHEREMPTYINPUTSLOTINTHEMULTIPLICATIONBLOCKINTHEMYMAPDEFINITIONTHEINPUTFUNCTIONISDECLAREDTOBETYPEREPORTERANDDATAISOFTYPELISTCALLRUNWITHINPUTSTHECALLBLOCKLIKETHERUNBLOCKHASARIGHTARROWHEADATTHEENDCLICKINGONITADDSTHEPHRASEWITHINPUTSANDTHENASLOTINTOWHICHANINPUTCANBEINSERTEDIFTHELEFTARROWHEADISUSEDTOREMOVETHELASTINPUTSLOTTHEWITHINPUTSDISAPPEARSALSOTHERIGHTARROWHEADCANBECLICKEDASMANYTIMESASNEEDEDFORTHENUMBEROFINPUTSREQUIREDBYTHEREPORTERBLOCKBEINGCALLEDIFTHENUMBEROFINPUTSGIVENTOCALLNOTCOUNTINGTHEREPORTERTYPEINPUTTHATCOMESFIRSTISTHESAMEASTHENUMBEROFEMPTYINPUTSLOTSTHENTHEEMPTYSLOTSAREFILLEDFROMLEFTTORIGHTWITHTHEGIVENINPUTVALUESIFCALLISGIVENEXACTLYONEINPUTTHENEVERYEMPTYINPUTSLOTOFTHECALLEDBLOCKISFILLEDWITHTHESAMEVALUEIFTHENUMBEROFINPUTSPROVIDEDISNEITHERONENORTHENUMBEROFEMPTYSLOTSTHENTHEREISNOAUTOMATICFILLINGOFEMPTYSLOTSINSTEADYOUMUSTUSEEXPLICITPARAMETERSINTHERINGASDISCUSSEDINSECTIONCBELOWANEVENMOREIMPORTANTTHINGTONOTICEABOUTTHESEEXAMPLESISTHERINGAROUNDTHEREPORTERTYPEINPUTSLOTSINCALLANDMAPABOVETHISNOTATIONINDICATESTHATTHEBLOCKITSELFNOTTHENUMBEROROTHERVALUETHATTHEBLOCKWOULDREPORTWHENCALLEDISTHEINPUTIFYOUWANTTOUSEABLOCKITSELFINANONREPORTERTYPEEGANYTYPEINPUTSLOTYOUCANENCLOSEITEXPLICITLYINARINGFOUNDATTHETOPOFTHEOPERATORSPALETTEASASHORTCUTIFYOURIGHTCLICKORCONTROLCLICKONABLOCKSUCHASTHEBLOCKINTHISEXAMPLEONEOFTHECHOICESINTHEMENUTHATAPPEARSISRINGIFYANDORUNRINGIFYTHERINGINDICATINGAREPORTERTYPEORPREDICATETYPEINPUTSLOTISESSENTIALLYTHESAMEIDEAFORREPORTERSASTHECSHAPEDINPUTSLOTWITHWHICHYOUREALREADYFAMILIARWITHACSHAPEDSLOTITSTHESCRIPTYOUPUTINTHESLOTTHATBECOMESTHEINPUTTOTHECSHAPEDBLOCKTHEREARETHREERINGSHAPESALLAREOVALONTHEOUTSIDEINDICATINGTHATTHERINGREPORTSAVALUETHEBLOCKORSCRIPTINSIDEITBUTTHEINSIDESHAPESARECOMMANDREPORTERORPREDICATEINDICATINGWHATKINDOFBLOCKORSCRIPTISEXPECTEDSOMETIMESYOUWANTTOPUTSOMETHINGMORECOMPLICATEDTHANASINGLEREPORTERINSIDEAREPORTERRINGIFSOYOUCANUSEASCRIPTBUTTHESCRIPTMUSTREPORTAVALUEASINACUSTOMREPORTERDEFINITIONVARIABLESINRINGSLOTSNOTETHATTHERUNBLOCKINTHEDEFINITIONOFTHEMYFORBLOCKPAGEDOESNTHAVEARINGAROUNDITSINPUTVARIABLEACTIONWHENYOUDRAGAVARIABLEINTOARINGEDINPUTSLOTYOUGENERALLYDOWANTTOUSETHEVALUEOFTHEVARIABLEWHICHWILLBETHEBLOCKORSCRIPTYOURETRYINGTORUNORCALLRATHERTHANTHEORANGEVARIABLEREPORTERITSELFSOSNAPAUTOMATICALLYREMOVESTHERINGINTHISCASEIFYOUEVERDOWANTTOUSETHEVARIABLEBLOCKITSELFRATHERTHANTHEVALUEOFTHEVARIABLEASAPROCEDURETYPEINPUTYOUCANDRAGTHEVARIABLEINTOTHEINPUTSLOTTHENCONTROLCLICKORRIGHTCLICKITANDCHOOSERINGIFYFROMTHEMENUTHATAPPEARSSIMILARLYIFYOUEVERWANTTOCALLAFUNCTIONTHATWILLREPORTABLOCKTOUSEASTHEINPUTSUCHASITEMOFAPPLIEDTOALISTOFBLOCKSYOUCANCHOOSEUNRINGIFYFROMTHEMENUALMOSTALLTHETIMETHOUGHSNAPDOESWHATYOUMEANWITHOUTHELPBWRITINGHIGHERORDERPROCEDURESAHIGHERORDERPROCEDUREISONETHATTAKESANOTHERPROCEDUREASANINPUTORTHATREPORTSAPROCEDUREINTHISDOCUMENTTHEWORDPROCEDUREENCOMPASSESSCRIPTSINDIVIDUALBLOCKSANDNESTEDREPORTERSUNLESSSPECIFIEDOTHERWISEREPORTERINCLUDESPREDICATESWHENTHEWORDISCAPITALIZEDINSIDEASENTENCEITMEANSSPECIFICALLYOVALSHAPEDBLOCKSSONESTEDREPORTERSINCLUDESPREDICATESBUTAREPORTERTYPEINPUTDOESNTALTHOUGHANANYTYPEINPUTSLOTWHATYOUGETIFYOUUSETHESMALLINPUTNAMEDIALOGBOXWILLACCEPTAPROCEDUREINPUTITDOESNTAUTOMATICALLYRINGTHEINPUTASDESCRIBEDABOVESOTHEDECLARATIONOFPROCEDURETYPEINPUTSMAKESTHEUSEOFYOURCUSTOMHIGHERORDERBLOCKMUCHMORECONVENIENTWHYWOULDYOUWANTABLOCKTOTAKEAPROCEDUREASINPUTTHISISACTUALLYNOTANOBSCURETHINGTODOTHEPRIMITIVECONDITIONALANDLOOPINGBLOCKSTHECSHAPEDONESINTHECONTROLPALETTETAKEASCRIPTASINPUTUSERSJUSTDONTUSUALLYTHINKABOUTITINTHOSETERMSWECOULDWRITETHEREPEATBLOCKASACUSTOMBLOCKTHISWAYIFSNAPDIDNTALREADYHAVEONETHELAMBDANEXTTOACTIONINTHEPROTOTYPEINDICATESTHATTHISISACSHAPEDBLOCKANDTHATTHESCRIPTENCLOSEDBYTHECWHENTHEBLOCKISUSEDISTHEINPUTNAMEDACTIONINTHEBODYOFTHESCRIPTTHEONLYWAYTOMAKESENSEOFTHEVARIABLEACTIONISTOUNDERSTANDTHATITSVALUEISASCRIPTTODECLAREANINPUTTOBEPROCEDURETYPEOPENTHEINPUTNAMEDIALOGASUSUALANDCLICKONTHEARROWHEADTHENINTHELONGDIALOGCHOOSETHEAPPROPRIATEPROCEDURETYPETHETHIRDROWOFINPUTTYPESHASARINGINTHESHAPEOFEACHBLOCKTYPEJIGSAWFORCOMMANDSOVALFORREPORTERSANDHEXAGONALFORPREDICATESINPRACTICETHOUGHINTHECASEOFCOMMANDSITSMORECOMMONTOCHOOSETHECSHAPEDSLOTONTHEFOURTHROWBECAUSETHISCONTAINERFORCOMMANDSCRIPTSISFAMILIARTOSCRATCHUSERSTECHNICALLYTHECSHAPEDSLOTISANUNEVALUATEDPROCEDURETYPESOMETHINGDISCUSSEDINSECTIONEBELOWTHETWOCOMMANDRELATEDINPUTTYPESINLINEANDCSHAPEDARECONNECTEDBYTHEFACTTHATIFAVARIABLEANITEMOFLISTBLOCKORACUSTOMREPORTERBLOCKISDROPPEDONTOACSHAPEDSLOTOFACUSTOMBLOCKITTURNSINTOANINLINESLOTASINTHEREPEATERBLOCKSRECURSIVECALLABOVEOTHERBUILTINREPORTERSCANTREPORTSCRIPTSSOTHEYARENTACCEPTEDINACSHAPEDSLOTWHYWOULDYOUEVERCHOOSEANINLINECOMMANDSLOTRATHERTHANACSHAPEOTHERTHANTHERUNBLOCKDISCUSSEDBELOWTHEONLYCASEICANTHINKOFISSOMETHINGLIKETHECCJAVAFORLOOPWHICHACTUALLYHASTHREECOMMANDSCRIPTINPUTSANDONEPREDICATEINPUTONLYONEOFWHICHISTHEFEATUREDLOOPBODYOKAYNOWTHATWEHAVEPROCEDURESASINPUTSTOOURBLOCKSHOWDOWEUSETHEMWEUSETHEBLOCKSRUNFORCOMMANDSANDCALLFORREPORTERSTHERUNBLOCKSSCRIPTINPUTISANINLINERINGNOTCSHAPEDBECAUSEWEANTICIPATETHATITWILLBERARETOUSEASPECIFICLITERALSCRIPTASTHEINPUTINSTEADTHEINPUTWILLGENERALLYBEAVARIABLEWHOSEVALUEISASCRIPTTHERUNANDCALLBLOCKSHAVEARROWHEADSATTHEENDTHATCANBEUSEDTOOPENSLOTSFORINPUTSTOTHECALLEDPROCEDURESHOWDOESSNAPKNOWWHERETOUSETHOSEINPUTSIFTHECALLEDPROCEDUREBLOCKORSCRIPTHASEMPTYINPUTSLOTSSNAPDOESTHERIGHTTHINGTHISHASSEVERALPOSSIBLEMEANINGSIFTHENUMBEROFEMPTYSLOTSISEXACTLYEQUALTOTHENUMBEROFINPUTSPROVIDEDTHENSNAPFILLSTHEEMPTYSLOTSFROMLEFTTORIGHTIFEXACTLYONEINPUTISPROVIDEDSNAPWILLFILLANYNUMBEROFEMPTYSLOTSWITHITOTHERWISESNAPWONTFILLANYSLOTSBECAUSETHEUSERSINTENTIONISUNCLEARIFTHEUSERWANTSTOOVERRIDETHESERULESTHESOLUTIONISTOUSEARINGWITHEXPLICITINPUTNAMESTHATCANBEPUTINTOTHEGIVENBLOCKORSCRIPTTOINDICATEHOWINPUTSARETOBEUSEDTHISWILLBEDISCUSSEDMOREFULLYBELOWRECURSIVECALLSTOMULTIPLEINPUTBLOCKSARELATIVELYRARESITUATIONNOTYETCONSIDEREDHEREISTHECASEOFARECURSIVEBLOCKTHATHASAVARIABLENUMBEROFINPUTSLETSSAYTHEUSEROFYOURPROJECTCALLSYOURBLOCKWITHFIVEINPUTSONETIMEANDINPUTSANOTHERTIMEHOWDOYOUWRITETHERECURSIVECALLTOYOURBLOCKWHENYOUDONTKNOWHOWMANYINPUTSTOGIVEITTHEANSWERISTHATYOUCOLLECTTHEINPUTSINALISTRECALLTHATWHENYOUDECLAREANINPUTNAMETOREPRESENTAVARIABLENUMBEROFINPUTSYOURBLOCKSEESTHOSEINPUTSASALISTOFVALUESINTHEFIRSTPLACEANDTHENINTHERECURSIVECALLYOUDROPTHATINPUTLISTONTOTHEARROWHEADSTHATINDICATEAVARIABLEINPUTSLOTRATHERTHANONTOTHEINPUTSLOTNOTETHATTHEHALOYOUSEEWHILEDRAGGINGONTOTHEARROWHEADSISREDINSTEADOFWHITEANDCOVERSTHEINPUTSLOTASWELLASTHEARROWHEADSANDWHENYOUDROPTHEEXPRESSIONONTOTHEARROWHEADSTHEWORDSINPUTLISTAREADDEDTOTHEBLOCKTEXTANDTHEARROWHEADSDISAPPEARINTHISINVOCATIONONLYTOREMINDYOUTHATTHELISTREPRESENTSALLOFTHEMULTIPLEINPUTSNOTJUSTASINGLEINPUTTHEITEMSINTHELISTARETAKENINDIVIDUALLYASINPUTSTOTHESCRIPTSINCENUMBERSISALISTOFNUMBERSEACHINDIVIDUALITEMISANUMBERJUSTWHATSIZESWANTSTHISBLOCKWILLTAKEANYNUMBEROFNUMBERSASINPUTSANDWILLMAKETHESPRITEGROWANDSHRINKACCORDINGLYTHEUSEROFTHISBLOCKCALLSITWITHANYNUMBEROFINDIVIDUALNUMBERSASINPUTSBUTINSIDETHEDEFINITIONOFTHEBLOCKALLOFTHOSENUMBERSFORMALISTTHATHASASINGLEINPUTNAMENUMBERSTHISRECURSIVEDEFINITIONFIRSTCHECKSTOMAKESURETHEREAREANYINPUTSATALLIFSOITPROCESSESTHEFIRSTINPUTITEMOFTHELISTTHENITWANTSTOMAKEARECURSIVECALLWITHALLBUTTHEFIRSTNUMBERBUTSIZESDOESNTTAKEALISTASINPUTITTAKESNUMBERSASINPUTSSOTHISWOULDBEWRONGCFORMALPARAMETERSTHERINGSAROUNDPROCEDURETYPEINPUTSHAVEANARROWHEADATTHERIGHTCLICKINGTHEARROWHEADALLOWSYOUTOGIVETHEINPUTSTOABLOCKORSCRIPTEXPLICITNAMESINSTEADOFUSINGEMPTYINPUTSLOTSASWEVEDONEUNTILNOWTHENAMESETCAREPROVIDEDBYDEFAULTBUTYOUCANCHANGEANAMEBYCLICKINGONITSORANGEOVALINTHEINPUTNAMESLISTBECAREFULNOTTODRAGTHEOVALWHENCLICKINGTHATSHOWYOUUSETHEINPUTINSIDETHERINGTHENAMESOFTHEINPUTVARIABLESARECALLEDTHEFORMALPARAMETERSOFTHEENCAPSULATEDPROCEDUREHERESASIMPLEBUTCONTRIVEDEXAMPLEUSINGEXPLICITNAMESTOCONTROLWHICHINPUTGOESWHEREINSIDETHERINGHEREWEJUSTWANTTOPUTONEOFTHEINPUTSINTOTWODIFFERENTSLOTSIFWELEFTALLTHREESLOTSEMPTYSNAPWOULDNOTFILLANYOFTHEMBECAUSETHENUMBEROFINPUTSPROVIDEDWOULDNOTMATCHTHENUMBEROFEMPTYSLOTSHEREISAMOREREALISTICMUCHMOREADVANCEDEXAMPLETHISISTHEDEFINITIONOFABLOCKTHATTAKESANYNUMBEROFLISTSANDREPORTSTHELISTOFALLPOSSIBLECOMBINATIONSOFONEITEMFROMEACHLISTTHEIMPORTANTPARTFORTHISDISCUSSIONISTHATNEARTHEBOTTOMTHEREARETWONESTEDCALLSTOMAPTHEHIGHERORDERFUNCTIONTHATAPPLIESANINPUTFUNCTIONTOEACHITEMOFANINPUTLISTINTHEINNERBLOCKTHEFUNCTIONBEINGMAPPEDISINFRONTOFANDTHATBLOCKTAKESTWOINPUTSTHESECONDTHEEMPTYLISTTYPESLOTWILLGETITSVALUEINEACHCALLFROMANITEMOFTHEINNERMAPSLISTINPUTBUTTHEREISNOWAYFORTHEOUTERMAPTOCOMMUNICATEVALUESTOEMPTYSLOTSOFTHEINFRONTOFBLOCKWEMUSTGIVEANEXPLICITNAMENEWITEMTOTHEVALUETHATTHEOUTERMAPISGIVINGTOTHEINNERONETHENDRAGTHATVARIABLEINTOTHEINFRONTOFBLOCKBYTHEWAYONCETHECALLEDBLOCKPROVIDESNAMESFORITSINPUTSSNAPWILLNOTAUTOMATICALLYFILLEMPTYSLOTSONTHETHEORYTHATTHEUSERHASTAKENCONTROLINFACTTHATSANOTHERREASONYOUMIGHTWANTTONAMETHEINPUTSEXPLICITLYTOSTOPSNAPFROMFILLINGASLOTTHATSHOULDREALLYREMAINEMPTYDPROCEDURESASDATAHERESANEXAMPLEOFASITUATIONINWHICHAPROCEDUREMUSTBEEXPLICITLYMARKEDASDATABYPULLINGARINGFROMTHEOPERATORSPALETTEANDPUTTINGTHEPROCEDUREBLOCKORSCRIPTINSIDEITHEREWEAREMAKINGALISTOFPROCEDURESBUTTHELISTBLOCKACCEPTSINPUTSOFANYTYPESOITSINPUTSLOTSARENOTRINGEDWEMUSTSAYEXPLICITLYTHATWEWANTTHEBLOCKITSELFASTHEINPUTRATHERTHANWHATEVERVALUEWOULDRESULTFROMEVALUATINGTHEBLOCKBESIDESTHELISTBLOCKINTHEEXAMPLEABOVEOTHERBLOCKSINTOWHICHYOUMAYWANTTOPUTPROCEDURESARESETTOSETTHEVALUEOFAVARIABLETOAPROCEDURESAYANDTHINKTODISPLAYAPROCEDURETOTHEUSERANDREPORTFORAREPORTERTHATREPORTSAPROCEDUREESPECIALFORMSTHEPRIMITIVEIFELSEBLOCKHASTWOCSHAPEDCOMMANDSLOTSANDCHOOSESONEORTHEOTHERDEPENDINGONABOOLEANTESTBECAUSESCRATCHDOESNTEMPHASIZEFUNCTIONALPROGRAMMINGITLACKSACORRESPONDINGREPORTERBLOCKTOCHOOSEBETWEENTWOEXPRESSIONSSNAPHASONEBUTWECOULDWRITEOUROWNOURBLOCKWORKSFORTHESESIMPLEEXAMPLESBUTIFWETRYTOUSEITINWRITINGARECURSIVEOPERATORITLLFAILTHEPROBLEMISTHATWHENANYBLOCKISCALLEDALLOFITSINPUTSARECOMPUTEDEVALUATEDBEFORETHEBLOCKITSELFRUNSTHEBLOCKITSELFKNOWSONLYTHEVALUESOFITSINPUTSNOTWHATEXPRESSIONSWEREUSEDTOCOMPUTETHEMINPARTICULARALLOFTHEINPUTSTOOURIFTHENELSEBLOCKAREEVALUATEDFIRSTTHINGTHATMEANSTHATEVENINTHEBASECASEFACTORIALWILLTRYTOCALLITSELFRECURSIVELYCAUSINGANINFINITELOOPWENEEDOURIFTHENELSEBLOCKTOBEABLETOSELECTONLYONEOFTHETWOALTERNATIVESTOBEEVALUATEDWEHAVEAMECHANISMTOALLOWTHATDECLARETHETHENANDELSEINPUTSTOBEOFTYPEREPORTERRATHERTHANTYPEANYTHENWHENCALLINGTHEBLOCKTHOSEINPUTSWILLBEENCLOSEDINARINGSOTHATTHEEXPRESSIONSTHEMSELVESRATHERTHANTHEIRVALUESBECOMETHEINPUTSINTHISVERSIONTHEPROGRAMWORKSWITHNOINFINITELOOPBUTWEVEPAIDAHEAVYPRICETHISREPORTERIFISNOLONGERASINTUITIVELYOBVIOUSASTHESCRATCHCOMMANDIFYOUHAVETOKNOWABOUTPROCEDURESASDATAABOUTRINGSANDABOUTATRICKTOGETACONSTANTVALUEINARINGEDSLOTTHEIDBLOCKIMPLEMENTSTHEIDENTITYFUNCTIONWHICHREPORTSITSINPUTWENEEDITBECAUSERINGSTAKEONLYREPORTERSASINPUTNOTNUMBERSWHATWEDLIKEISAREPORTERIFTHATBEHAVESLIKETHISONEDELAYINGTHEEVALUATIONOFITSINPUTSBUTLOOKSLIKEOURFIRSTVERSIONWHICHWASEASYTOUSEEXCEPTTHATITDIDNTWORKSUCHBLOCKSAREINDEEDPOSSIBLEABLOCKTHATSEEMSTOTAKEASIMPLEEXPRESSIONASINPUTBUTDELAYSTHEEVALUATIONOFTHATINPUTBYWRAPPINGANINVISIBLERINGAROUNDITANDIFNECESSARYANIDLIKETRANSFORMATIONOFCONSTANTDATAINTOCONSTANTFUNCTIONSISCALLEDASPECIALFORMTOTURNOURIFBLOCKINTOASPECIALFORMWEEDITTHEBLOCKSPROTOTYPEDECLARINGTHEINPUTSYESANDNOTOBEOFTYPEANYUNEVALUATEDINSTEADOFTYPEREPORTERTHESCRIPTFORTHEBLOCKISSTILLTHATOFTHESECONDVERSIONINCLUDINGTHEUSEOFCALLTOEVALUATEEITHERYESORNOBUTNOTBOTHBUTTHESLOTSAPPEARASWHITEANYTYPERECTANGLESNOTREPORTERTYPERINGSANDTHEFACTORIALBLOCKWILLLOOKLIKEOURFIRSTATTEMPTINASPECIALFORMSPROTOTYPETHEUNEVALUATEDINPUTSLOTSAREINDICATEDBYALAMBDANEXTTOTHEINPUTNAMEJUSTASIFTHEYWEREDECLAREDASPROCEDURETYPETHEYAREPROCEDURETYPEREALLYTHEYREJUSTDISGUISEDTOTHEUSEROFTHEBLOCKSPECIALFORMSTRADEOFFIMPLEMENTORSOPHISTICATIONFORUSERSOPHISTICATIONTHATISYOUHAVETOUNDERSTANDALLABOUTPROCEDURESASDATATOMAKESENSEOFTHESPECIALFORMIMPLEMENTATIONOFMYIFTHENELSEBUTANYEXPERIENCEDSCRATCHPROGRAMMERCANUSEMYIFTHENELSEWITHOUTTHINKINGATALLABOUTHOWITWORKSINTERNALLYSPECIALFORMSINSCRATCHSPECIALFORMSAREACTUALLYNOTANEWINVENTIONINSNAPMANYOFSCRATCHSCONDITIONALANDLOOPINGBLOCKSAREREALLYSPECIALFORMSTHEHEXAGONALINPUTSLOTINTHEIFBLOCKISASTRAIGHTFORWARDBOOLEANVALUEBECAUSETHEVALUECANBECOMPUTEDONCEBEFORETHEIFBLOCKMAKESITSDECISIONABOUTWHETHERORNOTTORUNITSACTIONINPUTBUTTHEFOREVERIFREPEATUNTILANDWAITUNTILBLOCKSINPUTSCANTBEBOOLEANSTHEYHAVETOBEOFTYPEBOOLEANUNEVALUATEDSOTHATSCRATCHCANEVALUATETHEMOVERANDOVERAGAINSINCESCRATCHDOESNTHAVECUSTOMCSHAPEDBLOCKSITCANAFFORDTOHANDWAVEAWAYTHEDISTINCTIONBETWEENEVALUATEDANDUNEVALUATEDBOOLEANSBUTSNAPCANTTHEPEDAGOGICVALUEOFSPECIALFORMSISPROVENBYTHEFACTTHATNOSCRATCHEREVERNOTICESTHATTHERESANYTHINGSTRANGEABOUTTHEWAYINWHICHTHEHEXAGONALINPUTSINTHECONTROLBLOCKSAREEVALUATEDALSOTHECSHAPEDSLOTFAMILIARTOSCRATCHUSERSISANUNEVALUATEDPROCEDURETYPEYOUDONTHAVETOUSEARINGTOKEEPTHECOMMANDSINTHECSLOTFROMBEINGRUNBEFORETHECSHAPEDBLOCKISRUNTHOSECOMMANDSTHEMSELVESNOTTHERESULTOFRUNNINGTHEMARETHEINPUTTOTHECSHAPEDCONTROLBLOCKTHISISTAKENFORGRANTEDBYSCRATCHUSERSESPECIALLYBECAUSESCRATCHERSDONTTHINKOFTHECONTENTSOFACSLOTASANINPUTATALLTHISISWHYITMAKESSENSETHATCSHAPEDISONTHEFOURTHROWOFTYPESINTHELONGFORMINPUTDIALOGWITHOTHERUNEVALUATEDTYPESTHEREISAPRIMITIVEIDFUNCTIONINTHEMENUOFTHESQRTOFBLOCKBUTWETHINKSEEINGITSVERYSIMPLEIMPLEMENTATIONWILLMAKETHISEXAMPLEEASIERTOUNDERSTANDVIIOBJECTORIENTEDPROGRAMMINGWITHSPRITESOBJECTORIENTEDPROGRAMMINGISASTYLEBASEDAROUNDTHEABSTRACTIONOBJECTACOLLECTIONOFDATAANDMETHODSPROCEDURESWHICHFROMOURPOINTOFVIEWAREJUSTMOREDATATHATYOUINTERACTWITHBYSENDINGITAMESSAGEJUSTANAMEMAYBEINTHEFORMOFATEXTSTRINGANDPERHAPSADDITIONALINPUTSTHEOBJECTRESPONDSTOTHEMESSAGEBYCARRYINGOUTAMETHODWHICHMAYORMAYNOTREPORTAVALUEBACKTOTHEASKERSOMEPEOPLEEMPHASIZETHEDATAHIDINGASPECTOFOOPBECAUSEEACHOBJECTHASLOCALVARIABLESTHATOTHEROBJECTSCANACCESSONLYBYSENDINGREQUESTMESSAGESTOTHEOWNINGOBJECTWHILEOTHERSEMPHASIZETHESIMULATIONASPECTINWHICHEACHOBJECTABSTRACTLYREPRESENTSSOMETHINGINTHEWORLDANDTHEINTERACTIONSOFOBJECTSINTHEPROGRAMMODELREALINTERACTIONSOFREALPEOPLEORTHINGSDATAHIDINGISIMPORTANTFORLARGEMULTIPROGRAMMERINDUSTRIALPROJECTSBUTFORSNAPUSERSITSTHESIMULATIONASPECTTHATSIMPORTANTOURAPPROACHISTHEREFORELESSRESTRICTIVETHANTHATOFSOMEOTHEROOPLANGUAGESWEGIVEOBJECTSEASYACCESSTOEACHOTHERSDATAANDMETHODSTECHNICALLYOBJECTORIENTEDPROGRAMMINGRESTSONTHREELEGSMESSAGEPASSINGTHEREISANOTATIONBYWHICHANYOBJECTCANSENDAMESSAGETOANOTHEROBJECTLOCALSTATEEACHOBJECTCANREMEMBERTHEIMPORTANTPASTHISTORYOFTHECOMPUTATIONITHASPERFORMEDIMPORTANTMEANSTHATITNEEDNOTREMEMBEREVERYMESSAGEITHASHANDLEDBUTONLYTHELASTINGEFFECTSOFTHOSEMESSAGESTHATWILLAFFECTLATERCOMPUTATIONINHERITANCEITWOULDBEIMPRACTICALIFEACHINDIVIDUALOBJECTHADTOCONTAINMETHODSMANYOFTHEMIDENTICALTOTHOSEOFOTHEROBJECTSFORALLOFTHEMESSAGESITCANACCEPTINSTEADWENEEDAWAYTOSAYTHATTHISNEWOBJECTISJUSTLIKETHATOLDOBJECTEXCEPTFORAFEWDIFFERENCESSOTHATONLYTHOSEDIFFERENCESNEEDBEPROGRAMMEDEXPLICITLYAFIRSTCLASSSPRITESLIKESCRATCHSNAPCOMESWITHTHINGSTHATARENATURALOBJECTSITSSPRITESEACHSPRITECANOWNLOCALVARIABLESEACHSPRITEHASITSOWNSCRIPTSMETHODSASCRATCHANIMATIONISPLAINLYASIMULATIONOFTHEINTERACTIONOFCHARACTERSINAPLAYTHEREARETWOWAYSINWHICHSCRATCHSPRITESARELESSVERSATILETHANTHEOBJECTSOFANOOPLANGUAGEFIRSTSCRATCHMESSAGEPASSINGISWEAKINTHREERESPECTSMESSAGESCANONLYBEBROADCASTNOTADDRESSEDTOANINDIVIDUALSPRITEMESSAGESCANTTAKEINPUTSANDMETHODSCANTRETURNVALUESTOTHEIRCALLERSECONDANDMOREBASICINTHEOOPPARADIGMOBJECTSAREDATATHEYCANBETHEVALUEOFAVARIABLEANELEMENTOFALISTANDSOONBUTTHATSNOTTHECASEFORSCRATCHSPRITESSNAPSPRITESAREFIRSTCLASSDATATHEYCANBECREATEDANDDELETEDBYASCRIPTSTOREDINAVARIABLEORLISTANDSENTMESSAGESINDIVIDUALLYTHECHILDRENOFASPRITECANINHERITSPRITELOCALVARIABLESMETHODSSPRITELOCALPROCEDURESANDOTHERATTRIBUTESEGXPOSITIONTHEFUNDAMENTALMEANSBYWHICHPROGRAMSGETACCESSTOSPRITESISTHEMYREPORTERBLOCKITHASADROPDOWNMENUINPUTSLOTTHATWHENCLICKEDGIVESACCESSTOALLTHESPRITESPLUSTHESTAGEREPORTSASINGLESPRITETHEONEASKINGTHEQUESTIONREPORTSALISTOFALLSPRITESOTHERTHANTHEONEASKINGTHEQUESTIONREPORTSALISTOFALLSPRITESTHATARENEARTHEONEASKINGTHEONESTHATARECANDIDATESFORHAVINGCOLLIDEDWITHTHISONEFOREXAMPLETHEMYBLOCKHASMANYOTHEROPTIONSDISCUSSEDBELOWIFYOUKNOWTHENAMEOFAPARTICULARSPRITETHEOBJECTREPORTERWILLREPORTTHESPRITEITSELFANOBJECTORLISTOFOBJECTSREPORTEDBYMYOROBJECTCANBEUSEDASINPUTTOANYBLOCKTHATACCEPTSANYINPUTTYPESUCHASSETSSECONDINPUTIFYOUSAYANOBJECTTHERESULTINGSPEECHBALLOONWILLCONTAINASMALLERIMAGEOFTHEOBJECTSCOSTUMEORFORTHESTAGEBACKGROUNDBPERMANENTANDTEMPORARYCLONESTHEBLOCKISUSEDTOCREATEANDREPORTANINSTANCEACLONEOFANYSPRITETHEREISALSOACOMMANDVERSIONFORHISTORICALREASONSTHEREARETWODIFFERENTKINDSOFSITUATIONSINWHICHCLONESAREUSEDONEISTHATYOUVEMADEANEXAMPLESPRITEANDWHENYOUSTARTTHEPROJECTYOUWANTAFAIRLYLARGENUMBEROFESSENTIALLYIDENTICALSPRITESTHATBEHAVELIKETHEEXAMPLEHEREAFTERWELLCALLTHEEXAMPLESPRITETHEPARENTANDTHEOTHERSTHECHILDRENONCETHEGAMEORANIMATIONISOVERYOUDONTNEEDTHECOPIESANYMOREASWELLSEECOPIESISTHEWRONGWORDBECAUSETHEPARENTANDTHECHILDRENSHAREALOTOFPROPERTIESTHATSWHYWEUSETHEWORDCLONESTODESCRIBETHECHILDRENRATHERTHANCOPIESTHESEARETEMPORARYCLONESTHEYAREAUTOMATICALLYDELETEDWHENTHEUSERPRESSESEITHERTHEGREENFLAGORTHEREDSTOPSIGNINSCRATCHANDLATERALLCLONESARETEMPORARYTHEOTHERKINDOFSITUATIONISWHATHAPPENSWHENYOUWANTSPECIALIZATIONSOFSPRITESFOREXAMPLELETSSAYYOUHAVEASPRITENAMEDDOGITHASCERTAINBEHAVIORSSUCHASRUNNINGUPTOAPERSONWHOCOMESNEARITNOWYOUDECIDETHATTHEFAMILYINYOURSTORYREALLYLIKESDOGSSOTHEYADOPTALOTOFTHEMSOMEARECOCKERSPANIELSWHOWAGTHEIRTAILSWHENTHEYSEEYOUOTHERSAREROTTWEILERSWHOGROWLATYOUWHENTHEYSEEYOUSOYOUMAKEACLONEOFDOGPERHAPSRENAMEITCOCKERSPANIELANDGIVEITANEWCOSTUMEANDASCRIPTFORWHATTODOWHENSOMEONEGETSNEARYOUMAKEANOTHERCLONEOFDOGPERHAPSRENAMEITROTTWEILERANDGIVEITANEWCOSTUMEETCTHENYOUMAKETHREECLONESOFCOCKERSPANIELSOTHEREAREFOURALTOGETHERANDTWOCLONESOFROTTWEILERMAYBEYOUHIDETHEDOGSPRITEAFTERALLTHISSINCEITSNOBREEDINPARTICULAREACHDOGHASITSOWNPOSITIONSPECIALBEHAVIORSANDSOONYOUWANTTOSAVEALLOFTHESEDOGSINTHEPROJECTTHESEAREPERMANENTCLONESINBYOBTHEPREDECESSORTOSNAPALLCLONESAREPERMANENTONEADVANTAGEOFTEMPORARYCLONESISTHATTHEYDONTSLOWDOWNSNAPEVENWHENYOUHAVEALOTOFTHEMIFYOURECURIOUSONEREASONISTHATPERMANENTCLONESAPPEARINTHESPRITECORRALWHERETHEIRPICTURESHAVETOBEUPDATEDTOREFLECTTHECLONESCURRENTCOSTUMEDIRECTIONANDSOONWEHAVETRIEDTOANTICIPATEYOURNEEDSASFOLLOWSWHENYOUMAKEACLONEINASCRIPTUSINGTHEBLOCKITISBORNTEMPORARYBUTWHENYOUMAKEACLONEFROMTHEUSERINTERFACEFOREXAMPLEBYRIGHTCLICKINGONASPRITEANDCHOOSINGCLONEITISBORNPERMANENTTHEREASONTHISMAKESSENSEISTHATYOUDONTCREATEKINDSOFDOGSAUTOMATICALLYEACHKINDHASMANYDIFFERENTCHARACTERISTICSPROGRAMMEDBYHANDBUTWHENYOURPROJECTISRUNNINGITMIGHTCREATEROTTWEILERSANDTHOSEWILLBEIDENTICALUNLESSYOUCHANGETHEMINTHEPROGRAMYOUCANCHANGEATEMPORARYSPRITETOPERMANENTBYRIGHTCLICKINGITANDCHOOSINGEDITITSCALLEDEDITRATHERTHANSAYPERMANENTBECAUSEITALSOSHIFTSTHESCRIPTINGAREATOREFLECTTHATSPRITEASIFYOUDPRESSEDITSBUTTONINTHESPRITECORRALYOUCANCHANGEAPERMANENTSPRITETOTEMPORARYBYRIGHTCLICKINGITANDCHOOSINGRELEASEYOUCANALSOCHANGETHESTATUSOFACLONEINYOURPROGRAMWITHWITHTRUEORFALSEASTHESECONDINPUTCSENDINGMESSAGESTOSPRITESTHEMESSAGESTHATASPRITEACCEPTSARETHEBLOCKSINITSPALETTESINCLUDINGBOTHALLSPRITESANDTHISSPRITEONLYBLOCKSFORCUSTOMBLOCKSTHECORRESPONDINGMETHODSARETHESCRIPTSASSEENINTHEBLOCKEDITORTHEWAYTOSENDAMESSAGETOASPRITEORTHESTAGEISWITHTHETELLBLOCKFORCOMMANDMESSAGESORTHEASKBLOCKFORREPORTERMESSAGESASMALLPOINTTONOTEINTHEEXAMPLESABOVEALLDROPDOWNMENUSINCLUDEANEMPTYENTRYATTHETOPWHICHCANBESELECTEDFORUSEINHIGHERORDERPROCEDURESLIKETHEFOREACHANDMAPEXAMPLESEACHOFTHESPRITESINMYNEIGHBORSORMYOTHERSPRITESISUSEDTOFILLTHEBLANKSPACEINTURNBYTHEWAYIFYOUWANTALISTOFALLTHESPRITESINCLUDINGTHISSPRITEYOUCANUSEEITHEROFTHESETELLANDASKWAITUNTILTHEOTHERSPRITEHASCARRIEDOUTITSMETHODBEFORETHISSPRITESSCRIPTCONTINUESTHATHASTOBETHECASEFORASKSINCEWEWANTTODOSOMETHINGWITHTHEVALUEITREPORTSSOTELLISANALOGOUSTOBROADCASTANDWAITSOMETIMESTHEOTHERSPRITESMETHODMAYTAKEALONGTIMEORMAYEVENBEAFOREVERLOOPSOYOUWANTTHEORIGINATINGSCRIPTTOCONTINUEWITHOUTWAITINGFORTHISPURPOSEWEHAVETHELAUNCHBLOCKLAUNCHISANALOGOUSTOBROADCASTWITHOUTTHEWAITSNAPFOLLOWINGBYOBUSEDANEXTENSIONOFTHEOFBLOCKTOPROVIDEACCESSTOOTHERSPRITESMETHODSTHATINTERFACEWASDESIGNEDBACKWHENWEWERETRYINGHARDTOAVOIDADDINGNEWPRIMITIVEBLOCKSITALLOWEDUSTOWRITEASKANDTELLASTOOLPROCEDURESINSNAPITSELFTHATTECHNIQUESTILLWORKSBUTISDEPRECATEDBECAUSENOBODYUNDERSTOODITANDNOWWEHAVETHEMORESTRAIGHTFORWARDPRIMITIVESPOLYMORPHISMSUPPOSEYOUHAVEADOGSPRITEWITHTWOCLONESCOCKERSPANIELANDPITBULLINTHEDOGSPRITEYOUDEFINETHISMETHODFORTHISSPRITEONLYBLOCKNOTETHELOCATIONMAPPINSYMBOLBEFORETHEBLOCKSNAMETHESYMBOLISNOTPARTOFTHEBLOCKTITLEITSAVISUALREMINDERTHATTHISISASPRITELOCALBLOCKSPRITELOCALVARIABLESARESIMILARLYMARKEDBUTYOUDONTDEFINEGREETASFRIENDORGREETASENEMYINDOGEACHKINDOFDOGHASADIFFERENTBEHAVIORHERESWHATACOCKERSPANIELDOESANDHERESWHATAPITBULLDOESGREETISDEFINEDINTHEDOGSPRITEIFFIDOISAPARTICULARCOCKERSPANIELANDYOUASKFIDOTOGREETSOMEONEFIDOINHERITSTHEGREETMETHODFROMDOGBUTDOGITSELFCOULDNTACTUALLYRUNTHATMETHODBECAUSEDOGDOESNTHAVEGREETASFRIENDORGREETASENEMYANDPERHAPSONLYINDIVIDUALDOGSSUCHASFIDOHAVEFRIENDMETHODSEVENTHOUGHTHEGREETMETHODISDEFINEDINTHEDOGSPRITEWHENITSRUNNINGITREMEMBERSWHATSPECIFICDOGSPRITECALLEDITSOITKNOWSWHICHGREETASFRIENDTOUSEDOGSGREETBLOCKISCALLEDAPOLYMORPHICMETHODBECAUSEITMEANSDIFFERENTTHINGSTODIFFERENTDOGSEVENTHOUGHTHEYALLSHARETHESAMESCRIPTDLOCALSTATEINSPRITESVARIABLESANDATTRIBUTESASPRITESMEMORYOFITSOWNPASTHISTORYTAKESTWOMAINFORMSITHASVARIABLESCREATEDEXPLICITLYBYTHEUSERWITHTHEMAKEAVARIABLEBUTTONITALSOHASATTRIBUTESTHEQUALITIESEVERYSPRITEHASAUTOMATICALLYSUCHASPOSITIONDIRECTIONANDPENCOLOREACHVARIABLECANBEEXAMINEDUSINGITSOWNORANGEOVALBLOCKTHEREISONESETBLOCKTOMODIFYALLVARIABLESATTRIBUTESHOWEVERHAVEALESSUNIFORMPROGRAMMINGINTERFACEINSCRATCHASPRITESDIRECTIONCANBEEXAMINEDWITHTHEDIRECTIONBLOCKANDMODIFIEDWITHTHEPOINTINDIRECTIONBLOCKITCANALSOBEMODIFIEDLESSDIRECTLYUSINGTHEBLOCKSTURNPOINTTOWARDSANDIFONEDGEBOUNCETHEREISNOWAYFORASCRIPTTOEXAMINEASPRITESPENCOLORBUTTHEREAREBLOCKSSETPENCOLORTOCOLORSETPENCOLORTONUMBERANDCHANGEPENCOLORTOMODIFYITASPRITESNAMECANBENEITHEREXAMINEDNORMODIFIEDBYSCRIPTSITCANBEMODIFIEDBYTYPINGANEWNAMEDIRECTLYINTOTHEBOXTHATDISPLAYSTHENAMEABOVETHESCRIPTINGAREATHEBLOCKIFANYTHATEXAMINESAVARIABLEORATTRIBUTEISCALLEDITSGETTERABLOCKTHEREMAYBEMORETHANONEASINTHEDIRECTIONEXAMPLEABOVETHATMODIFIESAVARIABLEORATTRIBUTEISCALLEDASETTERINSNAPWEALLOWVIRTUALLYALLATTRIBUTESTOBEEXAMINEDBUTINSTEADOFADDINGDOZENSOFREPORTERSWEUSEAMOREUNIFORMINTERFACEFORATTRIBUTESTHEMYBLOCKSMENUINSENSINGSEEPAGEINCLUDESMANYOFTHEATTRIBUTESOFASPRITEITSERVESASAGENERALGETTERFORTHOSEATTRIBUTESEGMYANCHORTOFINDTHESPRITEIFANYTOWHICHTHISSPRITEISATTACHEDINANESTINGARRANGEMENTSEEPAGESIMILARLYTHESAMESETBLOCKUSEDTOSETVARIABLEVALUESALLOWSSETTINGSOMESPRITEATTRIBUTESEPROTOTYPINGPARENTSANDCHILDRENMOSTCURRENTOOPLANGUAGESUSEACLASSINSTANCEAPPROACHTOCREATINGOBJECTSACLASSISAPARTICULARKINDOFOBJECTANDANINSTANCEISANACTUALOBJECTOFTHATTYPEFOREXAMPLETHEREMIGHTBEADOGCLASSANDSEVERALINSTANCESFIDOSPOTANDRUNTTHECLASSTYPICALLYSPECIFIESTHEMETHODSSHAREDBYALLDOGSROLLOVERSITUPANDBEGFETCHANDSOONANDTHEINSTANCESCONTAINDATASUCHASSPECIESCOLORANDFRIENDLINESSSNAPUSESADIFFERENTAPPROACHCALLEDPROTOTYPINGINWHICHTHEREISNODISTINCTIONBETWEENCLASSESANDINSTANCESPROTOTYPINGISBETTERSUITEDTOANEXPERIMENTALTINKERINGSTYLEOFWORKYOUMAKEASINGLEDOGSPRITEWITHBOTHMETHODSBLOCKSANDDATAVARIABLESYOUCANACTUALLYWATCHITANDINTERACTWITHITONTHESTAGEANDWHENYOULIKEITYOUUSEITASTHEPROTOTYPEFROMWHICHTOCLONEOTHERDOGSIFYOULATERDISCOVERABUGINTHEBEHAVIOROFDOGSYOUCANEDITAMETHODINTHEPARENTANDALLOFTHECHILDRENWILLAUTOMATICALLYSHARETHENEWVERSIONOFTHEMETHODBLOCKEXPERIENCEDCLASSINSTANCEPROGRAMMERSMAYFINDPROTOTYPINGSTRANGEATFIRSTBUTITISACTUALLYAMOREEXPRESSIVESYSTEMBECAUSEYOUCANEASILYSIMULATEACLASSINSTANCEHIERARCHYBYHIDINGTHEPROTOTYPESPRITEPROTOTYPINGISALSOABETTERFITWITHTHESCRATCHDESIGNPRINCIPLETHATEVERYTHINGINAPROJECTSHOULDBECONCRETEANDVISIBLEONTHESTAGEINCLASSINSTANCEOOPTHEPROGRAMMINGPROCESSBEGINSWITHANABSTRACTINVISIBLEENTITYTHECLASSTHATMUSTBEDESIGNEDBEFOREANYCONCRETEOBJECTSCANBEMADETHEREARETHREEWAYSTOMAKEACHILDSPRITEIFYOUCONTROLCLICKORRIGHTCLICKONASPRITEINTHESPRITECORRALATTHEBOTTOMRIGHTCORNEROFTHEWINDOWYOUGETAMENUTHATINCLUDESCLONEASONEOFTHECHOICESTHEREISANANEWCLONEOFBLOCKINTHECONTROLPALETTETHATCREATESANDREPORTSACHILDSPRITEANDSPRITESHAVEAPARENTATTRIBUTETHATCANBESETLIKEANYATTRIBUTETHEREBYCHANGINGTHEPARENTOFANEXISTINGSPRITEFINHERITANCEBYDELEGATIONACLONEINHERITSPROPERTIESOFITSPARENTPROPERTIESINCLUDESCRIPTSCUSTOMBLOCKSVARIABLESNAMEDLISTSSYSTEMATTRIBUTESCOSTUMESANDSOUNDSEACHINDIVIDUALPROPERTYCANBESHAREDBETWEENPARENTANDCHILDORNOTSHAREDWITHASEPARATEONEINTHECHILDTHEGETTERBLOCKFORASHAREDPROPERTYINTHECHILDSPALETTEISDISPLAYEDINALIGHTERCOLORSEPARATEPROPERTIESOFTHECHILDAREDISPLAYEDINTHETRADITIONALCOLORSWHENANEWCLONEISCREATEDBYDEFAULTITSHARESONLYITSMETHODSWARDROBEANDJUKEBOXWITHITSPARENTALLOTHERPROPERTIESARECOPIEDTOTHECLONEBUTNOTSHAREDONEEXCEPTIONISTHATANEWPERMANENTCLONEISGIVENARANDOMPOSITIONANOTHERISTHATTEMPORARYCLONESSHARETHESCRIPTSINTHEIRPARENTSSCRIPTINGAREAATHIRDISTHATSPRITELOCALVARIABLESTHATTHEPARENTCREATESAFTERCLONINGARESHAREDWITHITSCHILDRENIFTHEVALUEOFASHAREDPROPERTYISCHANGEDINTHEPARENTTHENTHECHILDRENSEETHENEWVALUEIFTHEVALUEOFASHAREDPROPERTYISCHANGEDINTHECHILDTHENTHESHARINGLINKISBROKENANDANEWPRIVATEVERSIONISCREATEDINTHATCHILDTHISISTHEMECHANISMBYWHICHACHILDCHOOSESNOTTOSHAREAPROPERTYWITHITSPARENTCHANGEDINTHISCONTEXTMEANSUSINGTHESETORCHANGEBLOCKFORAVARIABLEEDITINGABLOCKINTHEBLOCKEDITOREDITINGACOSTUMEORSOUNDORINSERTINGDELETINGORREORDERINGCOSTUMESORSOUNDSTOCHANGEAPROPERTYFROMUNSHAREDTOSHAREDTHECHILDUSESTHEINHERITCOMMANDBLOCKTHEPULLDOWNMENUINTHEBLOCKLISTSALLTHETHINGSTHISSPRITECANINHERITFROMITSPARENTWHICHMIGHTBENOTHINGIFTHISSPRITEHASNOPARENTANDISNOTALREADYINHERITINGBUTTHATWOULDPREVENTTELLINGACHILDTOINHERITSOIFTHEINHERITBLOCKISINSIDEARINGITSPULLDOWNMENUINCLUDESALLTHETHINGSACHILDCOULDINHERITFROMTHISSPRITERIGHTCLICKINGONTHESCRIPTINGAREAOFAPERMANENTCLONEGIVESAMENUOPTIONTOSHARETHEENTIRECOLLECTIONOFSCRIPTSFROMITSPARENTASATEMPORARYCLONEDOESSOMELANGUAGESPOPULARINTHEREALWORLDTODAYSUCHASJAVASCRIPTCLAIMTOUSEPROTOTYPINGBUTTHEIROBJECTSYSTEMISMUCHMORECOMPLICATEDTHANWHATWEAREDESCRIBINGWEREGUESSINGITSBECAUSETHEYWEREDESIGNEDBYPEOPLETOOFAMILIARWITHCLASSINSTANCEPROGRAMMINGTHATHASINSOMECIRCLESGIVENPROTOTYPINGABADNAMEOURPROTOTYPINGDESIGNCOMESFROMOBJECTLOGOANDBEFORETHATFROMHENRYLIEBERMANLIEBERMANHUSINGPROTOTYPICALOBJECTSTOIMPLEMENTSHAREDBEHAVIORINOBJECTORIENTEDSYSTEMSFIRSTCONFERENCEONOBJECTORIENTEDPROGRAMMINGLANGUAGESSYSTEMSANDAPPLICATIONSOOPSLAACMSIGCHIPORTLANDORSEPTEMBERALSOINOBJECTORIENTEDCOMPUTINGGERALDPETERSONEDIEEECOMPUTERSOCIETYPRESSTHERULESAREFULLOFDETAILSBUTTHEBASICIDEAISSIMPLEPARENTSCANCHANGETHEIRCHILDRENBUTCHILDRENCANTDIRECTLYCHANGETHEIRPARENTSTHATSWHATYOUDEXPECTFROMTHEWORDINHERITTHEINFLUENCEJUSTGOESINONEDIRECTIONWHENACHILDCHANGESSOMEPROPERTYITSDECLARINGINDEPENDENCEFROMITSPARENTWITHRESPECTTOTHATONEPROPERTYWHATIFYOUREALLYWANTTHECHILDTOBEABLETOMAKEACHANGEINTHEPARENTANDTHEREFOREINITSELFANDALLITSSIBLINGSREMEMBERTHATINTHISSYSTEMANYOBJECTCANTELLANYOTHEROBJECTTODOSOMETHINGWHENASPRITEGETSAMESSAGEFORWHICHITDOESNTHAVEACORRESPONDINGBLOCKTHEMESSAGEISDELEGATEDTOTHATSPRITESPARENTWHENASPRITEDOESHAVETHECORRESPONDINGBLOCKTHENTHEMESSAGEISNOTDELEGATEDIFTHESCRIPTTHATIMPLEMENTSADELEGATEDMESSAGEREFERSTOMYSELFITMEANSTHECHILDTOWHICHTHEMESSAGEWASORIGINALLYSENTNOTTHEPARENTTOWHICHTHEMESSAGEWASDELEGATEDGLISTOFATTRIBUTESATTHERIGHTISAPICTUREOFTHEDROPDOWNMENUOFATTRIBUTESINTHEMYBLOCKSEVERALOFTHESEARENOTREALATTRIBUTESBUTTHINGSRELATEDTOATTRIBUTESSELFTHISSPRITENEIGHBORSALISTOFNEARBYSPRITESOTHERSPRITESALISTOFALLSPRITESEXCEPTMYSELFSTAGETHESTAGEWHICHISFIRSTCLASSLIKEASPRITECLONESALISTOFMYTEMPORARYCLONESOTHERCLONESALISTOFMYTEMPORARYSIBLINGSPARTSALISTOFSPRITESWHOSEANCHORATTRIBUTEISTHISSPRITECHILDRENALISTOFALLMYCLONESTEMPORARYANDPERMANENTTHEOTHERSAREINDIVIDUALATTRIBUTESANCHORTHESPRITEOFWHICHIAMANESTEDPARTPARENTTHESPRITEOFWHICHIAMACLONETEMPORARYAMIATEMPORARYCLONENAMEMYNAMESAMEASPARENTSNAMEIFIMTEMPORARYCOSTUMESALISTOFTHESPRITESCOSTUMESSOUNDSALISTOFTHESPRITESSOUNDSBLOCKSALISTOFTHEBLOCKSVISIBLEINTHISSPRITECATEGORIESALISTOFALLTHEBLOCKCATEGORYNAMESDANGLINGTRUEIFIAMAPARTANDNOTINSYNCHRONOUSORBITDRAGGABLETRUEIFTHEUSERCANMOVEMEWITHTHEMOUSEWIDTHHEIGHTLEFTRIGHTTOPBOOMTHEWIDTHORHEIGHTOFMYCOSTUMEASSEENRIGHTNOWORTHELEFTETCEDGEOFMYBOUNDINGBOXTAKINGROTATIONINTOACCOUNTROTATIONXROTATIONYWHENREADINGWITHMYTHESAMEASXPOSITIONYPOSITIONWHENSETCHANGESTHESPRITESROTATIONCENTERWITHOUTMOVINGTHESPRITELIKEDRAGGINGTHEROTATIONCENTERINTHEPAINTEDITORCENTERXCENTERYTHEXANDYPOSITIONOFTHECENTEROFMYBOUNDINGBOXROUNDEDOFFTHEGEOMETRICCENTEROFTHECOSTUMENEIGHBORSAREALLOTHERSPRITESWHOSEBOUNDINGBOXESINTERSECTTHEDOUBLEDDIMENSIONSOFTHEREQUESTINGSPRITESBOUNDSHFIRSTCLASSCOSTUMESANDSOUNDSCOSTUMESANDSOUNDSDONTHAVEMETHODSASSPRITESDOYOUCANTASKTHEMTODOTHINGSBUTTHEYAREFIRSTCLASSYOUCANMAKEALISTOFTHEMPUTTHEMINVARIABLESUSETHEMASINPUTTOAPROCEDUREANDSOONMYCOSTUMESANDMYSOUNDSREPORTLISTSOFTHEMMEDIACOMPUTATIONWITHCOSTUMESTHECOMPONENTSOFACOSTUMEAREITSNAMEWIDTHHEIGHTANDPIXELSTHEBLOCKGIVESACCESSTOTHESECOMPONENTSUSINGITSLEFTMENUFROMITSRIGHTMENUYOUCANCHOOSETHECURRENTCOSTUMETHETURTLECOSTUMEORANYCOSTUMEINTHESPRITESWARDROBESINCECOSTUMESAREFIRSTCLASSYOUCANALSODROPANEXPRESSIONWHOSEVALUEISACOSTUMEORALISTOFCOSTUMESONTHATSECONDINPUTSLOTDUETOAMISFEATUREEVENTHOUGHYOUCANSELECTTURTLEINTHERIGHTMENUTHEBLOCKREPORTSFORITSWIDTHANDHEIGHTANDANEMPTYSTRINGFORTHEOTHERCOMPONENTSTHECOSTUMESWIDTHANDHEIGHTAREINITSSTANDARDORIENTATIONREGARDLESSOFTHESPRITESCURRENTDIRECTIONTHISISDIFFERENTFROMTHESPRITESWIDTHANDHEIGHTREPORTEDBYTHEMYBLOCKBUTTHEREALLYINTERESTINGPARTOFACOSTUMEISITSBITMAPALISTOFPIXELSAPIXELSHORTFORPICTUREELEMENTREPRESENTSONEDOTONYOURDISPLAYEACHPIXELISITSELFALISTOFFOURITEMSTHEREDGREENANDBLUECOMPONENTSOFITSCOLORINTHERANGEANDWHATISSTANDARDLYCALLEDITSTRANSPARENCYBUTSHOULDBECALLEDITSOPACITYALSOINTHERANGEINWHICHMEANSTHATTHEPIXELISINVISIBLEANDMEANSTHATITSFULLYOPAQUEYOUCANTSEEANYTHINGFROMAREARWARDLAYERATTHATPOINTONTHESTAGECOSTUMEPIXELSTYPICALLYHAVEANOPACITYOFONLYFORPOINTSINSIDETHEBOUNDINGBOXOFTHECOSTUMEBUTNOTACTUALLYPARTOFTHECOSTUMEPOINTSINTHEINTERIOROFACOSTUMETYPICALLYHAVEANOPACITYOFINTERMEDIATEVALUESAPPEARMAINLYATTHEEDGEOFACOSTUMEORATSHARPBOUNDARIESBETWEENCOLORSINSIDETHECOSTUMEWHERETHEYAREUSEDTOREDUCEJAGGIESTHESTAIRSTEPLIKESHAPEOFADIAGONALLINEDISPLAYEDONANARRAYOFDISCRETERECTANGULARSCREENCOORDINATESNOTETHATTHEOPACITYOFASPRITEPIXELISDETERMINEDBYCOMBININGTHECOSTUMESOPACITYWITHTHESPRITESGHOSTEFFECTTHELATTERREALLYISAMEASUREOFTRANSPARENCYMEANSOPAQUEANDMEANSINVISIBLETHEBITMAPISAONEDIMENSIONALLISTOFPIXELSNOTANARRAYOFHEIGHTROWSOFWIDTHPIXELSEACHTHATSWHYTHEPIXELLISTHASTOBECOMBINEDWITHTHEDIMENSIONSTOPRODUCEACOSTUMETHISCHOICEPARTLYREFLECTSTHEWAYBITMAPSARESTOREDINTHECOMPUTERSHARDWAREANDOPERATINGSYSTEMBUTALSOMAKESITEASYTOPRODUCETRANSFORMATIONSOFACOSTUMEWITHMAPINTHISSIMPLESTPOSSIBLETRANSFORMATIONTHEREDVALUEOFALLTHEPIXELSHAVEBEENCHANGEDTOACONSTANTCOLORSTHATWEREREDINTHEORIGINALSUCHASTHELOGOPRINTEDONTHETSHIRTBECOMECLOSERTOBLACKTHEOTHERCOLORCOMPONENTSBEINGNEARZEROTHEBLUEJEANSBECOMEPURPLEBLUEPLUSREDPERHAPSCOUNTERINTUITIVELYTHEWHITETSHIRTWHICHHASTHEMAXIMUMVALUEFORALLTHREECOLORCOMPONENTSLOSESSOMEOFITSREDANDBECOMESCYANTHECOLOROPPOSITEREDONTHECOLORWHEELINREADINGTHECODENOTETHATTHEFUNCTIONTHATISTHEFIRSTINPUTTOMAPISAPPLIEDTOASINGLEPIXELWHOSEFIRSTITEMISITSREDCOMPONENTALSONOTETHATTHISPROCESSWORKSONLYONBITMAPCOSTUMESIFYOUCALLPIXELSOFONAVECTORCOSTUMEONEWITHSVGINTHECORNEROFITSPICTUREITWILLBECONVERTEDTOPIXELSFIRSTONEIMPORTANTPOINTTOSEEHEREISTHATABITMAPLISTOFPIXELSISNOTBYITSELFACOSTUMETHENEWCOSTUMEBLOCKCREATESACOSTUMEBYCOMBININGABITMAPAWIDTHANDAHEIGHTBUTASINTHEEXAMPLEABOVESWITCHTOCOSTUMEWILLACCEPTABITMAPASINPUTANDWILLAUTOMATICALLYUSETHEWIDTHANDHEIGHTOFTHECURRENTCOSTUMENOTETHATTHERESNONAMEINPUTCOSTUMESCOMPUTEDINTHISWAYAREALLNAMEDCOSTUMENOTEALSOTHATTHEUSEOFSWITCHTOCOSTUMEDOESNOTADDTHECOMPUTEDCOSTUMETOTHESPRITESWARDROBETODOTHATSAYHERESAMOREINTERESTINGEXAMPLEOFCOLORMANIPULATIONEACHCOLORVALUEISCONSTRAINEDTOBEORTHISGIVESTHEPICTUREAMORECARTOONISHLOOKALTERNATIVELYYOUCANDOTHECOMPUTATIONTAKINGADVANTAGEOFHYPERBLOCKSHERESONEWAYTOEXCHANGEREDANDGREENVALUESITSTHELISTTHATDETERMINESTHEREARRANGEMENTOFCOLORSGREENREDREDGREENANDTHEOTHERTWOUNCHANGEDTHATLISTISINSIDEANOTHERLISTBECAUSEOTHERWISEITWOULDBESELECTINGROWSOFTHEPIXELARRAYANDWEWANTTOSELECTCOLUMNSWEUSEPIXELSOFCOSTUMECURRENTRATHERTHANCOSTUMEAPPLEBECAUSETHELATTERISALWAYSAREDAPPLESOTHISLITTLEPROGRAMWOULDGETSTUCKTURNINGITGREENINSTEADOFALTERNATINGCOLORSTHESTRETCHBLOCKTAKESACOSTUMEASITSFIRSTINPUTEITHERBYSELECTINGACOSTUMEFROMTHEMENUORBYDROPPINGACOSTUMEVALUEDEXPRESSIONSUCHASONTOITTHEOTHERTWOINPUTSAREPERCENTSOFTHEORIGINALWIDTHANDHEIGHTASADVERTISEDSOYOUCANMAKEFUNHOUSEMIRRORVERSIONSOFCOSTUMESTHERESULTINGCOSTUMESCANBEUSEDWITHSWITCHTOCOSTUMEANDSOONFINALLYYOUCANUSEPICTURESFROMYOURCOMPUTERSCAMERAINYOURPROJECTSUSINGTHESEBLOCKSUSINGTHEVIDEOONBLOCKTURNSONTHECAMERAANDDISPLAYSWHATITSEESONTHESTAGEREGARDLESSOFTHEINPUTSGIVENTHECAMERAREMAINSONUNTILYOUCLICKTHEREDSTOPBUTTONYOURPROGRAMRUNSTHESTOPALLBLOCKORYOUTURNITOFFEXPLICITLYWITHTHEBLOCKTHEVIDEOIMAGEONTHESTAGEISPARTLYGHOSTEDTOANEXTENTDETERMINEDBYTHESETVIDEOTRANSPARENCYBLOCKWHOSEINPUTREALLYISTRANSPARENCYANDNOTOPACITYSMALLNUMBERSMAKETHEVIDEOMOREVISIBLEBYDEFAULTTHEVIDEOIMAGEISMIRROREDLIKETHESELFIECAMERAONYOURCELLPHONEWHENYOURAISEYOURLEFTHANDYOURIMAGERAISESITSRIGHTHANDYOUCANCONTROLTHISMIRRORINGWITHTHEBLOCKTHEVIDEOSNAPONBLOCKTHENTAKESASTILLPICTUREFROMTHECAMERAANDTRIMSITTOFITONTHESELECTEDSPRITEVIDEOSNAPONSTAGEMEANSTOUSETHEENTIRESTAGESIZEDRECTANGLEFOREXAMPLEHERESACAMERASNAPSHOTTRIMMEDTOFITALONZOTHEVIDEOCAPTUREPROJECTINTHEEXAMPLESCOLLECTIONREPEATEDLYTAKESSUCHTRIMMEDSNAPSHOTSANDHASTHEALONZOSPRITEUSETHECURRENTSNAPSHOTASITSCOSTUMESOITLOOKSLIKETHISTHEPICTUREABOVEWASACTUALLYTAKENWITHTRANSPARENCYSETTOTOMAKETHEBACKGROUNDMOREVISIBLEFORPRINTINGBECAUSETHESPRITEISALWAYSSTILLINTHEPLACEWHERETHESNAPSHOTWASTAKENITSCOSTUMEEXACTLYFITSINWITHTHERESTOFTHEFULLSTAGEVIDEOIFYOUWERETOADDAMOVESTEPSBLOCKAFTERTHESWITCHTOCOSTUMEYOUDSEESOMETHINGLIKETHISTHISTIMETHESPRITESCOSTUMEWASCAPTUREDATONEPOSITIONANDTHENTHESPRITEISSHOWNATADIFFERENTPOSITIONYOUPROBABLYWOULDNTWANTTODOTHISBUTPERHAPSITSHELPFULFOREXPLANATORYPURPOSESWHATYOUWOULDWANTTODOISPUSHTHESPRITEAROUNDTHESTAGEREALLYTHESESHOULDBEJENSSPICTUREITSHISPROJECTBUTHESVACATIONINGVIDEOMOTIONCOMPARESTWOSNAPSHOTSAMOMENTAPARTLOOKINGONLYATTHEPARTWITHINTHEGIVENTRIMHEREMYSELFMEANINGTHECURRENTSPRITENOTTHEPERSONLOOKINGINTOTHECAMERATODETECTADIFFERENCEBETWEENTHEMITREPORTSANUMBERMEASURINGTHENUMBEROFPIXELSTHROUGHWHICHSOMEPARTOFTHEPICTUREHASMOVEDVIDEODIRECTIONALSOCOMPARESTWOSNAPSHOTSTODETECTMOTIONBUTWHATITREPORTSISTHEDIRECTIONINTHEPOINTINDIRECTIONSENSEOFTHEMOTIONSOTHESCRIPTABOVEMOVESTHESPRITEINTHEDIRECTIONINWHICHITSBEINGPUSHEDBUTONLYIFASIGNIFICANTAMOUNTOFMOTIONISFOUNDOTHERWISETHESPRITEWOULDJIGGLEAROUNDTOOMUCHANDYESYOUCANRUNTHESECONDSCRIPTWITHOUTTHEFIRSTTOPUSHABALLOONAROUNDTHESTAGEMEDIACOMPUTATIONWITHSOUNDSTHESTARTINGPOINTFORCOMPUTATIONWITHSOUNDISTHEMICROPHONEBLOCKITSTARTSBYRECORDINGABRIEFBURSTOFSOUNDFROMYOURMICROPHONEHOWBRIEFONMYCOMPUTERSECONDSBUTYOULLSEESHORTLYHOWTOFINDOUTORCONTROLTHESAMPLESIZEONYOURCOMPUTERJUSTASTHEPIXELISTHESMALLESTPIECEOFAPICTURETHESAMPLEISTHESMALLESTPIECEOFASOUNDITSAYSHERETHATONMYCOMPUTERSAMPLESARERECORDEDPERSECONDSOEACHSAMPLEISOFASECONDTHEVALUEOFASAMPLEISBETWEENANDANDREPRESENTSTHESOUNDPRESSUREONTHEMICROPHONEHOWHARDTHEAIRISPUSHINGATTHATINSTANTYOUCANSKIPTHENEXTPAGEORSOIFYOUKNOWABOUTFOURIERANALYSISHERESAPICTUREOFSAMPLESINTHISGRAPHTHEXAXISREPRESENTSTHETIMEATWHICHEACHSAMPLEWASMEASUREDTHEYAXISMEASURESTHEVALUEOFTHESAMPLEATTHATTIMETHEFIRSTOBVIOUSTHINGABOUTTHISGRAPHISTHATITHASALOTOFUPSANDDOWNSTHEMOSTBASICUPANDDOWNFUNCTIONISTHESINEWAVEEVERYPERIODICFUNCTIONMOREORLESSANYSAMPLETHATSOUNDSLIKEMUSICRATHERTHANSOUNDINGLIKESTATICISCOMPOSEDOFASUMOFSINEWAVESOFDIFFERENTFREQUENCIESLOOKBACKATTHEGRAPHOFOURSAMPLEDSOUNDTHEREISAGREENDOTEVERYSEVENSAMPLESTHERESNOTHINGMAGICABOUTTHENUMBERSEVENITRIEDDIFFERENTVALUESUNTILIFOUNDONETHATLOOKEDRIGHTWHATRIGHTMEANSISTHATFORTHEFIRSTFEWDOTSATLEASTTHEYCOINCIDEALMOSTPERFECTLYWITHTHEHIGHPOINTSANDLOWPOINTSOFTHEGRAPHNEARTHEMIDDLEHORIZONTALLYOFTHEGRAPHTHEGREENDOTSDONTSEEMANYWHERENEARTHEHIGHANDLOWPOINTSBUTIFYOUFINDTHEVERYLOWESTPOINTOFTHEGRAPHABOUTOFTHEWAYALONGTHEDOTSSTARTLININGUPALMOSTPERFECTLYAGAINTHEREDGRAPHABOVESHOWSTWOCYCLESOFASINEWAVEONECYCLEGOESUPTHENDOWNTHENUPAGAINTHEAMOUNTOFTIMETAKENFORONECYCLEISTHEPERIODOFTHESINEFUNCTIONIFTHEGREENDOTSMATCHBOTHUPSANDDOWNSINTHECAPTUREDSOUNDTHENTWODOTSSAMPLESOROFASECONDREPRESENTTHEPERIODTHEFIRSTCYCLEANDAHALFOFTHEGRAPHLOOKSLIKEITCOULDBEAPURESINEWAVEBUTAFTERTHATTHETOPSANDBOTTOMSDONTLINEUPANDTHEREAREPECULIARLITTLEJIGGLESSUCHASTHEONEBEFORETHEFIFTHGREENDOTTHISHAPPENSBECAUSESINEWAVESOFDIFFERENTPERIODSAREADDEDTOGETHERITTURNSOUTTOBEMOREUSEFULTOMEASURETHERECIPROCALOFTHEPERIODINOURCASEORABOUTCYCLESPERSECONDANOTHERNAMEFORCYCLESPERSECONDISHERTZABBREVIATEDHZSOOURSOUNDHASACOMPONENTATHZASAMUSICALNOTETHATSABOUTANAALITTLEFLATFOUROCTAVESABOVEMIDDLECDONTWORRYTOOMUCHABOUTTHENOTEBEINGALITTLEOFFREMEMBERTHATTHESAMPLEPERIODWASJUSTEYEBALLEDANDISUNLIKELYTOBEEXACTLYRIGHTFOUROCTAVESABOVEMIDDLECISREALLYHIGHTHATWOULDBEASHRILLSOUNDINGNOTEBUTREMEMBERTHATACOMPLEXWAVEFORMISTHESUMOFMULTIPLESINEWAVESATDIFFERENTFREQUENCYHERESADIFFERENTUPANDDOWNREGULARITYITSNOTOBVIOUSBUTINTHELEFTPARTOFTHEGRAPHTHESIGNALISMOREABOVETHEXAXISTHANBELOWITTOWARDTHERIGHTITSEEMSTOBEMOREBELOWTHANABOVETHEAXISATTHEVERYRIGHTITLOOKSLIKEITMIGHTBECLIMBINGAGAINTHEPERIODOFTHEREDSINEWAVEISSAMPLESORSECONDTHATSAFREQUENCYOFABOUTHZABOUTDBELOWMIDDLECAGAINTHISISMEASURINGBYEYEBALLBUTLIKELYTOBECLOSETOTHERIGHTFREQUENCYALLTHISEYEBALLINGDOESNTSEEMVERYSCIENTIFICCANTWEJUSTGETTHECOMPUTERTOFINDALLTHERELEVANTFREQUENCIESYESWECANUSINGAMATHEMATICALTECHNIQUECALLEDFOURIERANALYSISJEANBAPTISTEJOSEPHFOURIERMADEMANYCONTRIBUTIONSTOMATHEMATICSANDPHYSICSBUTISBESTKNOWNFORWORKINGOUTTHENATUREOFPERIODICFUNCTIONSASASUMOFSINEWAVESLUCKILYWEDONTHAVETODOTHEMATHTHEMICROPHONEBLOCKWILLDOITFORUSIFWEASKFORMICROPHONESPECTRUMTHESEAREFREQUENCYSPECTRAFROMSAMPLESOFTHREEDIFFERENTSONGSTHEMOSTOBVIOUSTHINGABOUTTHESEGRAPHSISTHATTHEIROVERALLSLOPEISDOWNWARDTHELOUDESTFREQUENCYISTHELOWESTFREQUENCYTHATSTYPICALOFMUSICTHENEXTTHINGTONOTICEISTHATTHERESAREGULARITYINTHESPACINGOFSPIKESINTHEGRAPHTHISISPARTLYJUSTANARTIFACTTHEFREQUENCYHORIZONTALAXISISNTCONTINUOUSTHEREAREAFINITENUMBEROFBUCKETSDEFAULTANDALLTHEFREQUENCIESWITHINABUCKETCONTRIBUTETOTHEAMPLITUDEVERTICALAXISOFTHATBUCKETTHESPECTRUMISALISTOFTHATMANYAMPLITUDESBUTTHEPATTERNSOFALTERNATINGRISINGANDFALLINGVALUESAREREALTHEFREQUENCIESTHATAREMULTIPLESOFTHEMAINNOTEBEINGSAMPLEDWILLHAVEHIGHERAMPLITUDETHANOTHERFREQUENCIESSAMPLESANDSPECTRUMARETHETWOMOSTDETAILEDREPRESENTATIONSOFASOUNDBUTTHEMICROPHONEBLOCKHASOTHERSIMPLEROPTIONSALSOVOLUMETHEINSTANTANEOUSVOLUMEWHENTHEBLOCKISCALLEDNOTETHEMIDINOTENUMBERASINPLAYNOTEOFTHEMAINNOTEHEARDFREQUENCYTHEFREQUENCYINHZOFTHEMAINNOTEHEARDSAMPLERATETHENUMBEROFSAMPLESBEINGCOLLECTEDPERSECONDRESOLUTIONTHESIZEOFTHEARRAYINWHICHDATAARECOLLECTEDTYPICALLYMUSTBEAPOWEROFTHEBLOCKFORSOUNDSTHATCORRESPONDSTONEWPICTUREFORPICTURESISITSFIRSTINPUTISALISTOFSAMPLESANDITSSECONDINPUTSPECIFIESHOWMANYSAMPLESOCCUPYONESECONDVIIIOOPWITHPROCEDURESTHEIDEAOFOBJECTORIENTEDPROGRAMMINGISOFTENTAUGHTINAWAYTHATMAKESITSEEMASIFASPECIALOBJECTORIENTEDPROGRAMMINGLANGUAGEISNECESSARYINFACTANYLANGUAGEWITHFIRSTCLASSPROCEDURESANDLEXICALSCOPEALLOWSOBJECTSTOBEIMPLEMENTEDEXPLICITLYTHISISAUSEFULEXERCISETOHELPDEMYSTIFYOBJECTSTHECENTRALIDEAOFTHISIMPLEMENTATIONISTHATANOBJECTISREPRESENTEDASADISPATCHPROCEDURETHATTAKESAMESSAGEASINPUTANDREPORTSTHECORRESPONDINGMETHODINTHISSECTIONWESTARTWITHASTRIPPEDDOWNEXAMPLETOSHOWHOWLOCALSTATEWORKSANDBUILDUPTOFULLIMPLEMENTATIONSOFCLASSINSTANCEANDPROTOTYPINGOOPALOCALSTATEWITHSCRIPTVARIABLESTHISSCRIPTIMPLEMENTSANOBJECTCLASSATYPEOFOBJECTNAMELYTHECOUNTERCLASSINTHISFIRSTSIMPLIFIEDVERSIONTHEREISONLYONEMETHODSONOEXPLICITMESSAGEPASSINGISNECESSARYWHENTHEMAKEACOUNTERBLOCKISCALLEDITREPORTSAPROCEDURETHERINGEDSCRIPTINSIDEITSBODYTHATPROCEDUREIMPLEMENTSASPECIFICCOUNTEROBJECTANINSTANCEOFTHECOUNTERCLASSWHENINVOKEDACOUNTERINSTANCEINCREASESANDREPORTSITSCOUNTVARIABLEEACHCOUNTERHASITSOWNLOCALCOUNTTHISEXAMPLEWILLREPAYCAREFULSTUDYBECAUSEITISNTOBVIOUSWHYEACHINSTANCEHASASEPARATECOUNTFROMTHEPOINTOFVIEWOFTHEMAKEACOUNTERPROCEDUREEACHINVOCATIONCAUSESANEWCOUNTVARIABLETOBECREATEDUSUALLYSUCHSCRIPTVARIABLESARETEMPORARYGOINGOUTOFEXISTENCEWHENTHESCRIPTENDSBUTTHISONEISSPECIALBECAUSEMAKEACOUNTERRETURNSANOTHERSCRIPTTHATMAKESREFERENCETOTHECOUNTVARIABLESOITREMAINSACTIVETHESCRIPTVARIABLESBLOCKMAKESVARIABLESLOCALTOASCRIPTITCANBEUSEDINASPRITESSCRIPTAREAORINTHEBLOCKEDITORSCRIPTVARIABLESCANBEEXPORTEDBYBEINGUSEDINAREPORTEDPROCEDUREASHEREINTHISAPPROACHTOOOPWEAREREPRESENTINGBOTHCLASSESANDINSTANCESASPROCEDURESTHEMAKEACOUNTERBLOCKREPRESENTSTHECLASSWHILEEACHINSTANCEISREPRESENTEDBYANAMELESSSCRIPTCREATEDEACHTIMEMAKEACOUNTERISCALLEDTHESCRIPTVARIABLESCREATEDINSIDETHEMAKEACOUNTERBLOCKBUTOUTSIDETHERINGAREINSTANCEVARIABLESBELONGINGTOAPARTICULARCOUNTERBMESSAGESANDDISPATCHPROCEDURESINTHESIMPLIFIEDCLASSABOVETHEREISONLYONEMETHODANDSOTHEREARENOMESSAGESYOUJUSTCALLTHEINSTANCETOCARRYOUTITSONEMETHODHEREISAMOREREFINEDVERSIONTHATUSESMESSAGEPASSINGAGAINTHEMAKEACOUNTERBLOCKREPRESENTSTHECOUNTERCLASSANDAGAINTHESCRIPTCREATESALOCALVARIABLECOUNTEACHTIMEITISINVOKEDTHELARGEOUTERRINGREPRESENTSANINSTANCEITISADISPATCHPROCEDUREITTAKESAMESSAGEJUSTATEXTWORDASINPUTANDITREPORTSAMETHODTHETWOSMALLERRINGSARETHEMETHODSTHETOPONEISTHENEXTMETHODTHEBOTTOMONEISTHERESETMETHODTHELATTERREQUIRESANINPUTNAMEDVALUEINTHEEARLIERVERSIONCALLINGTHEINSTANCEDIDTHEENTIREJOBINTHISVERSIONCALLINGTHEINSTANCEGIVESACCESSTOAMETHODWHICHMUSTTHENBECALLEDTOFINISHTHEJOBWECANPROVIDEABLOCKTODOBOTHPROCEDURECALLSINONETHEASKBLOCKHASTWOREQUIREDINPUTSANOBJECTANDAMESSAGEITALSOACCEPTSOPTIONALADDITIONALINPUTSWHICHSNAPPUTSINALISTTHATLISTISNAMEDARGSINSIDETHEBLOCKASKHASTWONESTEDCALLBLOCKSTHEINNERONECALLSTHEOBJECTIETHEDISPATCHPROCEDURETHEDISPATCHPROCEDUREALWAYSTAKESEXACTLYONEINPUTNAMELYTHEMESSAGEITREPORTSAMETHODWHICHMAYTAKEANYNUMBEROFINPUTSNOTETHATTHISISTHESITUATIONINWHICHWEDROPALISTOFVALUESONTOTHEARROWHEADSOFAMULTIPLEINPUTINTHEOUTERCALLBLOCKNOTEALSOTHATTHISISONEOFTHERARECASESINWHICHWEMUSTUNRINGIFYTHEINNERCALLBLOCKWHOSEVALUEWHENCALLEDGIVESTHEMETHODCINHERITANCEVIADELEGATIONSOOUROBJECTSNOWHAVELOCALSTATEVARIABLESANDMESSAGEPASSINGWHATABOUTINHERITANCEWECANPROVIDETHATCAPABILITYUSINGTHETECHNIQUEOFDELEGATIONEACHINSTANCEOFTHECHILDCLASSCONTAINSANINSTANCEOFTHEPARENTCLASSANDSIMPLYPASSESONTHEMESSAGESITDOESNTWANTTOSPECIALIZETHISSCRIPTIMPLEMENTSTHEBUZZERCLASSWHICHISACHILDOFCOUNTERINSTEADOFHAVINGACOUNTANUMBERASALOCALSTATEVARIABLEEACHBUZZERHASACOUNTERANOBJECTASALOCALSTATEVARIABLETHECLASSSPECIALIZESTHENEXTMETHODREPORTINGWHATTHECOUNTERREPORTSUNLESSTHATRESULTISDIVISIBLEBYINWHICHCASEITREPORTSBUZZYEAHITSHOULDALSOCHECKFORADIGITINTHENUMBERBUTTHISCODEISCOMPLICATEDENOUGHALREADYIFTHEMESSAGEISANYTHINGOTHERTHANNEXTTHOUGHSUCHASRESETTHENTHEBUZZERSIMPLYINVOKESITSCOUNTERSDISPATCHPROCEDURESOTHECOUNTERHANDLESANYMESSAGETHATTHEBUZZERDOESNTHANDLEEXPLICITLYNOTETHATINTHENONNEXTCASEWECALLTHECOUNTERNOTASKITSOMETHINGBECAUSEWEWANTTOREPORTAMETHODNOTTHEVALUETHATTHEMESSAGEREPORTSSOIFWEASKABUZZERTORESETTOAVALUEDIVISIBLEBYITWILLENDUPREPORTINGTHATNUMBERNOTBUZZDANIMPLEMENTATIONOFPROTOTYPINGOOPINTHECLASSINSTANCESYSTEMABOVEITISNECESSARYTODESIGNTHECOMPLETEBEHAVIOROFACLASSBEFOREYOUCANMAKEANYINSTANCESOFTHECLASSTHISISOKAYFORTOPDOWNDESIGNBUTNOTGREATFOREXPERIMENTATIONHEREWESKETCHTHEIMPLEMENTATIONOFAPROTOTYPINGOOPSYSTEMYOUMAKEANOBJECTTINKERWITHITMAKECLONESOFITANDKEEPTINKERINGANYCHANGESYOUMAKEINTHEPARENTAREINHERITEDBYITSCHILDRENINEFFECTTHATFIRSTOBJECTISBOTHTHECLASSANDANINSTANCEOFTHECLASSINTHEIMPLEMENTATIONBELOWCHILDRENSHAREPROPERTIESMETHODSANDLOCALVARIABLESOFTHEIRPARENTUNLESSANDUNTILACHILDCHANGESAPROPERTYATWHICHPOINTTHATCHILDGETSAPRIVATECOPYIFACHILDWANTSTOCHANGESOMETHINGFORITSENTIREFAMILYITMUSTASKTHEPARENTTODOITBECAUSEWEWANTTOBEABLETOCREATEANDDELETEPROPERTIESDYNAMICALLYWEWONTUSESNAPVARIABLESTOHOLDANOBJECTSVARIABLESORMETHODSINSTEADEACHOBJECTHASTWOTABLESCALLEDMETHODSANDDATAEACHOFWHICHISANASSOCIATIONLISTALISTOFTWOITEMLISTSINWHICHEACHOFTHELATTERCONTAINSAKEYANDACORRESPONDINGVALUEWEPROVIDEALOOKUPPROCEDURETOLOCATETHEKEYVALUEPAIRCORRESPONDINGTOAGIVENKEYINAGIVENTABLETHEREAREALSOCOMMANDSTOINSERTANDDELETEENTRIESASINTHECLASSINSTANCEVERSIONANOBJECTISREPRESENTEDASADISPATCHPROCEDURETHATTAKESAMESSAGEASITSINPUTANDREPORTSTHECORRESPONDINGMETHODWHENANOBJECTGETSAMESSAGEITWILLFIRSTLOOKFORTHATKEYWORDINITSMETHODSTABLEIFITSFOUNDTHECORRESPONDINGVALUEISTHEMETHODWEWANTIFNOTTHEOBJECTLOOKSINITSDATATABLEIFAVALUEISFOUNDTHEREWHATTHEOBJECTRETURNSISNOTTHATVALUEBUTRATHERAREPORTERMETHODTHATWHENCALLEDWILLREPORTTHEVALUETHISMEANSTHATWHATANOBJECTRETURNSISALWAYSAMETHODIFTHEOBJECTHASNEITHERAMETHODNORADATUMWITHTHEDESIREDNAMEBUTITDOESHAVEAPARENTTHENTHEPARENTTHATISTHEPARENTSDISPATCHPROCEDUREISINVOKEDWITHTHEMESSAGEASITSINPUTEVENTUALLYEITHERAMATCHISFOUNDORANOBJECTWITHNOPARENTISFOUNDTHELATTERCASEISANERRORMEANINGTHATTHEUSERHASSENTTHEOBJECTAMESSAGENOTINITSREPERTOIREMESSAGESCANTAKEANYNUMBEROFINPUTSASINTHECLASSINSTANCESYSTEMBUTINTHEPROTOTYPINGVERSIONEVERYMETHODAUTOMATICALLYGETSTHEOBJECTTOWHICHTHEMESSAGEWASORIGINALLYSENTASANEXTRAFIRSTINPUTWEMUSTDOTHISSOTHATIFAMETHODISFOUNDINTHEPARENTORGRANDPARENTETCOFTHEORIGINALRECIPIENTANDTHATMETHODREFERSTOAVARIABLEORMETHODITWILLUSETHECHILDSVARIABLEORMETHODIFTHECHILDHASITSOWNVERSIONTHECLONEOFBLOCKBELOWTAKESANOBJECTASITSINPUTANDMAKESACHILDOBJECTITSHOULDBECONSIDEREDASANINTERNALPARTOFTHEIMPLEMENTATIONTHEPREFERREDWAYTOMAKEACHILDOFANOBJECTISTOSENDTHATOBJECTACLONEMESSAGEEVERYOBJECTISCREATEDWITHPREDEFINEDMETHODSFORSETMETHODDELETEVARDELETEMETHODANDCLONEITHASONEPREDEFINEDVARIABLEPARENTOBJECTSWITHOUTAPARENTARECREATEDBYCALLINGNEWOBJECTASBEFOREWEPROVIDEPROCEDURESTOCALLANOBJECTSDISPATCHPROCEDUREANDTHENCALLTHEMETHODBUTINTHISVERSIONWEPROVIDETHEDESIREDOBJECTASTHEFIRSTMETHODINPUTWEPROVIDEONEPROCEDUREFORCOMMANDMETHODSANDONEFORREPORTERMETHODSREMEMBERTHATTHEINPUTLISTVARIANTOFTHERUNANDCALLBLOCKSISMADEBYDRAGGINGTHEINPUTEXPRESSIONOVERTHEARROWHEADSRATHERTHANOVERTHEINPUTSLOTTHESCRIPTBELOWDEMONSTRATESHOWTHISPROTOTYPINGSYSTEMCANBEUSEDTOMAKECOUNTERSWESTARTWITHONEPROTOTYPECOUNTERCALLEDCOUNTERWECOUNTTHISCOUNTERUPAFEWTIMESTHENCREATEACHILDCOUNTERANDGIVEITITSOWNCOUNTVARIABLEBUTNOTITSOWNTOTALVARIABLETHENEXTMETHODALWAYSSETSCOUNTERSTOTALVARIABLEWHICHTHEREFOREKEEPSCOUNTOFTHETOTALNUMBEROFTIMESTHATANYCOUNTERISINCREMENTEDRUNNINGTHISSCRIPTSHOULDSAYANDTHINKTHEFOLLOWINGLISTSIXTHEOUTSIDEWORLDTHEFACILITIESDISCUSSEDSOFARAREFINEFORPROJECTSTHATTAKEPLACEENTIRELYONYOURCOMPUTERSSCREENBUTYOUMAYWANTTOWRITEPROGRAMSTHATINTERACTWITHPHYSICALDEVICESSENSORSORROBOTSORWITHTHEWORLDWIDEWEBFORTHESEPURPOSESSNAPPROVIDESASINGLEPRIMITIVEBLOCKTHISMIGHTNOTSEEMLIKEENOUGHBUTINFACTITCANBEUSEDTOBUILDTHEDESIREDCAPABILITIESATHEWORLDWIDEWEBTHEINPUTTOTHEURLBLOCKISTHEURLUNIFORMRESOURCELOCATOROFAWEBPAGETHEBLOCKREPORTSTHEBODYOFTHEWEBSERVERSRESPONSEMINUSHTTPHEADERWITHOUTINTERPRETATIONTHISMEANSTHATINMOSTCASESTHERESPONSEISADESCRIPTIONOFTHEPAGEINHTMLHYPERTEXTMARKUPLANGUAGENOTATIONOFTENESPECIALLYFORCOMMERCIALWEBSITESTHEACTUALINFORMATIONYOURETRYINGTOFINDONTHEPAGEISACTUALLYATANOTHERURLINCLUDEDINTHEREPORTEDHTMLTHEWEBPAGEISTYPICALLYAVERYLONGTEXTSTRINGANDSOTHEPRIMITIVESPLITBLOCKISUSEFULTOGETTHETEXTINAMANAGEABLEFORMNAMELYASALISTOFLINESTHESECONDINPUTTOSPLITISTHECHARACTERTOBEUSEDTOSEPARATETHETEXTSTRINGINTOALISTOFLINESORONEOFASETOFCOMMONCASESSUCHASLINEWHICHSEPARATESONCARRIAGERETURNANDORNEWLINECHARACTERSTHISMIGHTBEAGOODPLACEFORAREMINDERTHATLISTVIEWWATCHERSSCROLLTHROUGHONLYITEMSATATIMETHEDOWNARROWNEARTHEBOTTOMRIGHTCORNEROFTHESPEECHBALLOONINTHEPICTUREPRESENTSAMENUOFHUNDREDITEMRANGESTHISMAYSEEMUNNECESSARYSINCETHESCROLLBARSHOULDALLOWFORANYNUMBEROFITEMSBUTDOINGITTHISWAYMAKESSNAPMUCHFASTERINTABLEVIEWTHEENTIRELISTISINCLUDEDIFYOUINCLUDEAPROTOCOLNAMEINTHEINPUTTOTHEURLBLOCKSUCHASHPORHPSTHATPROTOCOLWILLBEUSEDIFNOTTHEBLOCKFIRSTTRIESHTTPSANDTHENIFTHATFAILSHTTPASECURITYRESTRICTIONINJAVASCRIPTLIMITSTHEABILITYOFONEWEBSITETOINITIATECOMMUNICATIONWITHANOTHERSITETHEREISANOFFICIALWORKAROUNDFORTHISLIMITATIONCALLEDTHECORSPROTOCOLCROSSORIGINRESOURCESHARINGBUTTHETARGETSITEHASTOALLOWSNAPBERKELEYEDUEXPLICITLYANDOFCOURSEMOSTDONTTOGETAROUNDTHISPROBLEMYOUCANUSETHIRDPARTYSITESCORSPROXIESTHATARENOTLIMITEDBYJAVASCRIPTANDTHATFORWARDYOURREQUESTSBHARDWAREDEVICESANOTHERJAVASCRIPTSECURITYRESTRICTIONPREVENTSSNAPFROMHAVINGDIRECTACCESSTODEVICESCONNECTEDTOYOURCOMPUTERSUCHASSENSORSANDROBOTSMOBILEDEVICESSUCHASSMARTPHONESMAYALSOHAVEUSEFULDEVICESBUILTINSUCHASACCELEROMETERSANDGPSRECEIVERSTHEURLBLOCKISALSOUSEDTOINTERFACESNAPWITHTHESEEXTERNALCAPABILITIESTHEIDEAISTHATYOURUNASEPARATEPROGRAMTHATBOTHINTERFACESWITHTHEDEVICEANDPROVIDESALOCALHTTPSERVERTHATSNAPCANUSETOMAKEREQUESTSTOTHEDEVICEUNLIKESNAPITSELFTHESEPROGRAMSHAVEACCESSTOANYTHINGONYOURCOMPUTERSOYOUHAVETOTRUSTTHEAUTHOROFTHESOFTWAREOURWEBSITESNAPBERKELEYEDUPROVIDESLINKSTODRIVERSFORSEVERALDEVICESINCLUDINGATTHISWRITINGTHELEGONXTFINCHHUMMINGBIRDANDPARALLAXSROBOTSTHENINTENDOWIIMOTEANDLEAPMOTIONSENSORSTHEARDUINOMICROCOMPUTERANDSUPERAWESOMESYLVIASWATERCOLORBOTTHESAMESERVERTECHNIQUECANBEUSEDFORACCESSTOTHIRDPARTYSOFTWARELIBRARIESSUCHASTHESPEECHSYNTHESISPACKAGELINKEDONOURWEBSITEMOSTOFTHESEPACKAGESREQUIRESOMEEXPERTISETOINSTALLTHELINKSARETOSOURCECODEREPOSITORIESTHISSITUATIONWILLIMPROVEWITHTIMECDATEANDTIMETHECURRENTBLOCKINTHESENSINGPALETTECANBEUSEDTOFINDOUTTHECURRENTDATEORTIMEEACHCALLTOTHISBLOCKREPORTSONECOMPONENTOFTHEDATEORTIMESOYOUWILLPROBABLYCOMBINESEVERALCALLSLIKETHISFORAMERICANSORLIKETHISFOREUROPEANSXCONTINUATIONSBLOCKSAREUSUALLYUSEDWITHINASCRIPTTHECONTINUATIONOFABLOCKWITHINAPARTICULARSCRIPTISTHEPARTOFTHECOMPUTATIONTHATREMAINSTOBECOMPLETEDAFTERTHEBLOCKDOESITSJOBACONTINUATIONCANBEREPRESENTEDASARINGEDSCRIPTCONTINUATIONSAREALWAYSPARTOFTHEINTERPRETATIONOFANYPROGRAMINANYLANGUAGEBUTUSUALLYTHESECONTINUATIONSAREIMPLICITINTHEDATASTRUCTURESOFTHELANGUAGEINTERPRETERORCOMPILERMAKINGCONTINUATIONSEXPLICITISANADVANCEDBUTVERSATILEPROGRAMMINGTECHNIQUETHATALLOWSUSERSTOCREATECONTROLSTRUCTURESSUCHASNONLOCALEXITANDMULTITHREADINGINTHESIMPLESTCASETHECONTINUATIONOFACOMMANDBLOCKMAYJUSTBETHEPARTOFTHESCRIPTAFTERTHEBLOCKFOREXAMPLEINTHESCRIPTTHECONTINUATIONOFTHEMOVESTEPSBLOCKISBUTSOMESITUATIONSAREMORECOMPLICATEDFOREXAMPLEWHATISTHECONTINUATIONOFMOVESTEPSINTHEFOLLOWINGSCRIPTTHATSATRICKQUESTIONTHEMOVEBLOCKISRUNFOURTIMESANDITHASADIFFERENTCONTINUATIONEACHTIMETHEFIRSTTIMEITSCONTINUATIONISNOTETHATTHEREISNOREPEATBLOCKINTHEACTUALSCRIPTBUTTHECONTINUATIONHASTOREPRESENTTHEFACTTHATTHEREARETHREEMORETIMESTHROUGHTHELOOPTOGOTHEFOURTHTIMETHECONTINUATIONISJUSTWHATCOUNTSISNOTWHATSPHYSICALLYBELOWTHEBLOCKINTHESCRIPTBUTWHATCOMPUTATIONALWORKREMAINSTOBEDONETHISISASITUATIONINWHICHVISIBLECODEMAYBEALITTLEMISLEADINGWEHAVETOPUTAREPEATBLOCKINTHEPICTUREOFTHECONTINUATIONBUTTHEACTUALCONTINUATIONISMADEFROMTHEEVALUATORSINTERNALBOOKKEEPINGOFWHEREITSUPTOINASCRIPTSOITSREALLYTHEORIGINALSCRIPTPLUSSOMEEXTRAINFORMATIONBUTTHEPICTURESHEREDOCORRECTLYREPRESENTWHATWORKTHEPROCESSSTILLHASLEFTTODOWHENABLOCKISUSEDINSIDEACUSTOMBLOCKITSCONTINUATIONMAYINCLUDEPARTSOFMORETHANONESCRIPTFOREXAMPLEIFWEMAKEACUSTOMSQUAREBLOCKANDTHENUSETHATBLOCKINASCRIPTTHENTHECONTINUATIONOFTHEFIRSTUSEOFMOVESTEPSISINWHICHPARTCOMESFROMINSIDETHESQUAREBLOCKANDPARTCOMESFROMTHECALLTOSQUARENEVERTHELESSORDINARILYWHENWEDISPLAYACONTINUATIONWESHOWONLYTHEPARTWITHINTHECURRENTSCRIPTTHECONTINUATIONOFACOMMANDBLOCKASWEVESEENISASIMPLESCRIPTWITHNOINPUTSLOTSBUTTHECONTINUATIONOFAREPORTERBLOCKHASTODOSOMETHINGWITHTHEVALUEREPORTEDBYTHEBLOCKSOITTAKESTHATVALUEASINPUTFOREXAMPLEINTHESCRIPTTHECONTINUATIONOFTHEBLOCKISOFCOURSETHENAMERESULTINTHATPICTUREISARBITRARYANYNAMECOULDBEUSEDORNONAMEATALLBYUSINGTHEEMPTYSLOTNOTATIONFORINPUTSUBSTITUTIONACONTINUATIONPASSINGSTYLELIKEALLPROGRAMMINGLANGUAGESSNAPEVALUATESCOMPOSITIONSOFNESTEDREPORTERSFROMTHEINSIDEOUTFOREXAMPLEINTHEEXPRESSIONSNAPFIRSTADDSANDTHENMULTIPLIESBYTHATSUMTHISOFTENMEANSTHATTHEORDERINWHICHTHEOPERATIONSAREDONEISBACKWARDSFROMTHEORDERINWHICHTHEYAPPEARINTHEEXPRESSIONWHENREADINGTHEABOVEEXPRESSIONYOUSAYTIMESBEFOREYOUSAYPLUSINENGLISHINSTEADOFSAYINGTHREETIMESFOURPLUSFIVEWHICHACTUALLYMAKESTHEORDEROFOPERATIONSAMBIGUOUSYOUCOULDSAYTAKETHESUMOFFOURANDFIVEANDTHENTAKETHEPRODUCTOFTHREEANDTHATSUMTHISSOUNDSMOREAWKWARDBUTITHASTHEVIRTUEOFPUTTINGTHEOPERATIONSINTHEORDERINWHICHTHEYREACTUALLYPERFORMEDTHATMAYSEEMLIKEOVERKILLINASIMPLEEXPRESSIONBUTSUPPOSEYOURETRYINGTOCONVEYTHEEXPRESSIONTOAFRIENDOVERTHEPHONEIFYOUSAYFACTORIALOFTHREETIMESFACTORIALOFTWOPLUSTWOPLUSFIVEYOUMIGHTMEANANYOFTHESEWOULDNTITBEBETTERTOSAYADDTWOANDTWOTAKETHEFACTORIALOFTHATADDFIVETOTHATMULTIPLYTHREEBYTHATANDTAKETHEFACTORIALOFTHERESULTWECANDOASIMILARREORDERINGOFANEXPRESSIONIFWEFIRSTDEFINEVERSIONSOFALLTHEREPORTERSTHATTAKETHEIRCONTINUATIONASANEXPLICITINPUTINTHEFOLLOWINGPICTURENOTICETHATTHENEWBLOCKSARECOMMANDSNOTREPORTERSWECANCHECKTHATTHESEBLOCKSGIVETHERESULTSWEWANTTHEORIGINALEXPRESSIONCANNOWBEREPRESENTEDASIFYOUREADTHISTOPTOBOTTOMDONTYOUGETADDTWOANDTWOTAKETHEFACTORIALOFTHATADDFIVETOTHATMULTIPLYTHREEBYTHATANDTAKETHEFACTORIALOFTHERESULTJUSTWHATWEWANTEDTHISWAYOFWORKINGINWHICHEVERYBLOCKISACOMMANDTHATTAKESACONTINUATIONASONEOFITSINPUTSISCALLEDCONTINUATIONPASSINGSTYLECPSOKAYITLOOKSHORRIBLEBUTITHASSUBTLEVIRTUESONEOFTHEMISTHATEACHSCRIPTISJUSTONEBLOCKLONGWITHTHERESTOFTHEWORKBURIEDINTHECONTINUATIONGIVENTOTHATONEBLOCKSOEACHBLOCKDOESNTHAVETOREMEMBERWHATELSETODOINTHEVOCABULARYOFTHISSECTIONTHEIMPLICITCONTINUATIONOFEACHBLOCKISEMPTYINSTEADOFTHEUSUALPICTUREOFRECURSIONWITHABUNCHOFLITTLEPEOPLEALLWAITINGFOREACHOTHERWITHCPSWHATHAPPENSISTHATEACHLITTLEPERSONHANDSOFFTHEPROBLEMTOTHENEXTONEANDGOESTOTHEBEACHSOTHERESONLYONEACTIVELITTLEPERSONATATIMEINTHISEXAMPLEWESTARTWITHALFREDANADDSPECIALISTWHOCOMPUTESTHEVALUEANDTHENHANDSOFFTHERESTOFTHEPROBLEMTOFRANCINEAFACTORIALSPECIALISTSHECOMPUTESTHEVALUETHENHANDSTHEPROBLEMOFFTOANNEANOTHERADDSPECIALISTWHOCOMPUTESANDSOONUNTILFINALLYSAMASAYSPECIALISTSAYSTHEVALUEWHICHISAVERYLARGENUMBERGOBACKTOTHEDEFINITIONSOFTHESEBLOCKSTHEONESSUCHASADDTHATCORRESPONDTOPRIMITIVEREPORTERSARESIMPLETHEYJUSTCALLTHEREPORTERANDTHENCALLTHEIRCONTINUATIONWITHITSRESULTBUTTHEDEFINITIONOFFACTORIALISMOREINTERESTINGITDOESNTJUSTCALLOURORIGINALFACTORIALREPORTERANDSENDTHERESULTTOITSCONTINUATIONCPSISUSEDINSIDEFACTORIALTOOITSAYSSEEIFMYINPUTISZEROSENDTHETRUEORFALSERESULTTOIFIFTHERESULTISTRUETHENCALLMYCONTINUATIONWITHTHEVALUEOTHERWISESUBTRACTFROMMYINPUTSENDTHERESULTOFTHATTOFACTORIALWITHACONTINUATIONTHATMULTIPLIESTHESMALLERNUMBERSFACTORIALBYMYORIGINALINPUTFINALLYCALLMYCONTINUATIONWITHTHEPRODUCTYOUCANUSECPSTOUNWINDEVENTHEMOSTCOMPLICATEDBRANCHEDRECURSIONSBYTHEWAYICHEATEDABITABOVETHEIFELSEBLOCKSHOULDALSOUSECPSITSHOULDTAKEONETRUEFALSEINPUTANDTWOCONTINUATIONSITWILLGOTOONEORTHEOTHERCONTINUATIONDEPENDINGONTHEVALUEOFITSINPUTBUTINFACTTHECSHAPEDBLOCKSORESHAPEDLIKEIFELSEAREREALLYUSINGCPSINTHEFIRSTPLACEBECAUSETHEYIMPLICITLYWRAPRINGSAROUNDTHESUBSCRIPTSWITHINTHEIRBRANCHESSEEIFYOUCANMAKEANEXPLICITLYCPSIFELSEBLOCKBCALLRUNWCONTINUATIONTOUSEEXPLICITCONTINUATIONPASSINGSTYLEWEHADTODEFINESPECIALVERSIONSOFALLTHEREPORTERSADDANDSOONSNAPPROVIDESAPRIMITIVEMECHANISMFORCAPTURINGCONTINUATIONSWHENWENEEDTOWITHOUTUSINGCONTINUATIONPASSINGTHROUGHOUTAPROJECTHERESTHECLASSICEXAMPLEWEWANTTOWRITEARECURSIVEBLOCKTHATTAKESALISTOFNUMBERSASINPUTANDREPORTSTHEPRODUCTOFALLTHENUMBERSBUTWECANIMPROVETHEEFFICIENCYOFTHISBLOCKINTHECASEOFALISTTHATINCLUDESAZEROASSOONASWESEETHEZEROWEKNOWTHATTHEENTIREPRODUCTISZEROBUTTHISISNOTASEFFICIENTASITMIGHTSEEMCONSIDERASANEXAMPLETHELISTWEFINDTHEZEROONTHETHIRDRECURSIVECALLTHEFOURTHCALLALTOGETHERASTHEFIRSTITEMOFTHESUBLISTWHATISTHECONTINUATIONOFTHEREPORTBLOCKITSEVENTHOUGHWEALREADYKNOWTHATRESULTISZEROWEREGOINGTODOTHREEUNNECESSARYMULTIPLICATIONSWHILEUNWINDINGTHERECURSIVECALLSWECANIMPROVEUPONTHISBYCAPTURINGTHECONTINUATIONOFTHETOPLEVELCALLTOPRODUCTTHEBLOCKTAKESASITSINPUTAONEINPUTSCRIPTASSHOWNINTHEPRODUCTEXAMPLEITCALLSTHATSCRIPTWITHTHECONTINUATIONOFTHECALLWITHCONTINUATIONBLOCKITSELFASITSINPUTINTHISCASETHATCONTINUATIONISREPORTINGTOWHICHEVERSCRIPTCALLEDPRODUCTIFTHEINPUTLISTDOESNTINCLUDEAZEROTHENNOTHINGISEVERDONEWITHTHATCONTINUATIONANDTHISVERSIONWORKSJUSTLIKETHEORIGINALPRODUCTBUTIFTHEINPUTLISTISTHENTHREERECURSIVECALLSAREMADETHEZEROISSEENANDPRODUCTHELPERRUNSTHECONTINUATIONWITHANINPUTOFTHECONTINUATIONIMMEDIATELYREPORTSTHATTOTHECALLEROFPRODUCTWITHOUTUNWINDINGALLTHERECURSIVECALLSANDWITHOUTTHEUNNECESSARYMULTIPLICATIONSICOULDHAVEWRITTENPRODUCTALITTLEMORESIMPLYUSINGAREPORTERRINGINSTEADOFACOMMANDRINGBUTITSCUSTOMARYTOUSEASCRIPTTOREPRESENTTHEINPUTTOCALLWCONTINUATIONBECAUSEVERYOFTENTHATINPUTTAKESTHEFORMSOTHATTHECONTINUATIONISSAVEDPERMANENTLYANDCANBECALLEDFROMANYWHEREINTHEPROJECTTHATSWHYTHEINPUTSLOTINCALLWCONTINUATIONHASACOMMANDRINGRATHERTHANAREPORTERRINGFIRSTCLASSCONTINUATIONSAREANEXPERIMENTALFEATUREINSNAPANDTHEREAREMANYKNOWNLIMITATIONSINITONEISTHATTHEDISPLAYOFREPORTERCONTINUATIONSSHOWSONLYTHESINGLEBLOCKINWHICHTHECALLWCONTINUATIONISANINPUTNONLOCALEXITMANYPROGRAMMINGLANGUAGESHAVEABREAKCOMMANDTHATCANBEUSEDINSIDEALOOPINGCONSTRUCTSUCHASREPEATTOENDTHEREPETITIONEARLYUSINGFIRSTCLASSCONTINUATIONSWECANGENERALIZETHISMECHANISMTOALLOWNONLOCALEXITEVENWITHINABLOCKCALLEDFROMINSIDEALOOPORTHROUGHSEVERALLEVELSOFNESTEDLOOPSTHEUPVARBREAKHASASITSVALUEACONTINUATIONTHATCANBECALLEDFROMANYWHEREINTHEPROGRAMTOJUMPIMMEDIATELYTOWHATEVERCOMESAFTERTHECATCHBLOCKINITSSCRIPTHERESANEXAMPLEWITHTWONESTEDINVOCATIONSOFCATCHWITHTHEUPVARRENAMEDINTHEOUTERONEASSHOWNTHISWILLSAYTHENTHENTHENEXITBOTHNESTEDCATCHESANDTHINKHMMIFINTHERUNBLOCKTHEVARIABLEBREAKISUSEDINSTEADOFOUTERTHENTHESCRIPTWILLSAYANDHELLOBEFORETHINKINGHMMTHEREARECORRESPONDINGCATCHANDTHROWBLOCKSFORREPORTERSTHECATCHBLOCKISAREPORTERTHATTAKESANEXPRESSIONASINPUTINSTEADOFACSHAPEDSLOTBUTTHETHROWBLOCKISACOMMANDITDOESNTREPORTAVALUETOITSOWNCONTINUATIONBUTINSTEADREPORTSAVALUEWHICHITTAKESASANADDITIONALINPUTINADDITIONTOTHECATCHTAGTOTHECORRESPONDINGCATCHBLOCKSCONTINUATIONWITHOUTTHETHROWTHEINNERCALLREPORTSTHEBLOCKREPORTSSOTHECATCHBLOCKREPORTSANDTHEBLOCKREPORTSWITHTHETHROWTHEINNERCALLDOESNTREPORTATALLANDNEITHERDOESTHEBLOCKTHETHROWBLOCKSINPUTOFBECOMESTHEVALUEREPORTEDBYTHECATCHBLOCKANDTHEBLOCKMULTIPLIESANDCREATINGATHREADSYSTEMSNAPCANBERUNNINGSEVERALSCRIPTSATONCEWITHINASINGLESPRITEANDACROSSMANYSPRITESIFYOUONLYHAVEONECOMPUTERHOWCANITDOMANYTHINGSATONCETHEANSWERISTHATONLYONEISACTUALLYRUNNINGATANYMOMENTBUTSNAPSWITCHESITSATTENTIONFROMONESCRIPTTOANOTHERFREQUENTLYATTHEBOTTOMOFEVERYLOOPINGBLOCKREPEATREPEATUNTILFOREVERTHEREISANIMPLICITYIELDCOMMANDWHICHREMEMBERSWHERETHECURRENTSCRIPTISUPTOANDSWITCHESTOSOMEOTHERSCRIPTEACHINTURNATTHEENDOFEVERYSCRIPTISANIMPLICITENDTHREADCOMMANDATHREADISTHETECHNICALTERMFORTHEPROCESSOFRUNNINGASCRIPTWHICHSWITCHESTOANOTHERSCRIPTWITHOUTREMEMBERINGTHEOLDONESINCETHISALLHAPPENSAUTOMATICALLYTHEREISGENERALLYNONEEDFORTHEUSERTOTHINKABOUTTHREADSBUTJUSTTOSHOWTHATTHISTOOISNOTMAGICHEREISANIMPLEMENTATIONOFASIMPLETHREADSYSTEMITUSESAGLOBALVARIABLENAMEDTASKSTHATINITIALLYCONTAINSANEMPTYLISTEACHUSEOFTHECSHAPEDTHREADBLOCKADDSACONTINUATIONTHERINGEDSCRIPTTOTHELISTTHEYIELDBLOCKUSESRUNWCONTINUATIONTOCREATEACONTINUATIONFORAPARTLYDONETHREADADDSITTOTHETASKLISTANDTHENRUNSTHEFIRSTWAITINGTASKTHEENDTHREADBLOCKWHICHISAUTOMATICALLYADDEDATTHEENDOFEVERYTHREADSSCRIPTBYTHETHREADBLOCKJUSTRUNSTHENEXTWAITINGTASKHEREISASAMPLESCRIPTUSINGTHETHREADSYSTEMONETHREADSAYSNUMBERSTHEOTHERSAYSLETTERSTHENUMBERTHREADYIELDSAFTEREVERYPRIMENUMBERWHILETHELETTERTHREADYIELDSAFTEREVERYVOWELSOTHESEQUENCEOFSPEECHBALLOONSISABCDEFGHIJKLMNOPQRSTUVWXYZIFWEWANTEDTHISTOBEHAVEEXACTLYLIKESNAPSOWNTHREADSWEDDEFINENEWVERSIONSOFREPEATANDSOONTHATRUNYIELDAFTEREACHREPETITIONXIMETAPROGRAMMINGTHESCRIPTSANDCUSTOMBLOCKSTHATMAKEUPAPROGRAMCANBEEXAMINEDORCREATEDBYTHEPROGRAMITSELFAREADINGABLOCKTHEDENITIONOFBLOCKTAKESACUSTOMBLOCKINARINGSINCEITSTHEBLOCKITSELFTHATSTHEINPUTNOTTHERESULTOFCALLINGTHEBLOCKASINPUTANDREPORTSTHEBLOCKSDEFINITIONIEITSINPUTSANDBODYINTHEFORMOFARINGWITHNAMEDINPUTSCORRESPONDINGTOTHEBLOCKSINPUTNAMESSOTHATTHOSEINPUTNAMESAREBOUNDINTHEBODYTHESPLITBYBLOCKSBLOCKTAKESANYEXPRESSIONORSCRIPTASINPUTRINGEDANDREPORTSALISTREPRESENTINGASYNTAXTREEFORTHESCRIPTOREXPRESSIONINWHICHTHEFIRSTITEMISABLOCKWITHNOINPUTSANDTHEREMAININGITEMSARETHEINPUTVALUESWHICHMAYTHEMSELVESBESYNTAXTREESUSINGSPLITBYBLOCKSTOSELECTCUSTOMBLOCKSWHOSEDEFINITIONSCONTAINANOTHERBLOCKGIVESUSTHISDEBUGGINGAIDNOTEINPASSINGTHEMYBLOCKSBLOCKWHICHREPORTSALISTOFALLVISIBLEBLOCKSPRIMITIVEANDCUSTOMTHERESALSOAMYCATEGORIESBLOCKWHICHREPORTSALISTOFTHENAMESOFTHEPALETTECATEGORIESALSONOTECUSTOMOFBLOCKWHICHREPORTSTRUEIFITSINPUTISACUSTOMBLOCKBWRITINGABLOCKTHEINVERSEFUNCTIONTOSPLITBYBLOCKSISPROVIDEDBYTHEJOINBLOCKWHICHWHENGIVENASYNTAXTREEASINPUTREPORTSTHECORRESPONDINGEXPRESSIONORSCRIPTHEREWEARETAKINGTHEDEFINITIONOFSQUAREMODIFYINGTHEREPETITIONCOUNTTOMODIFYINGTHETURNINGANGLETOUSINGJOINTOTURNTHERESULTBACKINTOARINGEDDEFINITIONANDUSINGTHEDEFINEBLOCKTOCREATEANEWHEXAGONBLOCKTHEDENEBLOCKHASTHREEINPUTSLOTSTHEQUOTATIONMARKSARETHEREBECAUSETHEFIRSTSLOTISANUPVARIEAWAYFORDENETOPROVIDEINFORMATIONTOITSCALLERRATHERTHANTHEOTHERWAYAROUNDINTHISCASETHEVALUEOFBLOCKISTHENEWBLOCKITSELFTHEHEXAGONBLOCKINTHISEXAMPLETHESECONDSLOTISWHEREYOUGIVETHELABELFORTHENEWBLOCKINTHISEXAMPLETHELABELISHEXAGONINWHICHTHEUNDERSCOREREPRESENTSANINPUTSLOTSOHEREAREAFEWEXAMPLESOFBLOCKLABELSSETPENTOFORTOASKANDWAITOFNOTETHATTHEUNDERSCORESARESEPARATEDFROMTHEBLOCKTEXTBYSPACESNOTEINTHECASEOFTHEFORBLOCKSLABELTHATTHEUPVARTHEIANDTHECSLOTBOTHCOUNTASINPUTSNOTEALSOTHATTHELABELISNOTMEANTTOBEAUNIQUESYMBOLTHATREPRESENTSONLYTHISBLOCKFOREXAMPLEANDBOTHHAVETHELABELOFTHELABELDOESNOTGIVETHEINPUTSLOTSNAMESTHATSDONEINTHEBODYCOMINGNEXTORTYPESTHATSDONEINTHESETOFBLOCKTOBLOCKCOMINGINTWOPARAGRAPHSTHETHIRDSLOTISFORTHEDEFINITIONOFTHENEWBLOCKTHISISARINGEDSCRIPTWHOSEINPUTNAMESFORMALPARAMETERSWILLBECOMETHEFORMALPARAMETERSOFTHENEWBLOCKANDTHESCRIPTISITSSCRIPTSOFARWEKNOWTHEBLOCKSLABELPARAMETERSANDSCRIPTTHEREAREOTHERTHINGSTOSPECIFYABOUTTHEBLOCKANDONEPURPOSEOFTHEBLOCKUPVARISTOALLOWTHATINTHEEXAMPLEONTHEPREVIOUSPAGETHEREAREFOURSETOFBLOCKTOBLOCKSREPRODUCEDBELOWFORYOURCONVENIENCETHECATEGORYOFTHEBLOCKCANBESETTOANYPRIMITIVEORCUSTOMCATEGORYTHEDEFAULTISOTHERTHETYPEISCOMMANDREPORTERORPREDICATECOMMANDISTHEDEFAULTSOTHISSETTINGISREDUNDANTBUTWEWANTTOSHOWALLTHECHOICESINTHESETBLOCKTHESCOPEISEITHERGLOBALORSPRITEWITHGLOBALASTHEDEFAULTTHELASTINPUTTOSETSLOTSISALISTOFLENGTHLESSTHANOREQUALTOTHENUMBEROFUNDERSCORESINTHELABELEACHITEMOFTHELISTISATYPENAMELIKETHEONESINTHEISANUMBERBLOCKIFTHEREISONLYONEINPUTYOUCANUSEJUSTTHENAMEINSTEADOFPUTTINGITINALISTANEMPTYORMISSINGLISTITEMMEANSTYPEANYITSVERYIMPORTANTTHATTHESESETBLOCKSAPPEARINTHESAMESCRIPTASTHEDEFINETHATCREATESTHEBLOCKBECAUSETHEBLOCKUPVARISLOCALTOTHATSCRIPTYOUCANTLATERSAYFOREXAMPLEBECAUSETHECOPYOFTHEHEXAGONBLOCKINTHISINSTRUCTIONCOUNTSASUSINGITTHEOFBLOCKREPORTERISUSEFULTOCOPYATTRIBUTESFROMONEBLOCKTOANOTHERASWECOPIEDTHEDEFINITIONOFSQUAREMODIFIEDITANDUSEDITTODEFINEHEXAGONSOMEOFTHEVALUESTHISBLOCKREPORTSAREALITTLEUNFRIENDLYYESTHISBLOCKREPORTSNUMBERSINSTEADOFNAMESFORCATEGORYTYPEANDSCOPETHEREASONISTHATMAYBESOMEDAYWELLHAVETRANSLATIONSTOOTHERLANGUAGESFORCUSTOMCATEGORYNAMESASWEALREADYDOFORTHEBUILTINCATEGORIESTYPESANDSCOPESIFYOUTRANSLATEAPROGRAMUSINGTHISBLOCKTOANOTHERLANGUAGETHENUMERICOUTPUTSWONTCHANGESIMPLIFYINGCOMPARISONSINYOURCODETHESETBLOCKACCEPTSTHESENUMBERSASANALTERNATIVETOTHENAMESTHEREAREAFEWMOREATTRIBUTESOFABLOCKLESSCOMMONLYUSEDTHELISTINPUTISJUSTLIKETHEONEFORSETSLOTSEXCEPTFORDEFAULTVALUESINSTEADOFTYPESNOWFORABLOCKWITHAMENUINPUTPREFERAREADONLYMENUWEPASSEDTOOQUICKLYOVERHOWTHESCRIPTTURNEDTHESQUAREBLOCKINTOAHEXAGONBLOCKTHOSEREPLACEITEMBLOCKSARENTVERYELEGANTIHADTOLOOKATFOOBYHANDTOFIGUREOUTWHERETHENUMBERSIWANTEDTOCHANGEARETHISSITUATIONCANBEIMPROVEDWITHALITTLEPROGRAMMINGEXERCISEFORTHEREADERIMPLEMENTTHISRETURNINGTOTHEDEFINEBLOCKTHERESANOTHERREASONFORTHEBLOCKUPVARITSHELPFULINDEFININGARECURSIVEPROCEDUREUSINGDEFINEFORAPROCEDURETOCALLITSELFITNEEDSANAMEFORITSELFBUTINTHEDEFINITIONINPUTTOTHEDEFINEBLOCKDEFINEITSELFHASNTBEENCALLEDYETSOTHENEWBLOCKISNTINTHEPALETTEYETSOYOUDOTHISYESYOUPUTBLOCKINTHEDEFINEBUTITGETSCHANGEDINTOTHISSCRIPTINTHERESULTINGDEFINITIONYOUCOULDUSETHISSCRIPTDIRECTLYINASIMPLECASELIKETHISBUTINACOMPLICATEDCASEWITHARECURSIVECALLINSIDEARINGINSIDETHEONEGIVINGTHEBLOCKDEFINITIONTHISSCRIPTALWAYSMEANSTHEINNERMOSTRINGBUTTHEUPVARMEANSTHEOUTERRINGITSANALOGOUSTOUSINGEXPLICITFORMALPARAMETERSWHENYOUNESTCALLSTOHIGHERORDERFUNCTIONSCMACROSUSERSOFLANGUAGESINTHECFAMILYHAVELEARNEDTOTHINKOFMACROSASENTIRELYABOUTTEXTSTRINGSWITHNORELATIONTOTHESYNTAXOFTHELANGUAGESOYOUCANDOTHINGSLIKEDEFINEFOOBAZWITHTHERESULTTHATYOUCANONLYUSETHEFOOMACROAFTERANOPENPARENTHESISINTHELISPFAMILYOFLANGUAGESWEHAVEADIFFERENTTRADITIONINWHICHMACROSARESYNTACTICALLYJUSTLIKEPROCEDURECALLSEXCEPTTHATTHEPROCEDUREISAMACROWITHDIFFERENTEVALUATIONRULESFROMORDINARYPROCEDURESTWOTHINGSMAKEAMACRODIFFERENTITSINPUTEXPRESSIONSARENOTEVALUATEDSOAMACROCANESTABLISHITSOWNSYNTAXBUTSTILLDELIMITEDBYPARENTHESESINLISPORSTILLONEBLOCKINSNAPANDTHERESULTOFAMACROCALLISANEWEXPRESSIONTHATISEVALUATEDASIFITAPPEAREDINTHECALLEROFTHEMACROWITHACCESSTOTHECALLERSVARIABLESANDIMPLICITLYITSCONTINUATIONSNAPHASLONGHADTHEFIRSTPARTOFTHISTHEABILITYTOMAKEINPUTSUNEVALUATEDINVERSIONWEADDTHEABILITYTORUNCODEINTHECONTEXTOFANOTHERPROCEDUREJUSTASWECANRUNCODEINTHECONTEXTOFANOTHERSPRITEUSINGTHESAMEMECHANISMTHEOFBLOCKINTHEEXAMPLEONTHEPREVIOUSPAGETHEIFREPORTCALLERBLOCKRUNSAREPORTBLOCKBUTNOTINITSOWNCONTEXTITCAUSESTHEFIZZBUZZBLOCKTOREPORTFIZZORBUZZASAPPROPRIATEYESWEKNOWTHATTHERULESIMPLEMENTEDHEREARESIMPLIFIEDCOMPAREDTOTHEREALGAMEITDOESNTJUSTREPORTOUTOFTHEENTIRETOPLEVELSCRIPTYOUCANSEETHATMAPISABLETOPREPENDTHEANSWERISTOEACHREPORTEDVALUETHISMACROCAPABILITYISNTFULLYIMPLEMENTEDFIRSTWESHOULDNTHAVETOUSETHECALLINGSCRIPTASANEXPLICITINPUTTOTHEMACROINALATERRELEASETHISWILLBEFIXEDWHENDEFININGABLOCKYOULLBEABLETOSAYTHATITSAMACROANDITWILLAUTOMATICALLYGETITSCALLERSCONTEXTASANINVISIBLEINPUTSECONDTHEREISAPOSSIBILITYOFCONFUSIONBETWEENTHEVARIABLESOFTHEMACROANDTHEVARIABLESOFITSCALLERWHATIFTHEMACROWANTEDTOREFERTOAVARIABLEVALUEINITSCALLERTHEONESUBSTANTIALFEATUREOFSCHEMETHATWEDONTYETIMPLEMENTISHYGIENICMACROSWHICHMAKEITPOSSIBLETOKEEPTHETWONAMESPACESSEPARATEXIIUSERINTERFACEELEMENTSINTHISCHAPTERWEDESCRIBEINDETAILTHEVARIOUSBUTTONSMENUSANDOTHERCLICKABLEELEMENTSOFTHESNAPUSERINTERFACEHEREAGAINISTHEMAPOFTHESNAPWINDOWATOOLBARFEATURESHOLDINGDOWNTHESHIFTKEYWHILECLICKINGONANYOFTHEMENUBUTTONSGIVESACCESSTOANEXTENDEDMENUWITHOPTIONSSHOWNINREDTHATAREEXPERIMENTALORFORUSEBYTHEDEVELOPERSWERENOTLISTINGTHOSEEXTRAOPTIONSHEREBECAUSETHEYCHANGEFREQUENTLYANDYOUSHOULDNTRELYONTHEMBUTTHEYRENOTSECRETSTHESNAPLOGOMENUTHESNAPLOGOATTHELEFTENDOFTHETOOLBARISCLICKABLEITSHOWSAMENUOFOPTIONSABOUTSNAPITSELFTHEABOUTOPTIONDISPLAYSINFORMATIONABOUTSNAPITSELFINCLUDINGVERSIONNUMBERSFORTHESOURCEMODULESTHEIMPLEMENTORSANDTHELICENSEAGPLYOUCANDOANYTHINGWITHITEXCEPTCREATEPROPRIETARYVERSIONSBASICALLYTHEREFERENCEMANUALOPTIONDOWNLOADSACOPYOFTHELATESTREVISIONOFTHISMANUALINPDFFORMATTHESNAPWEBSITEOPTIONOPENSABROWSERWINDOWPOINTINGTOSNAPBERKELEYEDUTHEWEBSITEFORSNAPTHEDOWNLOADSOURCEOPTIONOPENSABROWSERWINDOWDISPLAYINGTHEGITHUBREPOSITORYOFTHESOURCEFILESFORSNAPATTHEBOTTOMOFTHEPAGEARELINKSTODOWNLOADTHELATESTOFFICIALRELEASEORYOUCANNAVIGATEAROUNDTHESITETOFINDTHECURRENTDEVELOPMENTVERSIONYOUCANREADTHECODETOLEARNHOWSNAPISIMPLEMENTEDHOSTACOPYONYOUROWNCOMPUTERTHISISONEWAYTOKEEPWORKINGWHILEONANAIRPLANEORMAKEAMODIFIEDVERSIONWITHCUSTOMIZEDFEATURESHOWEVERACCESSTOCLOUDACCOUNTSISLIMITEDTOTHEOFFICIALVERSIONHOSTEDATBERKELEYTHEFILEMENUTHEFILEICONSHOWSAMENUMOSTLYABOUTSAVINGANDLOADINGPROJECTSYOUMAYNOTSEEALLTHESEOPTIONSIFYOUDONTHAVEMULTIPLESPRITESSCENESCUSTOMBLOCKSANDCUSTOMCATEGORIESTHENOTESOPTIONOPENSAWINDOWINWHICHYOUCANTYPENOTESABOUTTHEPROJECTHOWTOUSEITWHATITDOESWHOSEPROJECTYOUMODIFIEDTOCREATEITIFANYWHATOTHERSOURCESOFIDEASYOUUSEDORANYOTHERINFORMATIONABOUTTHEPROJECTTHISTEXTISSAVEDWITHTHEPROJECTANDISUSEFULIFYOUSHAREITWITHOTHERUSERSTHENEWOPTIONSTARTSANEWEMPTYPROJECTANYPROJECTYOUWEREWORKINGONBEFOREDISAPPEARSSOYOUAREASKEDTOCONFIRMTHATTHISISREALLYWHATYOUWANTITDISAPPEARSONLYFROMTHECURRENTWORKINGSNAPWINDOWYOUSHOULDSAVETHECURRENTPROJECTIFYOUWANTTOKEEPITBEFOREUSINGNEWNOTETHENATTHEENDOFTHELINETHISINDICATESTHATYOUCANTYPECONTROLNASASHORTCUTFORTHISMENUITEMALASTHISISNOTTHECASEINEVERYBROWSERSOMEMACBROWSERSREQUIRECOMMANDNNINSTEADWHILEOTHERSOPENANEWBROWSERWINDOWINSTEADOFANEWPROJECTYOULLHAVETOEXPERIMENTINGENERALTHEKEYBOARDSHORTCUTSINSNAPARETHESTANDARDONESYOUEXPECTINOTHERSOFTWARETHEOPENOPTIONSHOWSAPROJECTOPENDIALOGBOXINWHICHYOUCANCHOOSEAPROJECTTOOPENINTHISDIALOGTHETHREELARGEBUTTONSATTHELEFTSELECTASOURCEOFPROJECTSCLOUDMEANSYOURSNAPACCOUNTSCLOUDSTORAGEEXAMPLESMEANSACOLLECTIONOFSAMPLEPROJECTSWEPROVIDECOMPUTERISFORPROJECTSSAVEDONYOUROWNCOMPUTERWHENYOUCLICKITTHISDIALOGISREPLACEDWITHYOURCOMPUTERSSYSTEMDIALOGFOROPENINGFILESTHETEXTBOXTOTHERIGHTOFTHOSEBUTTONSISANALPHABETICALLISTINGOFPROJECTSFROMTHATSOURCESELECTINGAPROJECTBYCLICKINGSHOWSITSTHUMBNAILAPICTUREOFTHESTAGEWHENITWASSAVEDANDITSPROJECTNOTESATTHERIGHTTHESEARCHBARATTHETOPCANBEUSEDTOFINDAPROJECTBYNAMEORTEXTINTHEPROJECTNOTESSOINTHISEXAMPLEIWASLOOKINGFORMYICECREAMPROJECTSANDTYPEDCREAINTHESEARCHBARTHENWONDEREDWHYFERRISMATCHEDBUTTHENWHENICLICKEDONFERRISISAWTHISMYSEARCHMATCHEDTHEWORDRECREATEINTHEPROJECTNOTESTHESIXBUTTONSATTHEBOTTOMSELECTANACTIONTOPERFORMONTHESELECTEDPROJECTINTHETOPROWRECOVERLOOKSINYOURCLOUDACCOUNTFOROLDERVERSIONSOFTHECHOSENPROJECTIFYOURPROJECTISDAMAGEDDONTKEEPSAVINGBROKENVERSIONSUSERECOVERFIRSTTHINGYOUWILLSEEALISTOFSAVEDVERSIONSCHOOSEONETOOPENITTYPICALLYYOULLSEETHEMOSTRECENTVERSIONBEFORETHELASTSAVEANDTHENEWESTVERSIONSAVEDBEFORETODAYTHENCOMEBUTTONSSHAREUNSHAREANDPUBLISHUNPUBLISHTHELABELLINGOFTHEBUTTONSDEPENDSONYOURPROJECTSPUBLICATIONSTATUSIFAPROJECTISNEITHERSHAREDNORPUBLISHEDTHEONESINLIGHTFACETYPEINTHEPROJECTLISTITISPRIVATEANDNOBODYCANSEEITEXCEPTYOUITSOWNERIFITISSHAREDBOLDFACEINTHEPROJECTLISTTHENWHENYOUOPENITYOULLSEEAURLLIKETHISONEHPSSNAPBERKELEYEDUSNAPSOURCESNAPHTMLPRESENTUSERNAMEBHPROJECTNAMECOUNTCHANGEBUTWITHYOURUSERNAMEANDPROJECTNAMEINTHEPROJECTNAMEREPRESENTSASPACEWHICHCANTBEPARTOFAURLANYONEWHOKNOWSTHISURLCANSEEYOURPROJECTFINALLYIFYOURPROJECTISPUBLISHEDBOLDITALICINTHELISTTHENYOURPROJECTISSHOWNONTHESNAPWEBSITEFORALLTHEWORLDTOSEEINALLOFTHESECASESYOUARETHEONLYONEWHOCANWRITETOSAVEYOURPROJECTIFANOTHERUSERSAVESITASEPARATECOPYWILLBESAVEDINTHATUSERSACCOUNTPROJECTSREMEMBERTHEHISTORYOFWHOCREATEDTHEORIGINALVERSIONANDANYOTHERREMIXVERSIONSALONGTHEWAYINTHESECONDROWTHEFIRSTBUTTONOPENLOADSTHEPROJECTINTOSNAPANDCLOSESTHEDIALOGBOXTHENEXTBUTTONIFCLOUDISTHESOURCEISDELETEANDIFCLICKEDITDELETESTHESELECTEDPROJECTFINALLYTHECANCELBUTTONCLOSESTHEDIALOGBOXWITHOUTOPENINGAPROJECTITDOESNOTUNDOANYSHARINGUNSHARINGORDELETIONYOUVEDONEBACKTOTHEFILEMENUTHESAVEMENUOPTIONSAVESTHEPROJECTTOTHESAMESOURCEANDSAMENAMETHATWASUSEDWHENOPENINGTHEPROJECTIFYOUOPENEDANOTHERUSERSSHAREDPROJECTORANEXAMPLEPROJECTTHEPROJECTWILLBESAVEDTOYOUROWNCLOUDACCOUNTYOUMUSTBELOGGEDINTOSAVETOTHECLOUDTHESAVEASMENUOPTIONOPENSADIALOGBOXINWHICHYOUCANSPECIFYWHERETOSAVETHEPROJECTTHISISMUCHLIKETHEOPENDIALOGEXCEPTFORTHEHORIZONTALTEXTBOXATTHETOPINTOWHICHYOUTYPEANAMEFORTHEPROJECTYOUCANALSOPUBLISHUNPUBLISHSHAREUNSHAREANDDELETEPROJECTSFROMHERETHEREISNORECOVERBUTTONTHEIMPORTMENUOPTIONISFORBRINGINGSOMEEXTERNALRESOURCEINTOTHECURRENTPROJECTORITCANLOADANENTIRELYSEPARATEPROJECTFROMYOURLOCALDISKYOUCANIMPORTCOSTUMESANYPICTUREFORMATTHATYOURBROWSERSUPPORTSSOUNDSAGAINANYFORMATSUPPORTEDBYYOURBROWSERANDBLOCKLIBRARIESORSPRITESXMLFORMATPREVIOUSLYEXPORTEDFROMSNAPITSELFIMPORTEDCOSTUMESANDSOUNDSWILLBELONGTOTHECURRENTLYSELECTEDSPRITEIMPORTEDBLOCKSAREGLOBALFORALLSPRITESUSINGTHEIMPORTOPTIONISEQUIVALENTTODRAGGINGTHEFILEFROMYOURDESKTOPONTOTHESNAPWINDOWDEPENDINGONYOURBROWSERTHEEXPORTPROJECTOPTIONEITHERDIRECTLYSAVESTOYOURDISKOROPENSANEWBROWSERTABCONTAININGYOURCOMPLETEPROJECTINXMLNOTATIONAPLAINTEXTFORMATYOUCANTHENUSETHEBROWSERSSAVEFEATURETOSAVETHEPROJECTASANXMLFILEWHICHSHOULDBENAMEDSOMETHINGXMLSOTHATSNAPWILLRECOGNIZEITASAPROJECTWHENYOULATERDRAGITONTOASNAPWINDOWTHISISANALTERNATIVETOSAVINGTHEPROJECTTOYOURCLOUDACCOUNTKEEPINGITONYOUROWNCOMPUTERITISEQUIVALENTTOCHOOSINGCOMPUTERFROMTHESAVEDIALOGDESCRIBEDEARLIERTHEEXPORTSUMMARYOPTIONCREATESAWEBPAGEINHTMLWITHALLOFTHEINFORMATIONABOUTYOURPROJECTITSNAMEITSPROJECTNOTESAPICTUREOFWHATSONITSSTAGEDEFINITIONSOFGLOBALBLOCKSANDTHENPERSPRITEINFORMATIONNAMEWARDROBELISTOFCOSTUMESANDLOCALVARIABLESANDBLOCKDEFINITIONSTHEPAGECANBECONVERTEDTOPDFBYTHEBROWSERITSINTENDEDTOMEETTHEDOCUMENTATIONREQUIREMENTSOFTHEADVANCEDPLACEMENTCOMPUTERSCIENCEPRINCIPLESCREATETASKTHEEXPORTBLOCKSOPTIONISUSEDTOCREATEABLOCKLIBRARYITPRESENTSALISTOFALLTHEGLOBALFORALLSPRITESBLOCKSINYOURPROJECTANDLETSYOUSELECTWHICHTOEXPORTITTHENOPENSABROWSERTABWITHTHOSEBLOCKSINXMLFORMATORSTORESDIRECTLYTOYOURLOCALDISKASWITHTHEEXPORTPROJECTOPTIONBLOCKLIBRARIESCANBEIMPORTEDWITHTHEIMPORTOPTIONORBYDRAGGINGTHEFILEONTOTHESNAPWINDOWTHISOPTIONISSHOWNONLYIFYOUHAVEDEFINEDCUSTOMBLOCKSTHEUNUSEDBLOCKSOPTIONPRESENTSALISTINGOFALLTHEGLOBALCUSTOMBLOCKSINYOURPROJECTTHATARENTUSEDANYWHEREANDOFFERSTODELETETHEMASWITHEXPORTBLOCKSYOUCANCHOOSEASUBSETTODELETEWITHCHECKBOXESTHISOPTIONISSHOWNONLYIFYOUHAVEDEFINEDCUSTOMBLOCKSTHEHIDEBLOCKSOPTIONSHOWSALLBLOCKSINCLUDINGPRIMITIVESWITHCHECKBOXESTHISOPTIONDOESNOTREMOVEANYBLOCKSFROMYOURPROJECTBUTITDOESHIDESELECTEDBLOCKINYOURPALETTETHEPURPOSEOFTHEOPTIONISTOALLOWTEACHERSTOPRESENTSTUDENTSWITHASIMPLIFIEDSNAPWITHSOMEFEATURESEFFECTIVELYREMOVEDTHEHIDDENNESSOFPRIMITIVESISSAVEDWITHEACHPROJECTSOSTUDENTSCANLOADASHAREDPROJECTANDSEEJUSTTHEDESIREDBLOCKSBUTUSERSCANALWAYSUNHIDEBLOCKSBYCHOOSINGTHISOPTIONANDUNCLICKINGALLTHECHECKBOXESRIGHTCLICKINTHEBACKGROUNDOFTHEDIALOGBOXTOGETAMENUFROMWHICHYOUCANCHECKALLBOXESORUNCHECKALLBOXESTHENEWCATEGORYOPTIONALLOWSYOUTOADDYOUROWNCATEGORIESTOTHEPALETTEITOPENSADIALOGBOXINWHICHYOUSPECIFYANAMEANDACOLORFORTHECATEGORYALIGHTERVERSIONOFTHESAMECOLORWILLBEUSEDFORTHEZEBRACOLORINGFEATURETHEREMOVEACATEGORYOPTIONAPPEARSONLYIFYOUVECREATEDCUSTOMCATEGORIESITOPENSAVERYSMALLEASYTOMISSMENUOFCATEGORYNAMESJUSTUNDERTHEFILEICONINTHEMENUBARIFYOUREMOVEACATEGORYTHATHASBLOCKSINITALLTHOSEBLOCKSAREALSOREMOVEDTHENEXTGROUPOFOPTIONSCONCERNTHESCENESFEATURENEWINSNAPASCENEISACOMPLETEPROJECTWITHITSOWNSTAGESPRITESANDCODEBUTSEVERALCANBEMERGEDINTOONEPROJECTUSINGTHEBLOCKTOBRINGANOTHERSCENEONSCREENTHESCENESOPTIONPRESENTSAMENUOFALLTHESCENESINYOURPROJECTWHERETHEFILEMENUWASBEFOREYOUCLICKEDITTHENEWSCENEOPTIONCREATESANEWEMPTYSCENEWHICHYOUCANRENAMEASYOULIKEFROMITSCONTEXTMENUADDSCENEISLIKEIMPORTBUTFORSCENESACOMPLETEPROJECTCANBEIMPORTEDASASCENEINTOANOTHERPROJECTSOYOUHAVETOSPECIFYTHATYOUREIMPORTINGTHEPROJECTASASCENERATHERTHANREPLACINGTHECURRENTPROJECTTHELIBRARIESOPTIONPRESENTSAMENUOFUSEFULOPTIONALBLOCKLIBRARIESTHELIBRARYMENUISDIVIDEDINTOFIVEBROADCATEGORIESTHEFIRSTISBROADLYUTILITIESBLOCKSTHATMIGHTWELLBEPRIMITIVESTHEYMIGHTBEUSEFULINALLKINDSOFPROJECTSTHESECONDCATEGORYISBLOCKSRELATEDTOMEDIACOMPUTATIONONESTHATHELPINDEALINGWITHCOSTUMESANDSOUNDSAKAJENSLIBRARIESTHEREISSOMEOVERLAPWITHBIGDATALIBRARIESFORDEALINGWITHLARGELISTSOFLISTSTHETHIRDCATEGORYISROUGHLYSPECIFICTONONMEDIAAPPLICATIONSAKABRIANLIBRARIESTHREEOFTHEMAREIMPORTSFROMOTHERPROGRAMMINGLANGUAGESWORDSANDSENTENCESFROMLOGOARRAYFUNCTIONSFROMAPLANDSTREAMSFROMSCHEMEMOSTOFTHEOTHERSARETOMEETTHENEEDSOFTHEBJCCURRICULUMTHEFOURTHCATEGORYISMAJORPACKAGESPROVIDEDBYUSERSTHEFIFTHCATEGORYPROVIDESSUPPORTFORHARDWAREDEVICESSUCHASROBOTSTHROUGHGENERALINTERFACESREPLACINGSPECIFICHARDWARELIBRARIESINVERSIONSBEFOREWHENYOUCLICKONTHEONELINEDESCRIPTIONOFALIBRARYYOUARESHOWNTHEACTUALBLOCKSINTHELIBRARYANDALONGEREXPLANATIONOFITSPURPOSEYOUCANBROWSETHELIBRARIESTOFINDONETHATWILLSATISFYYOURNEEDSTHELIBRARIESAREDESCRIBEDINDETAILINSECTIONIHPAGETHECOSTUMESOPTIONOPENSABROWSERINTOTHECOSTUMELIBRARYYOUCANIMPORTASINGLECOSTUMEBYCLICKINGITANDTHENCLICKINGTHEIMPORTBUTTONALTERNATIVELYYOUCANIMPORTMORETHANONECOSTUMEBYDOUBLECLICKINGEACHONEANDTHENCLICKINGCANCELWHENDONENOTICETHATSOMECOSTUMESARETAGGEDWITHSVGINTHISPICTURETHOSEAREVECTORFORMATCOSTUMESTHATARENOTYETEDITABLEWITHINSNAPIFYOUHAVETHESTAGESELECTEDINTHESPRITECORRALRATHERTHANASPRITETHECOSTUMESOPTIONCHANGESTOABACKGROUNDSOPTIONWITHDIFFERENTCHOICESINTHEBROWSERTHECOSTUMEANDBACKGROUNDLIBRARIESINCLUDEBOTHBITMAPGOJAGGEDIFENLARGEDANDVECTORENLARGESMOOTHLYIMAGESTHANKSTOSCRATCHFORMOSTOFTHESEIMAGESSOMEOLDERBROWSERSREFUSETOIMPORTAVECTORIMAGEBUTINSTEADCONVERTITTOBITMAPTHESOUNDSOPTIONOPENSTHETHIRDKINDOFMEDIABROWSERTHEPLAYBUTTONSCANBEUSEDTOPREVIEWTHESOUNDSFINALLYTHEUNDELETESPRITESOPTIONAPPEARSONLYIFYOUHAVEDELETEDASPRITEITALLOWSYOUTORECOVERASPRITETHATWASDELETEDBYACCIDENTPERHAPSINTENDINGTODELETEONLYACOSTUMETHECLOUDMENUSHOWSAMENUOFOPTIONSRELATINGTOYOURSNAPTHECLOUDICONCLOUDACCOUNTIFYOUARENOTLOGGEDINYOUSEETHEOUTLINEICONANDGETTHISMENUCHOOSELOGINIFYOUHAVEASNAPACCOUNTANDREMEMBERYOURPASSWORDCHOOSESIGNUPIFYOUDONTHAVEANACCOUNTCHOOSERESETPASSWORDIFYOUVEFORGOTTENYOURPASSWORDORJUSTWANTTOCHANGEITYOUWILLTHENGETANEMAILATTHEADDRESSYOUGAVEWHENYOUCREATEDYOURACCOUNTWITHANEWTEMPORARYPASSWORDUSETHATPASSWORDTOLOGINTHENYOUCANCHOOSEYOUROWNPASSWORDASSHOWNBELOWCHOOSERESENDVERICATIONEMAILIFYOUHAVEJUSTCREATEDASNAPACCOUNTBUTCANTFINDTHEEMAILWESENTYOUWITHTHELINKTOVERIFYTHATITSREALLYYOUREMAILIFYOUSTILLCANTFINDITCHECKYOURSPAMFOLDERIFYOUAREUSINGASCHOOLEMAILADDRESSYOURSCHOOLMAYBLOCKINCOMINGEMAILFROMOUTSIDETHESCHOOLTHEOPENINCOMMUNITYSITEOPTIONAPPEARSONLYIFYOUHAVEAPROJECTOPENITTAKESYOUTOTHECOMMUNITYSITEPAGEABOUTTHATPROJECTIFYOUAREALREADYLOGGEDINYOULLSEETHESOLIDICONANDGETTHISMENULOGOUTISOBVIOUSBUTHASTHEADDITIONALBENEFITOFSHOWINGYOUWHOSLOGGEDINCHANGEPASSWORDWILLASKFORYOUROLDPASSWORDTHETEMPORARYONEIFYOURERESETTINGYOURPASSWORDANDTHENEWPASSWORDYOUWANTENTEREDTWICEBECAUSEITDOESNTECHOOPENINCOMMUNITYSITEISTHESAMEASABOVETHESETTINGSMENUSHOWSAMENUOFSNAPOPTIONSEITHERFORTHECURRENTTHESETTINGSICONPROJECTORFORYOUPERMANENTLYDEPENDINGONTHEOPTIONTHELANGUAGEOPTIONLETSYOUSEETHESNAPUSERINTERFACEBLOCKSANDMESSAGESINALANGUAGEOTHERTHANENGLISHNOTETRANSLATIONSHAVEBEENPROVIDEDBYSNAPUSERSIFYOURNATIVELANGUAGEISMISSINGSENDUSANEMAILTHEZOOMBLOCKSOPTIONLETSYOUCHANGETHESIZEOFBLOCKSBOTHINTHEPALETTESANDINSCRIPTSTHESTANDARDSIZEISUNITSTHEMAINPURPOSEOFTHISOPTIONISTOLETYOUTAKEVERYHIGHRESOLUTIONPICTURESOFSCRIPTSFORUSEONPOSTERSITCANALSOBEUSEDTOIMPROVEREADABILITYWHENPROJECTINGONTOASCREENWHILELECTURINGBUTBEARINMINDTHATITDOESNTMAKETHEPALETTEORSCRIPTAREASANYWIDERSOYOURCOMPUTERSCOMMANDOPTIONFEATUREMAYBEMOREPRACTICALNOTETHATAZOOMOFISGIGANTICDONTEVENTRYTHEFADEBLOCKSOPTIONOPENSADIALOGINWHICHYOUCANCHANGETHEAPPEARANCEOFBLOCKSMOSTLYTHISISAPROPAGANDAAIDTOUSEONPEOPLEWHOTHINKTHATTEXTLANGUAGESARESOMEHOWBETTERORMOREGROWNUPTHANBLOCKLANGUAGESBUTSOMEPEOPLEDOPREFERLESSSATURATEDBLOCKCOLORSYOUCANUSETHEPULLDOWNMENUFORPRESELECTEDFADINGSUSETHESLIDERTOSEETHERESULTASYOUCHANGETHEFADINGAMOUNTORTYPEANUMBERINTOTHETEXTBOXONCEYOUVEDETERMINEDYOURFAVORITEVALUETHESTAGESIZEOPTIONLETSYOUSETTHESIZEOFTHEFULLSIZESTAGEINPIXELSIFTHESTAGEISINHALFSIZEORDOUBLESIZEPRESENTATIONMODETHESTAGESIZEVALUESDONTCHANGETHEYALWAYSREFLECTTHEFULLSIZESTAGETHEMICROPHONERESOLUTIONOPTIONSETSTHEBUFFERSIZEUSEDBYTHEMICROPHONEBLOCKINSETTINGSRESOLUTIONISANACCURATENAMEIFYOUAREGETTINGFREQUENCYDOMAINSAMPLESTHEMORESAMPLESTHENARROWERTHERANGEOFFREQUENCIESINEACHSAMPLEINTHETIMEDOMAINTHEBUFFERSIZEDETERMINESTHELENGTHOFTIMEOVERWHICHSAMPLESARECOLLECTEDTHEREMAININGOPTIONSLETYOUTURNVARIOUSFEATURESONANDOFFTHEREARETHREEGROUPSOFCHECKBOXESTHEFIRSTISFORTEMPORARYSETTINGSNOTSAVEDINYOURPROJECTNORINYOURUSERPREFERENCESTHEJAVASCRIPTEXTENSIONSOPTIONENABLESTHEUSEOFTHEJAVASCRIPTFUNCTIONBLOCKBECAUSEMALICIOUSPROJECTSCOULDUSEJAVASCRIPTTOCOLLECTPRIVATEINFORMATIONABOUTYOUORTODELETEORMODIFYYOURSAVEDPROJECTSYOUMUSTENABLEJAVASCRIPTEACHTIMEYOULOADAPROJECTTHATUSESITTHEEXTENSIONBLOCKSOPTIONADDSTWOBLOCKSTOTHEPALETTETHESEBLOCKSPROVIDEASSORTEDCAPABILITIESTOOFFICIALLIBRARIESTHATWEREFORMERLYIMPLEMENTEDWITHTHEJAVASCRIPTFUNCTIONBLOCKTHISALLOWSTHESELIBRARIESTORUNWITHOUTREQUIRINGTHEJAVASCRIPTEXTENSIONSOPTIONDETAILSARESUBJECTTOCHANGEINPUTSLIDERSPROVIDESANALTERNATEWAYTOPUTVALUESINNUMERICINPUTSLOTSIFYOUCLICKINSUCHASLOTASLIDERAPPEARSTHATYOUCANCONTROLWITHTHEMOUSETHERANGEOFTHESLIDERWILLBEFROMLESSTHANTHEINPUTSCURRENTVALUETOMORETHANTHECURRENTVALUEIFYOUWANTTOMAKEABIGGERCHANGETHANTHATYOUCANSLIDETHESLIDERALLTHEWAYTOEITHERENDTHENCLICKONTHEINPUTSLOTAGAINGETTINGANEWSLIDERWITHANEWCENTERPOINTBUTYOUWONTWANTTOUSETHISTECHNIQUETOCHANGETHEINPUTVALUEFROMTOANDITDOESNTWORKATALLFORNONINTEGERINPUTRANGESTHISFEATUREWASIMPLEMENTEDBECAUSESOFTWAREKEYBOARDINPUTONPHONESANDTABLETSDIDNTWORKATALLINTHEBEGINNINGANDSTILLDOESNTWORKPERFECTLYONANDROIDDEVICESSOSLIDERSPROVIDEAWORKAROUNDITHASSINCEFOUNDANOTHERUSEINPROVIDINGLIVELYRESPONSETOINPUTCHANGESIFINPUTSLIDERSISCHECKEDREOPENINGTHESETTINGSMENUWILLSHOWANADDITIONALOPTIONCALLEDEXECUTEONSLIDERCHANGEIFTHISOPTIONISALSOCHECKEDTHENCHANGINGASLIDERINTHESCRIPTINGAREAAUTOMATICALLYRUNSTHESCRIPTINWHICHTHATINPUTAPPEARSTHEPROJECTLIVETREEINTHEEXAMPLESCOLLECTIONSHOWSHOWTHISCANBEUSEDITFEATURESAFRACTALTREECUSTOMBLOCKWITHSEVERALINPUTSANDYOUCANSEEHOWEACHINPUTAFFECTSTHEPICTUREBYMOVINGASLIDERTURBOMODEMAKESMANYPROJECTSRUNMUCHFASTERATTHECOSTOFNOTKEEPINGTHESTAGEDISPLAYUPTODATESNAPORDINARILYSPENDSMOSTOFITSTIMEDRAWINGSPRITESANDUPDATINGVARIABLEWATCHERSRATHERTHANACTUALLYCARRYINGOUTTHEINSTRUCTIONSINYOURSCRIPTSSOTURBOMODEISNTAGOODIDEAFORAPROJECTWITHGLIDEBLOCKSORONEINWHICHTHEUSERINTERACTSWITHANIMATEDCHARACTERSBUTITSGREATFORDRAWINGACOMPLICATEDFRACTALORCOMPUTINGTHEFIRSTMILLIONDIGITSOFSOTHATYOUDONTNEEDTOSEEANYTHINGUNTILTHEFINALRESULTWHILEINTURBOMODETHEBUTTONTHATNORMALLYSHOWSAGREENFLAGINSTEADSHOWSAGREENLIGHTNINGBOLTBUTWHENCLICKEDHATBLOCKSSTILLACTIVATEWHENTHEBUTTONISCLICKEDVISIBLESTEPPINGENABLESTHESLOWEDDOWNSCRIPTEVALUATIONDESCRIBEDINCHAPTERICHECKINGTHISOPTIONISEQUIVALENTTOCLICKINGTHEFOOTPRINTBUTTONABOVETHESCRIPTINGAREAYOUDONTWANTTHISONEXCEPTWHENYOUREACTIVELYDEBUGGINGBECAUSEEVENTHEFASTESTSETTINGOFTHESLIDERISSTILLSLOWEDALOTLOGPENVECTORSTELLSSNAPTOREMEMBERLINESDRAWNBYSPRITESASEXACTVECTORSRATHERTHANREMEMBERONLYTHEPIXELSTHATTHEDRAWINGLEAVESONTHESTAGETHISREMEMBEREDVECTORPICTURECANBEUSEDINTWOWAYSFIRSTRIGHTCLICKINGONAPENTRAILSBLOCKGIVESANOPTIONTORELABELITINTOAPENVECTORSBLOCKWHICHWHENRUNREPORTSTHELOGGEDLINESASAVECTORSVGCOSTUMESECONDRIGHTCLICKINGONTHESTAGEWHENTHEREARELOGGEDVECTORSSHOWSANEXTRAOPTIONSVGTHATEXPORTSAPICTUREOFTHESTAGEINVECTORFORMATONLYLINESARELOGGEDNOTCOLORREGIONSMADEWITHTHELLBLOCKTHENEXTGROUPOFFOURAREUSERPREFERENCEOPTIONSPRESERVEDWHENYOULOADANEWPROJECTLONGFORMINPUTDIALOGIFCHECKEDMEANSTHATWHENEVERACUSTOMBLOCKINPUTNAMEISCREATEDOREDITEDYOUIMMEDIATELYSEETHEVERSIONOFTHEINPUTNAMEDIALOGTHATINCLUDESTHETYPEOPTIONSDEFAULTVALUESETTINGETCINSTEADOFTHESHORTFORMWITHJUSTTHENAMEANDTHECHOICEBETWEENINPUTNAMEANDTITLETEXTTHEDEFAULTUNCHECKEDSETTINGISDEFINITELYBESTFORBEGINNERSBUTMOREEXPERIENCEDSNAPPROGRAMMERSMAYFINDITMORECONVENIENTALWAYSTOSEETHELONGFORMPLAINPROTOTYPELABELSELIMINATESTHEPLUSSIGNSBETWEENWORDSINTHEBLOCKEDITORPROTOTYPEBLOCKTHISMAKESITHARDERTOADDANINPUTTOACUSTOMBLOCKYOUHAVETOHOVERTHEMOUSEWHERETHEPLUSSIGNWOULDHAVEBEENUNTILASINGLEPLUSSIGNAPPEARSTEMPORARILYFORYOUTOCLICKONITSINTENDEDFORPEOPLEMAKINGPICTURESOFSCRIPTSINTHEBLOCKEDITORFORUSEINDOCUMENTATIONSUCHASTHISMANUALYOUPROBABLYWONTNEEDITOTHERWISECLICKINGSOUNDCAUSESAREALLYANNOYINGSOUNDEFFECTWHENEVERONEBLOCKSNAPSNEXTTOANOTHERINASCRIPTCERTAINVERYYOUNGCHILDRENANDOURCOLLEAGUEDANGARCIALIKETHISBUTIFYOUARESUCHACHILDYOUSHOULDBEARINMINDTHATDRIVINGYOURPARENTSORTEACHERSCRAZYWILLRESULTINYOUNOTBEINGALLOWEDTOUSESNAPITMIGHTHOWEVERBEUSEFULFORVISUALLYIMPAIREDUSERSFLATDESIGNCHANGESTHESKINOFTHESNAPWINDOWTOAREALLYHIDEOUSDESIGNWITHWHITEANDPALEGREYBACKGROUNDRECTANGULARRATHERTHANROUNDEDBUTTONSANDMONOCHROMEBLOCKSRATHERTHANTHESHADEDSOMEWHATDLOOKINGNORMALBLOCKSTHEMONOCHROMEBLOCKSARETHEREASONFORTHEFLATINTHENAMEOFTHISOPTIONTHEONLYTHINGTOBESAIDFORTHISOPTIONISTHATBECAUSEOFTHEWHITEBACKGROUNDITMAYBLENDINBETTERWITHTHERESTOFAWEBPAGEWHENASNAPPROJECTISRUNINAFRAMEINALARGERPAGEICONFESSIUSEDITTOMAKETHEPICTUREOFBLOCKSFADEDALLTHEWAYTOJUSTTEXTTWOPAGESAGOTHOUGHTHEFINALGROUPOFSETTINGSCHANGETHEWAYSNAPINTERPRETSYOURPROGRAMTHEYARESAVEDWITHTHEPROJECTSOANYONEWHORUNSYOURPROJECTWILLEXPERIENCETHESAMEBEHAVIORTHREADSAFESCRIPTSCHANGESTHEWAYSNAPRESPONDSWHENANEVENTCLICKINGTHEGREENFLAGSAYSTARTSASCRIPTANDTHENWHILETHESCRIPTISSTILLRUNNINGTHESAMEEVENTHAPPENSAGAINORDINARILYTHERUNNINGPROCESSSTOPSWHEREITISIGNORINGTHEREMAININGCOMMANDSINTHESCRIPTANDTHEENTIRESCRIPTSTARTSAGAINFROMTHETOPTHISBEHAVIORISINHERITEDFROMSCRATCHANDSOMECONVERTEDSCRATCHPROJECTSDEPENDONITTHATSWHYITSTHEDEFAULTITSALSOSOMETIMESTHERIGHTTHINGESPECIALLYINPROJECTSTHATPLAYMUSICINRESPONSETOMOUSECLICKSORKEYSTROKESIFANOTEISSTILLPLAYINGBUTYOUASKFORANOTHERONEYOUWANTTHENEWONETOSTARTRIGHTTHENNOTLATERAFTERTHEOLDPROCESSFINISHESBUTIFYOURSCRIPTMAKESSEVERALCHANGESTOADATABASEANDISINTERRUPTEDINTHEMIDDLETHERESULTMAYBETHATTHEDATABASEISINCONSISTENTWHENYOUSELECTTHREADSAFESCRIPTSTHESAMEEVENTHAPPENINGAGAININTHEMIDDLEOFRUNNINGASCRIPTISSIMPLYIGNOREDTHISISARGUABLYSTILLNOTTHERIGHTTHINGTHEEVENTSHOULDBEREMEMBEREDANDTHESCRIPTRUNAGAINASSOONASITFINISHESWELLPROBABLYGETAROUNDTOADDINGTHATCHOICEEVENTUALLYKEYBOARDEVENTSWHENKEYPRESSEDAREALWAYSTHREADSAFEFLATLINEENDSAFFECTSTHEDRAWINGOFTHICKLINESLARGEPENWIDTHUSUALLYTHEENDSAREROUNDEDWHICHLOOKSBESTWHENTURNINGCORNERSWITHTHISOPTIONSELECTEDTHEENDSAREFLATITSUSEFULFORDRAWINGABRICKWALLORAFILLEDRECTANGLECODICATIONSUPPORTENABLESAFEATURETHATCANTRANSLATEASNAPPROJECTTOATEXTBASEDRATHERTHANBLOCKBASEDPROGRAMMINGLANGUAGETHEFEATUREDOESNTKNOWABOUTANYPARTICULAROTHERLANGUAGEINSTEADYOUCANPROVIDEATRANSLATIONFOREACHPRIMITIVEBLOCKUSINGTHESESPECIALBLOCKSUSINGTHESEPRIMITIVEBLOCKSYOUCANBUILDABLOCKLIBRARYTOTRANSLATEINTOANYPROGRAMMINGLANGUAGEWATCHFORSUCHLIBRARIESTOBEADDEDTOOURLIBRARYCOLLECTIONORCONTRIBUTEONETOSEESOMEEXAMPLESOPENTHEPROJECTCODICATIONINTHEEXAMPLESPROJECTLISTEDITTHEBLOCKSMAPTOSMALLTALKMAPTOJAVASCRIPTETCTOSEEEXAMPLESOFHOWTOPROVIDETRANSLATIONSFORBLOCKSTHESINGLEPALEEOPTIONPUTSALLBLOCKSREGARDLESSOFCATEGORYINTOASINGLEPALETTEITSINTENDEDMAINLYFORUSEBYCURRICULUMDEVELOPERSBUILDINGPARSONSPROBLEMSPROJECTSINWHICHONLYASMALLSETOFBLOCKSAREPROVIDEDANDTHETASKISTOARRANGETHOSEBLOCKSTOACHIEVEASETGOALINTHATAPPLICATIONTHISOPTIONISCOMBINEDWITHTHEHIDINGOFALMOSTALLPRIMITIVEBLOCKSSEEPAGEWHENSINGLEPALEEISTURNEDONTWOADDITIONALOPTIONSINITIALLYONAPPEARINTHESETTINGSMENUTHESHOWCATEGORIESOPTIONCONTROLSTHEAPPEARANCEOFTHEPALETTECATEGORYNAMESSUCHASANDWHILETHESHOWBUONSOPTIONCONTROLSTHEAPPEARANCEOFTHEANDBUTTONSINTHEPALETTETHEHSLPENCOLORMODELOPTIONCHANGESTHESETPENCHANGEPENANDPENBLOCKSTOPROVIDEMENUOPTIONSHUESATURATIONANDLIGHTNESSINSTEADOFHUESATURATIONANDBRIGHTNESSAKAVALUENOTETHENAMESATURATIONMEANSSOMETHINGDIFFERENTINHSLFROMINHSVSEEAPPENDIXAFORALLTHEINFORMATIONYOUNEEDABOUTCOLORSTHEDISABLECLICKTORUNOPTIONTELLSSNAPTOIGNOREUSERMOUSECLICKSONBLOCKSANDSCRIPTSIFITWOULDORDINARILYRUNTHEBLOCKORSCRIPTRIGHTCLICKINGANDDRAGGINGSTILLWORKANDSODOESCLICKINGINANINPUTSLOTTOEDITITTHISISANOTHERPARSONSPROBLEMFEATURETHEIDEAISTHATTHEREWILLBEBUTTONSDISPLAYEDTHATRUNCODEONLYINTEACHERAPPROVEDWAYSBUTKIDSCANUNCHECKTHECHECKBOXVISIBLESTEPPINGCONTROLSAFTERTHEMENUBUTTONSYOULLSEETHEPROJECTNAMEAFTERTHATCOMESTHEFOOTPRINTBUTTONUSEDTOTURNONVISIBLESTEPPINGANDWHENITSONTHESLIDERTOCONTROLTHESPEEDOFSTEPPINGSTAGERESIZINGBUTTONSSTILLINTHETOOLBARBUTABOVETHELEFTEDGEOFTHESTAGEARETWOBUTTONSTHATCHANGETHESIZEOFTHESTAGETHEFIRSTISTHESHRINKGROWBUTTONNORMALLYITLOOKSLIKETHISCLICKINGTHEBUTTONDISPLAYSTHESTAGEATHALFNORMALSIZEHORIZONTALLYANDVERTICALLYSOITTAKESUPOFITSUSUALAREAWHENTHESTAGEISHALFSIZETHEBUTTONLOOKSLIKETHISANDCLICKINGITRETURNSTHESTAGETONORMALSIZETHEMAINREASONYOUDWANTAHALFSIZESTAGEISDURINGTHEDEVELOPMENTPROCESSWHENYOUREASSEMBLINGSCRIPTSWITHWIDEINPUTEXPRESSIONSANDTHENORMALSCRIPTINGAREAISNTWIDEENOUGHTOSHOWTHECOMPLETESCRIPTYOUDTYPICALLYTHENSWITCHBACKTONORMALSIZETOTRYOUTTHEPROJECTTHENEXTPRESENTATIONMODEBUTTONNORMALLYLOOKSLIKETHISCLICKINGTHEBUTTONMAKESTHESTAGEDOUBLESIZEINBOTHDIMENSIONSANDELIMINATESMOSTOFTHEOTHERUSERINTERFACEELEMENTSTHEPALETTETHESCRIPTINGAREATHESPRITECORRALANDMOSTOFTHETOOLBARWHENYOUOPENASHAREDPROJECTUSINGALINKSOMEONEHASSENTYOUTHEPROJECTSTARTSINPRESENTATIONMODEWHILEINPRESENTATIONMODETHEBUTTONLOOKSLIKETHISCLICKINGITRETURNSTONORMALPROJECTDEVELOPMENTMODEPROJECTCONTROLBUTTONSABOVETHERIGHTEDGEOFTHESTAGEARETHREEBUTTONSTHATCONTROLTHERUNNINGOFTHEPROJECTTECHNICALLYTHEGREENAGISNOMOREAPROJECTCONTROLTHANANYTHINGELSETHATCANTRIGGERAHATBLOCKTYPINGONTHEKEYBOARDORCLICKINGONASPRITEBUTITSACONVENTIONTHATCLICKINGTHEFLAGSHOULDSTARTTHEACTIONOFTHEPROJECTFROMTHEBEGINNINGITSONLYACONVENTIONSOMEPROJECTSHAVENOFLAGCONTROLLEDSCRIPTSATALLBUTRESPONDTOKEYBOARDCONTROLSINSTEADCLICKINGTHEGREENFLAGALSODELETESTEMPORARYCLONESWHENEVERANYSCRIPTISRUNNINGNOTNECESSARILYINTHECURRENTSPRITETHEGREENFLAGISLITSHIFTCLICKINGTHEBUTTONENTERSTURBOMODEANDTHEBUTTONTHENLOOKSLIKEALIGHTNINGBOLTSHIFTCLICKINGAGAINTURNSTURBOMODEOFFSCRIPTSCANSIMULATECLICKINGTHEGREENFLAGBYBROADCASTINGTHESPECIALMESSAGETHEPAUSEBUTTONSUSPENDSRUNNINGALLSCRIPTSIFCLICKEDWHILESCRIPTSARERUNNINGTHEBUTTONCHANGESSHAPETOBECOMEAPLAYBUTTONCLICKINGITWHILEINTHISFORMRESUMESTHESUSPENDEDSCRIPTSTHEREISALSOAPAUSEALLBLOCKINTHECONTROLPALETTETHATCANBEINSERTEDINASCRIPTTOSUSPENDALLSCRIPTSTHISPROVIDESTHEESSENCEOFABREAKPOINTDEBUGGINGCAPABILITYTHEUSEOFTHEPAUSEBUTTONISSLIGHTLYDIFFERENTINVISIBLESTEPPINGMODEDESCRIBEDINCHAPTERITHESTOPBUTTONSTOPSALLSCRIPTSLIKETHESTOPALLBLOCKITDOESNOTPREVENTASCRIPTFROMSTARTINGAGAININRESPONSETOACLICKORKEYSTROKETHEUSERINTERFACEISALWAYSACTIVETHEREISONEEXCEPTIONGENERICWHENBLOCKSWILLNOTFIREAFTERASTOPUNTILSOMENONGENERICEVENTSTARTSASCRIPTTHESTOPBUTTONALSODELETESALLTEMPORARYCLONESBTHEPALETTEAREAATTHETOPOFTHEPALETTEAREAARETHEEIGHTBUTTONSTHATSELECTWHICHPALETTEWHICHBLOCKCATEGORYISSHOWNMOTIONLOOKSSOUNDPENCONTROLSENSINGOPERATORSANDVARIABLESWHICHALSOINCLUDESTHELISTANDOTHERBLOCKSTHEREARENOMENUSBEHINDTHESEBUTTONSBUTTONSINTHEPALETTEUNDERTHEEIGHTPALETTESELECTORBUTTONSATTHETOPOFTHEACTUALPALETTEARETWOSEMITRANSPARENTBUTTONSTHEFIRSTISTHESEARCHBUTTONWHICHISEQUIVALENTTOTYPINGCONTROLFITREPLACESTHEPALETTEWITHASEARCHBARINTOWHICHYOUCANTYPEPARTOFTHETITLETEXTOFTHEBLOCKYOURETRYINGTOFINDTOLEAVETHISSEARCHMODECLICKONEOFTHEEIGHTPALETTESELECTORSORTYPETHEESCAPEKEYTHEOTHERBUTTONISEQUIVALENTTOTHEMAKEABLOCKBUTTONEXCEPTTHATTHEDIALOGWINDOWTHATITOPENSHASTHECURRENTPALETTECOLORPRESELECTEDCONTEXTMENUSFORPALETTEBLOCKSMOSTELEMENTSOFTHESNAPDISPLAYCANBECONTROLCLICKEDRIGHTCLICKEDTOSHOWACONTEXTMENUWITHITEMSRELEVANTTOTHATELEMENTIFYOUCONTROLCLICKRIGHTCLICKAPRIMITIVEBLOCKINTHEPALETTEYOUSEETHISMENUTHEHELPOPTIONDISPLAYSABOXWITHDOCUMENTATIONABOUTTHEBLOCKHERESANEXAMPLEIFYOUCONTROLCLICKRIGHTCLICKACUSTOMUSERDEFINEDBLOCKINTHEPALETTEYOUSEETHISMENUTHEHELPOPTIONFORACUSTOMBLOCKDISPLAYSTHECOMMENTIFANYATTACHEDTOTHECUSTOMBLOCKSHATBLOCKINTHEBLOCKEDITORHEREISANEXAMPLEOFABLOCKWITHACOMMENTANDITSHELPDISPLAYIFTHEHELPTEXTINCLUDESAURLITISCLICKABLEANDWILLOPENTHEPAGEINANEWTABTHEDELETEBLOCKDENITIONOPTIONASKSFORCONFIRMATIONTHENDELETESTHECUSTOMBLOCKANDREMOVESITFROMANYSCRIPTSINWHICHITAPPEARSTHERESULTOFTHISREMOVALMAYNOTLEAVEASENSIBLESCRIPTITSBESTTOFINDANDCORRECTSUCHSCRIPTSBEFOREDELETINGABLOCKNOTETHATTHEREISNOOPTIONTOHIDEACUSTOMBLOCKTHISCANBEDONEINTHEBLOCKEDITORBYRIGHTCLICKINGONTHEHATBLOCKTHEDUPLICATEBLOCKDENITIONOPTIONMAKESACOPYOFTHEBLOCKANDOPENSTHATCOPYINTHEBLOCKEDITORSINCEYOUCANTHAVETWOCUSTOMBLOCKSWITHTHESAMETITLETEXTANDINPUTTYPESTHECOPYISCREATEDWITHORAHIGHERNUMBERIFNECESSARYATTHEENDOFTHEBLOCKPROTOTYPETHEEXPORTBLOCKDENITIONOPTIONWRITESAFILEINYOURBROWSERSDOWNLOADSDIRECTORYCONTAININGTHEDEFINITIONOFTHISBLOCKANDANYOTHERCUSTOMBLOCKSTHATTHISBLOCKINVOKESDIRECTLYORINDIRECTLYSOTHERESULTINGFILECANBELOADEDLATERWITHOUTTHERISKOFREDUNDENEDBLOCKSBECAUSEOFMISSINGDEPENDENCIESTHEEDITOPTIONOPENSABLOCKEDITORWITHTHEDEFINITIONOFTHECUSTOMBLOCKCONTEXTMENUFORTHEPALETTEBACKGROUNDRIGHTCLICKCONTROLCLICKONTHEGREYBACKGROUNDOFTHEPALETTEAREASHOWSTHISMENUTHENDBLOCKSOPTIONDOESTHESAMETHINGASTHEMAGNIFYINGGLASSBUTTONTHEHIDEBLOCKSOPTIONOPENSADIALOGBOXINWHICHYOUCANCHOOSEWHICHBLOCKSCUSTOMASWELLASPRIMITIVESHOULDBEHIDDENWITHINTHATDIALOGBOXTHECONTEXTMENUOFTHEBACKGROUNDALLOWSYOUTOCHECKORUNCHECKALLTHEBOXESATONCETHEMAKEACATEGORYOPTIONWHICHISINTENDEDMAINLYFORAUTHORSOFSNAPEXTENSIONSLETSYOUADDCUSTOMCATEGORIESTOTHEPALETTEITOPENSASMALLDIALOGWINDOWINWHICHYOUSPECIFYANAMEANDACOLORFORTHENEWCATEGORYPICKADARKCOLORBECAUSEITWILLBELIGHTENEDFORZEBRACOLORINGWHENUSERSNESTBLOCKSOFTHESAMECATEGORYCUSTOMCATEGORIESARESHOWNBELOWTHEBUILTINCATEGORIESINTHECATEGORYSELECTORTHISEXAMPLECOMESFROMECKARTMODROWSSCISNAPLIBRARYNOTETHATTHECUSTOMCATEGORYLISTHASITSOWNSCROLLBARWHICHAPPEARSIFYOUHAVEMORETHANSIXCUSTOMCATEGORIESNOTEALSOTHATTHEBUTTONSTOSELECTACUSTOMCATEGORYOCCUPYTHEFULLWIDTHOFTHEPALETTEAREAUNLIKETHEBUILTINCATEGORIESWHICHOCCUPYONLYHALFOFTHEWIDTHCUSTOMCATEGORIESARELISTEDINALPHABETICALORDERTHISISWHYPROFMODROWCHOSETOSTARTEACHCATEGORYNAMEWITHANUMBERSOTHATHECOULDCONTROLTHEIRORDERIFTHEREARENOBLOCKSVISIBLEINACATEGORYTHECATEGORYNAMEISDIMMEDINTHECATEGORYSELECTORHEREWESEETHATCATEGORYFOOHASBLOCKSINITBUTCATEGORIESBARANDGARPLYAREEMPTYTHEBUILTINCATEGORIESAREALSOSUBJECTTODIMMINGIFALLOFTHEBLOCKSOFACATEGORYAREHIDDENPALETTERESIZINGATTHERIGHTENDOFTHEPALETTEAREAJUSTTOTHELEFTOFTHESCRIPTINGAREAISARESIZINGHANDLETHATCANBEDRAGGEDRIGHTWARDTOINCREASETHEWIDTHOFTHEPALETTEAREATHISISUSEFULIFYOUWRITECUSTOMBLOCKSWITHVERYLONGNAMESYOUCANTREDUCETHEWIDTHOFTHEPALETTEBELOWITSSTANDARDVALUECTHESCRIPTINGAREATHESCRIPTINGAREAISTHEMIDDLEVERTICALREGIONOFTHESNAPWINDOWCONTAININGSCRIPTSANDALSOSOMECONTROLSFORTHEAPPEARANCEANDBEHAVIOROFASPRITETHEREISALWAYSACURRENTSPRITEWHOSESCRIPTSARESHOWNINTHESCRIPTINGAREAADARKGREYROUNDEDRECTANGLEINTHESPRITECORRALSHOWSWHICHSPRITEORTHESTAGEISCURRENTNOTETHATITSONLYTHEVISIBLEDISPLAYOFTHESCRIPTINGAREATHATISCURRENTFORASPRITEALLSCRIPTSOFALLSPRITESMAYBERUNNINGATTHESAMETIMECLICKINGONASPRITETHUMBNAILINTHESPRITECORRALMAKESITCURRENTTHESTAGEITSELFCANBESELECTEDASCURRENTINWHICHCASETHEAPPEARANCEISDIFFERENTWITHSOMEPRIMITIVESNOTSHOWNSPRITEAPPEARANCEANDBEHAVIORCONTROLSATTHETOPOFTHESCRIPTINGAREAAREAPICTUREOFTHESPRITEANDSOMECONTROLSFORITNOTETHATTHESPRITEPICTUREREFLECTSITSROTATIONIFANYTHEREARETHREETHINGSTHATCANBECONTROLLEDHERETHETHREECIRCULARBUTTONSINACOLUMNATTHELEFTCONTROLTHESPRITESROTATIONBEHAVIORSPRITECOSTUMESAREDESIGNEDTOBERIGHTSIDEUPWHENTHESPRITEISFACINGTOWARDTHERIGHTDIRECTIONIFTHETOPMOSTBUTTONISLITTHEDEFAULTASSHOWNINTHEPICTUREABOVETHENTHESPRITESCOSTUMEROTATESASTHESPRITECHANGESDIRECTIONIFTHEMIDDLEBUTTONISSELECTEDTHENTHECOSTUMEISREVERSEDLEFTRIGHTWHENTHESPRITESDIRECTIONISROUGHLYLEFTWARDDIRECTIONBETWEENANDOREQUIVALENTLYBETWEENANDIFTHEBOTTOMBUTTONISSELECTEDTHECOSTUMESORIENTATIONDOESNOTCHANGEREGARDLESSOFTHESPRITESDIRECTIONTHESPRITESNAMECANBECHANGEDINTHETEXTBOXTHATINTHISPICTURESAYSSPRITEFINALLYIFTHEDRAGGABLECHECKBOXISCHECKEDTHENTHEUSERCANMOVETHESPRITEONTHESTAGEBYCLICKINGANDDRAGGINGITTHECOMMONUSEOFTHISFEATUREISINGAMEPROJECTSINWHICHSOMESPRITESAREMEANTTOBEUNDERTHEPLAYERSCONTROLBUTOTHERSARENOTSCRIPTINGAREATABSJUSTBELOWTHESPRITECONTROLSARETHREETABSTHATDETERMINEWHATISSHOWNINTHESCRIPTINGAREASCRIPTSANDBLOCKSWITHINSCRIPTSMOSTOFWHATSDESCRIBEDINTHISSECTIONALSOAPPLIESTOBLOCKSANDSCRIPTSINABLOCKEDITORCLICKINGONASCRIPTWHICHINCLUDESASINGLEUNATTACHEDBLOCKRUNSITIFTHESCRIPTSTARTSWITHAHATBLOCKCLICKINGONTHESCRIPTRUNSITEVENIFTHEEVENTINTHEHATBLOCKDOESNTHAPPENTHISISAUSEFULDEBUGGINGTECHNIQUEWHENYOUHAVEADOZENSPRITESANDTHEYEACHHAVEFIVESCRIPTSWITHGREENFLAGHATBLOCKSANDYOUWANTTOKNOWWHATASINGLEONEOFTHOSESCRIPTSDOESTHESCRIPTWILLHAVEAGREENHALOAROUNDITWHILEITSRUNNINGIFTHESCRIPTISSHAREDWITHCLONESTHENWHILEITHASTHEGREENHALOITWILLALSOHAVEACOUNTOFHOWMANYINSTANCESOFTHESCRIPTARERUNNINGCLICKINGASCRIPTWITHSUCHAHALOSTOPSTHESCRIPTIFTHESCRIPTINCLUDESAWARPBLOCKWHICHMIGHTBEINSIDEACUSTOMBLOCKUSEDINTHESCRIPTTHENSNAPMAYNOTRESPONDIMMEDIATELYTOCLICKSIFASCRIPTISSHOWNWITHAREDHALOTHATMEANSTHATANERRORWASCAUGHTINTHATSCRIPTSUCHASUSINGALISTWHEREANUMBERWASNEEDEDORVICEVERSACLICKINGTHESCRIPTWILLTURNOFFTHEHALOIFANYBLOCKSHAVEBEENDRAGGEDINTOTHESCRIPTINGAREATHENINITSTOPRIGHTCORNERYOULLSEEANUNDOANDORREDOBUTTONTHATCANBEUSEDTOUNDOORREDOBLOCKANDSCRIPTDROPSWHENYOUUNDOADROPINTOANINPUTSLOTWHATEVERUSEDTOBEINTHESLOTISRESTOREDTHEREDOBUTTONAPPEARSONCEYOUVEUSEDUNDOTHETHIRDBUTTONSTARTSKEYBOARDEDITINGMODESECTIONDPAGECONTROLCLICKRIGHTCLICKINGAPRIMITIVEBLOCKWITHINASCRIPTSHOWSAMENULIKETHISONECOMMANDBLOCKREPORTERBLOCKTHEHELPOPTIONSHOWSTHEHELPSCREENFORTHEBLOCKJUSTASINTHEPALETTETHEOTHEROPTIONSAPPEARONLYWHENABLOCKISRIGHTCLICKEDCONTROLCLICKEDINTHESCRIPTINGAREANOTEVERYPRIMITIVEBLOCKHASARELABELOPTIONWHENPRESENTITALLOWSTHEBLOCKTOBEREPLACEDBYANOTHERSIMILARBLOCKKEEPINGTHEINPUTEXPRESSIONSINPLACEFOREXAMPLEHERESWHATHAPPENSWHENYOUCHOOSERELABELFORANARITHMETICOPERATORNOTETHATTHEINPUTSTOTHEEXISTINGBLOCKAREDISPLAYEDINTHEMENUOFALTERNATIVESALSOCLICKABLOCKINTHEMENUTOCHOOSEITORCLICKOUTSIDETHEMENUTOKEEPTHEORIGINALBLOCKNOTETHATTHELASTTHREECHOICESARENOTAVAILABLEINTHEPALETTEYOUMUSTUSETHERELABELFEATURETOACCESSTHEMNOTEVERYREPORTERHASACOMPILEOPTIONITEXISTSONLYFORTHEHIGHERORDERFUNCTIONSWHENSELECTEDALIGHTNINGBOLTAPPEARSBEFORETHEBLOCKNAMEANDSNAPTRIESTOCOMPILETHEFUNCTIONINSIDETHERINGTOJAVASCRIPTSOITRUNSATPRIMITIVESPEEDTHISWORKSONLYFORSIMPLEFUNCTIONSBUTTHEHIGHERORDERFUNCTIONSTILLWORKSEVENIFTHECOMPILATIONDOESNTTHEFUNCTIONTOBECOMPILEDMUSTBEQUICKBECAUSEITWILLBEUNINTERRUPTABLEINPARTICULARIFITSANINFINITELOOPYOUMAYHAVETOQUITYOURBROWSERTORECOVERTHEREFORESAVEYOURPROJECTBEFOREYOUEXPERIMENTWITHTHECOMPILATIONFEATURETHERIGHTCLICKMENUFORACOMPILEDHIGHERORDERFUNCTIONWILLHAVEANUNCOMPILEOPTIONTHISISANEXPERIMENTALFEATURETHEDUPLICATEOPTIONFORACOMMANDBLOCKMAKESACOPYOFTHEENTIRESCRIPTSTARTINGFROMTHESELECTEDBLOCKFORAREPORTERITCOPIESONLYTHATREPORTERANDITSINPUTSTHECOPYISATTACHEDTOTHEMOUSEANDYOUCANDRAGITTOANOTHERSCRIPTOREVENTOANOTHERBLOCKEDITORWINDOWEVENTHOUGHYOUARENOLONGERHOLDINGDOWNTHEMOUSEBUTTONCLICKTHEMOUSETODROPTHESCRIPTCOPYTHEBLOCKPICTUREUNDERNEATHTHEWORDDUPLICATEFORACOMMANDBLOCKISANOTHERDUPLICATIONOPTIONBUTITDUPLICATESONLYTHESELECTEDBLOCKNOTEVERYTHINGUNDERITINTHESCRIPTNOTETHATIFTHESELECTEDBLOCKISACSHAPEDCONTROLBLOCKTHESCRIPTINSIDEITSCSHAPEDSLOTISINCLUDEDIFTHEBLOCKISATTHEENDOFITSSCRIPTTHISOPTIONDOESNOTAPPEARUSEDUPLICATEINSTEADTHEEXTRACTOPTIONREMOVESTHESELECTEDBLOCKFROMTHESCRIPTANDLEAVESYOUHOLDINGITWITHTHEMOUSEINOTHERWORDSITSLIKETHEBLOCKPICTUREOPTIONBUTITDOESNTLEAVEACOPYOFTHEBLOCKINTHEORIGINALSCRIPTIFTHEBLOCKISATTHEENDOFITSSCRIPTTHISOPTIONDOESNOTAPPEARJUSTGRABTHEBLOCKWITHTHEMOUSEASHORTHANDFORTHISOPERATIONISTOSHIFTCLICKANDDRAGOUTTHEBLOCKTHEDELETEOPTIONDELETESTHESELECTEDBLOCKFROMTHESCRIPTTHEADDCOMMENTOPTIONCREATESACOMMENTLIKETHESAMEOPTIONINTHEBACKGROUNDOFTHESCRIPTINGAREABUTATTACHESITTOTHEBLOCKYOUCLICKEDTHESCRIPTPICOPTIONSAVESAPICTUREOFTHEENTIRESCRIPTNOTJUSTFROMTHESELECTEDBLOCKTOTHEENDINTOYOURDOWNLOADFOLDERORINSOMEBROWSERSOPENSANEWBROWSERTABCONTAININGTHEPICTUREINTHELATTERCASEYOUCANUSETHEBROWSERSSAVEFEATURETOPUTTHEPICTUREINAFILETHISISASUPERUSEFULFEATUREIFYOUHAPPENTOBEWRITINGASNAPMANUALIFYOUHAVEARETINADISPLAYCONSIDERTURNINGOFFRETINASUPPORTBEFOREMAKINGSCRIPTPICTURESIFNOTTHEYENDUPHUGEFORREPORTERSNOTINSIDEASCRIPTTHEREISANADDITIONALRESULTPICOPTIONTHATCALLSTHEREPORTERANDINCLUDESASPEECHBALLOONWITHTHERESULTINTHEPICTURENOTETHEDOWNLOADEDFILEISASMARTPICTUREITALSOCONTAINSTHECODEOFTHESCRIPTASIFYOUDEXPORTEDTHEPROJECTIFYOULATERDRAGTHEFILEINTOTHECOSTUMESTABITWILLBELOADEDASACOSTUMEBUTIFYOUDRAGITINTOTHESCRIPTSTABITWILLBELOADEDASASCRIPTWHICHYOUCANDROPWHEREVERYOUWANTITINTHESCRIPTINGAREAIFTHESCRIPTDOESNOTSTARTWITHAHATBLOCKORYOUCLICKEDONAREPORTERTHENTHERESONEMOREOPTIONRINGIFYANDIFTHEREISALREADYAGREYRINGAROUNDTHEBLOCKORSCRIPTUNRINGIFYRINGIFYSURROUNDSTHEBLOCKREPORTERORTHEENTIRESCRIPTCOMMANDWITHAGREYRINGMEANINGTHATTHEBLOCKSINSIDETHERINGARETHEMSELVESDATAASANINPUTTOAHIGHERORDERPROCEDURERATHERTHANSOMETHINGTOBEEVALUATEDWITHINTHESCRIPTSEECHAPTERVIPROCEDURESASDATACLICKINGACUSTOMBLOCKINASCRIPTGIVESASIMILARBUTDIFFERENTMENUTHERELABELOPTIONFORCUSTOMBLOCKSSHOWSAMENUOFOTHERSAMESHAPECUSTOMBLOCKSWITHTHESAMEINPUTSATPRESENTYOUCANTRELABELACUSTOMBLOCKTOAPRIMITIVEBLOCKORVICEVERSATHETWOOPTIONSATTHEBOTTOMFORCUSTOMBLOCKSONLYARETHESAMEASINTHEPALETTETHEOTHEROPTIONSARETHESAMEASFORPRIMITIVECOMMANDSIFAREPORTERBLOCKISINTHESCRIPTINGAREAPOSSIBLYWITHINPUTSINCLUDEDBUTNOTITSELFSERVINGASINPUTTOANOTHERBLOCKTHENTHEMENUISALITTLEDIFFERENTAGAINWHATSNEWHEREISTHERESULTPICOPTIONITSLIKESCRIPTPICBUTITINCLUDESINTHEPICTUREASPEECHBALLOONWITHTHERESULTOFCALLINGTHEBLOCKBROADCASTANDBROADCASTANDWAITBLOCKSINTHESCRIPTINGAREAHAVEANADDITIONALOPTIONRECEIVERSWHENCLICKEDITCAUSESAMOMENTARYBELOOKINGFORITWHENYOUCLICKHALOAROUNDTHEPICTUREINTHESPRITECORRALOFTHOSESPRITESTHATHAVEAWHENIRECEIVEHATBLOCKFORTHESAMEMESSAGESIMILARLYWHENIRECEIVEBLOCKSHAVEASENDERSOPTIONTHATLIGHTUPTHESPRITECORRALICONSOFSPRITESTHATBROADCASTTHESAMEMESSAGESCRIPTINGAREABACKGROUNDCONTEXTMENUCONTROLCLICKRIGHTCLICKONTHEGREYSTRIPEDBACKGROUNDOFTHESCRIPTINGAREAGIVESTHISMENUTHEUNDROPOPTIONISASORTOFUNDOFEATUREFORTHECOMMONCASEOFDROPPINGABLOCKSOMEWHEREOTHERTHANWHEREYOUMEANTITTOGOITREMEMBERSALLTHEDRAGGINGANDDROPPINGYOUVEDONEINTHISSPRITESSCRIPTINGAREATHATISOTHERSPRITESHAVETHEIROWNSEPARATEDROPMEMORYANDUNDOESTHEMOSTRECENTRETURNINGTHEBLOCKTOITSFORMERPOSITIONANDRESTORINGTHEPREVIOUSVALUEINTHERELEVANTINPUTSLOTIFANYONCEYOUVEUNDROPPEDSOMETHINGTHEREDROPOPTIONAPPEARSANDALLOWSYOUTOREPEATTHEOPERATIONYOUJUSTUNDIDTHESEMENUOPTIONSAREEQUIVALENTTOTHEANDBUTTONSDESCRIBEDEARLIERTHECLEANUPOPTIONREARRANGESTHEPOSITIONOFSCRIPTSSOTHATTHEYAREINASINGLECOLUMNWITHTHESAMELEFTMARGINANDWITHUNIFORMSPACINGBETWEENSCRIPTSTHISISAGOODIDEAIFYOUCANTREADYOUROWNPROJECTTHEADDCOMMENTOPTIONPUTSACOMMENTBOXLIKETHEPICTURETOTHERIGHTINTHESCRIPTINGAREAITSATTACHEDTOTHEMOUSEASWITHDUPLICATINGSCRIPTSSOYOUPOSITIONTHEMOUSEWHEREYOUWANTTHECOMMENTANDCLICKTORELEASEITYOUCANTHENEDITTHETEXTINTHECOMMENTASDESIREDYOUCANDRAGTHEBOTTOMRIGHTCORNEROFTHECOMMENTBOXTORESIZEITCLICKINGTHEARROWHEADATTHETOPLEFTCHANGESTHEBOXTOASINGLELINECOMPACTFORMSOTHATYOUCANHAVEANUMBEROFCOLLAPSEDCOMMENTSINTHESCRIPTINGAREAANDJUSTEXPANDONEOFTHEMWHENYOUWANTTOREADITINFULLIFYOUDRAGACOMMENTOVERABLOCKINASCRIPTTHECOMMENTWILLBEATTACHEDTOTHEBLOCKWITHAYELLOWLINECOMMENTSHAVETHEIROWNCONTEXTMENUWITHOBVIOUSMEANINGSBACKTOTHEOPTIONSINTHEMENUFORTHEBACKGROUNDOFTHESCRIPTINGAREAPICTUREONTHEPREVIOUSPAGETHESCRIPTSPICOPTIONSAVESOROPENSANEWBROWSERTABWITHAPICTUREOFALLSCRIPTSINTHESCRIPTINGAREAJUSTASTHEYAPPEARBUTWITHOUTTHEGREYSTRIPEDBACKGROUNDNOTETHATALLSCRIPTSINTHESCRIPTINGAREAMEANSJUSTTHETOPLEVELSCRIPTSOFTHECURRENTSPRITENOTOTHERSPRITESSCRIPTSORCUSTOMBLOCKDEFINITIONSTHISISALSOASMARTPICTUREIFYOUDRAGITINTOTHESCRIPTINGAREAITWILLCREATEANEWSPRITEWITHTHOSESCRIPTSINITSSCRIPTINGAREAFINALLYTHEMAKEABLOCKOPTIONDOESTHESAMETHINGASTHEMAKEABLOCKBUTTONINTHEPALETTESITSASHORTCUTSOTHATYOUDONTHAVETOKEEPSCROLLINGDOWNTHEPALETTEIFYOUMAKEALOTOFBLOCKSCONTROLSINTHECOSTUMESTABIFYOUCLICKONTHEWORDCOSTUMESUNDERTHESPRITECONTROLSYOULLSEESOMETHINGLIKETHISTHETURTLECOSTUMEISALWAYSPRESENTINEVERYSPRITEITISCOSTUMENUMBEROTHERCOSTUMESCANBEPAINTEDWITHINSNAPORIMPORTEDFROMFILESOROTHERBROWSERTABSIFYOURBROWSERSUPPORTSTHATCLICKINGONACOSTUMESELECTSITTHATISTHESPRITEWILLLOOKLIKETHESELECTEDCOSTUMECLICKINGONTHEPAINTBRUSHICONOPENSTHEPAINTEDITORINWHICHYOUCANCREATEANEWCOSTUMECLICKINGONTHECAMERAICONOPENSAWINDOWINWHICHYOUSEEWHATYOURCOMPUTERSCAMERAISSEEINGANDYOUCANTAKEAPICTUREWHICHWILLBETHEFULLSIZEOFTHESTAGEUNLESSYOUSHRINKITINTHEPAINTEDITORTHISWORKSONLYIFYOUGIVESNAPPERMISSIONTOUSETHECAMERAANDMAYBEONLYIFYOUOPENEDSNAPINSECUREHTTPSMODEANDTHENONLYIFYOURBROWSERLOVESYOUBRIANSBEDROOMWHENHESSTAYINGATPAULSHOUSECONTROLCLICKINGRIGHTCLICKINGONTHETURTLEPICTUREGIVESTHISMENUINTHISMENUYOUCHOOSETHETURTLESROTATIONPOINTWHICHISALSOTHEPOINTFROMWHICHTHETURTLEDRAWSLINESTHETWOPICTURESBELOWSHOWWHATTHESTAGELOOKSLIKEAFTERDRAWINGASQUAREINEACHMODETIPOTHERWISEKNOWNASJENSMODEISONTHELEFTINTHEPICTURESBELOWMIDDLEBRIANMODEONTHERIGHTASYOUSEETIPMEANSTHEFRONTTIPOFTHEARROWHEADMIDDLEISNOTTHEMIDDLEOFTHESHADEDREGIONBUTACTUALLYTHEMIDDLEOFTHEFOURVERTICESTHECONCAVEONEIFTHESHAPEWEREASIMPLEISOSCELESTRIANGLEINSTEADOFAFANCIERARROWHEADITWOULDMEANTHEMIDPOINTOFTHEBACKEDGETHEADVANTAGEOFTIPMODEISTHATTHESPRITEISLESSLIKELYTOOBSCURETHEDRAWINGTHEADVANTAGEOFMIDDLEMODEISTHATTHEROTATIONPOINTOFASPRITEISRARELYATATIPANDSTUDENTSAREPERHAPSLESSLIKELYTOBECONFUSEDABOUTJUSTWHATWILLHAPPENIFYOUASKTHETURTLETOTURNDEGREESFROMTHEPOSITIONSHOWNITSALSOTHETRADITIONALROTATIONPOINTOFTHELOGOTURTLEWHICHORIGINATEDTHISSTYLEOFDRAWINGCOSTUMESOTHERTHANTHETURTLEHAVEADIFFERENTCONTEXTMENUTHEEDITOPTIONOPENSTHEPAINTEDITORONTHISCOSTUMETHERENAMEOPTIONOPENSADIALOGBOXINWHICHYOUCANRENAMETHECOSTUMEACOSTUMESINITIALNAMECOMESFROMTHEFILEFROMWHICHITWASIMPORTEDIFANYORISSOMETHINGLIKECOSTUMEDUPLICATEMAKESACOPYOFTHECOSTUMEINTHESAMESPRITEPRESUMABLYYOUDDOTHATBECAUSEYOUINTENDTOEDITONEOFTHECOPIESDELETEISOBVIOUSTHEGETBLOCKSOPTIONAPPEARSONLYFORASMARTCOSTUMEANDBRINGSITSSCRIPTTOTHESCRIPTINGAREATHEEXPORTOPTIONSAVESTHECOSTUMEASAFILEONYOURCOMPUTERINYOURUSUALDOWNLOADSFOLDERYOUCANDRAGCOSTUMESUPANDDOWNINTHECOSTUMESTABINORDERTORENUMBERTHEMSOTHATNEXTCOSTUMEWILLBEHAVEASYOUPREFERIFYOUDRAGASMARTPICTUREOFASCRIPTINTOTHECOSTUMESTABITSICONWILLDISPLAYTHETEXTINTHECORNERTOREMINDYOUTHATITINCLUDESCODEITSRIGHTCLICKMENUWILLHAVEANEXTRAGETBLOCKSOPTIONTHATSWITCHESTOTHESCRIPTSTABWITHTHESCRIPTREADYTOBEDROPPEDTHERETHEPAINTEDITORHEREISAPICTUREOFAPAINTEDITORWINDOWIFYOUVEUSEDANYPAINTINGPROGRAMMOSTOFTHISWILLBEFAMILIARTOYOUCURRENTLYCOSTUMESYOUIMPORTCANBEEDITEDONLYIFTHEYAREINABITMAPFORMATPNGJPEGGIFETCTHEREISAVECTOREDITORBUTITWORKSONLYFORCREATINGACOSTUMENOTEDITINGANIMPORTEDVECTORSVGPICTUREUNLIKETHECASEOFTHEBLOCKEDITORONLYONEPAINTEDITORWINDOWCANBEOPENATATIMETHETENSQUAREBUTTONSINTWOROWSOFFIVENEARTHETOPLEFTOFTHEWINDOWARETHETOOLSTHETOPROWFROMLEFTTORIGHTARETHEPAINTBRUSHTOOLTHEOUTLINEDRECTANGLETOOLTHEOUTLINEDELLIPSETOOLTHEERASERTOOLANDTHEROTATIONPOINTTOOLTHEBOTTOMROWTOOLSARETHELINEDRAWINGTOOLTHESOLIDRECTANGLETOOLTHESOLIDELLIPSETOOLTHEFLOODFILLTOOLANDTHEEYEDROPPERTOOLBELOWTHETOOLSISAROWOFFOURBUTTONSTHATIMMEDIATELYCHANGETHEPICTURETHEFIRSTTWOCHANGEITSOVERALLSIZETHENEXTTWOFLIPTHEPICTUREAROUNDHORIZONTALLYORVERTICALLYBELOWTHESEAREACOLORPALETTEAGREYSCALETAPEANDLARGERBUTTONSFORBLACKWHITEANDTRANSPARENTPAINTBELOWTHESEISASOLIDBARDISPLAYINGTHECURRENTLYSELECTEDCOLORBELOWTHATISAPICTUREOFALINESHOWINGTHEBRUSHWIDTHFORPAINTINGANDDRAWINGANDBELOWTHATYOUCANSETTHEWIDTHEITHERWITHASLIDERORBYTYPINGANUMBERINPIXELSINTOTHETEXTBOXFINALLYTHECHECKBOXCONSTRAINSTHELINETOOLTODRAWHORIZONTALLYORVERTICALLYTHERECTANGLETOOLSTODRAWSQUARESANDTHEELLIPSETOOLSTODRAWCIRCLESYOUCANGETTHESAMEEFFECTTEMPORARILYBYHOLDINGDOWNTHESHIFTKEYWHICHMAKESACHECKAPPEARINTHEBOXASLONGASYOUHOLDITDOWNBUTTHECAPSLOCKKEYDOESNTAFFECTITYOUCANCORRECTERRORSWITHTHEUNDOBUTTONWHICHREMOVESTHELASTTHINGYOUDREWORTHECLEARBUTTONWHICHERASESTHEENTIREPICTURENOTEITDOESNOTREVERTTOWHATTHECOSTUMELOOKEDLIKEBEFOREYOUSTARTEDEDITINGITIFTHATSWHATYOUWANTCLICKTHECANCELBUTTONATTHEBOTTOMOFTHEEDITORWHENYOUREFINISHEDEDITINGTOKEEPYOURCHANGESCLICKOKNOTETHATTHEELLIPSETOOLSWORKMOREINTUITIVELYTHANONESINOTHERSOFTWAREYOUMAYHAVEUSEDINSTEADOFDRAGGINGBETWEENOPPOSITECORNERSOFTHERECTANGLECIRCUMSCRIBINGTHEELLIPSEYOUWANTSOTHATTHEENDPOINTSOFYOURDRAGGINGHAVENOOBVIOUSCONNECTIONTOTHEACTUALSHAPEINSNAPYOUSTARTATTHECENTEROFTHEELLIPSEYOUWANTANDDRAGOUTTOTHEEDGEWHENYOULETGOOFTHEBUTTONTHEMOUSECURSORWILLBEONTHECURVEIFYOUDRAGOUTFROMTHECENTERATDEGREESTOTHEAXESTHERESULTINGCURVEWILLBEACIRCLEIFYOUDRAGMOREHORIZONTALLYORVERTICALLYTHEELLIPSEWILLBEMOREECCENTRICOFCOURSEIFYOUWANTANEXACTCIRCLEYOUCANHOLDDOWNTHESHIFTKEYORCHECKTHECHECKBOXTHERECTANGLETOOLSTHOUGHWORKTHEWAYYOUEXPECTYOUSTARTATONECORNEROFTHEDESIREDRECTANGLEANDDRAGTOTHEOPPOSITECORNERUSINGTHEEYEDROPPERTOOLYOUCANCLICKANYWHEREINTHESNAPWINDOWEVENOUTSIDETHEPAINTEDITORANDTHETOOLWILLSELECTTHECOLORATTHEMOUSECURSORFORUSEINTHEPAINTEDITORYOUCANONLYDOTHISONCEBECAUSETHEPAINTEDITORAUTOMATICALLYSELECTSTHEPAINTBRUSHWHENYOUCHOOSEACOLOROFCOURSEYOUCANCLICKONTHEEYEDROPPERTOOLBUTTONAGAINTHEONLYOTHERNONOBVIOUSTOOLISTHEROTATIONPOINTTOOLITSHOWSINTHEPAINTEDITORWHERETHESPRITESCURRENTROTATIONCENTERISTHEPOINTAROUNDWHICHITTURNSWHENYOUUSEATURNBLOCKIFYOUCLICKORDRAGINTHEPICTURETHEROTATIONPOINTWILLMOVEWHEREYOUCLICKYOUDWANTTODOTHISFOREXAMPLEIFYOUWANTACHARACTERTOBEABLETOWAVEITSARMSOYOUUSETWOSPRITESCONNECTEDTOGETHERYOUWANTTHEROTATIONPOINTOFTHEARMSPRITETOBEATTHEENDWHEREITJOINSTHEBODYSOITREMAINSATTACHEDTOTHESHOULDERWHILEWAVINGTHEVECTOREDITORSCONTROLSAREMUCHLIKETHOSEINTHEBITMAPEDITORONEPOINTOFDIFFERENCEISTHATTHEBITMAPEDITORHASTWOBUTTONSFORSOLIDANDOUTLINERECTANGLESANDSIMILARLYFORELLIPSESBUTINTHEVECTOREDITORTHEREISALWAYSANEDGECOLORANDAFILLCOLOREVENIFTHELATTERISTRANSPARENTPAINTANDSOONLYONEBUTTONPERSHAPEISNEEDEDSINCEEACHSHAPETHATYOUDRAWISASEPARATELAYERLIKESPRITESONTHESTAGETHEREARECONTROLSTOMOVETHESELECTEDSHAPEUPFRONTWARDORDOWNREARWARDRELATIVETOOTHERSHAPESTHEREISASELECTIONTOOLTODRAGOUTARECTANGULARAREAANDSELECTALLTHESHAPESWITHINTHATAREACONTROLSINTHESOUNDSTABTHEREISNOSOUNDEDITORINSNAPANDALSONOCURRENTSOUNDTHEWAYTHERESACURRENTCOSTUMEFOREACHSPRITETHESPRITEALWAYSHASANAPPEARANCEUNLESSHIDDENBUTITDOESNTSINGUNLESSEXPLICITLYASKEDSOTHECONTEXTMENUFORSOUNDSHASONLYRENAMEDELETEANDEXPORTOPTIONSANDITHASACLICKABLEBUTTONLABELEDPLAYORSTOPASAPPROPRIATETHEREISASOUNDRECORDERWHICHAPPEARSIFYOUCLICKTHEREDRECORDBUTTONTHEFIRSTROUNDBUTTONSTARTSRECORDINGTHESECONDSQUAREBUTTONSTOPSRECORDINGTHETHIRDTRIANGULARBUTTONPLAYSBACKARECORDEDSOUNDIFYOUDONTLIKETHERESULTCLICKTHEROUNDBUTTONAGAINTORERECORDWHENYOURESATISFIEDPUSHTHESAVEBUTTONIFYOUNEEDASOUNDEDITORCONSIDERTHEFREEBOTHSENSESHTTPSAUDACITYSOURCEFORGENETDKEYBOARDEDITINGANONGOINGAREAOFRESEARCHISHOWTOMAKEVISUALPROGRAMMINGLANGUAGESUSABLEBYPEOPLEWITHVISUALORMOTORICDISABILITIESASAFIRSTSTEPINTHISDIRECTIONWEPROVIDEAKEYBOARDEDITORSOTHATYOUCANCREATEANDEDITSCRIPTSWITHOUTTRACKINGTHEMOUSESOFARNOTEVERYUSERINTERFACEELEMENTISCONTROLLABLEBYKEYBOARDANDWEHAVENTEVENBEGUNPROVIDINGOUTPUTSUPPORTSUCHASINTERFACINGWITHASPEECHSYNTHESIZERTHISISANAREAINWHICHWEKNOWWEHAVEALONGWAYTOGOBUTITSASTARTTHEKEYBOARDEDITORMAYALSOBEUSEFULTOANYONEWHOCANTYPEFASTERTHANTHEYCANDRAGBLOCKSSTARTINGANDSTOPPINGTHEKEYBOARDEDITORTHEREARETHREEWAYSTOSTARTTHEKEYBOARDEDITORSHIFTCLICKINGANYWHEREINTHESCRIPTINGAREAWILLSTARTTHEEDITORATTHATPOINTEITHEREDITINGANEXISTINGSCRIPTORIFYOUSHIFTCLICKONTHEBACKGROUNDOFTHESCRIPTINGAREAEDITINGANEWSCRIPTATTHEMOUSEPOSITIONALTERNATIVELYTYPINGSHIFTENTERWILLSTARTTHEEDITORONANEXISTINGSCRIPTANDYOUCANUSETHETABKEYTOSWITCHTOANOTHERSCRIPTORYOUCANCLICKTHEKEYBOARDBUTTONATTHETOPOFTHESCRIPTINGAREAWHENTHESCRIPTEDITORISRUNNINGITSPOSITIONISREPRESENTEDBYABLINKINGWHITEBARTOLEAVETHEKEYBOARDEDITORTYPETHEESCAPEKEYORJUSTCLICKONTHEBACKGROUNDOFTHESCRIPTINGAREANAVIGATINGINTHEKEYBOARDEDITORTOMOVETOADIFFERENTSCRIPTTYPETHETABKEYSHIFTTABTOMOVETHROUGHTHESCRIPTSINREVERSEORDERASCRIPTISAVERTICALSTACKOFCOMMANDBLOCKSACOMMANDBLOCKMAYHAVEINPUTSLOTSANDEACHINPUTSLOTMAYHAVEAREPORTERBLOCKINITTHEREPORTERMAYITSELFHAVEINPUTSLOTSTHATMAYHAVEOTHERREPORTERSYOUCANNAVIGATETHROUGHASCRIPTQUICKLYBYUSINGTHEUPARROWANDDOWNARROWKEYSTOMOVEBETWEENCOMMANDBLOCKSONCEYOUFINDTHECOMMANDBLOCKTHATYOUWANTTOEDITTHELEFTANDRIGHTARROWKEYSMOVEBETWEENEDITABLEITEMSWITHINTHATCOMMANDLEFTANDRIGHTARROWWHENTHEREARENOMOREEDITABLEITEMSWITHINTHECURRENTCOMMANDBLOCKWILLMOVEUPORDOWNTOANOTHERCOMMANDBLOCKRESPECTIVELYHEREISASEQUENCEOFPICTURESSHOWINGTHERESULTSOFREPEATEDRIGHTARROWKEYSSTARTINGFROMTHEPOSITIONSHOWNABOVEYOUCANREARRANGESCRIPTSWITHINTHESCRIPTINGAREAFROMTHEKEYBOARDTYPINGSHIFTARROWKEYSLEFTRIGHTUPORDOWNWILLMOVETHECURRENTSCRIPTIFYOUMOVEITONTOANOTHERSCRIPTTHETWOWONTSNAPTOGETHERTHEONEYOUREMOVINGWILLOVERLAPTHEONEALREADYTHERETHISMEANSTHATYOUCANMOVEACROSSANOTHERSCRIPTTOGETTOAFREESPACEEDITINGASCRIPTNOTETHATTHEKEYBOARDEDITORFOCUSTHEPOINTSHOWNASAWHITEBARORHALOISEITHERBETWEENTWOCOMMANDBLOCKSORONANINPUTSLOTTHEEDITINGKEYSDOSOMEWHATDIFFERENTTHINGSINEACHOFTHOSETWOCASESTHEBACKSPACEKEYDELETESABLOCKIFTHEFOCUSISBETWEENTWOCOMMANDSTHEONEBEFOREABOVETHEBLINKINGBARISDELETEDIFTHEFOCUSISONANINPUTSLOTTHEREPORTERINTHATSLOTISDELETEDIFTHATINPUTSLOTHASADEFAULTVALUEITWILLAPPEARINTHESLOTIFTHEFOCUSISONAVARIADICINPUTONETHATCANCHANGETHENUMBEROFINPUTSBYCLICKINGONARROWHEADSTHENONEINPUTSLOTISDELETEDWHENYOURIGHTARROWINTOAVARIADICINPUTTHEFOCUSFIRSTCOVERSTHEENTIRETHINGINCLUDINGTHEARROWHEADSANOTHERRIGHTARROWFOCUSESONTHEFIRSTSLOTWITHINTHATINPUTGROUPTHEFOCUSISONTHEVARIADICINPUTWHENITCOVERSTHEENTIRETHINGTHEENTERKEYDOESNOTHINGIFTHEFOCUSISBETWEENCOMMANDSORONAREPORTERIFTHEFOCUSISONAVARIADICINPUTTHEENTERKEYADDSONEMOREINPUTSLOTIFTHEFOCUSISONAWHITEINPUTSLOTONETHATDOESNTHAVEAREPORTERINITTHENTHEENTERKEYSELECTSTHATINPUTSLOTFOREDITINGTHATISYOUCANTYPEINTOITJUSTASIFYOUDCLICKEDONTHEINPUTSLOTOFCOURSEIFTHEFOCUSISONANINPUTSLOTCONTAININGAREPORTERYOUCANUSETHEBACKSPACEKEYTODELETETHATREPORTERANDTHENUSETHEENTERKEYTOTYPEAVALUEINTOITWHENYOUFINISHTYPINGTHEVALUETYPETHEENTERKEYAGAINTOACCEPTITANDRETURNTONAVIGATIONORTHEESCAPEKEYIFYOUDECIDENOTTOCHANGETHEVALUEALREADYINTHESLOTTHESPACEKEYISUSEDTOSEEAMENUOFPOSSIBILITIESFORTHEINPUTSLOTINFOCUSITDOESNOTHINGUNLESSTHEFOCUSISONASINGLEINPUTSLOTIFTHEFOCUSISONASLOTWITHAPULLDOWNMENUOFOPTIONSTHENTHESPACEKEYSHOWSTHATMENUIFITSABLOCKCOLOREDSLOTMEANINGTHATONLYTHECHOICESINTHEMENUCANBEUSEDTHEENTERKEYWILLDOTHESAMETHINGBUTIFITSAWHITESLOTWITHAMENUSUCHASINTHETURNBLOCKSTHENENTERLETSYOUTYPEAVALUEWHILESPACESHOWSTHEMENUOTHERWISETHESPACEKEYSHOWSAMENUOFVARIABLESAVAILABLEATTHISPOINTINTHESCRIPTINEITHERCASEUSETHEUPANDDOWNARROWKEYSTONAVIGATETHEMENUUSETHEENTERKEYTOACCEPTTHEHIGHLIGHTEDENTRYORUSETHEESCAPEKEYTOLEAVETHEMENUWITHOUTCHOOSINGANOPTIONTYPINGANYOTHERCHARACTERKEYNOTSPECIALKEYSONFANCYKEYBOARDSTHATDOSOMETHINGOTHERTHANGENERATINGACHARACTERACTIVATESTHEBLOCKSEARCHPALETTETHISPALETTEWHICHISALSOACCESSIBLEBYTYPINGCONTROLFORCOMMANDFOUTSIDETHEKEYBOARDEDITORORBYCLICKINGTHESEARCHBUTTONFLOATINGATTHETOPOFTHEPALETTEHASATEXTENTRYFIELDATTHETOPFOLLOWEDBYBLOCKSWHOSETITLETEXTINCLUDESWHATYOUTYPETHECHARACTERKEYYOUTYPEDTOSTARTTHEBLOCKSEARCHPALETTEISENTEREDINTOTHETEXTFIELDSOYOUSTARTWITHAPALETTEOFBLOCKSCONTAININGTHATCHARACTERWITHINTHEPALETTEBLOCKSWHOSETITLESSTARTWITHTHETEXTYOUTYPECOMEFIRSTTHENBLOCKSINWHICHAWORDOFTHETITLESTARTSWITHTHETEXTYOUTYPEANDFINALLYBLOCKSINWHICHTHETEXTAPPEARSINSIDEAWORDOFTHETITLEONCEYOUHAVETYPEDENOUGHTEXTTOSEETHEBLOCKYOUWANTUSETHEARROWKEYSTONAVIGATETOTHATBLOCKINTHEPALETTETHENENTERTOINSERTTHATBLOCKORESCAPETOLEAVETHEBLOCKSEARCHPALETTEWITHOUTINSERTINGTHEBLOCKWHENNOTINTHEKEYBOARDEDITORINSTEADOFNAVIGATINGWITHTHEARROWKEYSYOUDRAGTHEBLOCKYOUWANTINTOTHESCRIPTASYOUWOULDFROMANYOTHERPALETTEIFYOUTYPEANARITHMETICOPERATORORCOMPARISONOPERATORINTOTHEBLOCKSEARCHTEXTBOXYOUCANTYPEANARBITRARILYCOMPLICATEDEXPRESSIONANDACOLLECTIONOFARITHMETICOPERATORBLOCKSWILLBECONSTRUCTEDTOMATCHASTHEEXAMPLESHOWSYOUCANALSOUSEPARENTHESESFORGROUPINGANDNONNUMERICOPERANDSARETREATEDASVARIABLESORPRIMITIVEFUNCTIONSAVARIABLENAMEENTEREDINTHISWAYMAYORMAYNOTALREADYEXISTINTHESCRIPTONLYROUNDANDTHEONESINTHEPULLDOWNMENUOFTHESQRTBLOCKCANBEUSEDASFUNCTIONNAMESRUNNINGTHESELECTEDSCRIPTTYPECONTROLSHIFTENTERTORUNTHESCRIPTWITHTHEEDITORFOCUSLIKECLICKINGTHESCRIPTECONTROLSONTHESTAGETHESTAGEISTHEAREAINTHETOPRIGHTOFTHESNAPWINDOWINWHICHSPRITESMOVESPRITESMOSTSPRITESCANBEMOVEDBYCLICKINGANDDRAGGINGTHEMIFYOUHAVEUNCHECKEDTHEDRAGGABLECHECKBOXFORASPRITETHENDRAGGINGITHASNOEFFECTCONTROLCLICKINGRIGHTCLICKINGASPRITESHOWSTHISCONTEXTMENUTHEDUPLICATEOPTIONMAKESANOTHERSPRITEWITHCOPIESOFTHESAMESCRIPTSSAMECOSTUMESETCASTHISSPRITETHENEWSPRITESTARTSATARANDOMLYCHOSENPOSITIONDIFFERENTFROMTHEORIGINALSOYOUCANSEEQUICKLYWHICHISWHICHTHENEWSPRITEISSELECTEDITBECOMESTHECURRENTSPRITETHEONESHOWNINTHESCRIPTINGAREATHECLONEOPTIONMAKESAPERMANENTCLONEOFTHISSPRITEWITHSOMESHAREDATTRIBUTESANDSELECTSITTHEDELETEOPTIONDELETESTHESPRITEITSNOTJUSTHIDDENITSGONEFORGOODBUTYOUCANUNDELETEITBYCLICKINGTHEWASTEBASKETJUSTBELOWTHERIGHTEDGEOFTHESTAGETHEEDITOPTIONSELECTSTHESPRITEITDOESNTACTUALLYCHANGEANYTHINGABOUTTHESPRITEDESPITETHENAMEITSJUSTTHATMAKINGCHANGESINTHESCRIPTINGAREAWILLCHANGETHISSPRITETHEMOVEOPTIONSHOWSAMOVEHANDLEINSIDETHESPRITETHEDIAGONALSTRIPEDSQUAREINTHEMIDDLEYOUCANORDINARILYJUSTGRABANDMOVETHESPRITEWITHOUTTHISOPTIONBUTTHEREARETWOREASONSYOUMIGHTNEEDITFIRSTITWORKSEVENIFTHEDRAGGABLECHECKBOXABOVETHESCRIPTINGAREAISUNCHECKEDSECONDITWORKSFORPARTSPRITESRELATIVETOTHEIRANCHORORDINARILYDRAGGINGAPARTMOVESTHEENTIRENESTEDSPRITETHEROTATEOPTIONDISPLAYSAROTATIONMENUYOUCANCHOOSEONEOFTHEFOURCOMPASSDIRECTIONSINTHELOWERPARTTHESAMEASINTHEPOINTINDIRECTIONBLOCKORUSETHEMOUSETOROTATETHEHANDLEONTHEDIALININCREMENTSTHEPIVOTOPTIONSHOWSACROSSHAIRINSIDETHESPRITEYOUCANCLICKANDDRAGTHECROSSHAIRANYWHEREONSTAGETOSETTHECOSTUMESPIVOTPOINTIFYOUMOVEITOUTSIDETHESPRITETHENTURNINGTHESPRITEWILLREVOLVEASWELLASROTATEITAROUNDTHEPIVOTWHENDONECLICKONTHESTAGENOTONTHECROSSHAIRNOTETHATUNLIKEMOVINGTHEPIVOTPOINTINTHEPAINTEDITORTHISTECHNIQUEDOESNOTVISIBLYMOVETHESPRITEONTHESTAGEINSTEADTHEVALUESOFXPOSITIONANDYPOSITIONWILLCHANGETHEEDITOPTIONMAKESTHISTHESELECTEDSPRITEHIGHLIGHTINGITINTHESPRITECORRALANDSHOWINGITSSCRIPTINGAREAIFTHESPRITEWASATEMPORARYCLONEITBECOMESPERMANENTTHEEXPORTOPTIONSAVESOROPENSANEWBROWSERTABCONTAININGTHEXMLTEXTREPRESENTATIONOFTHESPRITENOTJUSTITSCOSTUMEBUTALLOFITSCOSTUMESSCRIPTSLOCALVARIABLESANDBLOCKSANDOTHERPROPERTIESYOUCANSAVETHISTABINTOAFILEONYOURCOMPUTERANDLATERIMPORTTHESPRITEINTOANOTHERPROJECTINSOMEBROWSERSTHESPRITEISDIRECTLYSAVEDINTOAFILEVARIABLEWATCHERSRIGHTCLICKINGONAVARIABLEWATCHERSHOWSTHISMENUTHEFIRSTSECTIONOFTHEMENULETSYOUCHOOSEONEOFTHREEVISUALIZATIONSOFTHEWATCHERTHEFIRSTNORMALVISUALIZATIONISFORDEBUGGINGTHESECONDLARGEISFORDISPLAYINGINFORMATIONTOTHEUSEROFAPROJECTOFTENTHESCOREINAGAMEANDTHETHIRDSLIDERISFORALLOWINGTHEUSERTOCONTROLTHEPROGRAMBEHAVIORINTERACTIVELYWHENTHEWATCHERISDISPLAYEDASASLIDERTHEMIDDLESECTIONOFTHEMENUALLOWSYOUTOCONTROLTHERANGEOFVALUESPOSSIBLEINTHESLIDERITWILLTAKETHEMINIMUMVALUEWHENTHESLIDERISALLTHEWAYTOTHELEFTTHEMAXIMUMVALUEWHENALLTHEWAYTOTHERIGHTTHETHIRDSECTIONOFTHEMENUALLOWSDATATOBEPASSEDBETWEENYOURCOMPUTERANDTHEVARIABLETHEIMPORTOPTIONWILLREADACOMPUTERTEXTFILEITSNAMEMUSTENDWITHTXTINWHICHCASETHETEXTISREADINTOTHEVARIABLEASISORCSVORJSONINWHICHCASETHETEXTISCONVERTEDINTOALISTSTRUCTUREWHICHWILLALWAYSBEATWODIMENSIONALARRAYFORCSVCOMMASEPARATEDVALUESDATABUTCANBEANYSHAPEFORJSONDATATHERAWDATAOPTIONPREVENTSTHATCONVERSIONTOLISTFORMTHEEXPORTOPTIONDOESTHEOPPOSITECONVERSIONPASSINGATEXTVALUEDVARIABLEVALUEINTOATXTFILEUNCHANGEDBUTCONVERTINGALISTVALUEINTOCSVFORMATIFTHELISTISONEORTWODIMENSIONALORINTOJSONFORMATIFTHELISTISMORECOMPLICATEDTHESCALARVALUESWITHINTHELISTMUSTBENUMBERSANDORTEXTLISTSOFBLOCKSSPRITESCOSTUMESETCCANNOTBEEXPORTEDANALTERNATIVETOUSINGTHEIMPORTOPTIONISSIMPLYTODRAGTHEFILEONTOTHESNAPWINDOWINWHICHCASEAVARIABLEWILLBECREATEDIFNECESSARYWITHTHESAMENAMEASTHEFILEBUTWITHOUTTHEEXTENSIONIFTHEVALUEOFTHEVARIABLEISALISTTHENTHEMENUWILLINCLUDEANADDITIONALBLOCKIFYOPTIONCLICKINGITWILLGENERATEANEXPRESSIONWITHNESTEDLISTBLOCKSTHATIFEVALUATEDWILLRECONSTRUCTTHELISTITSUSEFULIFYOUIMPORTEDALISTANDTHENWANTTOWRITECODETHATWILLCONSTRUCTTHESAMELISTLATERTHESTAGEITSELFCONTROLCLICKINGRIGHTCLICKINGONTHESTAGEBACKGROUNDTHATISANYWHEREONTHESTAGEEXCEPTONASPRITEORWATCHERSHOWSTHESTAGESOWNCONTEXTMENUTHESTAGESEDITOPTIONSELECTSTHESTAGESOTHESTAGESSCRIPTSANDBACKGROUNDSARESEENINTHESCRIPTINGAREANOTETHATWHENTHESTAGEISSELECTEDSOMEBLOCKSESPECIALLYTHEMOTIONONESARENOTINTHEPALETTEAREABECAUSETHESTAGECANTMOVETHESHOWALLOPTIONMAKESALLSPRITESVISIBLEBOTHINTHESENSEOFTHESHOWBLOCKANDBYBRINGINGTHESPRITEONSTAGEIFITHASMOVEDPASTTHEEDGEOFTHESTAGETHEPICOPTIONSAVESOROPENSABROWSERTABWITHAPICTUREOFEVERYTHINGONTHESTAGEITSBACKGROUNDLINESDRAWNWITHTHEPENANDANYVISIBLESPRITESWHATYOUSEEISWHATYOUGETIFYOUWANTAPICTUREOFJUSTTHEBACKGROUNDSELECTTHESTAGEOPENITSCOSTUMESTABCONTROLCLICKRIGHTCLICKONABACKGROUNDANDEXPORTITTHEPENTRAILSOPTIONCREATESANEWCOSTUMEFORTHECURRENTLYSELECTEDSPRITECONSISTINGOFALLLINESDRAWNONTHESTAGEBYTHEPENOFANYSPRITETHECOSTUMESROTATIONCENTERWILLBETHECURRENTPOSITIONOFTHESPRITEIFYOUPREVIOUSLYTURNEDONTHELOGPENVECTORSOPTIONANDTHEREARELOGGEDVECTORSTHEMENUINCLUDESANEXTRAOPTIONSVGTHATEXPORTSAPICTUREOFTHESTAGEINVECTORFORMATONLYLINESARELOGGEDNOTCOLORREGIONSMADEWITHTHELLBLOCKFTHESPRITECORRALANDSPRITECREATIONBUTTONSBETWEENTHESTAGEANDTHESPRITECORRALATTHEBOTTOMRIGHTOFTHESNAPWINDOWISADARKGREYBARCONTAININGTHREEBUTTONSATTHELEFTANDONEATTHERIGHTTHEFIRSTTHREEAREUSEDTOCREATEANEWSPRITETHEFIRSTBUTTONMAKESASPRITEWITHJUSTTHETURTLECOSTUMEWITHARANDOMLYCHOSENPOSITIONANDPENCOLORIFYOUHOLDDOWNTHESHIFTKEYWHILECLICKINGTHENEWSPRITESDIRECTIONWILLALSOBERANDOMTHESECONDBUTTONMAKESASPRITEANDOPENSTHEPAINTEDITORSOTHATYOUCANMAKEYOUROWNCOSTUMEFORITOFCOURSEYOUCOULDCLICKTHEFIRSTBUTTONANDTHENCLICKTHEPAINTBUTTONINITSCOSTUMESTABTHISPAINTBUTTONISASHORTCUTFORALLTHATSIMILARLYTHETHIRDBUTTONUSESYOURCAMERAIFPOSSIBLETOMAKEACOSTUMEFORTHENEWSPRITETHETRASHCANBUTTONATTHERIGHTHASTWOUSESYOUCANDRAGASPRITETHUMBNAILONTOITFROMTHESPRITECORRALTODELETETHATSPRITEORYOUCANCLICKITTOUNDELETEASPRITEYOUDELETEDBYACCIDENTINTHESPRITECORRALYOUCLICKONASPRITESTHUMBNAILPICTURETOSELECTTHATSPRITETOMAKEITTHEONEWHOSESCRIPTSCOSTUMESETCARESHOWNINTHESCRIPTINGAREAYOUCANDRAGSPRITETHUMBNAILSBUTNOTTHESTAGEONETOREORDERTHEMTHISHASNOSPECIALEFFECTONYOURPROJECTBUTLETSYOUPUTRELATEDONESNEXTTOEACHOTHERFOREXAMPLEDOUBLECLICKINGATHUMBNAILFLASHESAHALOAROUNDTHEACTUALSPRITEONTHESTAGEYOUCANRIGHTCLICKCONTROLCLICKASPRITESTHUMBNAILTOGETTHISCONTEXTMENUTHESHOWOPTIONMAKESTHESPRITEVISIBLEIFITWASHIDDENANDALSOBRINGSITONTOTHESTAGEIFITHADMOVEDPASTTHESTAGEBOUNDARYTHENEXTTHREEOPTIONSARETHESAMEASINTHECONTEXTMENUOFTHEACTUALSPRITEONTHESTAGEDISCUSSEDABOVETHEPARENTOPTIONDISPLAYSAMENUOFALLOTHERSPRITESSHOWINGWHICHIFANYISTHISSPRITESPARENTANDALLOWINGYOUTOCHOOSEANOTHERSPRITEREPLACINGANYEXISTINGPARENTTHERELEASEOPTIONISSHOWNONLYIFTHISSPRITEISAPERMANENTORITWOULDNTBEINTHESPRITECORRALCLONEITCHANGESTHESPRITETOATEMPORARYCLONETHENAMEISSUPPOSEDTOMEANTHATTHESPRITEISRELEASEDFROMTHECORRALTHEEXPORTOPTIONEXPORTSTHESPRITELIKETHESAMEOPTIONONTHESTAGETHECONTEXTMENUFORTHESTAGETHUMBNAILHASONLYONEOPTIONPICWHICHTAKESAPICTUREOFEVERYTHINGONTHESTAGEJUSTLIKETHESAMEOPTIONINTHECONTEXTMENUOFTHESTAGEBACKGROUNDIFPENTRAILSAREBEINGLOGGEDTHEREWILLALSOBEANSVGOPTIONIFYOURPROJECTINCLUDESSCENESTHENUNDERTHESTAGEICONINTHESPRITECORRALWILLBETHESCENECORRALCLICKINGONASCENEWILLSELECTITRIGHTCLICKINGWILLPRESENTAMENUINWHICHYOUCANRENAMEDELETEOREXPORTTHESCENEGPRELOADINGAPROJECTWHENSTARTINGSNAPTHEREARESEVERALWAYSTOINCLUDEAPOINTERTOAPROJECTINTHEURLWHENSTARTINGSNAPINORDERTOLOADAPROJECTAUTOMATICALLYYOUCANTHINKOFSUCHAURLASJUSTRUNNINGTHEPROJECTRATHERTHANASRUNNINGSNAPESPECIALLYIFTHEURLSAYSTOSTARTINPRESENTATIONMODEANDCLICKTHEGREENFLAGTHEGENERALFORMISHTTPSSNAPBERKELEYEDURUNVERBPROJECTFLAGFLAGTHEVERBABOVECANBEANYOFOPENRUNCLOUDPRESENTORDLTHELASTTHREEAREFORSHAREDPROJECTSINTHESNAPCLOUDTHEFIRSTTWOAREFORPROJECTSTHATHAVEBEENEXPORTEDANDMADEAVAILABLEANYWHEREONTHEINTERNETHERESANEXAMPLETHATLOADSAPROJECTSTOREDATTHESNAPWEBSITENOTTHESNAPCLOUDHTTPSSNAPBERKELEYEDURUNOPENHTTPSSNAPBERKELEYEDUSNAPSOURCEEXAMPLESVEEXMLTHEPROJECTFILEWILLBEOPENEDANDSNAPWILLSTARTINEDITMODEWITHTHEPROGRAMVISIBLEUSINGRUNINSTEADOFOPENWILLSTARTINPRESENTATIONMODEWITHONLYTHESTAGEVISIBLEANDWILLSTARTTHEPROJECTBYCLICKINGTHEGREENFLAGSTARTISINQUOTATIONMARKSBECAUSETHEREISNOGUARANTEETHATTHEPROJECTINCLUDESANYSCRIPTSTRIGGEREDBYTHEGREENFLAGSOMEPROJECTSARESTARTEDBYTYPINGONTHEKEYBOARDORBYCLICKINGASPRITEIFTHEVERBISRUNTHENYOUCANALSOUSEANYSUBSETOFTHEFOLLOWINGFLAGSEDITMODESTARTINEDITMODENOTPRESENTATIONMODENORUNDONTCLICKTHEGREENFLAGHIDECONTROLSDONTSHOWTHEROWOFBUTTONSABOVETHESTAGEEDITMODEGREENFLAGPAUSESTOPLANGFRSETLANGUAGETOINTHISEXAMPLEFRENCHNOCLOUDDONTALLOWCLOUDOPERATIONSFROMTHISPROJECTFORRUNNINGPROJECTSFROMUNKNOWNSOURCESTHATINCLUDEJAVASCRIPTCODENOEXITWARNINGWHENCLOSINGTHEWINDOWORLOADINGADIFFERENTURLDONTSHOWTHEBROWSERAREYOUSUREYOUWANTTOLEAVETHISPAGEMESSAGEBLOCKSZOOMNLIKETHEZOOMBLOCKSOPTIONINTHESETTINGSMENUTHELASTOFTHESEFLAGSISINTENDEDFORUSEONAWEBPAGEINWHICHASNAPWINDOWISEMBEDDEDHERESANEXAMPLETHATLOADSASHAREDPUBLICPROJECTFROMTHESNAPCLOUDHTTPSSNAPBERKELEYEDURUNPRESENTUSERNAMEJENSPROJECTNAMETREEANIMATIONNOTETHATUSERNAMEANDPROJECTNAMEARETITLECASEDEVENTHOUGHTHEFLAGSSUCHASNORUNARECAMELCASEDNOTEALSOTHATASPACEINTHEPROJECTNAMEMUSTBEREPRESENTEDINUNICODEASTHEVERBPRESENTBEHAVESLIKERUNITORDINARILYSTARTSTHEPROJECTINPRESENTATIONMODEBUTITSBEHAVIORCANBEMODIFIEDWITHTHESAMEFOURFLAGSASFORRUNTHEVERBCLOUDYESWEKNOWITSNOTAVERBINITSORDINARYUSEBEHAVESLIKEOPENEXCEPTTHATITLOADSFROMTHESNAPCLOUDRATHERTHANFROMTHEINTERNETINGENERALTHEVERBDLSHORTFORDOWNLOADDOESNOTSTARTSNAPBUTJUSTDOWNLOADSACLOUDSAVEDPROJECTTOYOURCOMPUTERASANXMLFILETHISISUSEFULFORDEBUGGINGSOMETIMESADEFECTIVEPROJECTTHATSNAPWONTRUNCANBEDOWNLOADEDEDITEDANDTHENRESAVEDTOTHECLOUDHMIRRORSITESIFTHESITESNAPBERKELEYEDUISEVERUNAVAILABLEYOUCANLOADSNAPATTHEFOLLOWINGMIRRORSITESHTTPSBJCEDCORGSNAPSOURCESNAPHTMLHTTPSCSORGSNAPAPPENDIXASNAPCOLORLIBRARYTHECOLORSANDCRAYONSLIBRARYPROVIDESSEVERALTOOLSFORMANIPULATINGCOLORALTHOUGHITSMAINPURPOSEISCONTROLLINGASPRITESPENCOLORITALSOESTABLISHESCOLORSASAFIRSTCLASSDATATYPEFORPEOPLEWHOJUSTWANTCOLORSINTHEIRPROJECTSWITHOUTHAVINGTOBECOLOREXPERTSWEPROVIDETWOSIMPLEMECHANISMSACOLORNUMBERSCALEWITHABROADRANGEOFCONTINUOUSCOLORVARIATIONANDASETOFCRAYONSORGANIZEDBYCOLORFAMILYTENREDSTENORANGESETCTHECRAYONSINCLUDETHEBLOCKCOLORSFOREXPERTSWEPROVIDECOLORSELECTIONBYRGBHSLHSVXWCNAMESANDVARIANTSONTHOSESCALESINTRODUCTIONTOCOLORYOURCOMPUTERMONITORCANDISPLAYMILLIONSOFCOLORSBUTYOUPROBABLYCANTDISTINGUISHTHATMANYFOREXAMPLEHERESREDGREENBLUEANDHERESREDGREENBLUEYOUMIGHTBEABLETOTELLTHEMAPARTIFYOUSEETHEMSIDEBYSIDEBUTMAYBENOTEVENTHENCOLORSPACETHECOLLECTIONOFALLPOSSIBLECOLORSISTHREEDIMENSIONALBUTTHEREAREMANYWAYSTOCHOOSETHEDIMENSIONSRGBREDGREENBLUETHEONEMOSTCOMMONLYUSEDINCOMPUTERSMATCHESTHEWAYTVSANDDISPLAYSPRODUCECOLORBEHINDEVERYDOTONTHESCREENARETHREETINYLIGHTSAREDONEAGREENONEANDABLUEONEBUTIFYOUWANTTOPRINTCOLORSONPAPERYOURPRINTERPROBABLYUSESADIFFERENTSETOFTHREECOLORSCMYCYANMAGENTAYELLOWYOUMAYHAVESEENTHEABBREVIATIONCMYKWHICHREPRESENTSTHECOMMONTECHNIQUEOFADDINGBLACKINKTOTHECOLLECTIONMIXINGCYANMAGENTAANDYELLOWINEQUALAMOUNTSISSUPPOSEDTORESULTINBLACKINKBUTTYPICALLYITCOMESOUTAMUDDYBROWNINSTEADBECAUSECHEMISTRYOTHERSYSTEMSTHATTRYTOMIMICHUMANPERCEPTIONAREHSLHUESATURATIONLIGHTNESSANDHSVHUESATURATIONVALUETHEREAREMANYMANYMOREEACHDESIGNEDFORAPARTICULARPURPOSEIFYOUAREACOLORPROFESSIONALAPRINTERAWEBDESIGNERAGRAPHICDESIGNERANARTISTTHENYOUNEEDTOUNDERSTANDALLTHISITCANALSOBEINTERESTINGTOLEARNABOUTFOREXAMPLETHEREARECOLORSTHATYOUCANSEEBUTYOURCOMPUTERDISPLAYCANTGENERATEIFTHATINTRIGUESYOULOOKUPCOLORTHEORYINWIKIPEDIACRAYONSANDCOLORNUMBERSBUTIFYOUJUSTWANTSOMECOLORSINYOURPROJECTWEPROVIDEASIMPLEONEDIMENSIONALSUBSETOFTHEAVAILABLECOLORSTWOSUBSETSACTUALLYCRAYONSANDCOLORNUMBERSHERESTHEDIFFERENCETHEFIRSTROWSHOWSDISTINCTCOLORSTHEYHAVENAMESTHISISPUMPKINANDTHISISDENIMYOURESUPPOSEDTOTHINKOFTHEMASABIGBOXOFCRAYONSTHEYREARRANGEDINFAMILIESGRAYSPINKSREDSBROWNSORANGESETCBUTTHEYRENOTCONSISTENTLYORDEREDWITHINAFAMILYYOUDBEUNLIKELYTOSAYNEXTCRAYONINAPROJECTBUTLOOKATTHECRAYONSPIRALONPAGEINSTEADYOUDTHINKIWANTTHISTOLOOKLIKEAREALLYOLDFASHIONEDPHOTOANDSOYOUDFINDSEPIAASCRAYONNUMBERYOUDONTHAVETOMEMORIZETHENUMBERSYOUCANFINDTHEMINAMENUWITHASUBMENUFOREACHFAMILYORIFYOUKNOWTHECRAYONNAMEJUSTTHECRAYONNUMBERSARECHOSENSOTHATSKIPPINGBYGIVESASENSIBLEBOXOFTENCRAYONSALTERNATIVELYSKIPPINGBYGIVESASTILLSENSIBLESETOFTWENTYCRAYONSTHESETOFCOLORNUMBERSISARRANGEDSOTHATEACHCOLORNUMBERISVISUALLYNEAREACHOFITSNEIGHBORSBRIGHTANDDARKCOLORSALTERNATEFOREACHFAMILYCOLORNUMBERSRANGEFROMTOLIKECRAYONNUMBERSBUTYOUCANUSEFRACTIONALNUMBERSTOGETASTINYASTEPASYOULIKEASTINYASYOULIKEISNTQUITETRUEBECAUSEINTHEENDYOURCOLORHASTOBEROUNDEDTOINTEGERRGBVALUESFORDISPLAYBOTHOFTHESESCALESINCLUDETHERANGEOFSHADESOFGRAYFROMBLACKTOWHITESINCEBLACKISTHEINITIALPENCOLORANDBLACKISNTAHUESCRATCHANDSNAPUSERSWOULDTRADITIONALLYTRYTOUSESETCOLORTOESCAPEFROMBLACKANDITWOULDNTWORKBYINCLUDINGBLACKINTHESAMESCALEASOTHERCOLORSWEELIMINATETHEBLACKHOLEPROBLEMIFPEOPLEUSEONLYTHERECOMMENDEDCOLORSCALESWEAREMAKINGAPOINTOFSAYINGCOLORNUMBERFORWHATWASSOMETIMESCALLEDJUSTCOLORINEARLIERVERSIONSOFTHELIBRARYBECAUSEWENOWRESERVETHENAMECOLORFORANACTUALCOLORANINSTANCEOFTHECOLORDATATYPEHOWTOUSETHELIBRARYTHEREARETHREELIBRARYBLOCKSSPECIFICALLYABOUTCONTROLLINGTHEPENTHEYHAVETHESAMENAMESASTHREEOFTHEPRIMITIVEPENBLOCKSTHEFIRSTPENBLOCKCOLOREDINPUTSLOTISUSEDTOSELECTWHICHCOLORSCALEYOUWANTTOUSETHESEBLOCKSALSOALLOWREADINGORSETTINGTWOBLOCKPROPERTIESTHATARENOTCOLORSTHEPENSIZEANDITSTRANSPARENCYTHEPENREPORTERREQUIRESNOOTHERINPUTSITREPORTSTHESTATEOFTHEPENINWHATEVERDIMENSIONYOUCHOOSEASTHELASTEXAMPLESHOWSYOUCANTASKFORTHEPENCOLORINASCALEINCOMPATIBLEWITHHOWYOUSETITUNLESSTHEBLOCKCANDEDUCEWHATYOUWANTFROMWHATITKNOWSABOUTTHECURRENTPENCOLORTHECHANGEPENBLOCKAPPLIESONLYTONUMERICSCALESINCLUDINGVECTORSOFTHREEORFOURNUMBERSITADDSITSNUMERICORLISTINPUTTOTHECURRENTPENVALUESDOINGVECTORITEMBYITEMADDITIONFORVECTORSCALESTHESETPENBLOCKCHANGESTHEPENCOLORTOTHEVALUESYOUSPECIFYTHEMEANINGOFTHEWHITEINPUTSLOTSDEPENDSONWHICHATTRIBUTEOFTHEPENYOURESETTINGINTHELASTEXAMPLETHENUMBERSETSTHETRANSPARENCYONTHESCALEOPAQUEINVISIBLEALLCOLORATTRIBUTESAREONASCALEEXCEPTFORRGBCOMPONENTSWHICHAREATRANSPARENCYVALUECANBECOMBINEDWITHANYOFTHESEATTRIBUTESCALESTHELIBRARYALSOINCLUDESTWOCONSTRUCTORSANDASELECTORFORCOLORSASADATATYPETHELATTERTWOAREINVERSESOFEACHOTHERTRANSLATINGBETWEENCOLORSANDTHEIRATTRIBUTESTHECOLORFROMBLOCKSATTRIBUTEMENUHASFEWERCHOICESTHANTHESIMILARSETPENBLOCKBECAUSEYOUCANFOREXAMPLESETTHEREDVALUEOFTHEEXISTINGPENCOLORLEAVINGTHERESTUNCHANGEDBUTWHENCREATINGACOLOROUTOFNOTHINGYOUHAVETOPROVIDEITSENTIRESPECIFICATIONEGALLOFREDGREENANDBLUEORTHEEQUIVALENTINOTHERSCALESASYOULLSEEONTHENEXTPAGEWEPROVIDETWOLINEARONEDIMENSIONALCOLORSCALESTHATALLOWYOUTOSPECIFYACOLORWITHASINGLENUMBERATTHECOSTOFINCLUDINGONLYASMALLSUBSETOFTHEMILLIONSOFCOLORSYOURCOMPUTERCANGENERATEIFYOUHAVEACOLORANDWANTANOTHERCOLORTHATSTHESAMEEXCEPTFORONENUMBERASINTHEREDEXAMPLEYOUCANUSETHISBLOCKFINALLYTHELIBRARYINCLUDESTHEMIXBLOCKANDAHELPERWELLHAVEMORETOSAYABOUTTHESEAFTERADETOURTHROUGHCOLORTHEORYTHATSALLYOUHAVETOKNOWABOUTCOLORSCRAYONSFORSPECIFICINTERESTINGONESCOLORNUMBERSFORGRADUALTRANSFORMATIONFROMONECOLORTOTHENEXTBUTTHERESABITMORETOSAYIFYOUREINTERESTEDIFNOTSTOPHEREBUTLOOKATTHESAMPLESOFTHEDIFFERENTSCALESONPAGEMOREABOUTCOLORSFAIRHUESANDSHADESSEVERALOFTHETHREEDIMENSIONALARRANGEMENTSOFCOLORSUSETHECONCEPTOFHUEWHICHMOREORLESSMEANSWHEREACOLORWOULDAPPEARINARAINBOWMAGENTANEARTHERIGHTISALONGSTORYTHESEARECALLEDSPECTRALCOLORSAFTERTHESPECTRUMOFRAINBOWCOLORSBUTTHESECOLORSARENTEQUALLYDISTRIBUTEDTHERESANAWFULLOTOFGREENHARDLYANYYELLOWANDJUSTASLIVEROFORANGEANDNOBROWNATALLANDTHISISALREADYAHANDWAVEBECAUSETHERANGEOFCOLORSTHATCANBEGENERATEDBYRGBMONITORSDOESNTINCLUDESOMEOFTHETRUESPECTRALCOLORSSEESPECTRALCOLORINWIKIPEDIAFORALLTHEGORYDETAILSTHISISNTAPROBLEMWITHTHEPHYSICSOFRAINBOWSITSINTHEHUMANEYEANDTHEHUMANBRAINTHATCERTAINRANGESOFWAVELENGTHOFLIGHTWAVESARELUMPEDTOGETHERASNAMEDCOLORSTHEEYEISJUSTTUNEDTORECOGNIZEAWIDERANGEOFCOLORSASGREENSEERODSANDCONESANDDIFFERENTHUMANCULTURESGIVENAMESTODIFFERENTCOLORRANGESNEVERTHELESSINOLDSCRATCHPROJECTSYOUDSAYCHANGEPENCOLORBYANDITDTAKEFOREVERTOREACHACOLORTHATWASNTGREENFORCOLORPROFESSIONALSTHEREAREGOODREASONSTOWANTTOWORKWITHTHEPHYSICALRAINBOWHUELAYOUTBUTFORAMATEURSUSINGASIMPLIFIEDONEDIMENSIONALCOLORMODELTHERESNOREASONNOTTOUSEAMOREPROGRAMMERFRIENDLYHUESCALEINTHISSCALEEACHOFTHESEVENRAINBOWCOLORSANDBROWNGETANEQUALSHAREREDSLOOKSTOOSMALLBUTTHATSBECAUSEITSSPLITBETWEENTHETWOENDSHUEISPUREREDBROWNISHREDSARETOITSRIGHTANDPURPLISHREDSAREWRAPPEDAROUNDTOTHERIGHTENDWECALLTHISSCALEFAIRHUEBECAUSEEACHCOLORFAMILYGETSAFAIRSHAREOFTHETOTALHUERANGEBYTHEWAYYOUWEREPROBABLYTAUGHTGREENBLUEINDIGOVIOLETINSCHOOLBUTITTURNSOUTTHATCOLORNAMESWEREDIFFERENTINISAACNEWTONSDAYANDTHECOLORHECALLEDBLUEISMORELIKEMODERNCYANWHILEHISINDIGOISMORELIKEMODERNBLUESEEWIKIPEDIAINDIGOOURCOLORNUMBERSCALEISBASEDONFAIRHUESADDINGARANGEOFGRAYSFROMBLACKCOLORNUMBERTOWHITECOLORNUMBERANDALSOADDINGSHADESOFTHESPECTRALCOLORSINCOLORTERMINOLOGYASHADEISADARKERVERSIONOFACOLORALIGHTERVERSIONISCALLEDATINTWHYDOWEADDSHADESBUTNOTTINTSPARTLYBECAUSEIFINDSHADESMOREEXCITINGASHADEOFREDCANBEDARKCANDYAPPLEREDORMAROONBUTATINTISJUSTSOMEKINDOFPINKTHISADMITTEDPREJUDICEISSUPPORTEDBYANOBJECTIVEFACTMOSTPROJECTSAREMADEONAWHITEBACKGROUNDSODARKCOLORSSTANDOUTBETTERTHANLIGHTONESSOINOURCOLORNUMBERSCALECOLORNUMBERSTOAREKINDSOFGRAYTHEREMAININGCOLORNUMBERSGOTHROUGHTHEFAIRHUESBUTALTERNATINGFULLSTRENGTHCOLORSWITHSHADESTHISCHARTSHOWSHOWTHECOLORSCALESDISCUSSEDSOFARARERELATEDNOTETHATALLSCALESRANGEFROMTOTHEFAIRHUESSCALEHASBEENCOMPRESSEDINTHECHARTSOTHATSIMILARCOLORSLINEUPVERTICALLYITSDIMENSIONSARECRAYONSBYCRAYONSBYCRAYONSFAIRHUESCOLORNUMBERSCOLORNUMBERSBYCOLORNUMBERSBYDIFFERENTBECAUSEITDOESNTINCLUDETHEGRAYSATTHELEFTSINCETHEREAREEIGHTCOLORFAMILIESTHEPURENAMEDFAIRHUESAREATMULTIPLESOFSTARTINGWITHREDWHITEISCRAYONANDCOLORNUMBERTHISVALUEWASDELIBERATELYCHOSENNOTTOBEAMULTIPLEOFSOTHATTHEEVERYFIFTHCRAYONANDEVERYTENTHCRAYONSELECTIONSDONTINCLUDEITSOTHATALLOFTHECRAYONSINTHOSESMALLERBOXESAREVISIBLEAGAINSTAWHITESTAGEBACKGROUNDAMONGPURPLESTHEOFFICIALSPECTRALVIOLETCRAYONISTHEENDOFTHESPECTRUMMAGENTABRIGHTERTHANVIOLETISNTASPECTRALCOLORATALLINTHEPICTUREATTHELEFTTHETOPPARTISTHESPECTRUMOFWHITELIGHTSPREADOUTTHROUGHAPRISMTHEMIDDLEPARTISAPHOTOGRAPHOFARAINBOWANDTHEBOTTOMPARTISADIGITALSIMULATIONOFARAINBOWMAGENTAISAMIXTUREOFREDANDBLUEATTRIBUTIONWIKIPEDIAUSERANDYSCCBYSATHELIGHTGRAYATCOLORNUMBERISSLIGHTLYDIFFERENTFROMCRAYONJUSTBECAUSEOFROUNDOFFINCOMPUTINGCRAYONVALUESCOLORNUMBERISDIFFERENTFROMCRAYONBECAUSETHEOFFICIALRGBVIOLETEQUALPARTSREDANDBLUEISACTUALLYLIGHTERTHANSPECTRALVIOLETTHEPURPLEFAMILYISALSOUNUSUALBECAUSEMAGENTACRAYONANDCOLORNUMBERISLIGHTERTHANTHEVIOLETATINOTHERFAMILIESTHECOLORNUMBERSCRAYONSANDSCALEDFAIRHUESALLAGREEATMULTIPLESOFTENTHESEMULTIPLEOFTENPOSITIONSARETHESTANDARDRGBPRIMARYANDSECONDARYCOLORSEGTHEYELLOWATCOLORNUMBERISINRGBGRAYBROWNANDORANGEDONTHAVESUCHSIMPLERGBSETTINGSTHECOLORNUMBERSATODDMULTIPLESOFFIVEAREGENERALLYDARKERSHADESTHANTHECORRESPONDINGCRAYONSTHELATTERAREOFTENOFFICIALNAMEDSHADESEGTEALCRAYONISAHALFINTENSITYSHADEOFCYANTHEODDFIVECOLORNUMBERSTHOUGHAREOFTENDARKERSINCETHEYARECHOSENTOBETHEDARKESTCOLORINAGIVENFAMILYTHATSVISIBLYDIFFERENTFROMBLACKTHEPINKATCOLORNUMBERTHOUGHISQUITEDIFFERENTFROMCRAYONBECAUSETHEFORMERISAPURETINTOFREDWHEREASTHECRAYONTOGETAMOREINTERESTINGPINKHASALITTLEMAGENTAMIXEDINCOLORNUMBERSATMULTIPLESOFFIVEARELOOKEDUPINATABLEOTHERCOLORVALUESAREDETERMINEDBYLINEARINTERPOLATIONINRGBSPACECRAYONSAREOFCOURSEALLFOUNDBYTABLELOOKUPTHEFROMCOLORBLOCKBEHAVESSPECIALLYWHENYOUASKFORTHECOLORNUMBEROFACOLORMOSTCOLORSDONTEXACTLYMATCHACOLORNUMBERANDFOROTHERATTRIBUTESOFACOLORCRAYONNUMBERXNAMEYOUDONTGETANANSWERUNLESSTHECOLOREXACTLYMATCHESONEOFTHENAMESORNUMBERSINTHATATTRIBUTEBUTFORCOLORNUMBERTHEBLOCKTRIESTOFINDTHENEARESTCOLORNUMBERTOTHECOLORYOUSPECIFYTHERESULTWILLBEONLYAPPROXIMATEYOUCANTUSETHENUMBERYOUGETTORECREATETHEINPUTCOLORBUTYOUCANSTARTCHOOSINGNEARBYCOLORNUMBERSASYOUANIMATETHESPRITEPERCEPTUALSPACESHSVANDHSLRGBISTHERIGHTWAYTOTHINKABOUTCOLORSIFYOUREBUILDINGORPROGRAMMINGADISPLAYMONITORCMYKISTHERIGHTWAYIFYOUREBUILDINGORPROGRAMMINGACOLORPRINTERBUTNEITHEROFTHOSECOORDINATESYSTEMSISVERYINTUITIVEIFYOURETRYINGTOUNDERSTANDWHATCOLORYOUSEEIFFOREXAMPLEYOUMIXREDLIGHTGREENANDBLUETHEHUESCALEISONEDIMENSIONOFMOSTATTEMPTSATAPERCEPTUALSCALETHESQUAREATTHERIGHTHASPALEBLUESALONGTHETOPEDGEDARKBLUESALONGTHERIGHTEDGEVARIOUSSHADESOFGRAYTOWARDTHELEFTBLACKATTHEBOTTOMANDPURESPECTRALBLUEINTHETOPRIGHTCORNERALTHOUGHNOOTHERPOINTINTHESQUAREISPUREBLUEYOUCANTELLATAGLANCETHATNOOTHERSPECTRALCOLORISMIXEDWITHTHEBLUEASIDEFROMHUETHEOTHERTWODIMENSIONSOFACOLORSPACEHAVETOREPRESENTHOWMUCHWHITEANDORBLACKISMIXEDWITHTHESPECTRALCOLORBEARINMINDTHATMIXINGBLACKISAMETAPHORWHENITCOMESTOMONITORSTHEREREALLYISBLACKPAINTBUTTHERESNOSUCHTHINGASBLACKLIGHTONESUCHSPACEHSVHASONEDIMENSIONFORTHEAMOUNTOFCOLORVSWHITECATTRIBUTIONWIKIPEDIAUSERSHARKDCCBYSAALLEDSATURATIONANDONEFORTHEAMOUNTOFBLACKIMAGINATIVELYCALLEDVALUEHSVSTANDSFORHUESATURATIONVALUEVALUEISALSOCALLEDBRIGHTNESSTHEVALUEISACTUALLYMEASUREDBACKWARDFROMTHEABOVEDESCRIPTIONTHATISIFVALUEISTHECOLORISPUREBLACKIFVALUEISTHENASATURATIONOFMEANSALLWHITENOSPECTRALCOLORASATURATIONOFMEANSNOWHITEATALLINTHESQUAREINTHEPREVIOUSPARAGRAPHTHEXAXISISTHESATURATIONANDTHEYAXISISTHEVALUETHEENTIREBOTTOMEDGEISBLACKBUTONLYTHETOPLEFTCORNERISWHITEHSVISTHETRADITIONALCOLORSPACEUSEDINSCRATCHANDSNAPSETPENCOLORSETTHEHUESETPENSHADESETTHEVALUETHEREWASORIGINALLYNOPENBLOCKTOSETTHESATURATIONBUTTHERESASETBRIGHTNESSEECTLOOKSBLOCKTOCONTROLTHESATURATIONOFTHESPRITESCOSTUMEISPECULATETHATTHESCRATCHDESIGNERSLIKEMETHOUGHTTINTSWERELESSVIVIDTHANSHADESAGAINSTAWHITEBACKGROUNDSOTHEYMADEITHARDERTOCONTROLTINTINGBUTIFYOURELOOKINGATCOLORSONACOMPUTERDISPLAYHSVISNTREALLYAGOODMATCHFORHUMANPERCEPTIONINTUITIVELYBLACKANDWHITESHOULDBETREATEDSYMMETRICALLYTHISISTHEHSLHUESATURATIONLIGHTNESSCOLORSPACESATURATIONINHSLISAMEASUREOFTHEGRAYNESSORDULLNESSOFACOLORHOWCLOSEITCOMESTOBEINGONABLACKANDWHITESCALEANDLIGHTNESSMEASURESSPECTRALNESSWITHPUREWHITEATONEENDPUREBLACKATTHEOTHERENDANDSPECTRALCOLORINTHEMIDDLETHESATURATIONNUMBERISACTUALLYTHEOPPOSITEOFGRAYNESSMEANSPUREGRAYANDMEANSPURESPECTRALCOLORPROVIDEDTHATTHELIGHTNESSISMIDWAYBETWEENBLACKANDWHITECOLORSWITHLIGHTNESSOTHERTHANHAVESOMEBLACKORWHITEMIXEDINBUTSATURATIONMEANSTHATTHECOLORISASFULLYSATURATEDASITCANBEGIVENTHEAMOUNTOFWHITEORBLACKNEEDEDTOACHIEVETHATLIGHTNESSSATURATIONLESSTHANMEANSTHATBOTHWHITEANDBLACKAREMIXEDWITHTHESPECTRALCOLORSUCHMIXTURESARECALLEDTONESOFTHESPECTRALCOLORPERCEPTUALLYCOLORSWITHSATURATIONDONTLOOKGRAYBUTCOLORSWITHSATURATIONDONOTETHATHSVANDHSLBOTHHAVEADIMENSIONCALLEDSATURATIONBUTTHEYRENOTTHESAMETHINGINHSVSATURATIONMEANSNONWHITENESSWHEREASINHSLITMEANSNONGRAYNESSVIVIDNESSMOREFINEPRINTITSMISLEADINGTOTALKABOUTTHESPECTRUMOFLIGHTWAVELENGTHSASIFITWERETHESAMEASPERCEIVEDHUEIFYOURCOMPUTERDISPLAYISSHOWINGYOUAYELLOWAREAFOREXAMPLEITSDOINGITBYTURNINGONITSREDANDGREENLEDSOVERTHATAREAANDWHATHITSYOURRETINAISSTILLTWOWAVELENGTHSOFLIGHTREDANDGREENSUPERIMPOSEDYOUCOULDMAKEWHATSPERCEPTUALLYTHESAMEYELLOWBYUSINGASINGLEINTERMEDIATEWAVELENGTHYOUREYEANDBRAINDONTDISTINGUISHBETWEENTHOSETWOKINDSOFYELLOWALSOYOURBRAINAUTOMATICALLYADJUSTSPERCEIVEDHUETOCORRECTFORDIFFERENCESINILLUMINATIONWHENYOUPLACEAMONOCHROMEOBJECTSOTHATITSHALFINSUNLIGHTANDHALFINTHESHADEYOUSEEITASONEEVENTHOUGHWHATSREACHINGYOUREYESFROMTHETWOREGIONSDIFFERSALOTANDSADLYITSHSLWHOSEUSEOFSATURATIONDISAGREESWITHTHEOFFICIALINTERNATIONALCOLORVOCABULARYSTANDARDIZATIONCOMMITTEEILEARNEDALLTHISFROMTHISTUTORIALWHICHYOUMIGHTFINDMORECOHERENTTHANJUMPINGAROUNDWIKIPEDIAIFYOUREINTERESTEDALTHOUGHTRADITIONALSCRATCHANDSNAPUSEHSVINPROGRAMSTHEYUSEHSLINTHECOLORPICKERTHEHORIZONTALAXISISHUEFAIRHUEINTHISVERSIONANDTHEVERTICALAXISISLIGHTNESSTHESCALEWITHBLACKATONEENDANDWHITEATTHEOTHERENDITWOULDMAKENOSENSETOHAVEONLYTHEBOTTOMHALFOFTHISSELECTORHSVVALUEORONLYTHETOPHALFHSVSATURATIONANDGIVENTHATYOUCANONLYFITTWODIMENSIONSONAFLATSCREENITMAKESSENSETOPICKHSLSATURATIONVIVIDNESSASTHEONETOKEEPATINTHISFAIRHUEPICKERSOMECOLORSAPPEARTWICESPECTRALLIGHTNESSBROWNSASSHADESLIGHTNESSOFREDORORANGEANDSHADESOFTHOSEBROWNSSOFTWARETHATISNTPRIMARILYABOUTCOLORSSONOTINCLUDINGPHOTOSHOPFOREXAMPLETYPICALLYUSEHSVORHSLWITHWEBBASEDSOFTWAREMORELIKELYTOUSEHSVBECAUSETHATSWHATSBUILTINTOTHEJAVASCRIPTPROGRAMMINGLANGUAGEPROVIDEDBYBROWSERSBUTIFTHEGOALISTOMODELHUMANCOLORPERCEPTIONNEITHEROFTHESECOLORSPACESISSATISFACTORYBECAUSETHEYASSUMETHATALLFULLINTENSITYSPECTRALCOLORSAREEQUALLYBRIGHTBUTIFYOURELIKEMOSTPEOPLEYOUSEESPECTRALYELLOWASMUCHBRIGHTERTHANSPECTRALBLUETHEREAREBETTERPERCEPTUALCOLORSPACESWITHNAMESLIKELUVANDLABTHATAREBASEDONRESEARCHWITHHUMANSUBJECTSTODETERMINETRUEPERCEIVEDBRIGHTNESSWIKIPEDIAEXPLAINSALLTHISANDMOREATHSLANDHSVWHERETHEYRECOMMENDDITCHINGBOTHOFTHESESIMPLISTICCOLORSPACESJMIXINGCOLORSGIVENFIRSTCLASSCOLORSTHENEXTQUESTIONISWHATOPERATIONSAPPLYTOTHEMTHEWAYARITHMETICOPERATORSAPPLYTONUMBERSANDHIGHERORDERFUNCTIONSAPPLYTOLISTSTHEEQUIVALENTTOADDINGNUMBERSISMIXINGCOLORSBUTUNFORTUNATELYTHEREISNTASIMPLEANSWERTOWHATTHATMEANSTHEEASIESTKINDOFCOLORMIXINGTOUNDERSTANDISADDITIVEMIXINGWHICHISWHATHAPPENSWHENYOUSHINETWOCOLOREDLIGHTSONTOAWHITEWALLITSALSOWHATHAPPENSINYOURCOMPUTERSCREENWHEREEACHDOTPIXELOFANIMAGEISCREATEDBYATINYREDLIGHTATINYGREENLIGHTANDATINYBLUELIGHTTHATCANBECOMBINEDATDIFFERENTSTRENGTHSTOMAKEDIFFERENTCOLORSESSENTIALLYADDITIVEMIXINGOFTWOCOLORSISCOMPUTEDBYADDINGTHETWOREDCOMPONENTSTHETWOGREENCOMPONENTSANDTHETWOBLUECOMPONENTSITSNOTQUITETHATSIMPLEONLYBECAUSEEACHCOMPONENTOFTHERESULTMUSTBEINTHERANGETOSOREDMIXEDWITHGREENGIVESWHICHISYELLOWBUTREDPLUSYELLOWCANTGIVEJUSTLIMITINGTHEREDINTHERESULTTOWOULDMEANTHATREDPLUSYELLOWISYELLOWWHICHDOESNTMAKESENSEINSTEADIFTHEREDVALUEHASTOBEREDUCEDBYHALFFROMTOTHENALLTHREEVALUESMUSTBEREDUCEDBYHALFSOTHERESULTISWHICHISORANGEHALFOFISBUTEACHRGBVALUEMUSTBEANINTEGERADIFFERENTKINDOFCOLORMIXINGBASEDONLIGHTISDONEWHENDIFFERENTCOLOREDTRANSPARENTPLASTICSHEETSAREHELDINFRONTOFAWHITELIGHTASISDONEINTHEATRICALLIGHTINGINTHATSITUATIONTHELIGHTTHATGETSTHROUGHBOTHFILTERSISWHATREMAINSAFTERSOMELIGHTISFILTEREDOUTBYTHEFIRSTONEANDSOMEOFWHATSLEFTISFILTEREDOUTBYTHESECONDONEINREDGREENBLUETERMSAREDFILTERFILTERSOUTGREENANDBLUEAYELLOWFILTERALLOWSREDANDGREENTHROUGHFILTERINGOUTBLUEBUTTHEREISNTANYGREENLIGHTFORTHEYELLOWFILTERTOPASSITWASFILTEREDOUTBYTHEREDFILTEREACHFILTERCANONLYREMOVELIGHTNOTADDLIGHTSOTHISISCALLEDSUBTRACTIVEMIXINGPERHAPSCONFUSINGLYTHENUMERICALCOMPUTATIONOFSUBTRACTIVEMIXINGISDONEBYMULTIPLYINGTHERGBVALUESTAKENASFRACTIONSOFTHEMAXIMUMSOREDTIMESYELLOWISREDAGAINTHOSEAREBOTHSTRAIGHTFORWARDTOCOMPUTEMUCHMUCHMORECOMPLICATEDISTRYINGTOSIMULATETHERESULTOFMIXINGPAINTSITSNOTJUSTTHATWEDHAVETOCOMPUTEAMORECOMPLICATEDFUNCTIONOFTHEREDGREENANDBLUEVALUESITSTHATRGBVALUESORANYOTHERTHREEDIMENSIONALCOLORSPACEAREINADEQUATETODESCRIBETHEBEHAVIOROFPAINTSTWOPAINTSCANLOOKIDENTICALANDHAVETHESAMERGBVALUESBUTMAYSTILLBEHAVEVERYDIFFERENTLYWHENMIXEDWITHOTHERCOLORSTHEDIFFERENCESAREMOSTLYDUETOTHECHEMISTRYOFTHEPAINTSBUTAREALSOAFFECTEDBYEXACTLYHOWTHECOLORSAREMIXEDTHEMIXINGISMOSTLYSUBTRACTIVEREDPAINTABSORBSMOSTOFTHECOLORSOTHERTHANREDSOWHATSREFLECTEDOFFTHESURFACEISWHATEVERISNTABSORBEDBYTHECOLORSBEINGMIXEDBUTTHERECANBEANADDITIVECOMPONENTALSOTHEPROPERMATHEMATICALABSTRACTIONTODESCRIBEAPAINTISAREFLECTANCEGRAPHLIKETHISTHESEARENTPAINTSBUTMINERALSANDONESOFTWAREGENERATEDSPECTRUMFROMTHEUSGEOLOGICALSURVEYSSPECTRALLIBRARYTHEDETAILSDONTMATTERJUSTTHEFACTTHATAGRAPHLIKETHESEGIVESMUCHMOREINFORMATIONTHANTHREERGBNUMBERSTOMIXTWOPAINTSPROPERLYYOUMULTIPLYTHEYVALUESASFRACTIONSATEACHMATCHINGXCOORDINATEOFTHETWOGRAPHSHAVINGSAIDALLTHATTHEMIXBLOCKTAKESTHECOLORSITISGIVENASINPUTSANDCONVERTSTHEMINTOWHATWEHOPEARETYPICALPAINTREFLECTANCESPECTRATHATWOULDLOOKLIKETHOSECOLORSANDTHENMIXESTHOSESPECTRAANDCONVERTSBACKTORGBBUTUNLIKETHEOTHERTWOKINDSOFMIXINGINTHISCASEWECANTSAYTHATTHESECOLORSARETHERIGHTANSWERWHATWOULDHAPPENWITHREALPAINTSDEPENDSONTHEIRCHEMICALCOMPOSITIONANDHOWTHEYREMIXEDTHEREARETHREEMOREMIXINGOPTIONSBUTTHESETHREEARETHEONESTHATCORRESPONDTOREALWORLDCOLORMIXINGTHEMIXBLOCKWILLACCEPTANYNUMBEROFCOLORSANDWILLMIXTHEMINEQUALPROPORTIONIFFORANYKINDOFMIXINGYOUWANTMOREOFONECOLORTHANANOTHERUSETHECOLORATWEIGHTBLOCKTOMAKEAWEIGHTEDCOLORTHISMIXESFOURPARTSREDPAINTTOONEPARTGREENPAINTALLCOLORSINAMIXTURECANBEWEIGHTEDTHANKSTOSCOTTBURNSFORHISHELPINUNDERSTANDINGPAINTMIXINGALONGWITHDAVIDBRIGGSSTUTORIALREMAININGMISTAKESAREBHSTLDRFORNORMALPEOPLESNAPPROVIDESTHREESIMPLEONEDIMENSIONALSCALESCRAYONSFORSPECIFICINTERESTINGCOLORSCOLORNUMBERSFORACONTINUUMOFHIGHCONTRASTCOLORSWITHARANGEOFHUESANDSHADINGANDFAIRHUESFORACONTINUUMWITHOUTSHADINGFORCOLORNERDSITPROVIDESTHREEDIMENSIONALCOLORSPACESRGBHSLHSVANDFAIRHUEVARIANTSOFTHELATTERTWOWERECOMMENDFAIRHSLFORZEROINGINONADESIREDCOLORCOLORALLCOLORNUMBERSNUMBERSNOGRAYSJUSTGRAYSFAIRHUESCRAYONSNOGRAYSSUBAPPENDIXGEEKYDETAILSONFAIRHUETHELEFTGRAPHSHOWSTHATUNSURPRISINGLYALLOFTHEBROWNFAIRHUESMAKEESSENTIALLYNOPROGRESSINREALHUEWITHTHEORANGEBROWNSECTIONACTUALLYALITTLERETROGRADESINCEBROWNSAREREALLYSHADESOFORANGEANDSOTHEREALHUESOVERLAPBETWEENFAIRBROWNSANDFAIRORANGESGREENMAKESUPSOMEOFTHEDISTANCEBECAUSETHEREARETOOMANYGREENREALHUESANDPARTOFTHEGOALOFTHEFAIRHUESCALEISTOSQUEEZETHATPARTOFTHEHUESPECTRUMBUTMUCHOFTHECATCHINGUPHAPPENSVERYQUICKLYBETWEENPUREMAGENTAATFAIRHUEANDTHESTARTOFTHEPURPLEREDSECTIONATFAIRHUETHISABRUPTCHANGEISUNFORTUNATEBUTTHEALTERNATIVESINVOLVEEITHERSTEALINGSPACEFROMREDORSTEALINGSPACEFROMPURPLEWHICHALREADYHASTOINCLUDEBOTHSPECTRALVIOLETANDRGBMAGENTATHEGRAPHHASDISCONTINUOUSDERIVATIVEATTHETABLELOOKUPPOINTSOFWHICHTHEREARETWOINEACHCOLORFAMILYONEATTHEPURENAMEDRGBCOLORSATMULTIPLESOFANDTHEOTHERROUGHLYHALFWAYTOTHENEXTCOLORFAMILYEXCEPTFORTHEPURPLEFAMILYWHICHHASLOOKUPPOINTSATAPPROXIMATESPECTRALVIOLETRGBMAGENTAANDTURNINGPOINTTOWARDTHEREDFAMILYINTHECOLORPICKERBLUECAPTURESCYANANDPURPLESPACEINDARKSHADESTHISTOOISANARTIFACTOFHUMANVISIONTHERIGHTGRAPHSHOWSTHEHSVSATURATIONANDVALUEFORALLTHEFAIRHUESSATURATIONISATASITSHOULDBEINAHUESCALEEXCEPTFORAVERYSLIGHTDROPINPARTOFTHEBROWNSBROWNSARESHADESOFORANGENOTTINTSSOONEWOULDEXPECTFULLSATURATIONEXCEPTTHATSOMEOFTHEBROWNSAREACTUALLYMIXTURESWITHRELATEDHUESBUTVALUEALSOASEXPECTEDFALLSSUBSTANTIALLYINTHEBROWNSTOALOWOFABOUTHALFWAYTOBLACKFORTHEPUREBROWNATFAIRHUEBUTTHECURVEISSMOOTHWITHOUTINFLECTIONPOINTSOTHERTHANTHATMINIMUMVALUEPUREBROWNFAIRSATURATIONANDFAIRVALUEAREBYDEFINITIONFORTHEENTIRERANGEOFFAIRHUESTHISMEANSTHATINTHEBROWNSTHEREALSATURATIONANDVALUEARETHEPRODUCTINPERCENTOFTHEINNATESHADINGOFTHESPECIFICBROWNFAIRHUEANDTHEUSERSFAIRSATURATIONVALUESETTINGWHENTHEUSERSPREVIOUSCOLORSETTINGWASINAREALSCALEANDTHENEWSETTINGISINAFAIRSCALETHEPROGRAMASSUMESTHATTHEPREVIOUSSATURATIONANDVALUEWEREENTIRELYUSERDETERMINEDWHENTHEPREVIOUSCOLORSETTINGWASINABROWNFAIRHUEANDTHENEWSETTINGISALSOINAFAIRSCALETHEPROGRAMREMEMBERSTHEUSERSINTENTIONFROMTHEPREVIOUSSETTINGINTERNALCALCULATIONSAREBASEDONHSVEVENTHOUGHWERECOMMENDHSLTOUSERSBECAUSEHSVCOMESTOUSDIRECTLYFROMTHEJAVASCRIPTCOLORMANAGEMENTIMPLEMENTATIONTHISISWHYTHESETPENBLOCKINCLUDESOPTIONSFORFAIRSATURATIONANDSOONFORTHEEXTRAGEEKYHEREARETHEEXACTTABLELOOKUPPOINTSFAIRHUEANDHEREARETHERGBSETTINGSATTHOSEPOINTSSUBAPPENDIXGEEKYDETAILSONCOLORNUMBERSHEREISAPICTUREOFINTEGERCOLORNUMBERSBUTREMEMBERTHATCOLORNUMBERSARECONTINUOUSASUSUALCONTINUOUSVALUESAREULTIMATELYCONVERTEDTOINTEGERRGBVALUESSOTHERESREALLYSOMEGRANULARITYCOLORNUMBERSARECONTINUOUSLYVARYINGGRAYSCALEFROMBLACKTOWHITECOLORNUMBERSTOARELINEARLYVARYINGSHADESOFPINKWITHRGBREDATCOLORNUMBERBEYONDTHATPOINTINEACHCOLORFAMILYTHEMULTIPLEOFTENCOLORNUMBERINTHEMIDDLEISTHERGBSTANDARDCOLOROFTHATFAMILYINWHICHEACHCOMPONENTISEITHEROREXCEPTIONSAREBROWNWHICHISOFCOURSEDARKERTHANANYOFTHOSECOLORSORANGEWITHITSGREENCOMPONENTHALFSTRENGTHANDVIOLETDISCUSSEDBELOWTHEFOLLOWINGMULTIPLEOFFIVEISTHENUMBEROFTHEDARKESTCOLORINTHATFAMILYALTHOUGHNOTNECESSARILYTHESAMEHUEASTHEMULTIPLEOFTENCOLORNUMBERCOLORNUMBERSBETWEENTHEMULTIPLEOFTENANDTHEFOLLOWINGMULTIPLEOFFIVEARESHADESOFCOLORSENTIRELYWITHINTHEFAMILYCOLORNUMBERSINTHEFOURBEFORETHEMULTIPLEOFTENAREMIXTURESOFTHISFAMILYANDTHEONEBEFOREITSOFOREXAMPLEINTHEGREENFAMILYWEHAVEDARKESTYELLOWSHADESOFYELLOWGREENMIXTURESASTHECOLORNUMBERINCREASESBOTHTHEHUEANDTHELIGHTNESSORVALUEDEPENDINGONYOURRELIGIONINCREASESOWEGETBRIGHTERANDGREENERCOLORSCANONICALGREENWHOSEWCCOLORNAMEISLIMENOTGREENSHADESOFGREENNOCYANMIXEDINDARKESTGREENSHADESOFGREENCYANMIXTURESINTHECOLORNUMBERCHARTALLTHEDARKCOLORNUMBERSLOOKALOTLIKEBLACKBUTTHEYREQUITEDIFFERENTHEREARETHEDARKESTCOLORSINEACHCOLORNUMBERFAMILYDARKESTYELLOWDOESNTLOOKENTIRELYYELLOWYOUMIGHTSEEITASGREENISHORBROWNISHASITTURNSOUTTHEDARKESTCOLORTHATREALLYLOOKSYELLOWISHARDLYDARKATALLTHISCOLORWASHANDTWEAKEDTOLOOKNEITHERGREENNORBROWNTOMEBUTYMMVINSOMEFAMILIESTHECENTERCRAYONISANIMPORTANTNAMEDDARKERVERSIONOFTHECENTERCOLORINTHEREDFAMILYISMAROONINTHECYANFAMILYISTEALANEARLYVERSIONOFTHECOLORNUMBERSCALEUSEDTHESENAMEDSHADESASTHECENTERCOLORNUMBERALSOBUTONTHISPAGEWEUSETHEWORDDARKESTADVISEDLYYOUCANTFINDADARKERSHADEOFTHISFAMILYANYWHEREINTHECOLORNUMBERSCALEBUTYOUCANFINDLIGHTERSHADESTEALISCOLORNUMBERBECAUSEDARKESTCYANCOLORISTHECOLORNUMBERFORMAROONISLEFTASANEXERCISEFORTHEREADERTHEPURPLEFAMILYISDIFFERENTFROMTHEOTHERSBECAUSEITHASTOINCLUDEBOTHSPECTRALVIOLETANDEXTRASPECTRALRGBMAGENTAVIOLETISUSUALLYGIVENASRGBBUTTHATSMUCHBRIGHTERTHANTHEVIOLETINANACTUALSPECTRUMSEEPAGEWEUSEAVALUEHANDTWEAKEDTOLOOKASMUCHASPOSSIBLELIKETHEVIOLETINRAINBOWPHOTOSASCOLORNUMBERCRAYONISMAGENTAISCOLORNUMBERTHISMEANSTHATTHECOLORSGETBRIGHTERNOTDARKERBETWEENANDTHEDARKESTVIOLETISACTUALLYCOLORNUMBERSOITSBLUERTHANSTANDARDVIOLETBUTSTILLPLAINLYAPURPLEANDNOTABLUEITSITSNOTHANDTWEAKEDITSALINEARINTERPOLATIONBETWEENDARKESTBLUEANDTHEVIOLETATCOLORNUMBERIDETERMINEDBYEXPERIMENTTHATCOLORNUMBERISTHEDARKESTONETHATSSTILLUNAMBIGUOUSLYPURPLEACCORDINGTOWIKIPEDIAVIOLETNAMESONLYTHESPECTRALCOLORWHILEPURPLEISTHENAMEOFTHEWHOLECOLORFAMILYHEREARETHEREFERENCEPOINTSFORCOLORNUMBERSTHATAREMULTIPLESOFFIVEEXCEPTFORITEMWHICHISUSEDFORCOLORNOTCOLORTHEVERYPALETHREEINPUTLISTBLOCKSAREFORCOLORNUMBERSTHATAREODDMULTIPLESOFFIVEGENERALLYTHEDARKESTMEMBERSOFEACHCOLORFAMILYTHEBLOCKCOLORSWEREADJUSTEDINPHOTOSHOPDONTASKHOWTOGETBLOCKSTHISCOLORINSNAPAPPENDIXBAPLFEATURESTHEBOOKAPROGRAMMINGLANGUAGEWASPUBLISHEDBYMATHEMATICIANKENNETHEIVERSONINHEWANTEDAFORMALLANGUAGETHATWOULDLOOKLIKEWHATMATHEMATICIANSWRITEONCHALKBOARDSTHETHENUNNAMEDLANGUAGEWOULDLATERTAKEITSNAMEFROMTHEFIRSTLETTERSOFTHEWORDSINTHEBOOKSTITLEITWASLITTLEKNOWNUNTILWHENAFORMALDESCRIPTIONOFTHEJUSTANNOUNCEDIBMSYSTEMINTHEIBMSYSTEMSJOURNALUSEDAPLNOTATIONAROUNDTHESAMETIMEIVERSONSASSOCIATEADINFALKOFFGAVEATALKONAPLTOANEWYORKASSOCIATIONFORCOMPUTINGMACHINERYCHAPTERWITHANEXCITEDYEAROLDBRIANHARVEYINTHEAUDIENCEBUTITWASNTUNTILTHATTHEFIRSTPUBLICIMPLEMENTATIONOFTHELANGUAGEFORTHESYSTEMWASPUBLISHEDBYIBMITWASCALLEDAPLBECAUSETHENORMALSLASHCHARACTERREPRESENTSTHEREDUCEOPERATORINAPLWHILEBACKSLASHISEXPANDTHECRUCIALIDEABEHINDAPLISTHATMATHEMATICIANSTHINKABOUTCOLLECTIONSOFNUMBERSONEDIMENSIONALVECTORSANDTWODIMENSIONALMATRICESASVALIDOBJECTSINTHEMSELVESWHATCOMPUTERSCIENTISTSLATERLEARNEDTOCALLFIRSTCLASSDATAAMATHEMATICIANWHOWANTSTOADDTWOVECTORSWRITESVVNOTFORITOLENGTHVRESULTIVIVISAMEFORAPROGRAMMERUSINGAPLTHEREARETHREEKINDSOFFUNCTIONINAPLSCALARFUNCTIONSMIXEDFUNCTIONSANDOPERATORSASCALARFUNCTIONISONEWHOSENATURALDOMAINISINDIVIDUALNUMBERSORTEXTCHARACTERSAMIXEDFUNCTIONISONEWHOSEDOMAININCLUDESARRAYSVECTORSMATRICESORHIGHERDIMENSIONALCOLLECTIONSINSNAPSCALARFUNCTIONSAREGENERALLYFOUNDINTHEGREENOPERATORSPALETTEWHILEMIXEDFUNCTIONSAREINTHEREDLISTSPALETTETHETHIRDCATEGORYCONFUSINGLYFORSNAPUSERSISCALLEDOPERATORSINAPLBUTCORRESPONDSTOWHATWECALLHIGHERORDERFUNCTIONSFUNCTIONSWHOSEDOMAININCLUDESFUNCTIONSSNAPHYPERBLOCKSARESCALARFUNCTIONSTHATBEHAVELIKEAPLSCALARFUNCTIONSTHEYCANBECALLEDWITHARRAYSASINPUTSANDTHEUNDERLYINGFUNCTIONISAPPLIEDTOEACHNUMBERINTHEARRAYSIFTHEFUNCTIONISMONADICMEANINGTHATITTAKESONEINPUTTHENTHERESNOCOMPLEXITYTOTHISIDEATAKETHESQUAREROOTOFANARRAYANDYOUARETAKINGTHESQUAREROOTOFEACHNUMBERINTHEARRAYIFTHEFUNCTIONISDYADICTAKINGTWOINPUTSTHENTHETWOARRAYSMUSTHAVETHESAMESHAPESNAPISMOREFORGIVINGTHANAPLIFTHEARRAYSDONTAGREEINNUMBEROFDIMENSIONSCALLEDTHERANKOFTHEARRAYTHELOWERRANKARRAYISMATCHEDREPEATEDLYWITHSUBSETSOFTHEHIGHERRANKONEIFTHEYDONTAGREEINLENGTHALONGONEDIMENSIONTHERESULTHASTHESHORTERLENGTHANDSOMEOFTHENUMBERSINTHELONGERLENGTHARRAYAREIGNOREDANEXCEPTIONINBOTHLANGUAGESISTHATIFONEOFTHETWOINPUTSISASCALARTHENITISMATCHEDWITHEVERYNUMBERINTHEOTHERARRAYINPUTASEXPLAINEDINSECTIONIVFTHISTERMWISEEXTENSIONOFSCALARFUNCTIONSISTHEMAINAPLLIKEFEATUREBUILTINTOSNAPITSELFWEALSOINCLUDEANEXTENSIONOFTHEITEMBLOCKTOADDRESSMULTIPLEDIMENSIONSANEXTENSIONTOTHELENGTHBLOCKWITHFIVELISTFUNCTIONSFROMAPLANDANEWPRIMITIVERESHAPEBLOCKTHEAPLLIBRARYEXTENDSTHEIMPLEMENTATIONOFAPLFEATURESTOINCLUDEAFEWMISSINGSCALARFUNCTIONSANDSEVERALMISSINGMIXEDFUNCTIONSANDOPERATORSPROGRAMMINGINAPLREALLYISVERYDIFFERENTINSTYLEFROMPROGRAMMINGINOTHERLANGUAGESEVENSNAPTHISAPPENDIXCANTHOPETOBEACOMPLETEREFERENCEFORAPLLETALONEATUTORIALIFYOUREINTERESTEDFINDONEOFTHOSEINALIBRARYORAPROBABLYUSEDBOOKSTOREREADITANDDOTHEEXERCISESSORRYTOSOUNDLIKEATEACHERBUTTHENOTATIONISSUFFICIENTLYWEIRDASTOTAKEALOTOFPRACTICEBEFOREYOUSTARTTOTHINKINAPLANOTEONVERSIONSTHEREISAWIDELYSTANDARDIZEDAPLSEVERALIDIOSYNCRATICEXTENSIONSANDASUCCESSORLANGUAGENAMEDJTHELATTERUSESPLAINASCIICHARACTERSUNLIKETHEONESWITHAPLINTHEIRNAMESWHICHUSETHEMATHEMATICIANSCHARACTERSETWITHGREEKLETTERSTYPESTYLESBOLDFACEANDORITALICSINBOOKSUNDERLINEDUPPERCASEORLOWERCASEINAPLASLOOSETYPEDECLARATIONSANDSYMBOLSNOTPARTOFANYONESALPHABETSUCHASFORFLOORANDFORCEILINGTOUSETHEORIGINALAPLYOUNEEDEDEXPENSIVESPECIALCOMPUTERTERMINALSTHISWASBEFOREYOUCOULDDOWNLOADFONTSINSOFTWARETODAYTHEMOREUNUSUALAPLCHARACTERSAREINUNICODEATUTOUTHECHARACTERSETWASPROBABLYTHEMAINREASONAPLDIDNTTAKEOVERTHEWORLDAPLHASALOTTORECOMMENDITFORSNAPUSERSMAINLYBECAUSEITMOVESFROMTHEORIGINALAPLIDEATHATALLARRAYSMUSTBEUNIFORMINDIMENSIONANDTHEELEMENTSOFARRAYSMUSTBENUMBERSORSINGLETEXTCHARACTERSTOOURIDEATHATALISTCANBEANELEMENTOFANOTHERLISTANDTHATSUCHELEMENTSDONTALLHAVETOHAVETHESAMEDIMENSIONSNEVERTHELESSITSMECHANISMFORALLOWINGBOTHOLDSTYLEAPLARRAYSANDMOREGENERALNESTEDARRAYSISCOMPLICATEDANDHARDFORANAPLBEGINNERPROBABLYALLBUTTWOORTHREESNAPUSERSTOUNDERSTANDSOWEARESTARTINGWITHPLAINAPLIFITTURNSOUTTOBEWILDLYPOPULARWEMAYDECIDELATERTOINCLUDEAPLFEATURESHEREARESOMEOFTHEGUIDINGIDEASINTHEDESIGNOFTHEAPLLIBRARYGOALENABLEINTERESTEDSNAPUSERSTOLEARNTHEFEELANDSTYLEOFAPLPROGRAMMINGITSREALLYWORTHTHEEFFORTFOREXAMPLEWEDIDNTHYPERIZETHEBLOCKBECAUSESNAPUSERSEXPECTITTOGIVEASINGLEYESORNOANSWERABOUTTHEEQUALITYOFTWOCOMPLETESTRUCTURESWHATEVERTHEIRTYPESANDSHAPESINAPLISASCALARFUNCTIONITCOMPARESTWONUMBERSORTWOCHARACTERSHOWCOULDAPLUSERSLIVEWITHOUTTHEABILITYTOASKIFTWOSTRUCTURESAREEQUALBECAUSEINAPLYOUCANSAYABTOGETTHATANSWERREADINGFROMRIGHTTOLEFTABREPORTSANARRAYOFBOOLEANSREPRESENTEDINAPLASFORFALSEFORTRUETHECOMMAOPERATORTURNSTHESHAPEOFTHEARRAYINTOASIMPLEVECTORANDMEANSREDUCEWITHANDREDUCEISOURCOMBINEFUNCTIONTHATSIXCHARACTERPROGRAMISMUCHLESSEFFORTTHANTHEEQUIVALENTINSNAPNOTEINPASSINGTHATIFYOUWANTEDTOKNOWHOWMANYCORRESPONDINGELEMENTSOFTHETWOARRAYSAREEQUALYOUDJUSTUSEINSTEADOFNOTEALSOTHATOURAPLISHBLOCKSAREALITTLEVERBOSEBECAUSETHEYINCLUDEUPTOTHREENOTATIONSFORTHEFUNCTIONTHEUSUALSNAPNAMEEGAENTHENAMEAPLPROGRAMMERSUSEWHENTALKINGABOUTITRAVELANDINYELLOWTYPETHESYMBOLUSEDINACTUALAPLCODEWERENOTCONSISTENTABOUTITSEEMSSELFDOCUMENTINGANDLCMANDISDIFFERENTEVENTHOUGHITHASTWONAMESITTURNSOUTTHATIFYOUREPRESENTBOOLEANVALUESASANDTHENTHEALGORITHMTOCOMPUTETHELEASTCOMMONMULTIPLEOFTWOINTEGERSCOMPUTESTHEANDFUNCTIONIFTHETWOINPUTSHAPPENTOBEBOOLEANINCLUDINGTHEAPLSYMBOLSSERVESTWOPURPOSESTHETWOORTHREESNAPUSERSWHOVEACTUALLYPROGRAMMEDINAPLWILLBESUREWHATFUNCTIONTHEYREUSINGBUTMOREIMPORTANTLYTHEONESWHOAREREADINGANAPLTUTORIALWHILEBUILDINGPROGRAMSINSNAPWILLFINDTHEBLOCKTHATMATCHESTHEAPLTHEYREREADINGGOALBRINGTHEBESTANDMOSTGENERALAPLIDEASINTOMAINSTREAMSNAPPROGRAMMINGSTYLEMEDIACOMPUTATIONINPARTICULARBECOMESMUCHSIMPLERWHENSCALARFUNCTIONSCANBEAPPLIEDTOANENTIREPICTUREORSOUNDYESMAPPROVIDESESSENTIALLYTHESAMECAPABILITYBUTTHENOTATIONGETSCOMPLICATEDIFYOUWANTTOMAPOVERCOLUMNSRATHERTHANROWSALSOSNAPLISTSAREFUNDAMENTALLYONEDIMENSIONALBUTREALDATAOFTENHAVEMOREDIMENSIONSASNAPPROGRAMMERHASTOBETHINKINGALLTHETIMEABOUTTHECONVENTIONTHATWEREPRESENTAMATRIXASALISTOFROWSEACHOFWHICHISALISTOFINDIVIDUALCELLSTHATISROWOFASPREADSHEETISITEMOFSPREADSHEETBUTCOLUMNISMAPITEMOFOVERSPREADSHEETAPLTREATSROWSANDCOLUMNSMORESYMMETRICALLYNONGOALALLOWPROGRAMSWRITTENORIGINALLYINAPLTORUNINSNAPESSENTIALLYUNCHANGEDFOREXAMPLEINAPLTHEATOMICTEXTUNITISASINGLECHARACTERANDSTRINGSOFCHARACTERSARELISTSWETREATATEXTSTRINGASSCALARANDTHATISNTGOINGTOCHANGEBECAUSEAPLPROGRAMMERSRARELYUSECONDITIONALSINSTEADCOMPUTINGFUNCTIONSINVOLVINGARRAYSOFBOOLEANVALUESTOACHIEVETHESAMEEFFECTTHENOTATIONTHEYDOHAVEFORCONDITIONALSISPRIMITIVEINTHESENSEOFPALEOLITHICNOTINTHESENSEOFBUILTINWERENOTCHANGINGOURSNONGOALEMULATETHETERSEAPLSYNTAXITSTOOBADINAWAYASNOTEDABOVETHETERSENESSOFEXPRESSINGACOMPUTATIONAFFECTSAPLPROGRAMMERSSENSEOFWHATSDIFFICULTANDWHATISNTBUTYOUCANTSAYTERSEANDBLOCKLANGUAGEINTHESAMESENTENCEOURWHOLERAISONDTREISTOMAKEITPOSSIBLETOBUILDAPROGRAMWITHOUTHAVINGTOMEMORIZETHESYNTAXORTHENAMESOFFUNCTIONSANDTOALLOWTHOSENAMESTOBELONGENOUGHTOBESELFDOCUMENTINGANDAPLSSYNTAXHASITSOWNISSUESOFWHICHTHEBIGGESTISTHATITSHARDTOUSEFUNCTIONSWITHMORETHANTWOINPUTSBECAUSEMOSTMATHEMATICALDYADICFUNCTIONSUSEINFIXNOTATIONTHEFUNCTIONSYMBOLBETWEENTHETWOINPUTSTHENOTIONOFLEFTARGUMENTANDRIGHTARGUMENTISUNIVERSALINAPLDOCUMENTATIONTHETHINGPEOPLEMOSTCOMPLAINABOUTTHATTHEREISNOOPERATORPRECEDENCELIKETHEMULTIPLICATIONBEFOREADDITIONRULEINNORMALARITHMETICNOTATIONREALLYDOESNTTURNOUTTOBEAPROBLEMFUNCTIONGROUPINGISSTRICTLYRIGHTTOLEFTSOMEANSTWOTIMESSEVENNOTSIXPLUSFOURTHATTAKESSOMEGETTINGUSEDTOBUTITREALLYDOESNTTAKELONGIFYOUIMMERSEYOURSELFINAPLTHEREASONISTHATTHEREARETOOMANYINFIXOPERATORSFORPEOPLETOMEMORIZEAPRECEDENCETABLEBUTINANYCASEBLOCKNOTATIONELIMINATESTHEPROBLEMESPECIALLYWITHSNAPSZEBRACOLORINGYOUCANSEEANDCONTROLTHEGROUPINGBYWHICHBLOCKISINSIDEWHICHOTHERBLOCKSINPUTSLOTANOTHERPROBLEMWITHAPLSSYNTAXISTHATITBENDSOVERBACKWARDNOTTOHAVERESERVEDWORDSASOPPOSEDTOFORTRANITSMAINCOMPETITIONBACKTHENSOTHEDYADICCIRCULARFUNCTIONSFUNCTIONUSESTHELEFTARGUMENTTOSELECTATRIGFUNCTIONXISSINXXISCOSXANDSOONXISARCSINXWHATSXGLADYOUASKEDITSWBOOLEANVALUESSNAPUSESDISTINCTBOOLEANVALUESTRUEANDFALSETHATAREDIFFERENTFROMOTHERDATATYPESAPLUSESANDRESPECTIVELYTHEAPLSTYLEOFPROGRAMMINGDEPENDSHEAVILYONDOINGARITHMETICONBOOLEANSALTHOUGHTHEIRCONDITIONALSINSISTONONLYORINABOOLEANINPUTSLOTNOTOTHERNUMBERSSNAPARITHMETICFUNCTIONSTREATFALSEASANDTRUEASSOOURAPLLIBRARYTRIESTOREPORTSNAPBOOLEANVALUESFROMPREDICATEFUNCTIONSSCALARFUNCTIONSTHESEARETHESCALARFUNCTIONSINTHEAPLLIBRARYMOSTOFTHEMARESTRAIGHTFORWARDTOFIGUREOUTTHESCALARBLOCKPROVIDESANAPLSTYLEVERSIONOFANDOTHEREXCEPTIONSASAHYPERBLOCKTHATEXTENDSTERMWISETOARRAYSJOINTHEONLYNONPREDICATENONHYPERSCALARPRIMITIVEHASITSOWNSCALARJOINBLOCKDEALREPORTSARANDOMVECTOROFSEVENNUMBERSFROMTOWITHNOREPETITIONSASINDEALINGAHANDOFCARDSSIGNUMOFANUMBERREPORTSIFTHENUMBERISPOSITIVEIFITSZEROORIFITSNEGATIVEROLLREPORTSARANDOMROLLOFASIXSIDEDDIETOROLLDICEUSEWHICHWOULDLOOKMUCHMOREPLEASANTASBUTPERHAPSOURVERSIONISMOREINSTANTLYREADABLEBYSOMEONEWHODIDNTGROWUPWITHAPLALLTHELIBRARYFUNCTIONSHAVEHELPMESSAGESAVAILABLEMIXEDFUNCTIONSMIXEDFUNCTIONSINCLUDELISTSINTHEIRNATURALDOMAINORRANGETHATISONEORBOTHOFITSINPUTSMUSTBEALISTORITALWAYSREPORTSALISTSOMETIMESBOTHINPUTSARENATURALLYLISTSSOMETIMESONEINPUTOFADYADICMIXEDFUNCTIONISNATURALLYASCALARANDTHEFUNCTIONTREATSALISTINTHATINPUTSLOTASANIMPLICITMAPASFORSCALARFUNCTIONSTHISMEANSYOUHAVETOLEARNTHERULEFOREACHMIXEDFUNCTIONINDIVIDUALLYTHESHAPEOFFUNCTIONTAKESANYINPUTANDREPORTSAVECTOROFTHEMAXIMUMSIZEOFTHESTRUCTUREALONGEACHDIMENSIONFORAVECTORITRETURNSALISTOFLENGTHCONTAININGTHELENGTHOFTHEINPUTFORAMATRIXITRETURNSATWOITEMLISTOFTHENUMBEROFROWSANDNUMBEROFCOLUMNSOFTHEINPUTANDSOONFORHIGHERDIMENSIONSIFTHEINPUTISNTALISTATALLTHENITHASZERODIMENSIONSANDSHAPEOFREPORTSANEMPTYVECTOREQUIVALENTTOTHEDIMENSIONSOFPRIMITIVEASOFRANKOFISNTANACTUALAPLPRIMITIVEBUTTHECOMPOSITIONSHAPEOFSHAPEOFASTRUCTUREWHICHREPORTSTHENUMBEROFDIMENSIONSOFTHESTRUCTURETHELENGTHOFITSSHAPEVECTORISTOOUSEFULTOOMITITSVERYEASYTOTYPETHESAMECHARACTERTWICEONTHEAPLKEYBOARDBUTLESSEASYTODRAGBLOCKSTOGETHEREQUIVALENTTOTHERANKOFPRIMITIVEASOFRESHAPETAKESASHAPEVECTORSUCHASSHAPEMIGHTREPORTONTHELEFTANDANYSTRUCTUREONTHERIGHTITIGNORESTHESHAPEOFTHERIGHTINPUTSTRINGINGTHEATOMICELEMENTSINTOAVECTORINROWMAJORORDERTHATISALLOFTHEFIRSTROWLEFTTORIGHTTHENALLOFTHESECONDROWETCTHEPRIMITIVERESHAPETAKESTHEINPUTSINTHEOTHERORDERITTHENREPORTSANARRAYWITHTHESHAPESPECIFIEDBYTHEFIRSTINPUTCONTAININGTHEITEMSOFTHESECONDIFTHERIGHTINPUTHASMOREATOMICELEMENTSTHANAREREQUIREDBYTHELEFTINPUTSHAPEVECTORTHEEXCESSAREIGNOREDWITHOUTREPORTINGANERRORIFTHERIGHTINPUTHASTOOFEWATOMICELEMENTSTHEPROCESSOFFILLINGTHEREPORTEDARRAYSTARTSAGAINFROMTHEFIRSTELEMENTTHISISMOSTUSEFULINTHESPECIFICCASEOFANATOMICRIGHTINPUTWHICHPRODUCESANARRAYOFANYDESIREDSHAPEALLOFWHOSEATOMICELEMENTSAREEQUALBUTOTHERCASESARESOMETIMESUSEFULTOOIDFLAENTAKESANARBITRARYSTRUCTUREASINPUTANDREPORTSAVECTOROFITSATOMICELEMENTSINROWMAJORORDERLISPIANSCALLTHISFLATTENINGTHESTRUCTUREBUTAPLERSCALLITRAVELBECAUSEOFTHEMETAPHOROFPULLINGONABALLOFYARNSOWHATTHEYREALLYMEANISUNRAVELBUTTHESNARKYSOUNDOFTHATISUNCALLEDFORBECAUSEAMOREADVANCEDVERSIONTHATWEMIGHTIMPLEMENTSOMEDAYISMORELIKERAVELINGONEAPLIDIOMISTOAPPLYTHISTOASCALARINORDERTOTURNITINTOAONEELEMENTVECTORBUTWECANTUSEITTHATWAYBECAUSEYOUCANTTYPEASCALARVALUEINTOTHELISTTYPEINPUTSLOTEQUIVALENTTOTHEPRIMITIVEAENOFBLOCKCATENATEISLIKEOURPRIMITIVEAPPENDWITHTWODIFFERENCESFIRSTIFEITHERINPUTISASCALARITISTREATEDLIKEAONEITEMVECTORSECONDIFTHETWOINPUTSAREOFDIFFERENTRANKTHECATENATEFUNCTIONISRECURSIVELYMAPPEDOVERTHEHIGHERRANKINPUTCATENATEVERTICALLYISSIMILARBUTITADDSNEWROWSINSTEADOFADDINGNEWCOLUMNSINTEGERSITHINKTHATSWHATITSTANDSFORALTHOUGHAPLERSJUSTSAYIOTATAKESAPOSITIVEINTEGERINPUTANDREPORTSAVECTOROFTHEINTEGERSFROMTOTHEINPUTTHISISANEXAMPLEOFAFUNCTIONCLASSEDASMIXEDNOTBECAUSEOFITSDOMAINBUTBECAUSEOFITSRANGETHEDIFFERENCEBETWEENTHISBLOCKANDTHEPRIMITIVENUMBERSFROMBLOCKISINITSTREATMENTOFLISTSASINPUTSNUMBERSFROMISAHYPERBLOCKAPPLYINGITSELFTOEACHITEMOFITSINPUTLISTIOTAHASASPECIALMEANINGFORLISTINPUTSTHEINPUTMUSTBEASHAPEVECTORTHERESULTISANARRAYWITHTHATSHAPEINWHICHEACHITEMISALISTOFTHEINDICESOFTHECELLALONGEACHDIMENSIONAPICTUREISWORTHWORDSBUTSNAPISNTSOGOODATDISPLAYINGARRAYSWITHMORETHANTWODIMENSIONSSOHEREWEREDUCEEACHCELLSINDEXLISTTOASTRINGDYADICIOTAISLIKETHEINDEXOFPRIMITIVEEXCEPTFORITSHANDLINGOFMULTIDIMENSIONALARRAYSITLOOKSONLYFORATOMICELEMENTSSOAVECTORINTHESECONDINPUTDOESNTMEANTOSEARCHFORTHATVECTORASAROWOFAMATRIXWHICHISWHATITMEANSTOINDEXOFBUTRATHERTOLOOKSEPARATELYFOREACHITEMOFTHEVECTORANDREPORTALISTOFTHELOCATIONSOFEACHITEMIFTHEFIRSTINPUTISAMULTIDIMENSIONALARRAYTHENTHELOCATIONOFANITEMISAVECTORWITHTHEINDICESALONGEACHROWINTHISEXAMPLETHEISINTHESECONDROWSECONDCOLUMNTHISISACTUALLYANEXTENSIONOFAPLIOTAWHICHISMORELIKEAHYPERIZEDINDEXOFGENERALIZINGIFTHERANKOFTHESECONDINPUTISLESSTHANTHERANKOFTHEFIRSTINPUTBYTWOORMORETHENIOTALOOKSFORTHEENTIRESECONDINPUTINTHEFIRSTINPUTTHEREPORTEDPOSITIONISAVECTORWHOSELENGTHISEQUALTOTHEDIFFERENCEBETWEENTHETWORANKSIFTHERANKOFTHESECONDINPUTISONELESSTHANTHERANKOFTHEFIRSTTHEREPORTEDVALUEISASCALARTHEINDEXOFTHEENTIRESECONDINPUTINTHEFIRSTWHYTHESTRANGEDESIGNDECISIONTOREPORTLENGTHWHENSOMETHINGISNTFOUNDINSTEADOFAMOREOBVIOUSFLAGVALUESUCHASORFALSEHERESWHYNOTETHATCODEHASITEMSNOTTHEASTERISKATTHEENDISTHECIPHERTEXTISTHETRANSLATIONOFALLNONALPHABETCHARACTERSSPACESANDTHEAPOSTROPHEINDOESNTTHISISASILLYEXAMPLEBECAUSEITMAKESUPARANDOMCIPHEREVERYTIMEITSCALLEDANDITDOESNTREPORTTHECIPHERSOTHERECIPIENTCANTDECIPHERTHEMESSAGEANDYOUWOULDNTWANTTOMAKETHESPACESINTHEMESSAGESOOBVIOUSBUTDESPITEBEINGSILLYTHEEXAMPLESHOWSTHEBENEFITOFREPORTINGLENGTHASTHEPOSITIONOFITEMSNOTFOUNDTHECONTAINEDINBLOCKISLIKEAHYPERIZEDCONTAINSWITHTHEINPUTORDERREVERSEDITREPORTSANARRAYOFBOOLEANSTHESAMESHAPEASTHELEFTINPUTTHESHAPEOFTHERIGHTINPUTDOESNTMATTERTHEBLOCKLOOKSONLYFORATOMICELEMENTSHOWEVERIFTHETWORANKSAREEQUALTHENTHEBLOCKISHYPERIZEDEACHITEMOFTHESECONDINPUTISLOCATEDINTHEFIRSTINPUTASTHENEXTEXAMPLESHOWSONLYTHEFIRSTINSTANCEOFEACHITEMISFOUNDEGTHEINPOSITIONNOTTHEINPOSITIONIFANITEMDOESNOTOCCURINTHELEFTINPUTWHATISREPORTEDISONEMORETHANTHELENGTHOFTHELEFTINPUTHERETHEBLOCKSGRADEUPANDGRADEDOWNAREUSEDFORSORTINGDATAGIVENANARRAYASINPUTITREPORTSAVECTOROFTHEINDICESINWHICHTHEITEMSTHEROWSIFAMATRIXSHOULDBEREARRANGEDINORDERTOBESORTEDTHISWILLBECLEARERWITHANEXAMPLETHERESULTFROMGRADEUPTELLSUSTHATITEMOFFOOCOMESFIRSTINSORTEDORDERTHENITEMTHENTHENWHENWEACTUALLYSELECTITEMSOFFOOBASEDONTHISORDERINGWEGETTHEDESIREDSORTEDVERSIONTHERESULTREPORTEDBYGRADEDOWNISALMOSTTHEREVERSEOFTHATFROMGRADEUPBUTNOTQUITEIFTHEREAREEQUALITEMSINTHELISTTHESORTISSTABLESOIFTHEREAREEQUALITEMSTHENWHICHEVERCOMESFIRSTINTHEINPUTLISTWILLALSOBEFIRSTINTHESORTEDLISTWHYTHISTWOSTEPPROCESSWHYNOTJUSTHAVEASORTPRIMITIVEINAPLONEANSWERISTHATINADATABASEAPPLICATIONYOUMIGHTWANTTOSORTONEARRAYBASEDONTHEORDEROFANOTHERARRAYTHISISTHELISTOFEMPLOYEESOFASMALLCOMPANYTAKENFROMSTRUCTUREANDINTERPRETATIONOFCOMPUTERPROGRAMSBYABELSONANDSUSSMANCREATIVECOMMONSLICENSEDEACHOFTHESMALLERLISTSCONTAINSAPERSONSNAMEJOBTITLEANDYEARLYSALARYWEWOULDLIKETOSORTTHEEMPLOYEESNAMESINBIGTOSMALLORDEROFSALARYFIRSTWEEXTRACTCOLUMNOFTHEDATABASETHESALARIESTHENWEUSEGRADEDOWNTOGETTHEREORDERINGINDICESATTHISPOINTWECOULDUSETHEINDEXVECTORTOSORTTHESALARIESBUTWHATWEACTUALLYWANTISALISTOFNAMESSORTEDBYSALARYBYTAKINGTHEINDEXVECTORFROMGRADEDOWNOFCOLUMNANDTELLINGITEMTOAPPLYITTOCOLUMNWEGETWHATWESETOUTTOFINDASUSUALTHECODEISMOREELEGANTINAPLDATABASEDATABASEINCASEYOUVEFORGOTTENORWOULDSELECTTHETHIRDROWOFTHEDATABASEWENEEDTHELISTINTHESECONDINPUTSLOTOFTHEOUTERLISTTOSELECTBYCOLUMNSRATHERTHANBYROWSSELECTIFTAKEORSELECTALLBUTIFDROPTHEFIRSTIFNORLASTIFNNITEMSFROMAVECTORORROWSFROMAMATRIXALTERNATIVELYIFTHELEFTINPUTISATWOITEMVECTORSELECTROWSWITHTHEFIRSTITEMANDCOLUMNSWITHTHESECONDTHECOMPRESSBLOCKSELECTSASUBSETOFITSRIGHTINPUTBASEDONTHEBOOLEANVALUESINITSLEFTINPUTWHICHMUSTBEAVECTOROFBOOLEANSWHOSELENGTHEQUALSTHELENGTHOFTHEARRAYTHENUMBEROFROWSFORAMATRIXINTHERIGHTINPUTTHEBLOCKREPORTSANARRAYOFTHESAMERANKASTHERIGHTINPUTBUTCONTAININGONLYTHOSEROWSWHOSECORRESPONDINGBOOLEANVALUEISTRUETHECOLUMNSVERSIONISTHESAMEBUTSELECTINGCOLUMNSRATHERTHANSELECTINGROWSAWORDABOUTTHEPOSSIBLYCONFUSINGNAMESOFTHESEBLOCKSTHEREARETWOWAYSTOTHINKABOUTWHATTHEYDOTAKETHESTANDARDVERSIONTOAVOIDTALKINGABOUTBOTHATONCEONEWAYTOTHINKABOUTITISTHATITSELECTSSOMEOFTHEROWSTHEOTHERWAYISTHATITSHORTENSTHECOLUMNSFORLISPIANSWHICHINCLUDESYOUSINCEYOUVELEARNEDABOUTKEEPTHENATURALWAYTOTHINKABOUTISTHATITKEEPSSOMEOFTHEROWSSINCEWEREPRESENTAMATRIXASALISTOFROWSTHATALSOFITSWITHHOWTHISFUNCTIONISIMPLEMENTEDREADTHECODEYOULLFINDAKEEPINSIDEBUTAPLPEOPLETHINKABOUTITTHEOTHERWAYSOWHENYOUREADAPLDOCUMENTATIONISDESCRIBEDASOPERATINGONTHELASTDIMENSIONTHECOLUMNSWHILEISDESCRIBEDASOPERATINGONROWSWEWEREMORETHANAMONTHINTOTHISPROJECTBEFOREIUNDERSTOODALLTHISYOUGETLONGBLOCKNAMESSOITWONTTAKEYOUAMONTHDONTCONFUSETHISBLOCKWITHTHEREDUCEBLOCKWHOSEAPLSYMBOLISALSOASLASHINTHATBLOCKWHATCOMESTOTHELEFTOFTHESLASHISADYADICCOMBININGFUNCTIONITSTHEAPLEQUIVALENTOFCOMBINETHISBLOCKISMORENEARLYEQUIVALENTTOKEEPBUTKEEPTAKESAPREDICATEFUNCTIONASINPUTANDCALLSTHEFUNCTIONFOREACHITEMOFTHESECONDINPUTWITHCOMPRESSTHEPREDICATEFUNCTIONIFANYHASALREADYBEENCALLEDONALLTHEITEMSOFTHERIGHTINPUTINPARALLELRESULTINGINAVECTOROFBOOLEANVALUESTHISISATYPICALAPLMOVESINCEHYPERBLOCKSAREEQUIVALENTTOANIMPLICITMAPITSEASYTOMAKETHEVECTOROFBOOLEANSBECAUSEANYSCALARFUNCTIONINCLUDINGPREDICATESCANBEAPPLIEDTOALISTINSTEADOFTOASCALARTHEREASONBOTHBLOCKSUSETHECHARACTERISTHATBOTHOFTHEMREDUCETHESIZEOFTHEINPUTARRAYALTHOUGHINDIFFERENTWAYSTHEREVERSEROWORDERREVERSECOLUMNORDERANDTRANSPOSEBLOCKSFORMAGROUPTHEGROUPOFREFLECTIONSOFAMATRIXTHEAPLSYMBOLSAREALLACIRCLEWITHALINETHROUGHITTHELINESARETHEDIFFERENTAXESOFREFLECTIONSOTHEREVERSEROWORDERBLOCKREVERSESWHICHROWISWHERETHEREVERSECOLUMNORDERBLOCKREVERSESWHICHCOLUMNISWHEREANDTHETRANSPOSEBLOCKTURNSROWSINTOCOLUMNSANDVICEVERSAEXCEPTFORREVERSEROWORDERTHESEWORKONLYONFULLARRAYSNOTRAGGEDRIGHTLISTSOFLISTSBECAUSETHERESULTOFTHEOTHERTWOWOULDBEANARRAYINWHICHSOMEROWSHADHOLESITEMSANDEXISTBUTNOTITEMWEDONTHAVEAREPRESENTATIONFORTHATINAPLALLARRAYSAREFULLSOITSEVENMORERESTRICTIVEHIGHERORDERFUNCTIONSTHEFINALCATEGORYOFFUNCTIONISOPERATORSAPLHIGHERORDERFUNCTIONSAPLHASNOEXPLICITMAPFUNCTIONBECAUSETHEHYPERBLOCKCAPABILITYSERVESMUCHTHESAMENEEDBUTAPLDIDADDANEXPLICITMAPWHICHWEMIGHTGETAROUNDTOADDINGTOTHELIBRARYNEXTTIMEAROUNDITSSYMBOLISDIAERESISORUMLAUTTHEAPLEQUIVALENTOFKEEPISCOMPRESSBUTITSNOTAHIGHERORDERFUNCTIONYOUCREATEAVECTOROFBOOLEANSSANDSINAPLBEFOREAPPLYINGTHEFUNCTIONTOTHEARRAYYOUWANTTOCOMPRESSBUTAPLDOESHAVEAHIGHERORDERVERSIONOFCOMBINETHEREDUCEBLOCKWORKSJUSTLIKECOMBINETAKINGADYADICFUNCTIONANDALISTTHEVERSIONTRANSLATESEACHROWTOASINGLEVALUETHEVERSIONTRANSLATESEACHCOLUMNTOASINGLEVALUETHATSTHEONLYWAYTOTHINKABOUTITFROMTHEPERSPECTIVEOFCOMBININGINDIVIDUALELEMENTSYOUAREADDINGUPORWHATEVERTHEFUNCTIONISTHENUMBERSINASINGLEROWORINASINGLECOLUMNBUTAPLERSTHINKOFAMATRIXASMADEUPOFVECTORSEITHERROWVECTORSORCOLUMNVECTORSANDIFYOUTHINKOFWHATTHESEBLOCKSDOASADDINGVECTORSRATHERTHANADDINGINDIVIDUALNUMBERSITSCLEARTHATINTHEVECTORISTHESUMOFCOLUMNVECTORSINPRESNAPWEDGETTHESAMERESULTTHISWAYMAPPINGOVERTHEROWSOFTHEMATRIXAPPLYINGCOMBINETOEACHROWCOMBININGROWSREDUCINGCOLUMNVECTORSTHEOUTERPRODUCTBLOCKTAKESTWOARRAYSVECTORSTYPICALLYANDADYADICSCALARFUNCTIONASINPUTSITREPORTSANARRAYWHOSERANKISTHESUMOFTHERANKSOFTHEINPUTSSOTYPICALLYAMATRIXINWHICHEACHITEMISTHERESULTOFAPPLYINGTHEFUNCTIONTOANATOMICELEMENTOFEACHARRAYTHETHIRDELEMENTOFTHESECONDROWOFTHERESULTISTHEVALUEREPORTEDBYTHEFUNCTIONWITHTHESECONDELEMENTOFTHELEFTINPUTANDTHETHIRDELEMENTOFTHERIGHTINPUTTHEAPLSYMBOLISPRONOUNCEDJOTDOTTHEWAYTOTHINKABOUTTHISBLOCKISMULTIPLICATIONTABLEFROMELEMENTARYSCHOOLTHEINNERPRODUCTBLOCKTAKESTWOMATRICESANDTWOOPERATIONSASINPUTTHENUMBEROFCOLUMNSINTHELEFTMATRIXMUSTEQUALTHENUMBEROFROWSINTHERIGHTMATRIXWHENTHETWOOPERATIONSAREANDTHISISTHEMATRIXMULTIPLICATIONFAMILIARTOMATHEMATICIANSBUTOTHEROPERATIONSCANBEUSEDONECOMMONINNERPRODUCTISORDOTANDAPPLIEDTOBOOLEANMATRICESTOFINDROWSANDCOLUMNSTHATHAVECORRESPONDINGITEMSINCOMMONTHEPRINTABLEBLOCKISNTANAPLFUNCTIONITSANAIDTOEXPLORINGAPLINSNAPITTRANSFORMSARRAYSTOACOMPACTREPRESENTATIONTHATSTILLMAKESTHESTRUCTURECLEAREXPERTSWILLRECOGNIZETHISASTHELISPREPRESENTATIONOFLISTSTRUCTURECC</l></variable><variable name="Rules"><list struct="atomic" id="2618">E,_,_,_,K,_,X,R,C,_,_,S,O,H,I,D,_,M,N,A,_,_,_,_,B,_</list></variable><variable name="solution"><l>NAEMKODCMK</l></variable><variable name="Alphabet"><list struct="atomic" id="2619">A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z</list></variable><variable name="data"><list struct="atomic" id="2620">45,6,38,10,42,3,0,44,40,15,62,10,35,35,11,1,0,25,22,14,7,0,6,10,11,8</list></variable><variable name="crypto1"><l>YCKIMKXIYECOOLIDRONKGXCOKBVIVSQRDGRKDCYZBYENVIGORKSVONKDDRODGSVSQRDCVKCDQVOKWSXQGRYCOLBYKNCDBSZOCKXNLBSQRDCDKBCDRBYEQRDROZOBSVYECPSQRDYOBDROBKWZKBDCGOGKDMRONGOBOCYQKVVKXDVICDBOKWSXQKXNDROBYMUODCBONQVKBODROLYWLCLEBCDSXQSXKSBQKFOZBYYPDRBYEQRDROXSQRDDRKDYEBPVKQGKCCDSVVDROBOYCKINYOCDRKDCDKBCZKXQVONLKXXOBIODGKFOYOBDROVKXNYPDROPBOOKXNDRORYWOYPDROLBKFO</l></variable><variable name="crypto2"><l>NPJHGJHOGPJUBKVNLLNZPAGZALGMLGGJZENWJTPJWTMGHZLETMJGBYTBGLKGWOTANPQMBZVJHGEGWJBUOJNZPZMONSNLNITJNZPYKTQGPZONETLTLNGPMZGJHGQYTYTYGOTUWGJHGGPGVKJBTOCGEWNQPWZMTESTPOGEJGOHPZLZQKJZHUPJEZDPZJHGBGVGBQGPOKOZLZPNGWJHGALTPNWJZGPMZBOGTABGNPEUWJBNTLWZONGJKUPJNLJHGETPQGBATWWGWTEVNPNWJBTJZBGBNOLTPQHZBPGTVGQTLZVTPNTOTPEPGZLUEENJGNPWJGTEHTWJHGOZLZPNWJWVGVZBNGWGBTWGETPEBGALTOGEDNJHJHGYGLNGMJHGKTBGJHGMNBWJHUVTPWTETVWTPEGSGWJHGOBGTJNZPWZMQZEUAZPWTMGHZLEDNJHTBOHTPQGLLTPQHZBPGTPZNPJGETWABZAHGJTPELGTEGBZMJHGOHUBOHZMQZETDTNJNPQZPLKYKABZWOBNYNPQWONGPOGTWHGBGJNOTLLTPQHZBPGYGLNGSGWOTPHUVTPNJKWWTMGJKYGTWWUBGEYGKZPEZAAZWNPQHNWVTEPGWWZPVZBTLQBZUPEWAGNWHTPDGNHZLEWJHTJGSGPJUTLLKLTPQHZBPGWBGLNQNZPDNLLOZLLTAWGLGTSNPQHUVTPNJKEGMGPWGLGWWTWNJBGJUBPWJZJHGWJTBWDNJHPZVGVZBKZMJHGATWJEGMKNPQLTPQHZBPGWHGWGJWUATLGFTPEBNTTBGMUQGMZBCPZDLGEQGZPWTMGHZLEWWZUJHGBPVZWJOZPJNPGPJJGPWNZPWBNWGYGMZBGTLGFTPEBNTNWEGWJBZKGEMBZVWATOGYKTHNEEGPCNPGJNOYZVYTBEVGPJALTJMZBVTBGJTLNTJZBKWJBNCGCNLLWLTPQHZBPGTPEVTPKZMHNWMZLLZDGBWYUJJHGOHUBOHBGVTNPWLTPQHZBPGNWGWJTYLNWHGETWTOHBNWJLNCGVTBJKBDHNLGWHTPDGNNWEGVZPNIGEJHGNBPTVGWYGOZVNPQOZVVZPGFABGWWNZPWZMABTNWGTPEENWVTKJHGBUNPGELTPEZMTLGFTPEBNTNWOUBWGETWTBVTQGEEZPBGGMKGJWHTPDGNHTETYTOCUAALTPJHGNVVZBJTLOKYGBPGJNOTSTJTBZMZPGZMJHGJGBBTPMGEGBTJNZPWKZUPQVNLNJTBKZMMNOGBWPNVUGTLYTPDHZQTSGHGBLNMGJZTLLZDJHGWTMGHZLEOZLZPNWJWJZGWOTAGJHGWZLTBWKWJGVWGOBGJGEMZBOGPJUBNGWTDTKNPOTSGBPWMULLZMDGTAZPWTPEJGOHPZLZQKPNVUGTDTCGPWLGTBPWZMDHTJHTWJBTPWANBGETPESZDWJZQUNEGHUVTPNJKUPJNLNJNWBGTEKJZMTOGJHGQYTYTPNVUGTEZAJWJHGJBTNJWZMTVTPVGBLNPTJHBTDGWWZWHGNWYGJJGBWUNJGEJZLGTENPATJBNTBOHTLWTMGHZLEVGBLNPBGWZLSGWJZAZWGTWTQNMJGENPENSNEUTLBTJHGBJHTPTPZJHGBTPQGLVTCNPQVNBTOLGWDNJHJGOHPZLZQKHGALTPWJZWLZDLKUPEGBVNPGJHGOHUBOHDNJHNJWZDPMLTDWTWBGABGWGPJGEYKTEZVNPTPJOTYTLZMOZBBUAJABGLTJGWJHGQBZUAZMMZUBVGBLNPOHZZWGWJHGVZWJABZQBGWWNSGZMJHGSTBNZUWPTJNZPWJHTJQZSGBPNPJHGOHUBOHWPTVGJHGNWLTPECNPQEZVZMOHTBNWTWTHZWJMZBTSNBUWZMNPPZSTJNZPHGQTNPWCNPQHTTBTHLEWJBUWJYKWTSNPQHNWWZPOTKLGYMBZVTJGTVZMTWWTWWNPWYGMZBGUPOZSGBNPQTETPQGBZUWALTPMZBTOZUAVGBLNPNPWANBGWJHGWGTMTBNPQOHTBNWNTPWJZYUNLETPNPEUWJBNTLGOZPZVKTPTESTPOGEMLGGJZMWHNAWZMJHGLNPGTPETPTWOGPJWONGPJNMNOGWJTYLNWHVGPJHGYZPEWEGGALKDNJHJHGTHBVTHCWDHZQZSGBPDNJHJHGWUAAZBJZMTPOTEBGZMYBNLLNTPJPZYLGLNGUJGPTPJWTPETPGLGOJGEATBLNTVGPJDHNLGGSTENPQRUGWJNZPWTYZUJHNWJBUGPTJUBGJHGOHUBOHYTWGENPJHGHZLKONJKZMINZPDHNOHJTCGWVZPJHWJZBGTOHYKWGTMBZVOHTBNWWJGDWNPWUWANONZPTPEXGTLZUWKJHZUQHBGAGTJGMMZBJWJZUPEGBVNPGHTTBTHLETPEUPOZSGBHNWHGBGWKTBGMZBPTUQHJJHGQBZUAZMMZUBGSGPJUTLLKZBEGBWGSGBKPTSTLAZDGBZMWTMGHZLEJZTJJTOCOHTBNWTPKDTKVGBLNPUWGWHNWWATOGTQGNPMZBVTJNZPQTJHGBNPQOTATYNLNJNGWJZABGENOJJHGNPSTWNZPTPEANPAZNPJGPGVKLZOTJNZPWTLLZDNPQOTKLGYVGBLNPTPEJHGPGDVZEGLBZKTLOHTBNWNTPPTSKJZTPPNHNLTJGHTLMZMJHGGPGVKMZBOGZMMTBVTQGEEZPBGGMNPTWUBABNWGTJJTOCHZDGSGBJHGLGWWOTATYLGENSGBWNZPMZBOGLGEYKHTTBTHLENWMZBOGENPJZYTJJLGTPEJHGCNPQMTLLWYGMZBGOTKLGYWMLGGJOTPNPJGBSGPGJHGOZPMLNOJEGWJBZKWJHGTYNLNJKZMGSGBKOHTBNWNTPBNSTLJZVTCGDTBTJWGTYUJLGTSGWCNPQOTKLGYWAGZALGJZWJTPETLZPGTQTNPWJTBUJHLGWWOHUBOHJHTJOZVVTPEWJHGEGSZJNZPZMPGTBLKGSGBKHUVTPTLNSGHTTBTHLESGBWOHYUOHWJTYGPVGBLNPTJHBTDGWSGBWOHYUOHWJTYGP</l></variable><variable name="ContactDataN"><list id="2621"><item><ref id="2617"></ref></item><item><list struct="atomic" id="2622">80,5,98,97,4,8,149,17,1,2,1,1,0,2,22,3,3,0,6,0,0,2,0,0,0,0</list></item><item><list struct="atomic" id="2623">37,93,42,29,4,3,23,36,2,59,8,6,24,3,18,59,11,21,7,8,3,3,0,0,0,0</list></item><item><l>N</l></item></list></variable><variable name="ContactDataE"><list id="2624"><item><ref id="2617"></ref></item><item><list struct="atomic" id="2625">15,48,0,2,21,65,5,37,108,19,32,4,12,26,8,14,2,18,6,18,21,11,5,1,2,0</list></item><item><list struct="atomic" id="2626">15,41,38,15,45,58,22,64,4,35,18,13,35,17,4,4,6,20,10,14,9,1,1,11,0,2</list></item><item><l>E</l></item></list></variable><variable name="crypto2 hints"><list struct="atomic" id="2627">MERLINATHRAWES,KINGDOMOFCHARIS</list></variable></variables></scene></scenes></project><media name="SnapCon2023Cryptology" app="Snap! 9.0, https://snap.berkeley.edu" version="2"></media></snapdata>