12 character(:, SK),
allocatable :: StrA_SK , StrB_SK
13 character(
2, SK),
allocatable :: SetA_SK(:) , SetB_SK(:)
14 integer(IK) ,
allocatable :: SetA_IK(:) , SetB_IK(:)
15 complex(CK) ,
allocatable :: SetA_CK(:) , SetB_CK(:)
16 real(RK) ,
allocatable :: SetA_RK(:) , SetB_RK(:)
18 type(display_type) :: disp
22 SetA_SK
= [
"AA",
"BB",
"CC",
"AA",
"FF",
"CC",
"DD"]
23 SetB_SK
= [
"aa",
"CC",
"CC",
"CC",
"DD",
"EE",
"EE"]
26 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
27 call disp%show(
"! Find the complement of string scalar A in B: B \ A.")
28 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
31 StrA_SK
= "AADBCCFEEZ"
32 StrB_SK
= "EADGBBCGCE"
36 call disp%show( StrA_SK, deliml
= SK_
"""" )
38 call disp%show( StrB_SK, deliml
= SK_
"""" )
39 call disp%show(
"getComplement(StrA_SK, StrB_SK)")
44 call disp%show(
"call setSorted(StrA_SK)")
47 call disp%show( StrA_SK, deliml
= SK_
"""" )
48 call disp%show(
"call setSorted(StrB_SK)")
51 call disp%show( StrB_SK, deliml
= SK_
"""" )
52 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .false._LK)")
53 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK), deliml
= SK_
"""" )
57 call disp%show(
"StrA_SK = getUnique(StrA_SK)")
60 call disp%show( StrA_SK, deliml
= SK_
"""" )
61 call disp%show(
"StrB_SK = getUnique(StrB_SK)")
64 call disp%show( StrB_SK, deliml
= SK_
"""" )
65 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .true._LK)")
66 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .true._LK), deliml
= SK_
"""" )
69 StrA_SK
= "AADBCCFEEZ"
70 StrB_SK
= "AAAAAAAAAA"
74 call disp%show( StrA_SK, deliml
= SK_
"""" )
76 call disp%show( StrB_SK, deliml
= SK_
"""" )
77 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .true._LK) ! The result is wrong because both sets must contain unique elements when `unique = .true.`.")
78 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .true._LK), deliml
= SK_
"""" )
81 StrA_SK
= "AADBCCFEEZ"
82 StrB_SK
= "BAAAAAAAAA"
86 call disp%show( StrA_SK, deliml
= SK_
"""" )
88 call disp%show( StrB_SK, deliml
= SK_
"""" )
89 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .false._LK) ! The result is wrong because both sets must be similarly sorted when `sorted = .true.`.")
90 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK), deliml
= SK_
"""" )
93 StrA_SK
= "AABCCDEEFZ"
94 StrB_SK
= "ZFEEDCCBAA"
98 call disp%show( StrA_SK, deliml
= SK_
"""" )
100 call disp%show( StrB_SK, deliml
= SK_
"""" )
101 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .false._LK) ! The result is wrong because both sets must be similarly sorted when `sorted = .true.`.")
102 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK), deliml
= SK_
"""" )
103 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .false._LK, unique = .false._LK)")
104 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .false._LK, unique
= .false._LK), deliml
= SK_
"""" )
108 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
109 call disp%show(
"! Find the complement of string vector A in B: B \ A.")
110 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
115 call disp%show( SetA_SK, deliml
= SK_
"""" )
117 call disp%show( SetB_SK, deliml
= SK_
"""" )
118 call disp%show(
"getComplement(SetA_SK, SetB_SK)")
123 call disp%show(
"call setSorted(SetA_SK)")
126 call disp%show( SetA_SK, deliml
= SK_
"""" )
127 call disp%show(
"call setSorted(SetB_SK)")
130 call disp%show( SetB_SK, deliml
= SK_
"""" )
131 call disp%show(
"getComplement(SetA_SK, SetB_SK, sorted = .true._LK, unique = .false._LK)")
132 call disp%show(
getComplement(SetA_SK, SetB_SK, sorted
= .true._LK, unique
= .false._LK), deliml
= SK_
"""" )
136 call disp%show(
"SetA_SK = getUnique(SetA_SK)")
139 call disp%show( SetA_SK, deliml
= SK_
"""" )
140 call disp%show(
"SetB_SK = getUnique(SetB_SK)")
143 call disp%show( SetB_SK, deliml
= SK_
"""" )
144 call disp%show(
"getComplement(SetA_SK, SetB_SK, sorted = .true._LK, unique = .true._LK)")
145 call disp%show(
getComplement(SetA_SK, SetB_SK, sorted
= .true._LK, unique
= .true._LK), deliml
= SK_
"""" )
149 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
150 call disp%show(
"! Find the complement of integer vector A in B: B \ A.")
151 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
154 SetA_IK
= [
integer(IK) ::
4,
5,
4,
1,
2,
1,
5]
155 SetB_IK
= [
integer(IK) ::
6,
3,
4,
2,
1,
2,
6]
162 call disp%show(
"getComplement(SetA_IK, SetB_IK)")
167 call disp%show(
"call setSorted(SetA_IK)")
171 call disp%show(
"call setSorted(SetB_IK)")
175 call disp%show(
"getComplement(SetA_IK, SetB_IK, sorted = .true._LK, unique = .false._LK)")
180 call disp%show(
"SetA_IK = getUnique(SetA_IK)")
184 call disp%show(
"SetB_IK = getUnique(SetB_IK)")
188 call disp%show(
"getComplement(SetA_IK, SetB_IK, sorted = .true._LK, unique = .true._LK)")
193 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
194 call disp%show(
"! Find the complement of complex vector A in B: B \ A.")
195 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
198 SetA_CK
= [
complex(CK) :: (
4,
-4), (
5,
-5), (
4,
-4), (
1,
-1), (
2,
-2), (
8,
-8), (
1,
-1), (
5,
-5)]
199 SetB_CK
= [
complex(CK) :: (
6,
-6), (
3,
-3), (
4,
-4), (
2,
-2), (
1,
-1), (
7,
-7), (
2,
-2), (
6,
-6)]
206 call disp%show(
"getComplement(SetA_CK, SetB_CK)")
211 call disp%show(
"call setSorted(SetA_CK)")
215 call disp%show(
"call setSorted(SetB_CK)")
219 call disp%show(
"getComplement(SetA_CK, SetB_CK, sorted = .true._LK, unique = .false._LK)")
224 call disp%show(
"SetA_CK = getUnique(SetA_CK)")
228 call disp%show(
"SetB_CK = getUnique(SetB_CK)")
232 call disp%show(
"getComplement(SetA_CK, SetB_CK, sorted = .true._LK, unique = .true._LK)")
237 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
238 call disp%show(
"! Find the complement of real vector A in B: B \ A.")
239 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
242 SetA_RK
= [
real(
RK) ::
4,
5,
4,
1,
2,
8,
1,
5]
243 SetB_RK
= [
real(
RK) ::
6,
3,
4,
2,
1,
7,
2,
6]
250 call disp%show(
"getComplement(SetA_RK, SetB_RK)")
255 call disp%show(
"call setSorted(SetA_RK)")
259 call disp%show(
"call setSorted(SetB_RK)")
263 call disp%show(
"getComplement(SetA_RK, SetB_RK, sorted = .true._LK, unique = .false._LK)")
268 call disp%show(
"SetA_RK = getUnique(SetA_RK)")
272 call disp%show(
"SetB_RK = getUnique(SetB_RK)")
276 call disp%show(
"getComplement(SetA_RK, SetB_RK, sorted = .true._LK, unique = .true._LK)")
281 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
282 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
283 call disp%show(
"! Find the complement using a custom equivalence check.")
284 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
285 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
288 StrA_SK
= "AADBCCFEEZ"
289 StrB_SK
= "eadgbbcgce"
293 call disp%show( StrA_SK, deliml
= SK_
"""" )
295 call disp%show( StrB_SK, deliml
= SK_
"""" )
296 call disp%show(
"getComplement(StrA_SK, StrB_SK)")
298 call disp%show(
"getComplement(StrA_SK, StrB_SK, iseq = iseq_SK)")
303 call disp%show(
"call setSorted(StrA_SK)")
306 call disp%show( StrA_SK, deliml
= SK_
"""" )
307 call disp%show(
"call setSorted(StrB_SK)")
310 call disp%show( StrB_SK, deliml
= SK_
"""" )
311 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .false._LK)")
312 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK), deliml
= SK_
"""" )
313 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .false._LK, iseq = iseq_SK)")
314 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK, iseq
= iseq_SK), deliml
= SK_
"""" )
318 call disp%show(
"StrA_SK = getUnique(StrA_SK)")
321 call disp%show( StrA_SK, deliml
= SK_
"""" )
322 call disp%show(
"StrB_SK = getUnique(StrB_SK)")
325 call disp%show( StrB_SK, deliml
= SK_
"""" )
326 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .true._LK)")
327 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .true._LK), deliml
= SK_
"""" )
328 call disp%show(
"getComplement(StrA_SK, StrB_SK, sorted = .true._LK, unique = .true._LK, iseq = iseq_SK)")
329 call disp%show(
getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .true._LK, iseq
= iseq_SK), deliml
= SK_
"""" )
334 pure function iseq_SK(element1, element2)
result(iseq)
336 character(
1, SK) ,
intent(in) :: element1, element2
Sort the input scalar string or contiguous vector in ascending order, or return the sorted indices of...
Generate and return a vector of unique values in the input array.
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
Generate and return the input character where the uppercase English alphabet is converted to lowercas...
This module contains procedures and generic interfaces for various sorting tasks.
This module contains procedures and generic interfaces for finding unique values of an input array of...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
integer, parameter CKS
The single-precision complex kind in Fortran mode. On most platforms, this is a 32-bit real kind.
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
This module contains the uncommon and hardly representable ASCII characters as well as procedures for...
Generate and return an object of type display_type.
21getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK)
31getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .true._LK)
39getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .true._LK)
47getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK)
55getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK)
57getComplement(StrA_SK, StrB_SK, sorted
= .false._LK, unique
= .false._LK)
67"AA",
"BB",
"CC",
"AA",
"FF",
"CC",
"DD"
69"aa",
"CC",
"CC",
"CC",
"DD",
"EE",
"EE"
76"AA",
"AA",
"BB",
"CC",
"CC",
"DD",
"FF"
79"CC",
"CC",
"CC",
"DD",
"EE",
"EE",
"aa"
80getComplement(SetA_SK, SetB_SK, sorted
= .true._LK, unique
= .false._LK)
86"AA",
"BB",
"CC",
"DD",
"FF"
90getComplement(SetA_SK, SetB_SK, sorted
= .true._LK, unique
= .true._LK)
100+4,
+5,
+4,
+1,
+2,
+1,
+5
102+6,
+3,
+4,
+2,
+1,
+2,
+6
109+1,
+1,
+2,
+4,
+4,
+5,
+5
112+1,
+2,
+2,
+3,
+4,
+6,
+6
113getComplement(SetA_IK, SetB_IK, sorted
= .true._LK, unique
= .false._LK)
123getComplement(SetA_IK, SetB_IK, sorted
= .true._LK, unique
= .true._LK)
133(
+4.00000000,
-4.00000000), (
+5.00000000,
-5.00000000), (
+4.00000000,
-4.00000000), (
+1.00000000,
-1.00000000), (
+2.00000000,
-2.00000000), (
+8.00000000,
-8.00000000), (
+1.00000000,
-1.00000000), (
+5.00000000,
-5.00000000)
135(
+6.00000000,
-6.00000000), (
+3.00000000,
-3.00000000), (
+4.00000000,
-4.00000000), (
+2.00000000,
-2.00000000), (
+1.00000000,
-1.00000000), (
+7.00000000,
-7.00000000), (
+2.00000000,
-2.00000000), (
+6.00000000,
-6.00000000)
137(
+6.00000000,
-6.00000000), (
+3.00000000,
-3.00000000), (
+7.00000000,
-7.00000000), (
+6.00000000,
-6.00000000)
142(
+1.00000000,
-1.00000000), (
+1.00000000,
-1.00000000), (
+2.00000000,
-2.00000000), (
+4.00000000,
-4.00000000), (
+4.00000000,
-4.00000000), (
+5.00000000,
-5.00000000), (
+5.00000000,
-5.00000000), (
+8.00000000,
-8.00000000)
145(
+1.00000000,
-1.00000000), (
+2.00000000,
-2.00000000), (
+2.00000000,
-2.00000000), (
+3.00000000,
-3.00000000), (
+4.00000000,
-4.00000000), (
+6.00000000,
-6.00000000), (
+6.00000000,
-6.00000000), (
+7.00000000,
-7.00000000)
146getComplement(SetA_CK, SetB_CK, sorted
= .true._LK, unique
= .false._LK)
147(
+3.00000000,
-3.00000000), (
+6.00000000,
-6.00000000), (
+6.00000000,
-6.00000000), (
+7.00000000,
-7.00000000)
152(
+1.00000000,
-1.00000000), (
+2.00000000,
-2.00000000), (
+4.00000000,
-4.00000000), (
+5.00000000,
-5.00000000), (
+8.00000000,
-8.00000000)
155(
+1.00000000,
-1.00000000), (
+2.00000000,
-2.00000000), (
+3.00000000,
-3.00000000), (
+4.00000000,
-4.00000000), (
+6.00000000,
-6.00000000), (
+7.00000000,
-7.00000000)
156getComplement(SetA_CK, SetB_CK, sorted
= .true._LK, unique
= .true._LK)
157(
+3.00000000,
-3.00000000), (
+6.00000000,
-6.00000000), (
+7.00000000,
-7.00000000)
166+4.00000000,
+5.00000000,
+4.00000000,
+1.00000000,
+2.00000000,
+8.00000000,
+1.00000000,
+5.00000000
168+6.00000000,
+3.00000000,
+4.00000000,
+2.00000000,
+1.00000000,
+7.00000000,
+2.00000000,
+6.00000000
170+6.00000000,
+3.00000000,
+7.00000000,
+6.00000000
175+1.00000000,
+1.00000000,
+2.00000000,
+4.00000000,
+4.00000000,
+5.00000000,
+5.00000000,
+8.00000000
178+1.00000000,
+2.00000000,
+2.00000000,
+3.00000000,
+4.00000000,
+6.00000000,
+6.00000000,
+7.00000000
179getComplement(SetA_RK, SetB_RK, sorted
= .true._LK, unique
= .false._LK)
180+3.00000000,
+6.00000000,
+6.00000000,
+7.00000000
185+1.00000000,
+2.00000000,
+4.00000000,
+5.00000000,
+8.00000000
188+1.00000000,
+2.00000000,
+3.00000000,
+4.00000000,
+6.00000000,
+7.00000000
189getComplement(SetA_RK, SetB_RK, sorted
= .true._LK, unique
= .true._LK)
190+3.00000000,
+6.00000000,
+7.00000000
216getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK)
218getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .false._LK, iseq
= iseq_SK)
228getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .true._LK)
230getComplement(StrA_SK, StrB_SK, sorted
= .true._LK, unique
= .true._LK, iseq
= iseq_SK)