## Introduction to Logo Turtle [LogoTurtle](https://helloacm.com/turtle-programming-while-loop-do-else-loop-and-unit-tests-added/) is currently the FIRST and only one Chrome Extension for Turtle Graphics. I have also written [a PHP version of Logo Interpreter](https://steakovercooked.com/Software.Logo) in 2006 but that runs only on the server.  ## Previous Contributions - v0.0.10: [Turtle Programming: Fractal Stars, Random, Console, Eraser, SetPC, SetXY, Examples, Wait, Bug Fixes and So much more!](https://helloacm.com/turtle-programming-fractal-stars-random-console-eraser-setpc-setxy-examples-wait-bug-fixes-and-so-much-more/) - v0.0.9: [Turtle Programming v0.0.9: Add SetX, SetY, Square and Rect!](https://helloacm.com/turtle-programming-v0-0-9-add-setx-sety-square-and-rect/) - v0.0.8: [Turtle Programming v0.0.8: /* */ comments, dotxy, and javascript!](https://helloacm.com/turtle-programming-v0-0-8-comments-dotxy-and-javascript/) - v0.0.7: [Turtle Programming v0.0.7: Functions with Parameters + Recursion!](https://helloacm.com/turtle-programming-v0-0-7-functions-with-parameters-recursion/) - v0.0.6: [Turtle Programming v0.0.6: Adding Circle, MoveTo, Turn and Screen!](https://helloacm.com/turtle-programming-v0-0-6-adding-circle-moveto-turn-and-screen/) - v0.0.5: [Turtle Programming v0.0.5: Adding IF/ELSE and STOP!](https://helloacm.com/turtle-programming-v0-0-5-adding-if-else-and-stop/) - v0.0.4: [LogoTurtle: Make Variables and Comments](https://helloacm.com/logoturtle-make-variables-and-comments/) - v0.0.3: [Turtle Graphics Programming Update: Adding text, jump, dot, fontsize, download as png](https://helloacm.com/turtle-graphics-programming-update-adding-text-jump-dot-fontsize-download-as-png/) - v0.0.2: [LogoTurtle v0.0.2: ShowTurtle, HideTurtle, Color, Width and Help](https://helloacm.com/logoturtle-v0-0-2-showturtle-hideturtle-color-width-and-help/). - Teach Your Kids Programming - The First Logo Interpreter (Turtle Graphics) in Chrome Extension! [v0.0.1](https://helloacm.com/teach-your-kids-programming-the-first-logo-interpreter-turtle-graphics-in-chrome-extension/) ## v0.0.11 New Features [**This Commit**](https://github.com/DoctorLai/LogoTurtle/commit/cf2f99af086d25927f5d280f59e314c7b6c913dc) has the following changes: 1. Add While Loop 2. Add Do/Else Loop 3. SetXY - Y Coordinate reversed to match math coordinate. 4. Understore is allowed in variable names. 5. Add global variables: *turtlex*, *turtley* and *turtleangle* 6. Add Unit Tests `npm test` ## Screenshots In LOGO programming language, there isn't a While Loop. The boolean expression is evaluated per loop iteration. For example: ``` make "x 0 make "sum 0 while :x<=100 [ make "sum :sum+:x make "x :x+1 ] text [sum is :sum] ``` The Do/Else is a syntax sugar as `if (condition) { while (condition) { /* loop */} } else { / * else */}` ``` cs ht make "x 10 do :x<4 [ fd 100 rt 90 make "x :x+1 ] else [ repeat 5 [fd 100 rt 144] ] ``` The above draws a square if `x=0` and a star if `x` is set to above 4. ``` to spiral :size if (:size>30) [stop] ; an exit condition fd :size rt 15 ; many lines of action spiral :size*1.02 ; the tailend recursive call end ``` can be re-written in non-recursive DO loop (the else is optional). ``` to spiral :size do :size<=30 [ fd :size rt 15 make "size :size*1.02 ] else [ console [:size is larger than 30] ] end ```  ## Implement the LOGO/DO loop in Javascript ``` case "do": find_left = getNextWord(s, y.next, U); if (find_left.word != '[') { this.pushErr(word, LOGO_ERR_MISSING_LEFT, find_left.word); return false; } repeat_left = find_left.next; find_right = repeat_left + 1; nested = 1; // need to match [ and ] while (find_right < U) { if (s[find_right] == '[') { nested ++; } if (s[find_right] == ']') { nested --; if (nested == 0) { break; } } find_right ++; } if (find_right >= U) { this.pushWarning(word, LOGO_ERR_MISSING_RIGHT); } let do_exp = word_next; word_next = this.evalVars(do_exp); ifelse = iftrue(word_next); if (word_next === '') { this.pushErr(word, LOGO_ERR_MISSING_EXP, word_next); return false; } while (iftrue(word_next)) { // do body if (!this.run(s, repeat_left, find_right, depth + 1)) { return false; } word_next = this.evalVars(do_exp); } find_else = getNextWord(s, find_right + 1, U); if (find_else.word.toLowerCase() == 'else') { let else_block = getNextBody(s, find_else.next, U); if (else_block.ch != '[') { this.pushErr(word, LOGO_ERR_MISSING_LEFT, else_block.ch); return false; } if (!ifelse) { // else body if (!this.run(s, else_block.left, else_block.right, depth + 1)) { return false; } } i = else_block.right + 1; } else { // no else block i = find_right + 1; } break; ``` ## Roadmap of Chrome Extension: Logo Turtle I believe LogoTurtle is more or less in beta now. Therefore, bug Fixes and any suggestions, please shout @justyy ## Technology Stack If an App can be written in [Javascript](https://helloacm.com/steemit-javascript-function-to-get-original-post-from-comments-permlink/), eventually it will be written in Javascript. # Chrome Webstore Install the [Turtle Programming for Kids](https://chrome.google.com/webstore/detail/logo-turtle/dcoeaobaokbccdcnadncifmconllpihp) Now! # Contribution Welcome Github: https://github.com/DoctorLai/LogoTurtle 1. Fork it! 2. Create your feature branch: `git checkout -b my-new-feature` 3. Commit your changes: `git commit -am 'Add some feature'` 4. Push to the branch: `git push origin my-new-feature` 5. Submit a pull request. <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@justyy/turtle-programming-while-loop-do-else-loop-and-unit-tests-added">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | justyy | ||||||
---|---|---|---|---|---|---|---|
permlink | turtle-programming-while-loop-do-else-loop-and-unit-tests-added | ||||||
category | utopian-io | ||||||
json_metadata | "{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":121791502,"name":"LogoTurtle","full_name":"DoctorLai/LogoTurtle","html_url":"https://github.com/DoctorLai/LogoTurtle","fork":false,"owner":{"login":"DoctorLai"}},"pullRequests":[],"platform":"github","type":"development","tags":["utopian-io","steemstem","programming","cn-programming","steemapps"],"users":["justyy"],"links":["https://helloacm.com/turtle-programming-while-loop-do-else-loop-and-unit-tests-added/","https://steakovercooked.com/Software.Logo","https://helloacm.com/turtle-programming-fractal-stars-random-console-eraser-setpc-setxy-examples-wait-bug-fixes-and-so-much-more/","https://helloacm.com/turtle-programming-v0-0-9-add-setx-sety-square-and-rect/","https://helloacm.com/turtle-programming-v0-0-8-comments-dotxy-and-javascript/","https://helloacm.com/turtle-programming-v0-0-7-functions-with-parameters-recursion/","https://helloacm.com/turtle-programming-v0-0-6-adding-circle-moveto-turn-and-screen/","https://helloacm.com/turtle-programming-v0-0-5-adding-if-else-and-stop/","https://helloacm.com/logoturtle-make-variables-and-comments/","https://helloacm.com/turtle-graphics-programming-update-adding-text-jump-dot-fontsize-download-as-png/","https://helloacm.com/logoturtle-v0-0-2-showturtle-hideturtle-color-width-and-help/","https://helloacm.com/teach-your-kids-programming-the-first-logo-interpreter-turtle-graphics-in-chrome-extension/","https://github.com/DoctorLai/LogoTurtle/commit/cf2f99af086d25927f5d280f59e314c7b6c913dc","https://helloacm.com/steemit-javascript-function-to-get-original-post-from-comments-permlink/","https://chrome.google.com/webstore/detail/logo-turtle/dcoeaobaokbccdcnadncifmconllpihp","https://github.com/DoctorLai/LogoTurtle","https://utopian.io/utopian-io/@justyy/turtle-programming-while-loop-do-else-loop-and-unit-tests-added"],"image":["https://steemitimages.com/DQmXSwCpG14nWsRsfhbjPiCSmdGcLHLCriXHf5pFxJk1DVo/image.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1520998145/ilfyzujaw2x6ittqiojc.png"],"moderator":{"account":"decebal2dac","time":"2018-03-15T00:07:18.863Z","reviewed":true,"pending":false,"flagged":false},"questions":[{"question":"Is the project description formal?","answers":[{"value":"Yes itβs straight to the point","selected":true,"score":10},{"value":"Need more description ","selected":false,"score":5},{"value":"Not too descriptive","selected":false,"score":0}],"selected":0},{"question":"Is the language / grammar correct?","answers":[{"value":"Yes","selected":false,"score":20},{"value":"A few mistakes","selected":true,"score":10},{"value":"It's pretty bad","selected":false,"score":0}],"selected":1},{"question":"Was the template followed?","answers":[{"value":"Yes","selected":true,"score":10},{"value":"Partially","selected":false,"score":5},{"value":"No","selected":false,"score":0}],"selected":0},{"question":"How do you rate the amount of work?","answers":[{"value":"Very High","selected":true,"score":20},{"value":"High","selected":false,"score":16},{"value":"Medium","selected":false,"score":12},{"value":"Low","selected":false,"score":7},{"value":"Very Low","selected":false,"score":3}],"selected":0},{"question":"How do you rate the impact on the Project?","answers":[{"value":"Very High","selected":false,"score":20},{"value":"High","selected":true,"score":16},{"value":"Medium","selected":false,"score":12},{"value":"Low","selected":false,"score":7},{"value":"Very Low","selected":false,"score":3}],"selected":1}],"score":100}" | ||||||
created | 2018-03-14 03:31:48 | ||||||
last_update | 2018-03-15 00:07:18 | ||||||
depth | 0 | ||||||
children | 4 | ||||||
last_payout | 2018-03-21 03:31:48 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 51.371 HBD | ||||||
curator_payout_value | 19.510 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 6,079 | ||||||
author_reputation | 280,616,224,641,976 | ||||||
root_title | "Turtle Programming: While Loop, Do/Else Loop and Unit Tests Added" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 44,276,523 | ||||||
net_rshares | 28,791,242,766,427 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
adm | 0 | 4,716,339,455,493 | 30% | ||
ace108 | 0 | 214,729,988,348 | 17% | ||
shaka | 0 | 642,681,752,381 | 20% | ||
magicmonk | 0 | 96,608,952,670 | 50% | ||
oldtimer | 0 | 94,139,857,881 | 3% | ||
charlie777pt | 0 | 111,129,457,379 | 100% | ||
cnfund | 0 | 10,682,834,498 | 22% | ||
bitcoinparadise | 0 | 1,568,123,405 | 0.02% | ||
justyy | 0 | 789,289,865,372 | 85% | ||
anomaly | 0 | 201,788,775 | 1% | ||
smasher | 0 | 1,150,271,255 | 20% | ||
luneknight | 0 | 579,860,776 | 100% | ||
dapeng | 0 | 2,492,983,039 | 2% | ||
happyukgo | 0 | 1,704,859,773 | 85% | ||
nokeh | 0 | 236,593,321 | 95% | ||
sv67216721 | 0 | 422,470,135 | 5% | ||
frankintaiwan | 0 | 80,958,102 | 20% | ||
jassennessaj | 0 | 3,847,471,210 | 10% | ||
helo | 0 | 1,053,004,861 | 10% | ||
shenchensucc | 0 | 4,000,147,457 | 20% | ||
czechglobalhosts | 0 | 278,016,125,629 | 3% | ||
victorialuxx | 0 | 167,705,306 | 100% | ||
susanli3769 | 0 | 203,111,838,325 | 100% | ||
st3llar | 0 | 623,660,141 | 3% | ||
travelgirl | 0 | 21,778,549,683 | 23% | ||
robinlee | 0 | 446,654,692 | 95% | ||
fauzipase | 0 | 415,604,764 | 100% | ||
rainyapril | 0 | 420,309,193 | 85% | ||
al2ping | 0 | 98,136,256 | 95% | ||
liangfengyouren | 0 | 1,158,291,859 | 50% | ||
shengjian | 0 | 15,666,148,129 | 75% | ||
kangnajiang | 0 | 226,204,825 | 95% | ||
geass | 0 | 439,904,390 | 85% | ||
moonvoid | 0 | 614,503,785 | 100% | ||
boontjie | 0 | 25,493,965,327 | 100% | ||
irenett | 0 | 421,127,454 | 100% | ||
rosatravels | 0 | 67,210,082,240 | 50% | ||
xuran | 0 | 5,075,463,584 | 100% | ||
awiwea1974 | 0 | 368,262,486 | 100% | ||
superbing | 0 | 8,587,225,179 | 85% | ||
dailyfortune | 0 | 6,140,637,731 | 85% | ||
antone | 0 | 432,744,075 | 100% | ||
xiaoshancun | 0 | 405,013,068 | 100% | ||
dailystats | 0 | 12,783,727,498 | 85% | ||
zizizhuji | 0 | 6,504,810,325 | 100% | ||
wangwenjing | 0 | 2,982,296,939 | 60% | ||
xuzhen | 0 | 5,358,316,610 | 60% | ||
ayman101 | 0 | 377,033,280 | 100% | ||
bobdos | 0 | 3,472,419,134 | 10% | ||
vandadream | 0 | 6,320,863,271 | 100% | ||
steemline | 0 | 210,605,073 | 100% | ||
winniex | 0 | 3,471,099,675 | 10% | ||
ivysrono | 0 | 436,441,846 | 1% | ||
jianan | 0 | 422,648,311 | 85% | ||
utopian-io | 0 | 21,319,935,881,064 | 13.34% | ||
nada101 | 0 | 472,978,527 | 100% | ||
dbddv01 | 0 | 776,779,092 | 100% | ||
nileelily | 0 | 5,799,460,592 | 100% | ||
chann | 0 | 9,091,226,278 | 20% | ||
daxiang | 0 | 234,918,811 | 95% | ||
anxin | 0 | 6,352,984,041 | 85% | ||
lebin | 0 | 9,768,752,962 | 15% | ||
vivia | 0 | 196,102,420 | 7% | ||
cryptonewsly | 0 | 211,041,823 | 100% | ||
gamelineika | 0 | 544,775,593 | 100% | ||
wyp | 0 | 554,323,536 | 100% | ||
tdre | 0 | 711,029,889 | 100% | ||
moobear | 0 | 1,161,683,840 | 85% | ||
jjay | 0 | 644,700,316 | 100% | ||
madokami | 0 | 93,377,656 | 95% | ||
prch | 0 | 1,655,718,365 | 60% | ||
nean | 0 | 420,386,389 | 85% | ||
foodielifestyle | 0 | 2,138,439,401 | 75% | ||
woolfe19861008 | 0 | 1,179,645,749 | 75% | ||
comingback | 0 | 188,259,006 | 100% | ||
tamaraterentev | 0 | 550,893,591 | 100% | ||
dailychina | 0 | 8,791,028,619 | 85% | ||
arabel | 0 | 1,285,402,574 | 60% | ||
rayday | 0 | 501,579,736 | 100% | ||
vincenthan | 0 | 421,527,800 | 85% | ||
yuxuan | 0 | 84,782,886 | 95% | ||
dongfengman | 0 | 6,168,093,107 | 75% | ||
historylover | 0 | 588,002,621 | 100% | ||
serenazz | 0 | 753,897,345 | 85% | ||
yedda | 0 | 420,628,837 | 85% | ||
polbot | 0 | 1,077,250,836 | 50% | ||
shentrading | 0 | 846,019,558 | 75% | ||
zasilla | 0 | 422,847,018 | 85% | ||
fishaa | 0 | 2,507,069,323 | 50% | ||
aaronstar | 0 | 128,886,386 | 95% | ||
ayanamoon | 0 | 122,181,361 | 95% | ||
ethanlee | 0 | 5,759,377,409 | 60% | ||
kamel101 | 0 | 493,492,385 | 100% | ||
twinsnicole | 0 | 419,975,892 | 85% | ||
deepthinking | 0 | 424,795,778 | 85% | ||
wilfredn | 0 | 2,786,095,212 | 60% | ||
fanso | 0 | 761,939,455 | 75% | ||
lilypang22 | 0 | 2,025,645,335 | 85% | ||
a-0-0-a-0-0 | 0 | -249,134,387 | -100% | ||
zens | 0 | 422,188,221 | 85% | ||
ashi0 | 0 | 471,651,014 | 95% | ||
steemitvip | 0 | 421,012,137 | 85% | ||
lakemountain | 0 | 389,790,831 | 95% | ||
regals | 0 | 421,002,986 | 85% | ||
baymaxos | 0 | 80,144,636 | 95% | ||
fel1xw | 0 | 2,156,126,602 | 100% | ||
joelone | 0 | 413,868,128 | 85% | ||
sweet-jenny8 | 0 | 13,396,605,948 | 85% | ||
theshadowek | 0 | 67,403,445 | 100% | ||
clayjohn | 0 | 566,590,956 | 100% | ||
laijihua | 0 | 612,521,282 | 100% |
Thank you for the contribution. It has been approved. You can contact us on [Discord](https://discord.gg/uTyJkNm). **[[utopian-moderator]](https://utopian.io/moderators)**
author | decebal2dac |
---|---|
permlink | re-justyy-turtle-programming-while-loop-do-else-loop-and-unit-tests-added-20180315t000723958z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-03-15 00:07:24 |
last_update | 2018-03-15 00:07:24 |
depth | 1 |
children | 0 |
last_payout | 2018-03-22 00:07:24 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 172 |
author_reputation | 13,975,053,566,819 |
root_title | "Turtle Programming: While Loop, Do/Else Loop and Unit Tests Added" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,478,116 |
net_rshares | 0 |
Great information here love your post
author | maanabdullah |
---|---|
permlink | re-justyy-turtle-programming-while-loop-do-else-loop-and-unit-tests-added-20180314t033641069z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-03-14 03:36:57 |
last_update | 2018-03-14 03:36:57 |
depth | 1 |
children | 0 |
last_payout | 2018-03-21 03:36:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 37 |
author_reputation | 4,394,544,845,307 |
root_title | "Turtle Programming: While Loop, Do/Else Loop and Unit Tests Added" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,277,259 |
net_rshares | 0 |
### Hey @justyy I am @utopian-io. I have just upvoted you! #### Achievements - WOW WOW WOW People loved what you did here. GREAT JOB! - Seems like you contribute quite often. AMAZING! #### Community-Driven Witness! I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [](https://steemit.com/~witnesses) **Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
author | utopian-io |
---|---|
permlink | re-justyy-turtle-programming-while-loop-do-else-loop-and-unit-tests-added-20180315t201706333z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-03-15 20:17:48 |
last_update | 2018-03-15 20:17:48 |
depth | 1 |
children | 0 |
last_payout | 2018-03-22 20:17:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,061 |
author_reputation | 152,955,367,999,756 |
root_title | "Turtle Programming: While Loop, Do/Else Loop and Unit Tests Added" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,658,307 |
net_rshares | 0 |
### Hey @justyy I am @utopian-io. I have just upvoted you! #### Achievements - WOW WOW WOW People loved what you did here. GREAT JOB! - Seems like you contribute quite often. AMAZING! #### Community-Driven Witness! I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [](https://steemit.com/~witnesses) **Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
author | utopian-io |
---|---|
permlink | re-justyy-turtle-programming-while-loop-do-else-loop-and-unit-tests-added-20180315t201929145z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-03-15 20:20:00 |
last_update | 2018-03-15 20:20:00 |
depth | 1 |
children | 0 |
last_payout | 2018-03-22 20:20:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,061 |
author_reputation | 152,955,367,999,756 |
root_title | "Turtle Programming: While Loop, Do/Else Loop and Unit Tests Added" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 44,658,580 |
net_rshares | 0 |