Alternatively, you could do backtracking with MonadPlus in Haskell ...

NB that although MonadPlus has a name in Haskell, it may also exist somewhat more anonymously in other programming environments.

For instance, a Posix shell has at least two different ways to handle the desired sum-of-products constructions: parameter expansions and conditional expressions.

"interpolate $foo and $bar conjunctively" => echo ${foo:+${bar: +"interpolate $foo and $bar conjunctively"}} "interpolate $foo and $bar conjunctively" => [[ $foo && $bar ]] && echo "interpolate $foo and $bar conjunctively"

"disjunction of $foo" | "or of $bar" => x=;x=${x:-${foo: +"disjunction of $foo"}};x=${x:-${bar:+"or of $bar"}};echo $x "disjunction of $foo" | "or of $bar" => { [[ $foo ]] && echo "disjunction of $foo" ;} || { [[ $bar ]] && echo "or of $bar" ;}

(I believe Kragen's <if... construction requires the conditional expression form, although simple presence/absence can be handled in the parameter expansion form. Array mapping and the comma operator (as well as the algorithmic extraction of variable names from an interpolation in order to automatically generate the proper guards!) are left as an exercise for the reader...)

-Dave

--
To unsubscribe: http://lists.canonical.org/mailman/listinfo/kragen-discuss

Reply via email to