aboutsummaryrefslogtreecommitdiffstats
path: root/src/relation.erl
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-03-05 23:42:15 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-03-05 23:42:15 -0300
commit8c640a262969ef44cd8bc0e0abe95e2a54f4c3f5 (patch)
tree84f9ddd9e41236fb7a6f540aab07e65db9bc93cb /src/relation.erl
parent295c6a5a1f2b0db9d756ffe7bf413553a0c02737 (diff)
downloadSakura-8c640a262969ef44cd8bc0e0abe95e2a54f4c3f5.tar.gz
Sakura-8c640a262969ef44cd8bc0e0abe95e2a54f4c3f5.zip
ocaml re-migration
Diffstat (limited to 'src/relation.erl')
-rw-r--r--src/relation.erl42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/relation.erl b/src/relation.erl
deleted file mode 100644
index 66930d2..0000000
--- a/src/relation.erl
+++ /dev/null
@@ -1,42 +0,0 @@
--module(relation).
--export([new_attribute/2, new_tuple/1, new_relation/1]).
-
-%% Attribute: A pair of (Name, Value), eg. ("Name", "Augusto")
-%% Tuple: A set of attributes, eg. (("Name", "Augusto"), ("Age", 20), ("Surname", "Rengel"))
-%% Relation: A set of tuples organized through some selector
-%% Example Relation: f(x: Nat) = x + 1
-%% |{(0, 1), (1, 2), (2, 3), ...}| = |N|
-%% RelationCustomer = [(Username, Text), (Password, Text)]
-%% RelationProduct = [(Name, Text), (Price, Real)]
-%% RelationOrder = [(OrderId, Natural), ((Username, Text),
-%% (Password, Text), RelationCustomer), ((Name, Text),
-%% (Price, Real), RelationProduct)]
-
-new_attribute(Name, Value) ->
- #{name => Name, value => Value}.
-
-new_tuple(Attributes) when is_list(Attributes) ->
- Fun = fun (#{name := Name, value := Value}, Acc) ->
- maps:put(Name, Value, Acc)
- end,
- lists:foldl(Fun, #{}, Attributes).
-
-new_relation(Tuples) when is_list(Tuples) ->
- sets:from_list(Tuples, [{version, 2}]).
-
-%% SoapName1 = relation:new_attribute(name, "ABC").
-%% SoapPrice1 = relation:new_attribute(price, 1.0).
-%% SoapName2 = relation:new_attribute(name, "XYZ").
-%% SoapPrice2 = relation:new_attribute(price, 1.25).
-%% BazookaName = relation:new_attribute(name, "Bazzum").
-%% BazookaPrice = relation:new_attribute(price, 413.0).
-%% SwordName = relation:new_attribute(name, "Sword").
-%% SwordPrice = relation:new_attribute(price, 100.0).
-%% relation:new_relation([relation:new_tuple([SoapName, SoapPrice]), relation:new_tuple([BazookaName, BazookaPrice]), relation:new_tuple([SwordName, SwordPrice])]).
-
-%% Jules = relation:new_attribute(customer_name, "Jules").
-%% Emily = relation:new_attribute(customer_name, "Emily").
-%% Customers = relation:new_relation([relation:new_tuple([Jules]),
-%% relation:new_tuple([Emily])]).
-
-%% operations:project(operations:select(operations:cartesian_product(relation:new_relation([relation:new_tuple([SoapName1, SoapPrice1]), relation:new_tuple([SoapName2, SoapPrice2]), relation:new_tuple([BazookaName, BazookaPrice]), relation:new_tuple([SwordName, SwordPrice])]), Customers), fun (Tuple) -> maps:get(price, Tuple) =< 1.0 end), [name, customer_name]).