->with_additional_proposition($prop);
my $sol_ss = $self->new_search_state_for($prop_seq)
->find_solution;
- die "No solution" unless $sol_ss;
+ die "No solution\n" unless $sol_ss;
$self->but(
proposition_sequence => $prop_seq,
search_state => $sol_ss,
);
}
+sub with_forced_backtrack {
+ my ($self) = @_;
+ my $next_ss = $self->search_state->find_next_solution;
+ die "No next solution\n" unless $next_ss;
+ $self->but(search_state => $next_ss);
+}
+
1;
sub force_backtrack {
my ($self) = @_;
- my ($first_alt, @rest_alt) = $self->alternatives;
+ my ($first_alt, @rest_alt) = @{$self->alternatives};
+ return undef unless $first_alt;
return ref($self)->new(
current_hypothesis => $first_alt->[0],
resume_step => $first_alt->[1],
$self->apply_to_state([ mode => 'shell' ]);
$qvars->();
});
+ $tcl->CreateCommand('...' => sub {
+ $self->apply_to_state([ mode => 'shell' ]);
+ my ($cur) = $self->shell_state->current_query_state;
+ while ($cur) {
+ $self->_set_shell_state(
+ $self->shell_state->but(current_query_state => $cur)
+ );
+ $qvars->();
+ $cur = eval { $cur->with_forced_backtrack };
+ push our @Result, [ output => $@ ] if $@;
+ }
+ });
$tcl->CreateCommand(qlist => sub {
push our @Result, map [ output => $_ ], @{
$self->shell_state->current_query_state->proposition_sequence->members