BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

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 [%.#]!(.)  😉

0 Kudos
Message 811 of 2,635
(12,668 Views)

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:

 

RayRString2.png

 

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).

Message 812 of 2,635
(12,664 Views)

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):

 

 

Message 813 of 2,635
(12,646 Views)

Uhgh!! Our Java prude just said that 'G' stands for 'Goldberg'! Ouch!

 

Edit: How do I respond?

=====================
LabVIEW 2012


Message 814 of 2,635
(12,570 Views)

 


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.

0 Kudos
Message 815 of 2,635
(12,544 Views)

 


@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.

0 Kudos
Message 816 of 2,635
(12,524 Views)

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?

0 Kudos
Message 817 of 2,635
(12,508 Views)

 


@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"

 

0 Kudos
Message 818 of 2,635
(12,503 Views)

 


@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!!"

 

 

Message 819 of 2,635
(12,499 Views)

Reminds me of "The Bing Bang Theory"  or TBBT for short..

0 Kudos
Message 820 of 2,635
(12,496 Views)