01-25-2011 06:18 PM
I'll have to change my signature to regexevirginaholic.
Sorry for doubting your abilities... I'll have to lookup that regEx..
Why would the regular expression be slower than typecast & flip the array?
cursing?? Never thought of that.. But yeah, I could see people thinking of that [%.#]!(.) 😉
01-25-2011 06:58 PM
In LV, regexes are implemented with an external library so there is some overhead versus an all-native implementation. We are talking about microseconds so unless you are unleashing this on a monster database you probably won't notice.
The regex in this case is pretty straightforward. (.) is a capturing group of a single character. What I do is grab two characters this way, and then the replacement is $2$1 which is second capture group followed by the first one (ie. a swap).
Yet another non-Type Cast and Non-regex version:
This reminds me that someday I will post an idea that all array functions treat strings automatically as the byte arrays they are, without the String To Byte array and reverse, this version would not look that bad. (I'd probably still Type Cast, but a fun game to play is how many different ways can you do the same operation).
01-26-2011 01:22 AM - edited 01-26-2011 01:27 AM
Another job for Typecast Man! 😄
As Dennis correctly pointed out here, there are better ways to do the hex-string and string-hex conversion. I am only showing one of the two here, but you get the idea.

The toplevel program (hotplate.vi) is a mindboggling collection of rube constructs, greedy loops, useless loops, and datatype conflicts. The code coud be rewritten with 10% of the resources. A quick excerpt is how two controls are formatted into a instrument string. Most of the rest of the code is even worse!
See the original thread for more details.
Original code (incorrect for certain inputs!):

My simplified code (correct):

01-27-2011 09:51 AM - edited 01-27-2011 09:52 AM
Uhgh!! Our Java prude just said that 'G' stands for 'Goldberg'! Ouch!
Edit: How do I respond?
01-27-2011 11:32 AM
Darin.K wrote:This reminds me that someday I will post an idea that all array functions treat strings automatically as the byte arrays they are, without the String To Byte array and reverse, this version would not look that bad.
I actually played with that idea a long time ago and came to the conclusion that there might be difficulties with e.g. arrays of strings. Currently, we cannot have arrays of arrays, so that might be similar, maybe ... maybe not? This requires some thoughts...
There are also some related ideas, for example to allow FOR loops to autoindex over characters of strings.
01-27-2011 01:08 PM
@altenbach wrote:
I actually played with that idea a long time ago and came to the conclusion that there might be difficulties with e.g. arrays of strings. Currently, we cannot have arrays of arrays, so that might be similar, maybe ... maybe not? This requires some thoughts...
There are also some related ideas, for example to allow FOR loops to autoindex over characters of strings.
Arrays of strings are their own unique beast, I am only interested in allowing all array functions which could otherwise be wrapped in String to Byte Array and Byte Array to String to just accept the string directly. Of course I am one of the few who would also like to autoindex chars as well, so that could be an added bonus as long is it was off by default.
Given the nature of LV11, I am less keen on the Idea Exchange these days, perhaps when the chances improve from 0 to epsilon I will post the idea.
01-27-2011 07:53 PM - edited 01-27-2011 07:54 PM
You mean Epsilon defined as:
#define FLT_EPSILON 1.19209290e-07F
#define DBL_EPSILON 2.2204460492503131e-16
#define LDBL_EPSILON 2.2204460492503131e-16L
There is a machine Epsilon constant which is : 2.22045E-16 in the numeric palette. Am I missing something?
01-27-2011 08:10 PM
@Ray.R wrote:
You mean Epsilon defined as:
#define FLT_EPSILON 1.19209290e-07F
#define DBL_EPSILON 2.2204460492503131e-16
#define LDBL_EPSILON 2.2204460492503131e-16L
There is a machine Epsilon constant which is : 2.22045E-16 in the numeric palette. Am I missing something?
Bad physicist joke. That is the epsilon I refer to, it basically means "The lowest probability of occuring without actually being zero probability"
01-27-2011 09:52 PM
@Darin.K wrote:
@Ray.R wrote:
You mean Epsilon defined as:
#define FLT_EPSILON 1.19209290e-07F
#define DBL_EPSILON 2.2204460492503131e-16
#define LDBL_EPSILON 2.2204460492503131e-16L
There is a machine Epsilon constant which is : 2.22045E-16 in the numeric palette. Am I missing something?
Bad physicist joke. That is the epsilon I refer to, it basically means "The lowest probability of occuring without actually being zero probability"
No, no, not a bad joke. I personally got a kick out of picturing Darin in some chic 90's western wear exclaiming "YEAAH!!"
01-27-2011 10:16 PM
Reminds me of "The Bing Bang Theory" or TBBT for short..