Here's some possible PHP code to do what that Scheme code sample does (I've excluded the HTML for brevity):
$result = $conn->execute('select * from favcolor order by color, name');
while($row = $result->next()) {
if ($result->groupBeginning('color')) {
echo $row['color'].': '.$row['name'];
} else {
echo ', '.$row['name'];
}
if ($result->groupEnding('color')) echo "\n";
}
echo 'Count:'.$result->count();
I just came up that off the top of my head, but there's nothing impossible in there. Also, instead of field name for groupBeginning(), passing a closure would also be possible.
Nice. I've done something similar myself but I didn't take it exactly in the same direction. I leave much of grouping, wrapping, appending work to my own template engine layer. Is the source to your DSL available?
Yeah I would normally never mix the templating/html w/ the data processing but I was trying to stick to the example but w/ one line hah. Right now it is part of my new web framework which is very much a work in progress but available on http://voltron.googlecode.com the relevant code for the Array dsl is under Model/Type/Array.php and FluentLambda.php and the constant declarations are in bootstrap.php - again total work in progress so things are not as clean as they should be just yet.