Why do we check if empty before we move? [closed] - cobol

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I see a lot of codes like this:
if WA > SPACES
move WA to WA2
end-if
What are the advantages that this is checked? Is it more efficient to check if it is empty than to just move it anyways?
Additional information:
WA and WA2 can be simple structures (without fillers) but also just simple attributes. They are not redifined and typed as chars or structures of chars. They can be either low-values (semantically NULL) or have alphanumeric content.

Nobody can tell you what the actual reason is except for the people who coded it, but here is a very probable reason:
Usually this is accompanied with an ELSE that would cover what happens if the value is less than spaces, but in this case I would assume that what every happens to this data later is relying on that field NOT being LOW-VALUES or some funky non-displayable control character.
If I had to guess, I would assume that WA2 is initialized to spaces. So doing this check before the move ensures that nothing lower than spaces would be moved to that variable. Remember, less than spaces does not mean empty, it just means that hex values of that string are less than X'40' (so for example is the string was full of low values, it would be all X'00'. So I would guess that its more about ensuring that the data is valid than efficiency.

Related

is one hot encoding is free of the dummy trap [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
there is a thing called dummy trap in one hot encoder that is when we encode the categorical column with 3 categories lest say a,b,and c then with one hot encoder we get 3 categories like or columns a, b ,and c but when we use get_dummies we get 2 columns instead a, and b then it is save from dummy trap. is one hot encoding exposed to dummy trap or it takes care of it . am i right? which one is save of dummy trap? or is it ok to use both with our removing columns, iam using the dataset for many algorithms.
looking for help . thanks in advance.
OneHotEncoder cannot process string values directly. If your nominal features are strings, then you need to first map them into integers.
pandas.get_dummies is kind of the opposite. By default, it only converts string columns into one-hot representation, unless columns are specified.

Structuring data in a conversion app [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
In an application I need to convert values between metric, British imperial and US imperial, e.g. kilos to stones + pounds (UK) to pounds (US). How best to store the user-inputted data?
Is it better to convert all inputted values to e.g. metric and save as a float, or keep the user inputted data as say a literal string and interpret on each application launch?
The maths/equations etc is all good, it's more knowing what the most efficient structure is for storing values that can be represented in different ways, in a database?
It really comes down to what precision you need. Storing the value as String might be safe but is extremely inefficient. For simple 1 to 1 value conversions it might be efficient enough. For converting thousands of values it probably won't.
I would go with scalar types representing the most complex value the user is able to enter manually. Derive calculations from those original values to avoid losing complexity.
One note: since you're dealing with real world values (I presume), ditch the sign and use the unsigned variants if you're going with scalar value types.
This is the approach I use, Make an NSObject called WeightObject that have 2 propertiesL
1- the value the user entered (for example 3)
2- a unit the user used example:(KiloGrams/pounds etc..).
lastly save the object. this way yo keep the record exactly as user entred, and you make the method inside the object to return the value in KG or in punds etc...
so later you say float x = myWeightObject.KilosValue

can a top-down parser detect ungrammaticality an input string? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I read that its possible to do this ,
Will it require backtracking?
What would be the sketch from recovering from the parsing errors .
The way a top down parser can detect the ungrammaticality, i.e. the invalidity of an input string is, for example:
if you have the non-terminal A on the top of your stack for instance, and the next token in your input string is the symbol b,
then go to your parse table and go to the row for A, and the column for b, and if there is an empty cell, then the input string is invalid.
A method to recover would be to entry panic mode, where you skip tokens in the input string until you find one in the synchronising set, and then pop A off the stack and continue.
several ways of choosing the synchronising set, it could be follow(A) for example

what decimal separators are in use around the world? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
what decimal separators are in use around the world? (I have a few places between programs where I must exchange a floating point number as a string without a thousands separator.) yes, I know this isn't a fantastic idea...there are many ways this could be done but more serious improvements will need to come later...
I know of "," and "." but are there any others?
http://en.wikipedia.org/wiki/Decimal_mark
There you have a list of separators (basically ",", "." and " " in writing and also "'" and "˙" for handwriting), with many examples of all of them in different countries.
Since this is applied to programming, you should only worry about ",", "." and " ", that is, unless you are doing some OCR'ing.
Check this out: http://mathworld.wolfram.com/DecimalPoint.html. It makes it sound like the decimal point, the decimal comma and the raised period are the only things in use.
You can also check out wikipedia http://en.wikipedia.org/wiki/Decimal_point but it doesn't really say much else.
I checked this on .NET environment by looping all CultureInfos framework had (806). The result set was ".", "," and "/". The last one was Persian CultureInfo.

Regular expression for password validation that doesn't allow spaces [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need a regular expression for my Ruby on Rails application for the password field.
Any character or number or symbols is allowed except space.
If this is client-side validation in Javascript (or any language other than Ruby), this expression will match a string with no whitespace (\S) at least one character (+), no max:
^\S+$
Ruby is the only language that uses multi-line mode by default, so the start-of-line ^ and end-of-line $ behave differently (they match once per input, no matter how many lines). So, if you are validating the input in Ruby, you'd need to use \A for start-of-line and \Z for end-of-line.
\A\S+\Z
All except spaces, do you need to narrow the results a bit more than this?
/[^ ]+/
This is without minimum length (or rather, with minimum length 1):
^\S+$
With minimum length 8:
^\S{7}\S+$
or, if your regex engine supports it (don't know why it wouldn't):
^\S{8,}$

Resources