Camel: How to evaluate an expression twice? - apache-camel

I'm retrieving an expression from a variable that itself contains a simple expression. How can I evaluate that fetched expression again to get the real result?
Is it even possible?

Related

SSIS Conditional Split Error - The data type DT_BYTES cannot be used with binary operator "=="

While configuring a conditional split component with the following expression:
[VersionStamp_Source] == (DT_I8)[VersionStamp_Destination]
I am getting the following error:
The data type DT_BYTES cannot be used with binary operator "==".
Screenshot:
As shown in the error message, one of the columns used in the conditional split expression has a data type of DT_BYTES which cannot be compared using binary operators.
You need to cast this column to another data type. As mentioned in the official documentation, DT_BYTES can be converted to DT_I8 or to a string data type.
As #billinkc mentioned in the comments, casting DT_BYTES to a string data type is more preferable since some values cannot be converted to an 8-byte integer.
To solve your problem, try using the following expression:
(DT_WSTR,255)[VersionStamp_Source] == (DT_WSTR,255)[VersionStamp_Destination]
Also, make sure to use an accurate length for the string casting operator. You can increase the string length to 4000

Precedence of the arrow operator and post increment?

New to C. So I saw this line of code
system->word[system->index++] = system->next_char;
Is it equivalent to:
system->word[system->index] = system->next_char;
index++;
What is the precedence for post increment? Does it only increment index's value by 1 after all the operations on the line are done executing?
Updating system->index is defined as a side effect that is not sequenced (is not specified to come before or after) the other operations in the statement. The update may occur before, during, or after other operations.
The fact that it is not sequenced is irrelevant as long as it is not used elsewhere in the statement, because, if it is not used elsewhere, then nothing the statement does can be affected by when the update occurs. (Note that, even if the update to system->index in memory is done before the value is used, the compiler is response for ensuring that the pre-update value is used.)
If the object being updated were used elsewhere in the statement in an unsequenced way (that is, no rule specifies which comes first, the update or the other use), then the behavior of the program would not be defined by the C standard.
This is not a consequence of precedence. Precedence determines the structure of how expressions are interpreted, not the sequencing of their operations.
Not.
system->word[system->index++] = system->next_char;
is equivalent to:
system->word[system->index] = system->next_char;
system->index++;
as index is a field on a struct pointed to by system. In case you have also a scalar variable named index you had had no errors but the wrong variable should have been incremented.
As a general rule, all the unary operators evaluate first on the right side of the variable, then the ones on the left (the right side operators have higher precedence thatn left side ones) and evaluate from closest to the operand, to farthest. So the operator closest to the operand evaluates first, then the one next in the right... so until there are no more right operators on the right, then the closest on the left side, and so on until there are no more left operators on the left.
So what happens if we have -x++ ? The ++ is evaluated first to the value of x and a post increment of the variable is schedule to occur, then the one on the left is evaluated, givin as result the value of x before incrementing, changed of sign, and the variable x gets its value incremented (only incremented, no sign change).
Another example: let's compute ++x->field: first of all ->field (the whole thing, the -> arrow and the field name) is considered a right unary operator, given a pointer gets the value in field named field fo structure pointed to by x. This value is incremented (and stored again in x->field) and the returned value is the final incremented one.
Another final example: let's compute *p++. The value of p is scheduled to be post incremented, but it's previous value is retained. Then the old value of p is used to access the value pointed to by it, giving the original pointed to value. Finally p is incremented and points to the value next to the value accessed.

How is a primitive procedure tagged in SICP's evaluator (chapter 4)?

I am reading chapter 4 of SICP. In the eval procedure, there is a procedure application. This procedure checks whether the expression is tagged with the symbol 'primitive or 'procedure.
I can see where the symbol 'procedure is added. (It is when evaluating a lambda expression.).
I am not able to find where the tag 'primitive is added? Clearly, when I supply a program to the evaluator, I supply (+ 1 2) and not ('primitive + 1 2). I would guess the 'primitive tag is added somewhere (like 'procedure), but I cannot find where.
Take a look at the primitive-procedure-objects procedure, that's where the 'primitive tag is added to the elements of the primitive-procedures list, which contains the primitive operations available to the interpreter.
In turn, primitive-procedure-objects is called inside setup-environment, which is used for creating the initial environment for the interpreter.
When evaluating an expression such as (+ 1 2), the evaluator simply goes all the way down in the case analysis of eval, matching the application? predicate, which invokes apply and then (eval (operator exp) env) on the first element of the expression. In turn, this matches variable? in the case analysis, which calls lookup-variable-value, that returns a procedure, which we tagged with 'primitive in setup-environment. Whew!

Why required "=" before ANY function with array as param, in postgres procedure?

I was answering a postgres question yesterday, and also came across a postgres thread (here) where they describe the following error:
ERROR: operator does not exist: text = text[]
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.
The error seems to appear whenever an ARRAY string type is fed to ANY without using = ANY. This seems completely strange since based on language, logic, and sql conventions, usually you have (e.g. IN):
variable FUNCTION(set)
instead of.
variable = FUNCTION(set) , unless ofcourse operator is a summation/count operation returning one result :)
It would make more senseto have variable ANY(Set/Array) instead of variable=ANY(Set/Array). Similar example is the IN function.
Can anyone explain what is going on here?
IN (...) is basically equivalent to = ANY (ARRAY[...])
Crucially, ANY is not a function. It's syntax defined by the SQL standard, and is no more a function than GROUP BY or the OVER clause in a window function.
The reason that = is required before ANY is that ANY can apply to other operators too. What it means is "Test the operator to the left against every element in the array on the right, and return true if the test is true for at least one element."
You can use > ANY (ARRAY[...]) or whatever. It's a general purpose operator that isn't restricted to =. Notably useful for LIKE ANY (albeit with somewhat bad performance).
There is ALL too, which does much the same thing but returns true only if all results are true.

Matlab "if array" functionality

Just stumbled across a bug in some old code of mine where to check if an array was empty or not I just wrote:
if my_array
...(do stuff)
end
instead of using isempty or something like that.
What I have discovered is that "if my_array" returns 0 only if the array is indeed empty OR if one or more of the components in the array are 0.
Is this expected? What exactly is going on? Is matlab performing an and operation on all the elements?
Many thanks
That is exactly the behaviour as it is documented:
An evaluated expression is true when the result is nonempty
and contains all nonzero elements (logical or real numeric). Otherwise,
the expression is false.

Resources