MINISTRY OF HIGHER AND SECONDARY PUBLIC EDUCATION OF THE REPUBLIC OF UZBEKISTAN
ACADEMIC LYCEUM AT THE UZBEK STATE UNIVERSITY OF WORLD LANGUAGES
COURSE WORK
OPTIONAL TYPES. DEFINING ARRAYS.
ONE-DIMENSIONAL ARRAYS. ARRAY SORTINGS
DONE BY A STUDENT: RAXMATULLAYEVA MUNISA
TEACHER: ABDUVOHIDOVA SAYYORA
Tashkent 2022
CONTENT…………………………………………………………………...2
INTRODUCTION…………………………………………………….3
OPTIONAL TYPES..….……….……………………….…………….3
ARRAYS IN PROGRAMING...……………………………………..8
INITIALIZING ARRAYS……..……………………………………..9
ARRAY ACCESSING.. …………………………………………….10
ARRAY SORTING IN C++ ………………………………………..12
ONE DIMENSIONAL ARRAY……………………………………..15
CONCLUSION……………………………………………………………..19
BIBLIOGRAPHY…………………………………………………………..20
WHAT IS OPTIONAL TYPES?
In programming languages (especially functional programming languages) and type theory, an option type or maybe type is a polymorphic type that represents encapsulation of an optional value; e.g., it is used as the return type of functions which may or may not return a meaningful value when they are applied. It consists of a constructor which either is empty (often named None or Nothing), or which encapsulates the original data type A (often written Just A or Some A).
A distinct, but related concept outside of functional programming, which is popular in object-oriented programming, is called nullable types (often expressed as A?). The core difference between option types and nullable types is that option types support nesting (Maybe (Maybe A) ≠ Maybe A), while nullable types do not (String?? = String?).
In type theory, it may be written as: {\displaystyle A^{?}=A+1} . This expresses the fact that for a given set of values in {\displaystyle A} , an option type adds exactly one additional value (the empty value) to the set of valid values for {\displaystyle A} . This is reflected in programming by the fact that in languages having tagged unions, option types can be expressed as the tagged union of the encapsulated type plus a unit type.
In the Curry–Howard correspondence, option types are related to the annihilatio law for ∨: x∨1=1.[how?]
An option type can also be seen as a collection containing either one or zero elements.
The option type is also a monad where
return = Just -- Wraps the value into a maybe
Nothing >>= f = Nothing -- Fails if the previous monad fails
(Just x) >>= f = f x -- Succeeds when both monads succeed
The monadic nature of the option type is useful for efficiently tracking failure and errors.[3]
Do'stlaringiz bilan baham: |