Most efficient/elegant way to clip a number?

What about boring, old, readable, and shortest yet: float clip(float n, float lower, float upper) { return std::max(lower, std::min(n, upper)); } ? This expression could also be ‘genericized’ like so: template <typename T> T clip(const T& n, const T& lower, const T& upper) { return std::max(lower, std::min(n, upper)); } Update Billy ONeal added: Note that … Read more

Curry-Howard isomorphism

The Curry-Howard isomorphism simply states that types correspond to propositions, and values correspond to proofs. Int -> Int doesn’t really mean much interesting as a logical proposition. When interpreting something as a logical proposition, you’re only interested in whether the type is inhabited (has any values) or not. So, Int -> Int just means “given … Read more

Looking for simple rules-engine library in .NET [closed]

Agreeing with will I would say use something from the workflow engine family although not workflow. Examine System.Workflow.Activities.Rules Namespace a little bit – it’s supported in .Net 3, and built into .Net3.5. You have everything in hand for free to use like you mentioned : RuleCondition for conditions , RuleAction for actions standardized format for … Read more

In Java, what are the boolean “order of operations”?

The Java Tutorials has a list illustrating operator precedence. The equality operators will be evaluated first, then &&, then ||. Parentheses will be evaluated before anything else, so adding them can change the order. This is usually pretty much the same from language to language, but it’s always a good idea to double check. It’s … Read more

What is the combinatory logic equivalent of intuitionistic type theory?

So I thought about it a bit more and made some progress. Here’s a first stab at encoding Martin-Löf’s delightfully simple (but inconsistent) Set : Set system in a combinatory style. It’s not a good way to finish, but it’s the easiest place to get started. The syntax of this type theory is just lambda-calculus … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)