tail-recursive interpreteded for loop
This commit is contained in:
@@ -54,16 +54,15 @@
|
||||
iter (collection.iterator)]
|
||||
(dictSet (last localScopes) "__iter__" iter)
|
||||
(localFunction run []
|
||||
(if (iter.hasNext)
|
||||
(evalCC (callSymbol "let" (.concat [(listExp [varName (callSymbol "__iter__.next" [])])] body))
|
||||
->v {(when collect
|
||||
(results.push v))
|
||||
(run)
|
||||
})
|
||||
{
|
||||
(localScopes.pop)
|
||||
(cc results)
|
||||
}))
|
||||
// Oof -- everything needs to be synchronous
|
||||
(unless (iter.hasNext)
|
||||
(localScopes.pop)
|
||||
(cc results)
|
||||
(return))
|
||||
(evalCC (callSymbol "let" (.concat [(listExp [varName (callSymbol "__iter__.next" [])])] body))
|
||||
->v (when collect
|
||||
(results.push v)))
|
||||
(run))
|
||||
(run)))))
|
||||
|
||||
(method makeFunction [:Array<ReaderExp> argExps :Array<ReaderExp> bodyExps]
|
||||
|
||||
Reference in New Issue
Block a user