summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level1.cpp
blob: 2e005e2e4a1c99188e3f835ab77a20b561e7fa98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "level-1/level-1.hpp"

#include <iostream>

using namespace intellect::level1;
using namespace intellect::level1::concepts;

int main()
{
	decls(make, linked, habit);
	decls(needs, assumes, makes);
	decls(not, topic);
	decls(A, B, C);
	decls(source, type, target);
	decls(structure, function, argument, position);
	decls(variable, provide);
	decls(act);

	(make-linked).link(
		is, habit,
		needs, a(structure).link(
			is, function-argument,
			argument-position, ref(1),
			a(variable, A), provide,
			a(variable, B), provide,
			a(variable, C), provide
		)
	);
	movetoname(a(link), A-B-C-linked).link(
		link-source, A,
		link-type, B,
		link-target, C
	);
	a(not, not-A-B-C-linked).set(topic, A-B-C-linked);
	(make-linked).link(
		assumes, not-A-B-C-linked,
		makes, A-B-C-linked
	);
	(make-linked).fset(
		act,
		(std::function<void(ref)>)[](ref args)
		{
			ref source = args.get("A");
			ref type = args.get("B");
			ref target = args.get("C");
			std::cout << "Linking " << source.name() << " by " << type.name() << " to " << target.name() << std::endl;
			source.link(type, target);
		}
	);

	std::cout << (make-linked).dump("dumped", true) << std::endl;

	decls(apple, fruit);
	(make-linked).get(act)
		(a(function-argument)
		 .link(
			 A, apple,
			 B, is,
			 C, fruit
		));

	std::cout << apple.dump("dumped", true) << std::endl;

	return 0;
}