Can a variable of type "int" be considered a primitive / fundamental data structure?

A rough definition of the data structure is that it allows you to store data and apply a set of operations to that data, while maintaining data consistency before and after the operation. However, some people insist that a primitive variable of type "int" can also be considered as a data structure. I get the part where it allows you to store data, but I think that part of the operation is missing. Primitive variables have no operations attached to them. Therefore, I feel that if you do not have a specific set of operations and are not attached to it, you cannot call it a data structure. "int" has no operation on it; you can work with it with a set of common operators.

Please let me know if something is wrong with me.

+5
source share
9 answers

To say that something is structured implies that there is a form or formatting that determines HOW data is structured. Please note that this has nothing to do with how the data is actually stored. For example, you can create a data structure that exists entirely within one whole, but represents several different values.

- , , . , . , . "", , , , . "", .

, , , , . - . , , , , 32- , (Ie: ), , .

+4

, .

, struct ( ) , "". . .

int , . ().

, : " ? ! int!".

, " ".

+2

; , - .

=, +, -, == .. - . , , , (.. ) (, ++), int, char , , .

+1

. - . ADT - , . ADT , . int ADT, , . int , ADT, , , . ADT .

wikipedia .

+1

, "int" - - ​​ . , , , ( -). " ".

.

0

. , , , .

'int' , .

Generic? 2+2, "ninja" + List<float> ? , . . , .

, . , , , , . ToString() - , . int. , int , . int , . -. , , . .

0

, (ref: ), ( ). , ++ -, . / - . .

0

'int' , .

, ; , .

(< , ), ( a + b , a b , +).

0

, , " ". . , : " , ?" ,

  • ,
  • A set of operations on this data

Then, of course, intqualifies. (If intthere were no operations, we would all be stuck!)

For a more mathematical approach to programming that starts with these questions and leads them to what some call β€œalgebra of computation,” see Programming Elements by Alex Stepanov and Paul McJones.

0
source

All Articles