| 1 |
module person |
| 2 |
def ssn = 123-45-6789 |
| 3 |
module name |
| 4 |
def first = "John" |
| 5 |
def middle = "Q" |
| 6 |
def last = "Public" |
| 7 |
end |
| 8 |
module birth |
| 9 |
def city = "Pittsburg" |
| 10 |
def state = "PA" |
| 11 |
def country = "USA" |
| 12 |
def date = parse_date["2000-01-01", "Y-m-d"] |
| 13 |
end |
| 14 |
end |
| 15 |
|
| 16 |
module mymodule |
| 17 |
def R = {1; 2} |
| 18 |
ic {count[R] = 2} |
| 19 |
end |
| 20 |
|
| 21 |
@inline |
| 22 |
module my_stats[R] |
| 23 |
def my_minmax = (min[R], max[R]) |
| 24 |
def my_mean = mean[R] |
| 25 |
def my_median = median[R] |
| 26 |
end |
| 27 |
|
| 28 |
@inline |
| 29 |
module BipartiteGraph[M, N] |
| 30 |
def node = M; N |
| 31 |
def edge = M, N |
| 32 |
end |
| 33 |
|
| 34 |
@inline |
| 35 |
module CycleGraph[N] |
| 36 |
def node = N |
| 37 |
def edge(a in N, b in N) = |
| 38 |
sort[N](x, a) |
| 39 |
and sort[N](y, b) |
| 40 |
and y = x%count[N] + 1 |
| 41 |
from x, y |
| 42 |
end |
| 43 |
|
| 44 |
@inline |
| 45 |
module GraphProperties[G] |
| 46 |
def outdegree[v in G:node] = count[v1 : G:edge(v, v1)] <++ 0 |
| 47 |
def indegree[v in G:node] = count[v1 : G:edge(v1, v)] <++ 0 |
| 48 |
def edge_count = count[G:edge] <++ 0 |
| 49 |
end |
| 50 |
|
| 51 |
def cg = CompleteGraph[range[1 ,5, 1]] |
| 52 |
def cg_props = GraphProperties[cg] |
| 53 |
|
| 54 |
def bg = BipartiteGraph[{1; 2}, {3; 4; 5}] |
| 55 |
def bg_props = GraphProperties[bg] |
| 56 |
|
| 57 |
def cycleg = CycleGraph[{"a"; "b"; "c"; "d" ; "e"}] |
| 58 |
def cycleg_props = GraphProperties[cycleg] |
| 59 |
|
| 60 |
module output |
| 61 |
def complete_edge_count = cg_props:edge_count |
| 62 |
def bipartite_edge_count = bg_props:edge_count |
| 63 |
def cycle_edge_count = cycleg_props:edge_count |
| 64 |
end |
| 65 |
|
| 66 |
# From https://docs.relational.ai/rel/concepts/modules/ |