Category talk:Wren-lsystem: Difference between revisions
→Source code: Added 'listSteps' method.
m (→Source code: Added quotes to 'lang' attribute.) |
(→Source code: Added 'listSteps' method.) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1:
===Source code===
<syntaxhighlight lang="
/*
Line 35:
// Performs an operation on each symbol in the symbols string.
static execute(symbols, operations) {
if (!((symbols is String) && symbols.count >
Fiber.abort("Symbols must be a non-empty string.")
}
if (!((operations is Map) && operations.count >
Fiber.abort("Operations must be a non-empty map of single character strings to functions.")
}
Line 67:
}
}
if (!((axiom is String) && axiom.count >
Fiber.abort("Axiom must be a non-empty string.")
}
Line 132:
for (i in 0...n) result = iterateOnce_(result)
return result
}
// As iterate(n) but returns a list of all intermediate steps.
listSteps(n) {
var result = _axiom
var steps = [result]
for (i in 1..n) {
result = iterateOnce_(result)
steps.add(result)
}
return steps
}
|