This post is about prolog programming in general, not specific to swi-prolog.
floor_locations([ 0.0, 0.17, 0.33, 0.5, 0.67, 0.83, 1.0 ]).
cabin_location_is_reached( cabin_location, floor_location, true ) :-
abs( cabin_location - floor_location ) =< 0.01.
cabin_location_is_reached( cabin_location, floor_location, false ) :-
abs( cabin_location - floor_location ) > 0.01.
list_floors_to_be_served( [], [],_, [] ).
list_floors_to_be_served(
[request|floor_requests],
[floor_location|floor_locations],
cabin_location,
[has_to_be_served|floors_to_be_served_list] ) :-
cabin_location_is_reached(
cabin_location,
floor_location,
has_to_be_served ),
list_floors_to_be_served(
floor_requests,
floor_locations,
cabin_location,
floors_to_be_served_list ).
The question is:
list_floors_to_be_served(
[ false, false, true, false, false, false, true ],
floor_locations,
0.33,
X ).
And the expected result should be:
[false, false, false, false, false, false, true]
The current result is: false :-(
How to correct my mistakes?