Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%%-------------------------------------------------------------------
- %%% @author przemek
- %%% @copyright (C) 2020, <COMPANY>
- %%% @doc
- %%%
- %%% @end
- %%% Created : 3. kwi 2020 12:58
- %%%-------------------------------------------------------------------
- -module(parcellockerfinder).
- -author("przemek").
- %% API
- -export(getRandomPointsToList/1).
- getRandomPointsToList(N) ->
- [{rand:uniform(10000), rand:uniform(10000)} || _ <- lists:seq(1,N)].
- findDistance({X1, Y1}, {X2, Y2}) ->
- math:sqrt(math:pow(X1 - X2, 2) + math:pow(Y1-Y2, 2)).
- findMyParcelLocker(PersonLocation, LockerLocations) ->
- AllDistances = [{LockerX, LockerY, findDistance(PersonLocation, {LockerX, LockerY} || {LockerX, LockerY} <- LockerLocations],
- [{ClosestX, ClosestY, _} | _] = lists:keysort(3, AllDistances),
- {PersonLocation, {ClosestX, ClosestY}}.
- findMyParcelLockerForEachPerson(PeopleLocation, LockerLocations) ->
- [{findMyParcelLocker(PersonLocation, LockerLocations)} || PersonLocation <- PeopleLocation].
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement