第 76 关挑战
goto = (a) ->
turnTo a
step distanceTo a
for match in matches
goto match
grab()
goto pile
drop()
//================================================
goto = (a) ->
turnTo a
step distanceTo a
goto matches[0]
grab()
goto pile
drop()
goto matches[1]
grab()
goto pile
drop()
第 77 关挑战
goto = (a) ->
turnTo a
step distanceTo a
for m in matches
goto m
grab()
goto pile
drop()
第 78 关挑战
goto = (c) ->
turnTo c
step distanceTo c
goto bridge
goto match
grab()
goto bridge
goto(pile)
drop()
第 79 关挑战
goto = (p) ->
#请在这里编写函数的实现
turnTo p
step distanceTo p
for m in matches
goto bridge
goto m
grab()
goto bridge
goto pile
drop()
第 80 关挑战
collect = (e) ->
turnTo e
step distanceTo e
grab()
turnTo pile
step distanceTo pile
drop()
for m in matches
collect m
第 81 关挑战
这里不只有一个函数, 而是有 两个 函数 !
goto = (t) ->
turnTo t
step distanceTo t
collect = (e) ->
goto e
grab()
goto pile
drop()
for m in matches
collect m
第 82 关挑战
#请在这里定义 goto 函数
goto = (x)->
turnTo x
step distanceTo x
goto match
grab()
goto pile
drop()
第 83 关挑战
接下来我们试试将小岛 islands 和木筏 rafts 作为函数的参数来使用
goto = (t) ->
turnTo t
step distanceTo t
gotoAll = (stuff) ->
for s in stuff
goto s
gotoAll islands
grab()
gotoAll rafts
drop()
第 84 关挑战
goto = (t) ->
turnTo t
step distanceTo t
getAndReturn = (r) ->
goto r
grab()
goto turtle
for m in matches
getAndReturn m
goto pile
drop()
goto turtle
turtle.step 8
第 85 关挑战
我们也可以用数字 numbers 作为函数的参数
goto = (t) ->
turnTo t
step distanceTo t
collect = (m) ->
goto m
grab()
goto pile
drop()
#这个函数应该让所有
#turtles 前进 d (d是数字)
allTurtlesStep = (d) ->
#请完成这里!
for c in turtles
c.step d
allTurtlesStep 10
collect matches[0]
allTurtlesStep -10
collect matches[1]