<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:Arial,Helvetica,sans-serif">On Mon, Nov 30, 2020 at 11:05 AM <<a href="mailto:empro2@web.de">empro2@web.de</a>> wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">```<br>
Ls = [{geoloc, 6.1457, 46.2022},<br>
{geoloc, 2.3387, 48.8582},<br>
...],<br>
Lc = [{geocart, X, Y, Z}, ...].<br>
<br>
%% Perhaps with something like:<br>
-record(geoloc, {longitude :: float(),<br>
latitude :: float()}).<br>
```<br></blockquote><div><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">From experience, I usually recommend you use naming when handling multiple fields of the same type. I.e., the record is probably the best solution. Otherwise, switching up lat/lng is simply too easy. It also happens with lots of other data. In languages with types you would do something like</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">module GeoLoc = struct</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> type t = { lat : float; lng : float }</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> let from_pair ~lat ~lng = { lat; lng }</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> let distance x y = ... (* This will have type t -> t -> float *)</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">end</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">So in order to create a GeoLoc.t you call `from_pair ~lng:6.1457 ~lat:46.2022`. You can then make GeoLoc.t abstract such that you can't access the internal representation outside the module, protecting against a large number of mistakes as the system develops.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"></div></div></div>