0

Sorry if this is a stupid question but I am learning python from this site:

http://interactivepython.org/courselib/static/thinkcspy/Strings/strings.html#exercises

Questions 10-14:

and I am working on the Lindenmayer system questions, I do not know what L, R, X, Y stand for. The book already stated that F = forward, B = backward, - = turn left, + = turn right So what is left for L, R, X, Y?

Are they arbitrarily defined by the user?

Thanks.

4

1 に答える 1

1

L-systems are defined in terms of grammars. A grammar has a set of terminals (sometimes called literals), and a set of non-terminals.

Terminals can't be expanded, but they are executed by the turtle. Conversely, non-terminals can be expanded (and the grammar gives the rules governing the expansion), but they can't be directly executed as they aren't turtle instructions.

In an L-system, the terminals are the characters F, B, + and -, and they clearly map onto specific operations executed by the turtle. All other characters are non-terminals: they may be expanded into sequences of terminals and nonterminals according to the provided rules to increase the complexity of the figure.

So, L, R, X, Y are arbitrary names for non-terminals. We could also call them K, L, M, N and the L-system wouldn't change. Sometimes, the names are given as a hint to the symbol's role (maybe L means a "left-handed component", for instance), but sometimes they are just arbitrary (like X and Y).

于 2012-10-02T23:25:14.083 に答える