Skip to content

Commit

Permalink
Fixed Duplicated String Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
R0mb0 committed Jul 12, 2022
1 parent 35911d5 commit 3ecca03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
30 changes: 15 additions & 15 deletions Prolog/Detection.pl
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@
throw(error(wrong_input_number, Num, verify_primes/2))
).

/*Verify if the Latters of Detection Are Real.
/*Verify if the Seconds of Detection Are Real.
* Input: An Integer or Float Number.
* Output: A Boolean that is "true" If the Latters Are Real, "false" Otherwise.*/
verify_latters(Num, Return_bool) :-
* Output: A Boolean that is "true" If the Seconds Are Real, "false" Otherwise.*/
verify_seconds(Num, Return_bool) :-
(number(Num) ->
(Num < 0 ->
Return_bool = false
Expand All @@ -148,7 +148,7 @@
)
)
;
throw(error(wrong_input_number, Num, verify_latters/2))
throw(error(wrong_input_number, Num, verify_seconds/2))
).

/*Verify if the Latitude Sign is Right.
Expand Down Expand Up @@ -205,7 +205,7 @@
throw(error(wrong_input_list, List, split/2))
).

/*Transform the Input String Containing the Latitude part into a Latitude List, [Sign, Degrees, Primes, Latters].
/*Transform the Input String Containing the Latitude part into a Latitude List, [Sign, Degrees, Primes, Seconds].
* Input: A List.
* Output: A List containing the latitude.*/
get_latitude([], _) :-
Expand All @@ -226,14 +226,14 @@
number_chars(Primes, D),
take(14, List, E),
drop(8, E, F),
number_chars(Latters, F),
Final_list = [Sign, Degrees, Primes, Latters]
number_chars(Seconds, F),
Final_list = [Sign, Degrees, Primes, Seconds]
)
;
throw(error(wrong_input_list, List, get_latitude/2))
).

/*Transform the Input String Containing the Longitude part into a Longitude List, [Sign, Degrees, Primes, Latters].
/*Transform the Input String Containing the Longitude part into a Longitude List, [Sign, Degrees, Primes, Seconds].
* Input: A List.
* Output: A List containing the longitude.*/
get_longitude([], _) :-
Expand All @@ -255,8 +255,8 @@
number_chars(Primes, D),
take(15, List1, E),
drop(9, E, F),
number_chars(Latters, F),
Final_list = [Sign, Degrees, Primes, Latters]
number_chars(Seconds, F),
Final_list = [Sign, Degrees, Primes, Seconds]
)
;
throw(error(wrong_input_list, List, get_longitude/2))
Expand All @@ -276,10 +276,10 @@
(B1 == false ->
throw(error(wrong_primes_in, List, verify_coordinate_body/2))
;
index(3, List, Latters),
verify_latters(Latters, B2),
index(3, List, Seconds),
verify_seconds(Seconds, B2),
(B2 == false ->
throw(error(wrong_latters_in, List, verify_coordinate_body/2))
throw(error(wrong_seconds_in, List, verify_coordinate_body/2))
;
Return_bool = true
)
Expand Down Expand Up @@ -317,8 +317,8 @@
check_sign(Sign, Sign1),
index(1, List, Degrees),
index(2, List, Primes),
index(3, List, Latters),
A is Latters / 60,
index(3, List, Seconds),
A is Seconds / 60,
B is Primes + A,
C is B / 60,
D is C + Degrees,
Expand Down
13 changes: 12 additions & 1 deletion Prolog/Main.pl
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
/***** Main & Main Util Module. *****/

/*Verify If the Two Detections inserted Are Different.
* Input: Two Lists.
* Output An Error If the Two Detections Inserted Aren't Different.*/
verify_detections(List1, List2, Return_bool) :-
(List1 == List2 ->
throw(error(inserted_the_same_detection_twice, verify_detections/2))
;
Return_bool = true
).

/*Main.*/
main :-
consult('ListTools.pl'),
consult('Detection.pl'),
consult('Properties.pl'),
write('Detections Properties Calculator V1.0'), nl,
write('Warning: The Detections must be in D.M.G format and inserted into the program like: `N 40 45 36.000 - E 073 59 2.400`.'), nl,
write('Warning: The Detections must be in D.M.G format and inserted into the program like: `N 40 45 36.000 - E 073 59 02.400`.'), nl,
write('Insert the First Detection...'), nl,
read(A),
atom_chars(A, Det1),
Expand All @@ -16,6 +26,7 @@
write('Proceed [yes./no.]?'), nl,
read(C),
(C == 'yes' ->
verify_detections(Det1, Det2, _),
write('First Detection in Decimal Format ---> '),
get_point(Det1, P1),
index(0, P1, Dlat1),
Expand Down

0 comments on commit 3ecca03

Please sign in to comment.