User loginNavigation |
archivesContext free grammar for shapes in a 2d grid?I was playing around with defining grammar productions rules for shapes in a 2d grid. Seems like using this type of scheme to generate complex shapes is very easy. But going the opposite direction and recognizing the language is impossible. If one has a grid consisting of cells filled with all terminal characters, if an arbitrary cell is chosen and the attempt is made to derive a parse tree from this cell, the ambiguity mounts quickly. Basically, any cell picked will give a different parse tree. Thinking about it, this approach should generalize to grammars applied to graphs. Googling about for a bit and viewing the bibliograph statistics shows that there was some work done in this area in the late 90's but has since entirely disappeared: Bibligraph stats for "graph grammar" So, is anyone familiar with this area? Why did work in this area (almost) completely stop? Looks like some work was oriented toward parsing visual programming languages... Computing History at Bell LabsOver at Russ Cox's blog:
Can local variables assignments be considered pure functional without monads?Okay, this might seem like an odd question, but is there contention on whether or not a while loop that performs assignment on local function variables is pure functional? For example the following Java code: int process(int[] xs) { int zeros = 0; int sum = 0; int i=0; while (i < xs.Size) { if (xs[i] == 0) zeros++; sum += xs[i]; ++i; } return sum - zeros; } Now I have heard frequently that the above code is considered to have side-effects because of the local assignments to variables. However, the mapping to pure-functional stack-based code (here shown in Cat) is very straightforward: define process { // top argument = xs 0 // zeros 0 // sum 0 // i [ dig3 // bring xs to top of local stack dupd swap get_at eqz // xs[i] == 0 [[inc] dip3] // inc zeros [] if dupd swap get_at // tmp = xs[i] [bury3] dip // put xs to bottom of local stack swap [add_int] dip // sum += tmp inc // ++i ] [ dig3 count [bury3] dip // tmp = xs.Size dupd lt_int // i < tmp ] while pop // remove i swap sub_int // sum-zeros } So, my problem is that I am not sure whether this is old news or new news. Any feedback would be appreciated. |
Browse archivesActive forum topics |
Recent comments
22 weeks 1 day ago
22 weeks 2 days ago
22 weeks 2 days ago
44 weeks 3 days ago
48 weeks 5 days ago
50 weeks 2 days ago
50 weeks 2 days ago
1 year 6 days ago
1 year 5 weeks ago
1 year 5 weeks ago