Live data from Hacker News

Lindenmayer.jl: Defining recursive patterns in Julia

cormullion.github.io

11–12 of 12 posts

Re: Lindenmayer.jl: Defining recursive patterns in Julia

#11

Earlier quoted context omitted.

> No concept of recursive "generations" in phrase structure grammars! Not sure what you're getting at here. Generation in a CFG proceeds recursively until no more terminals can be rewritten. If "f" is a nonterminal then you'd keep rewriting just as in an L-system and you'd generate the strings you want just fine. Or is what is distinctive the fact that you can limit the number of "generations"? It seems you could sim…

Yes, that's what I mean by "recursive generations". L-System strings are interpreted in successive generations where the output of generation n becomes the input of generation n+1. The recursion I refer to here is at the level of generation steps. You can simulate this with a parser for e.g. CFGs like you say, but then you need an outer loop that feeds the parsed strings back to the parser. There's also a subtlety th…

Interesting. What I was thinking was you could get the bounded-number-of-generations behavior by defining nonterminals with indices. Like this CFG which would rewrite for K steps.

S -> F_K

F_i -> F_{i-1} + G_{i-1} for i>0

G_i -> F_{i-1} - G_{i-1} for i>0

F_0 -> f

G_0 -> g

This kind of CFG is used for example by https://journals.aps.org/prx/pdf/10.1103/PhysRevX.14.031001

Re: Lindenmayer.jl: Defining recursive patterns in Julia

#12

Earlier quoted context omitted.

Yes, that's what I mean by "recursive generations". L-System strings are interpreted in successive generations where the output of generation n becomes the input of generation n+1. The recursion I refer to here is at the level of generation steps. You can simulate this with a parser for e.g. CFGs like you say, but then you need an outer loop that feeds the parsed strings back to the parser. There's also a subtlety th…

Interesting. What I was thinking was you could get the bounded-number-of-generations behavior by defining nonterminals with indices. Like this CFG which would rewrite for K steps. S -> F_K F_i -> F_{i-1} + G_{i-1} for i>0 G_i -> F_{i-1} - G_{i-1} for i>0 F_0 -> f G_0 -> g This kind of CFG is used for example by https://journals.aps.org/prx/pdf/10.1103/PhysRevX.14.031001

>> Like this CFG which would rewrite for K steps.

I believe that would work too and you could convert to this sub-scripted format with a simple pre-processor. I prefer the simpler and clearer notation that leaves the counting of generations to an interpreter because it's easier to read, but that's personal taste.

Thanks for the link to the paper which looks interesting. I'll have to read it more carefully.

Post reply on HN