Current section
Files
Jump to
Current section
Files
src/tastoids@compare.erl
-module(tastoids@compare).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/tastoids/compare.gleam").
-export([ordering/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Given any `Tastoid` is differentiable with respect to its\n"
" `distance` to another, (_either `total` and `partial`),\n"
" it can then be said to impose a _total (partial) ordering_\n"
" of any other set of Tastoids.\n"
" \n"
" Akin to `gleam/order`, a `Tastoid` *is* its own ordering\n"
).
-file("src/tastoids/compare.gleam", 17).
?DOC(" Return a `compare` which orders elements by the provided `differentiator`\n").
-spec ordering(tastoids@tastoid:tastoid(EMJ)) -> fun((tastoids@tastoid:tastoid(EMJ), tastoids@tastoid:tastoid(EMJ)) -> gleam@order:order()).
ordering(Differentiator) ->
fun(A, B) ->
Delta_a = begin
_pipe = tastoids:less(Differentiator, A),
tastoids:distance(_pipe)
end,
Delta_b = begin
_pipe@1 = tastoids:less(Differentiator, B),
tastoids:distance(_pipe@1)
end,
gleam@float:compare(Delta_a, Delta_b)
end.