Simon's blog

I cannot believe I just wrote that.

Show me all the courses which (if there's a restriction) have (if we're interested in the first session) a presentation where the first session beginning between date X and date Y, or (if we're interested in any session) at least one of the course sessions of any of the presentations beginning between date X and date Y, or all the courses if there's no restriction.
        push @results, $x if 
            !$until ||
            (
            $session eq "first" ?
                grep { 
                    ($_->first_session->_epoch() < $until) &&
                    ($_->first_session->_epoch() > $from)
                } $x->presentations
            :
                grep { 
                    grep {
                        ($_->_epoch() < $until) &&
                        ($_->_epoch() > $from)
                    } $_->sessions
                } $x->presentations
            );
Of course, the push is there only to stop it being a triple-nested grep, because I got scared at that point.








Working from home

Seriously, I got a lot of good work done today; I fleshed out the outline of my new book a little more, and I finished off some more work on Shishi. I spent the morning working out how to remove recursion from Shishi - then it dawned on me that since Shishi's a recursive descent parser (essentially) that removing the recursion may turn out to be difficult. This has various knock-on effects for the Perl 6 regex engine - people have to be very careful not to blow the C stack if they implement the regexes naively. I'm currently looking up clever ways to turn the depth-first search into an iterative algorithm. (Yes, I know I have to maintain a stack of child nodes, but that's as far as I've got.)